Skip to content

Commit 75969d8

Browse files
author
Jonathan Wayne Parrott
committed
Merge pull request #92 from GoogleCloudPlatform/mainify-storage
Reorganizing storage samples.
2 parents 2fe9e39 + a6aa223 commit 75969d8

17 files changed

+33
-189
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ This repository holds the samples used in the python documentation on [cloud.goo
88
For more detailed introduction to a product, check the README in the
99
corresponding folder.
1010

11-
## Running the samples
12-
13-
Most samples must be run as modules instead of directly, for example:
14-
15-
```
16-
$ python -m bigquery.samples.async_query [your-project-id] [your-query]
17-
```
18-
19-
Refer to the README in the corresponding folder for any special instructions.
20-
2111
## Contributing changes
2212

2313
* See [CONTRIBUTING.md](CONTRIBUTING.md)

bigquery/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
This section contains samples for [Google BigQuery](https://cloud.google.com/bigquery).
44

5-
## Running the samples
6-
7-
These samples must be run as modules, for example:
8-
9-
```
10-
$ python -m bigquery.samples.async_query [your-project-id] [your-query]
11-
```
12-
135
## Other Samples
146

157
* [Using BigQuery from Google App Engine](../appengine/bigquery).

storage/api/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

storage/tests/test_compose_objects.py renamed to storage/api/test_compose_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414
import os
1515

16-
from storage.compose_objects import main
16+
from .compose_objects import main
1717
from tests import CloudBaseTest
1818

1919

storage/tests/test_list_objects.py renamed to storage/api/test_list_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313
#
14-
from storage.list_objects import main
14+
from .list_objects import main
1515
from tests import CloudBaseTest
1616

1717

storage/storage_transfer/test_aws_request.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

storage/storage_transfer/test_create_client.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

storage/storage_transfer/test_nearline_request.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

storage/storage_transfer/test_transfer_check.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

storage/transfer_service/__init__.py

Whitespace-only changes.

storage/storage_transfer/aws_request.py renamed to storage/transfer_service/aws_request.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
import json
1616
import logging
1717

18-
import create_client
18+
from apiclient import discovery
19+
from oauth2client.client import GoogleCredentials
20+
21+
22+
logging.basicConfig(level=logging.DEBUG)
1923

2024

2125
def main():
2226
"""Create a one-off transfer from Amazon S3 to GCS."""
23-
logging.getLogger().setLevel(logging.DEBUG)
24-
transfer_service_client = create_client.create_transfer_client()
27+
credentials = GoogleCredentials.get_application_default()
28+
storagetransfer = discovery.build(
29+
'storagetransfer', 'v1', credentials=credentials)
2530

2631
# Edit this template with desired parameters.
2732
# Specify times below using US Pacific Time Zone.
@@ -61,7 +66,7 @@ def main():
6166
}
6267
'''
6368

64-
result = transfer_service_client.transferJobs().create(body=json.loads(
69+
result = storagetransfer.transferJobs().create(body=json.loads(
6570
transfer_job)).execute()
6671
logging.info('Returned transferJob: %s', json.dumps(result, indent=4))
6772

storage/storage_transfer/nearline_request.py renamed to storage/transfer_service/nearline_request.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
import json
1616
import logging
1717

18-
import create_client
18+
from apiclient import discovery
19+
from oauth2client.client import GoogleCredentials
20+
21+
22+
logging.basicConfig(level=logging.DEBUG)
1923

2024

2125
def main():
2226
"""Transfer from standard Cloud Storage to Cloud Storage Nearline."""
23-
logging.getLogger().setLevel(logging.DEBUG)
24-
transfer_service_client = create_client.create_transfer_client()
27+
credentials = GoogleCredentials.get_application_default()
28+
storagetransfer = discovery.build(
29+
'storagetransfer', 'v1', credentials=credentials)
2530

2631
# Edit this template with desired parameters.
2732
# Specify times below using US Pacific Time Zone.
@@ -57,7 +62,7 @@ def main():
5762
}
5863
}
5964
'''
60-
result = transfer_service_client.transferJobs().create(body=json.loads(
65+
result = storagetransfer.transferJobs().create(body=json.loads(
6166
transfer_job)).execute()
6267
logging.info('Returned transferJob: %s', json.dumps(result, indent=4))
6368

storage/storage_transfer/transfer_check.py renamed to storage/transfer_service/transfer_check.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,34 @@
1515
import json
1616
import logging
1717

18-
import create_client
18+
from apiclient import discovery
19+
from oauth2client.client import GoogleCredentials
20+
21+
22+
logging.basicConfig(level=logging.DEBUG)
1923

2024
# Edit these values with desired parameters.
2125
PROJECT_ID = 'YOUR_PROJECT_ID'
2226
JOB_NAME = 'YOUR_JOB_NAME'
2327

2428

25-
def check_operation(transfer_service_client, project_id, job_name):
29+
def check_operation(storagetransfer, project_id, job_name):
2630
"""Review the transfer operations associated with a transfer job."""
2731
filterString = (
2832
'{{"project_id": "{project_id}", '
29-
'"job_names": ["{job_name}"]}}').format(
30-
project_id=project_id, job_name=job_name)
31-
return transfer_service_client.transferOperations().list(
33+
'"job_names": ["{job_name}"]}}'
34+
).format(project_id=project_id, job_name=job_name)
35+
return storagetransfer.transferOperations().list(
3236
name="transferOperations",
3337
filter=filterString).execute()
3438

3539

3640
def main():
37-
logging.getLogger().setLevel(logging.DEBUG)
38-
transfer_service_client = create_client.create_transfer_client()
41+
credentials = GoogleCredentials.get_application_default()
42+
storagetransfer = discovery.build(
43+
'storagetransfer', 'v1', credentials=credentials)
3944

40-
result = check_operation(transfer_service_client, PROJECT_ID, JOB_NAME)
45+
result = check_operation(storagetransfer, PROJECT_ID, JOB_NAME)
4146
logging.info('Result of transferOperations/list: %s',
4247
json.dumps(result, indent=4, sort_keys=True))
4348

0 commit comments

Comments
 (0)