|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 |
|
| 17 | +import sys |
17 | 18 |
|
18 | | -def run_quickstart(project="my-project"): |
| 19 | + |
| 20 | +def run_quickstart(override_values={}): |
19 | 21 | # [START bigquerydatatransfer_quickstart] |
20 | 22 | from google.cloud import bigquery_datatransfer |
21 | 23 |
|
22 | 24 | client = bigquery_datatransfer.DataTransferServiceClient() |
23 | 25 |
|
24 | 26 | # TODO: Update to your project ID. |
25 | | - # project = "my-project" |
| 27 | + project_id = "my-project" |
| 28 | + # [END bigquerydatatransfer_quickstart] |
| 29 | + # To facilitate testing, we replace values with alternatives |
| 30 | + # provided by the testing harness. |
| 31 | + project_id = override_values.get("project_id", project_id) |
| 32 | + # [START bigquerydatatransfer_quickstart] |
26 | 33 |
|
27 | 34 | # Get the full path to your project. |
28 | | - parent = f"projects/{project}" |
| 35 | + parent = client.common_project_path(project_id) |
29 | 36 |
|
30 | | - print('Supported Data Sources:') |
| 37 | + print("Supported Data Sources:") |
31 | 38 |
|
32 | 39 | # Iterate over all possible data sources. |
33 | 40 | for data_source in client.list_data_sources(parent=parent): |
34 | | - print('{}:'.format(data_source.display_name)) |
35 | | - print('\tID: {}'.format(data_source.data_source_id)) |
36 | | - print('\tFull path: {}'.format(data_source.name)) |
37 | | - print('\tDescription: {}'.format(data_source.description)) |
| 41 | + print("{}:".format(data_source.display_name)) |
| 42 | + print("\tID: {}".format(data_source.data_source_id)) |
| 43 | + print("\tFull path: {}".format(data_source.name)) |
| 44 | + print("\tDescription: {}".format(data_source.description)) |
38 | 45 | # [END bigquerydatatransfer_quickstart] |
39 | 46 |
|
40 | 47 |
|
41 | | -if __name__ == '__main__': |
42 | | - run_quickstart() |
| 48 | +if __name__ == "__main__": |
| 49 | + run_quickstart(override_values={"project_id": sys.argv[1]}) |
0 commit comments