21
21
22
22
23
23
# [START healthcare_get_client]
24
- def get_client (service_account_json , api_key ):
24
+ def get_client (service_account_json ):
25
25
"""Returns an authorized API client by discovering the Healthcare API and
26
26
creating a service object using the service account credentials JSON."""
27
27
api_scopes = ['https://www.googleapis.com/auth/cloud-platform' ]
@@ -33,8 +33,8 @@ def get_client(service_account_json, api_key):
33
33
service_account_json )
34
34
scoped_credentials = credentials .with_scopes (api_scopes )
35
35
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 )
38
38
39
39
return discovery .build (
40
40
service_name ,
@@ -48,13 +48,12 @@ def get_client(service_account_json, api_key):
48
48
# [START healthcare_create_dicom_store]
49
49
def create_dicom_store (
50
50
service_account_json ,
51
- api_key ,
52
51
project_id ,
53
52
cloud_region ,
54
53
dataset_id ,
55
54
dicom_store_id ):
56
55
"""Creates a new DICOM store within the parent dataset."""
57
- client = get_client (service_account_json , api_key )
56
+ client = get_client (service_account_json )
58
57
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
59
58
project_id , cloud_region , dataset_id )
60
59
@@ -76,13 +75,12 @@ def create_dicom_store(
76
75
# [START healthcare_delete_dicom_store]
77
76
def delete_dicom_store (
78
77
service_account_json ,
79
- api_key ,
80
78
project_id ,
81
79
cloud_region ,
82
80
dataset_id ,
83
81
dicom_store_id ):
84
82
"""Deletes the specified DICOM store."""
85
- client = get_client (service_account_json , api_key )
83
+ client = get_client (service_account_json )
86
84
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
87
85
project_id , cloud_region , dataset_id )
88
86
dicom_store_name = '{}/dicomStores/{}' .format (
@@ -104,13 +102,12 @@ def delete_dicom_store(
104
102
# [START healthcare_get_dicom_store]
105
103
def get_dicom_store (
106
104
service_account_json ,
107
- api_key ,
108
105
project_id ,
109
106
cloud_region ,
110
107
dataset_id ,
111
108
dicom_store_id ):
112
109
"""Gets the specified DICOM store."""
113
- client = get_client (service_account_json , api_key )
110
+ client = get_client (service_account_json )
114
111
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
115
112
project_id , cloud_region , dataset_id )
116
113
dicom_store_name = '{}/dicomStores/{}' .format (
@@ -133,12 +130,11 @@ def get_dicom_store(
133
130
# [START healthcare_list_dicom_stores]
134
131
def list_dicom_stores (
135
132
service_account_json ,
136
- api_key ,
137
133
project_id ,
138
134
cloud_region ,
139
135
dataset_id ):
140
136
"""Lists the DICOM stores in the given dataset."""
141
- client = get_client (service_account_json , api_key )
137
+ client = get_client (service_account_json )
142
138
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
143
139
project_id , cloud_region , dataset_id )
144
140
@@ -159,14 +155,13 @@ def list_dicom_stores(
159
155
# [START healthcare_patch_dicom_store]
160
156
def patch_dicom_store (
161
157
service_account_json ,
162
- api_key ,
163
158
project_id ,
164
159
cloud_region ,
165
160
dataset_id ,
166
161
dicom_store_id ,
167
162
pubsub_topic ):
168
163
"""Updates the DICOM store."""
169
- client = get_client (service_account_json , api_key )
164
+ client = get_client (service_account_json )
170
165
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
171
166
project_id , cloud_region , dataset_id )
172
167
dicom_store_name = '{}/dicomStores/{}' .format (
@@ -198,15 +193,14 @@ def patch_dicom_store(
198
193
# [START healthcare_export_dicom_instance]
199
194
def export_dicom_instance (
200
195
service_account_json ,
201
- api_key ,
202
196
project_id ,
203
197
cloud_region ,
204
198
dataset_id ,
205
199
dicom_store_id ,
206
200
uri_prefix ):
207
201
"""Export data to a Google Cloud Storage bucket by copying
208
202
it from the DICOM store."""
209
- client = get_client (service_account_json , api_key )
203
+ client = get_client (service_account_json )
210
204
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
211
205
project_id , cloud_region , dataset_id )
212
206
dicom_store_name = '{}/dicomStores/{}' .format (
@@ -234,7 +228,6 @@ def export_dicom_instance(
234
228
# [START healthcare_import_dicom_instance]
235
229
def import_dicom_instance (
236
230
service_account_json ,
237
- api_key ,
238
231
project_id ,
239
232
cloud_region ,
240
233
dataset_id ,
@@ -243,7 +236,7 @@ def import_dicom_instance(
243
236
"""Import data into the DICOM store by copying it from the specified
244
237
source.
245
238
"""
246
- client = get_client (service_account_json , api_key )
239
+ client = get_client (service_account_json )
247
240
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
248
241
project_id , cloud_region , dataset_id )
249
242
dicom_store_name = '{}/dicomStores/{}' .format (
@@ -273,13 +266,12 @@ def import_dicom_instance(
273
266
# [START healthcare_dicom_store_get_iam_policy]
274
267
def get_dicom_store_iam_policy (
275
268
service_account_json ,
276
- api_key ,
277
269
project_id ,
278
270
cloud_region ,
279
271
dataset_id ,
280
272
dicom_store_id ):
281
273
"""Gets the IAM policy for the specified dicom store."""
282
- client = get_client (service_account_json , api_key )
274
+ client = get_client (service_account_json )
283
275
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
284
276
project_id , cloud_region , dataset_id )
285
277
dicom_store_name = '{}/dicomStores/{}' .format (
@@ -297,7 +289,6 @@ def get_dicom_store_iam_policy(
297
289
# [START healthcare_dicom_store_set_iam_policy]
298
290
def set_dicom_store_iam_policy (
299
291
service_account_json ,
300
- api_key ,
301
292
project_id ,
302
293
cloud_region ,
303
294
dataset_id ,
@@ -320,7 +311,7 @@ def set_dicom_store_iam_policy(
320
311
A role can be any IAM role, such as 'roles/viewer', 'roles/owner',
321
312
or 'roles/editor'
322
313
"""
323
- client = get_client (service_account_json , api_key )
314
+ client = get_client (service_account_json )
324
315
dicom_store_parent = 'projects/{}/locations/{}/datasets/{}' .format (
325
316
project_id , cloud_region , dataset_id )
326
317
dicom_store_name = '{}/dicomStores/{}' .format (
@@ -362,11 +353,6 @@ def parse_command_line_args():
362
353
default = os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" ),
363
354
help = 'Path to service account JSON file.' )
364
355
365
- parser .add_argument (
366
- '--api_key' ,
367
- default = os .environ .get ("API_KEY" ),
368
- help = 'Your API key' )
369
-
370
356
parser .add_argument (
371
357
'--project_id' ,
372
358
default = os .environ .get ("GOOGLE_CLOUD_PROJECT" ),
@@ -458,7 +444,6 @@ def run_command(args):
458
444
elif args .command == 'create-dicom-store' :
459
445
create_dicom_store (
460
446
args .service_account_json ,
461
- args .api_key ,
462
447
args .project_id ,
463
448
args .cloud_region ,
464
449
args .dataset_id ,
@@ -467,7 +452,6 @@ def run_command(args):
467
452
elif args .command == 'delete-dicom-store' :
468
453
delete_dicom_store (
469
454
args .service_account_json ,
470
- args .api_key ,
471
455
args .project_id ,
472
456
args .cloud_region ,
473
457
args .dataset_id ,
@@ -476,7 +460,6 @@ def run_command(args):
476
460
elif args .command == 'get-dicom-store' :
477
461
get_dicom_store (
478
462
args .service_account_json ,
479
- args .api_key ,
480
463
args .project_id ,
481
464
args .cloud_region ,
482
465
args .dataset_id ,
@@ -485,15 +468,13 @@ def run_command(args):
485
468
elif args .command == 'list-dicom-stores' :
486
469
list_dicom_stores (
487
470
args .service_account_json ,
488
- args .api_key ,
489
471
args .project_id ,
490
472
args .cloud_region ,
491
473
args .dataset_id )
492
474
493
475
elif args .command == 'patch-dicom-store' :
494
476
patch_dicom_store (
495
477
args .service_account_json ,
496
- args .api_key ,
497
478
args .project_id ,
498
479
args .cloud_region ,
499
480
args .dataset_id ,
@@ -503,7 +484,6 @@ def run_command(args):
503
484
elif args .command == 'export-dicom-store' :
504
485
export_dicom_instance (
505
486
args .service_account_json ,
506
- args .api_key ,
507
487
args .project_id ,
508
488
args .cloud_region ,
509
489
args .dataset_id ,
@@ -513,7 +493,6 @@ def run_command(args):
513
493
elif args .command == 'import-dicom-store' :
514
494
import_dicom_instance (
515
495
args .service_account_json ,
516
- args .api_key ,
517
496
args .project_id ,
518
497
args .cloud_region ,
519
498
args .dataset_id ,
@@ -523,7 +502,6 @@ def run_command(args):
523
502
elif args .command == 'get_iam_policy' :
524
503
get_dicom_store_iam_policy (
525
504
args .service_account_json ,
526
- args .api_key ,
527
505
args .project_id ,
528
506
args .cloud_region ,
529
507
args .dataset_id ,
@@ -532,7 +510,6 @@ def run_command(args):
532
510
elif args .command == 'set_iam_policy' :
533
511
set_dicom_store_iam_policy (
534
512
args .service_account_json ,
535
- args .api_key ,
536
513
args .project_id ,
537
514
args .cloud_region ,
538
515
args .dataset_id ,
0 commit comments