Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Commit 1f703f1

Browse files
gguussJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
Gets API key, project ID, and service account JSON from environment [(#1064)](GoogleCloudPlatform/python-docs-samples#1064)
1 parent 367ebbd commit 1f703f1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

samples/api-client/manager/manager.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import argparse
3535
import io
36+
import os
3637
import sys
3738
import time
3839

@@ -344,16 +345,21 @@ def parse_command_line_args():
344345
formatter_class=argparse.RawDescriptionHelpFormatter)
345346

346347
# Required arguments
347-
parser.add_argument(
348-
'--project_id', required=True, help='GCP cloud project name.')
349348
parser.add_argument(
350349
'--pubsub_topic',
351350
required=True,
352351
help=('Google Cloud Pub/Sub topic. '
353352
'Format is projects/project_id/topics/topic-id'))
354-
parser.add_argument('--api_key', required=True, help='Your API key.')
355353

356354
# Optional arguments
355+
parser.add_argument(
356+
'--api_key',
357+
default=os.environ.get("API_KEY"),
358+
help='Your API key.')
359+
parser.add_argument(
360+
'--project_id',
361+
default=os.environ.get("GOOGLE_CLOUD_PROJECT"),
362+
help='GCP cloud project name.')
357363
parser.add_argument(
358364
'--ec_public_key_file',
359365
default=None,
@@ -366,7 +372,7 @@ def parse_command_line_args():
366372
'--cloud_region', default='us-central1', help='GCP cloud region')
367373
parser.add_argument(
368374
'--service_account_json',
369-
default='service_account.json',
375+
default=os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"),
370376
help='Path to service account json file.')
371377
parser.add_argument(
372378
'--registry_id',

0 commit comments

Comments
 (0)