Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 526802402
  • Loading branch information
mksyed-google authored and copybara-github committed Apr 25, 2023
1 parent 3ca804d commit c7a4484
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
29 changes: 22 additions & 7 deletions common/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,33 @@
from common import chronicle_auth

verbose_option = click.option(
"--verbose", is_flag=True, help="Prints verbose output to the console.")
"--verbose", is_flag=True, help="Prints verbose output to the console."
)

credential_file_option = click.option(
"-c",
"--credential_file",
help=f"Path of Service Account JSON. Default: {chronicle_auth.default_cred_file_path}"
help=(
"Path of Service Account JSON. Default:"
f" {chronicle_auth.default_cred_file_path}"
),
)

region_option = click.option(
"--region",
type=click.Choice(["US", "ASIA-SOUTHEAST1", "EUROPE"],
case_sensitive=False),
type=click.Choice(
[
"US",
"ASIA-SOUTHEAST1",
"EUROPE",
"EUROPE-WEST2",
"AUSTRALIA-SOUTHEAST1",
],
case_sensitive=False,
),
default="US",
help="Select region")
help="Select region",
)

url_option = click.option("--url", help="Base URL to be used for API calls")

Expand All @@ -41,7 +54,9 @@
type=click.Choice(["prod", "test"], case_sensitive=False),
default="prod",
help="""Optionally specify
the environment for API calls""")
the environment for API calls""",
)

export_option = click.option(
"--export", help="Export output to specified file path")
"--export", help="Export output to specified file path"
)
8 changes: 8 additions & 0 deletions common/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@

REGION_EUROPE = "europe"
REGION_ASIA_SOUTHEAST1 = "asia-southeast1"
REGION_EUROPE_WEST2 = "europe-west2"
REGION_AUSTRALIA_SOUTHEAST1 = "australia-southeast1"
BASE_URL = "https://backstory.googleapis.com"
BASE_URL_EUROPE = "https://europe-backstory.googleapis.com"
BASE_URL_ASIA_SOUTHEAST1 = "https://asia-southeast1-backstory.googleapis.com"
BASE_URL_EUROPE_WEST2 = "https://europe-west2-backstory.googleapis.com"
BASE_URL_AUSTRALIA_SOUTHEAST1 = "https://australia-southeast1-backstory.googleapis.com"
CHRONICLE_TEST_API_URL = "https://test-backstory.sandbox.googleapis.com"


Expand All @@ -40,6 +44,10 @@ def get_base_url(region: str, custom_url: str, env: str = "prod") -> str:
return BASE_URL_EUROPE
if region == REGION_ASIA_SOUTHEAST1:
return BASE_URL_ASIA_SOUTHEAST1
if region == REGION_EUROPE_WEST2:
return BASE_URL_EUROPE_WEST2
if region == REGION_AUSTRALIA_SOUTHEAST1:
return BASE_URL_AUSTRALIA_SOUTHEAST1
if env == "test":
return CHRONICLE_TEST_API_URL
return BASE_URL

0 comments on commit c7a4484

Please sign in to comment.