2121
2222
2323# [START healthcare_get_client]
24- def get_client (service_account_json , api_key ):
24+ def get_client (service_account_json ):
2525 """Returns an authorized API client by discovering the Healthcare API and
2626 creating a service object using the service account credentials JSON."""
2727 api_scopes = ['https://www.googleapis.com/auth/cloud-platform' ]
@@ -33,8 +33,8 @@ def get_client(service_account_json, api_key):
3333 service_account_json )
3434 scoped_credentials = credentials .with_scopes (api_scopes )
3535
36- discovery_url = '{}?labels=CHC_BETA&version={}&key={} ' .format (
37- discovery_api , api_version , api_key )
36+ discovery_url = '{}?labels=CHC_BETA&version={}' .format (
37+ discovery_api , api_version )
3838
3939 return discovery .build (
4040 service_name ,
@@ -47,12 +47,11 @@ def get_client(service_account_json, api_key):
4747# [START healthcare_create_dataset]
4848def create_dataset (
4949 service_account_json ,
50- api_key ,
5150 project_id ,
5251 cloud_region ,
5352 dataset_id ):
5453 """Creates a dataset."""
55- client = get_client (service_account_json , api_key )
54+ client = get_client (service_account_json )
5655 dataset_parent = 'projects/{}/locations/{}' .format (
5756 project_id , cloud_region )
5857
@@ -74,12 +73,11 @@ def create_dataset(
7473# [START healthcare_delete_dataset]
7574def delete_dataset (
7675 service_account_json ,
77- api_key ,
7876 project_id ,
7977 cloud_region ,
8078 dataset_id ):
8179 """Deletes a dataset."""
82- client = get_client (service_account_json , api_key )
80+ client = get_client (service_account_json )
8381 dataset_name = 'projects/{}/locations/{}/datasets/{}' .format (
8482 project_id , cloud_region , dataset_id )
8583
@@ -99,12 +97,11 @@ def delete_dataset(
9997# [START healthcare_get_dataset]
10098def get_dataset (
10199 service_account_json ,
102- api_key ,
103100 project_id ,
104101 cloud_region ,
105102 dataset_id ):
106103 """Gets any metadata associated with a dataset."""
107- client = get_client (service_account_json , api_key )
104+ client = get_client (service_account_json )
108105 dataset_name = 'projects/{}/locations/{}/datasets/{}' .format (
109106 project_id , cloud_region , dataset_id )
110107
@@ -119,9 +116,9 @@ def get_dataset(
119116
120117
121118# [START healthcare_list_datasets]
122- def list_datasets (service_account_json , api_key , project_id , cloud_region ):
119+ def list_datasets (service_account_json , project_id , cloud_region ):
123120 """Lists the datasets in the project."""
124- client = get_client (service_account_json , api_key )
121+ client = get_client (service_account_json )
125122 dataset_parent = 'projects/{}/locations/{}' .format (
126123 project_id , cloud_region )
127124
@@ -141,13 +138,12 @@ def list_datasets(service_account_json, api_key, project_id, cloud_region):
141138# [START healthcare_patch_dataset]
142139def patch_dataset (
143140 service_account_json ,
144- api_key ,
145141 project_id ,
146142 cloud_region ,
147143 dataset_id ,
148144 time_zone ):
149145 """Updates dataset metadata."""
150- client = get_client (service_account_json , api_key )
146+ client = get_client (service_account_json )
151147 dataset_parent = 'projects/{}/locations/{}' .format (
152148 project_id , cloud_region )
153149 dataset_name = '{}/datasets/{}' .format (dataset_parent , dataset_id )
@@ -176,7 +172,6 @@ def patch_dataset(
176172# [START healthcare_deidentify_dataset]
177173def deidentify_dataset (
178174 service_account_json ,
179- api_key ,
180175 project_id ,
181176 cloud_region ,
182177 dataset_id ,
@@ -185,7 +180,7 @@ def deidentify_dataset(
185180 """Creates a new dataset containing de-identified data
186181 from the source dataset.
187182 """
188- client = get_client (service_account_json , api_key )
183+ client = get_client (service_account_json )
189184 source_dataset = 'projects/{}/locations/{}/datasets/{}' .format (
190185 project_id , cloud_region , dataset_id )
191186 destination_dataset = 'projects/{}/locations/{}/datasets/{}' .format (
@@ -240,12 +235,11 @@ def deidentify_dataset(
240235# [START healthcare_dataset_get_iam_policy]
241236def get_dataset_iam_policy (
242237 service_account_json ,
243- api_key ,
244238 project_id ,
245239 cloud_region ,
246240 dataset_id ):
247241 """Gets the IAM policy for the specified dataset."""
248- client = get_client (service_account_json , api_key )
242+ client = get_client (service_account_json )
249243 dataset_name = 'projects/{}/locations/{}/datasets/{}' .format (
250244 project_id , cloud_region , dataset_id )
251245
@@ -261,7 +255,6 @@ def get_dataset_iam_policy(
261255# [START healthcare_dataset_set_iam_policy]
262256def set_dataset_iam_policy (
263257 service_account_json ,
264- api_key ,
265258 project_id ,
266259 cloud_region ,
267260 dataset_id ,
@@ -283,7 +276,7 @@ def set_dataset_iam_policy(
283276 A role can be any IAM role, such as 'roles/viewer', 'roles/owner',
284277 or 'roles/editor'
285278 """
286- client = get_client (service_account_json , api_key )
279+ client = get_client (service_account_json )
287280 dataset_name = 'projects/{}/locations/{}/datasets/{}' .format (
288281 project_id , cloud_region , dataset_id )
289282
@@ -323,11 +316,6 @@ def parse_command_line_args():
323316 default = os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" ),
324317 help = 'Path to service account JSON file.' )
325318
326- parser .add_argument (
327- '--api_key' ,
328- default = os .environ .get ("API_KEY" ),
329- help = 'Your API key.' )
330-
331319 parser .add_argument (
332320 '--project_id' ,
333321 default = os .environ .get ("GOOGLE_CLOUD_PROJECT" ),
@@ -395,38 +383,33 @@ def run_command(args):
395383 elif args .command == 'create-dataset' :
396384 create_dataset (
397385 args .service_account_json ,
398- args .api_key ,
399386 args .project_id ,
400387 args .cloud_region ,
401388 args .dataset_id )
402389
403390 elif args .command == 'delete-dataset' :
404391 delete_dataset (
405392 args .service_account_json ,
406- args .api_key ,
407393 args .project_id ,
408394 args .cloud_region ,
409395 args .dataset_id )
410396
411397 elif args .command == 'get-dataset' :
412398 get_dataset (
413399 args .service_account_json ,
414- args .api_key ,
415400 args .project_id ,
416401 args .cloud_region ,
417402 args .dataset_id )
418403
419404 elif args .command == 'list-datasets' :
420405 list_datasets (
421406 args .service_account_json ,
422- args .api_key ,
423407 args .project_id ,
424408 args .cloud_region )
425409
426410 elif args .command == 'patch-dataset' :
427411 patch_dataset (
428412 args .service_account_json ,
429- args .api_key ,
430413 args .project_id ,
431414 args .cloud_region ,
432415 args .dataset_id ,
@@ -435,7 +418,6 @@ def run_command(args):
435418 elif args .command == 'deidentify-dataset' :
436419 deidentify_dataset (
437420 args .service_account_json ,
438- args .api_key ,
439421 args .project_id ,
440422 args .cloud_region ,
441423 args .dataset_id ,
@@ -445,15 +427,13 @@ def run_command(args):
445427 elif args .command == 'get_iam_policy' :
446428 get_dataset_iam_policy (
447429 args .service_account_json ,
448- args .api_key ,
449430 args .project_id ,
450431 args .cloud_region ,
451432 args .dataset_id )
452433
453434 elif args .command == 'set_iam_policy' :
454435 set_dataset_iam_policy (
455436 args .service_account_json ,
456- args .api_key ,
457437 args .project_id ,
458438 args .cloud_region ,
459439 args .dataset_id ,
0 commit comments