Skip to content

Commit

Permalink
Reorganizing storage samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott committed Sep 15, 2015
1 parent 2e5d57c commit 6e8fc90
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 187 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ This repository holds the samples used in the python documentation on [cloud.goo
For more detailed introduction to a product, check the README in the
corresponding folder.

## Running the samples

Most samples must be run as modules instead of directly, for example:

```
$ python -m bigquery.samples.async_query [your-project-id] [your-query]
```

Refer to the README in the corresponding folder for any special instructions.

## Contributing changes

* See [CONTRIBUTING.md](CONTRIBUTING.md)
Expand Down
8 changes: 0 additions & 8 deletions bigquery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

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

## Running the samples

These samples must be run as modules, for example:

```
$ python -m bigquery.samples.async_query [your-project-id] [your-query]
```

## Other Samples

* [Using BigQuery from Google App Engine](../appengine/bigquery).
Empty file added storage/api/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 0 additions & 39 deletions storage/storage_transfer/test_aws_request.py

This file was deleted.

44 changes: 0 additions & 44 deletions storage/storage_transfer/test_create_client.py

This file was deleted.

39 changes: 0 additions & 39 deletions storage/storage_transfer/test_nearline_request.py

This file was deleted.

31 changes: 0 additions & 31 deletions storage/storage_transfer/test_transfer_check.py

This file was deleted.

File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@
import json
import logging

import create_client
from apiclient import discovery
from oauth2client.client import GoogleCredentials


logging.basicConfig(level=logging.DEBUG)


def main():
"""Create a one-off transfer from Amazon S3 to GCS."""
logging.getLogger().setLevel(logging.DEBUG)
transfer_service_client = create_client.create_transfer_client()
credentials = GoogleCredentials.get_application_default()
storagetransfer = discovery.build(
'storagetransfer', 'v1', credentials=credentials)

# Edit this template with desired parameters.
# Specify times below using US Pacific Time Zone.
Expand Down Expand Up @@ -61,7 +66,7 @@ def main():
}
'''

result = transfer_service_client.transferJobs().create(body=json.loads(
result = storagetransfer.transferJobs().create(body=json.loads(
transfer_job)).execute()
logging.info('Returned transferJob: %s', json.dumps(result, indent=4))

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@
import json
import logging

import create_client
from apiclient import discovery
from oauth2client.client import GoogleCredentials


logging.basicConfig(level=logging.DEBUG)


def main():
"""Transfer from standard Cloud Storage to Cloud Storage Nearline."""
logging.getLogger().setLevel(logging.DEBUG)
transfer_service_client = create_client.create_transfer_client()
credentials = GoogleCredentials.get_application_default()
storagetransfer = discovery.build(
'storagetransfer', 'v1', credentials=credentials)

# Edit this template with desired parameters.
# Specify times below using US Pacific Time Zone.
Expand Down Expand Up @@ -57,7 +62,7 @@ def main():
}
}
'''
result = transfer_service_client.transferJobs().create(body=json.loads(
result = storagetransfer.transferJobs().create(body=json.loads(
transfer_job)).execute()
logging.info('Returned transferJob: %s', json.dumps(result, indent=4))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,34 @@
import json
import logging

import create_client
from apiclient import discovery
from oauth2client.client import GoogleCredentials


logging.basicConfig(level=logging.DEBUG)

# Edit these values with desired parameters.
PROJECT_ID = 'YOUR_PROJECT_ID'
JOB_NAME = 'YOUR_JOB_NAME'


def check_operation(transfer_service_client, project_id, job_name):
def check_operation(storagetransfer, project_id, job_name):
"""Review the transfer operations associated with a transfer job."""
filterString = (
'{{"project_id": "{project_id}", '
'"job_names": ["{job_name}"]}}').format(
project_id=project_id, job_name=job_name)
return transfer_service_client.transferOperations().list(
'"job_names": ["{job_name}"]}}'
).format(project_id=project_id, job_name=job_name)
return storagetransfer.transferOperations().list(
name="transferOperations",
filter=filterString).execute()


def main():
logging.getLogger().setLevel(logging.DEBUG)
transfer_service_client = create_client.create_transfer_client()
credentials = GoogleCredentials.get_application_default()
storagetransfer = discovery.build(
'storagetransfer', 'v1', credentials=credentials)

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

Expand Down

0 comments on commit 6e8fc90

Please sign in to comment.