Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit abb1d9a

Browse filesBrowse files
authored
Remove api keys (GoogleCloudPlatform#2125)
* Updated datasets samples to remove api keys * Updated dicom samples to remove api keys * Updated fhir samples to remove api keys * Updated all samples to remove api keys
1 parent ccc8fda commit abb1d9a
Copy full SHA for abb1d9a
Expand file treeCollapse file tree

16 files changed

+71
-284
lines changed

‎healthcare/api-client/datasets/README.rst.in

Copy file name to clipboardExpand all lines: healthcare/api-client/datasets/README.rst.in
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ product:
1616

1717
setup:
1818
- auth
19-
- auth_api_key
2019
- install_deps
2120

2221
samples:

‎healthcare/api-client/datasets/datasets.py

Copy file name to clipboardExpand all lines: healthcare/api-client/datasets/datasets.py
+12-32Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
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]
4848
def 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]
7574
def 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]
10098
def 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]
142139
def 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]
177173
def 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]
241236
def 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]
262256
def 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,

‎healthcare/api-client/datasets/datasets_test.py

Copy file name to clipboardExpand all lines: healthcare/api-client/datasets/datasets_test.py
+5-16Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import datasets
1919

2020
cloud_region = 'us-central1'
21-
api_key = os.environ['API_KEY']
2221
project_id = os.environ['GOOGLE_CLOUD_PROJECT']
2322
service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS']
2423

@@ -31,20 +30,19 @@
3130
def test_CRUD_dataset(capsys):
3231
datasets.create_dataset(
3332
service_account_json,
34-
api_key,
3533
project_id,
3634
cloud_region,
3735
dataset_id)
3836

3937
datasets.get_dataset(
40-
service_account_json, api_key, project_id, cloud_region, dataset_id)
38+
service_account_json, project_id, cloud_region, dataset_id)
4139

4240
datasets.list_datasets(
43-
service_account_json, api_key, project_id, cloud_region)
41+
service_account_json, project_id, cloud_region)
4442

4543
# Test and also clean up
4644
datasets.delete_dataset(
47-
service_account_json, api_key, project_id, cloud_region, dataset_id)
45+
service_account_json, project_id, cloud_region, dataset_id)
4846

4947
out, _ = capsys.readouterr()
5048

@@ -58,22 +56,20 @@ def test_CRUD_dataset(capsys):
5856
def test_patch_dataset(capsys):
5957
datasets.create_dataset(
6058
service_account_json,
61-
api_key,
6259
project_id,
6360
cloud_region,
6461
dataset_id)
6562

6663
datasets.patch_dataset(
6764
service_account_json,
68-
api_key,
6965
project_id,
7066
cloud_region,
7167
dataset_id,
7268
time_zone)
7369

7470
# Clean up
7571
datasets.delete_dataset(
76-
service_account_json, api_key, project_id, cloud_region, dataset_id)
72+
service_account_json, project_id, cloud_region, dataset_id)
7773

7874
out, _ = capsys.readouterr()
7975

@@ -84,14 +80,12 @@ def test_patch_dataset(capsys):
8480
def test_deidentify_dataset(capsys):
8581
datasets.create_dataset(
8682
service_account_json,
87-
api_key,
8883
project_id,
8984
cloud_region,
9085
dataset_id)
9186

9287
datasets.deidentify_dataset(
9388
service_account_json,
94-
api_key,
9589
project_id,
9690
cloud_region,
9791
dataset_id,
@@ -100,10 +94,9 @@ def test_deidentify_dataset(capsys):
10094

10195
# Clean up
10296
datasets.delete_dataset(
103-
service_account_json, api_key, project_id, cloud_region, dataset_id)
97+
service_account_json, project_id, cloud_region, dataset_id)
10498
datasets.delete_dataset(
10599
service_account_json,
106-
api_key,
107100
project_id,
108101
cloud_region,
109102
destination_dataset_id)
@@ -117,21 +110,18 @@ def test_deidentify_dataset(capsys):
117110
def test_get_set_dataset_iam_policy(capsys):
118111
datasets.create_dataset(
119112
service_account_json,
120-
api_key,
121113
project_id,
122114
cloud_region,
123115
dataset_id)
124116

125117
get_response = datasets.get_dataset_iam_policy(
126118
service_account_json,
127-
api_key,
128119
project_id,
129120
cloud_region,
130121
dataset_id)
131122

132123
set_response = datasets.set_dataset_iam_policy(
133124
service_account_json,
134-
api_key,
135125
project_id,
136126
cloud_region,
137127
dataset_id,
@@ -141,7 +131,6 @@ def test_get_set_dataset_iam_policy(capsys):
141131
# Clean up
142132
datasets.delete_dataset(
143133
service_account_json,
144-
api_key,
145134
project_id,
146135
cloud_region,
147136
dataset_id)

‎healthcare/api-client/dicom/README.rst.in

Copy file name to clipboardExpand all lines: healthcare/api-client/dicom/README.rst.in
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ product:
1616

1717
setup:
1818
- auth
19-
- auth_api_key
2019
- install_deps
2120

2221
samples:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.