Skip to content

Commit 8ae1cf6

Browse files
authored
Update dogshell site parameter handling, fix us1 and add gov and custom url (#780)
1 parent 42d7678 commit 8ae1cf6

File tree

3 files changed

+20
-36
lines changed

3 files changed

+20
-36
lines changed

datadog/dogshell/__init__.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,8 @@ def main():
7474
parser.add_argument(
7575
"--api_host",
7676
help="Datadog site to send data, us (datadoghq.com), eu (datadoghq.eu), us3 (us3.datadoghq.com), \
77-
us5 (us5.datadoghq.com), or ap1 (ap1.datadoghq.com). default: us",
77+
us5 (us5.datadoghq.com), ap1 (ap1.datadoghq.com), gov (ddog-gov.com), or custom url. default: us",
7878
dest="api_host",
79-
choices=[
80-
"datadoghq.com",
81-
"us",
82-
"datadoghq.eu",
83-
"eu",
84-
"us3.datadoghq.com",
85-
"us3",
86-
"us5.datadoghq.com",
87-
"us5",
88-
"ap1.datadoghq.com",
89-
"ap1"
90-
],
9179
)
9280

9381
config = DogshellConfig()

datadog/dogshell/common.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,20 @@ def load(self, config_file, api_key, app_key, api_host):
4747
config = configparser.ConfigParser()
4848

4949
if api_host is not None:
50-
if api_host in ("us" or "datadoghq.com"):
51-
self["api_host"] = "https://datadoghq.com"
50+
if api_host in ("datadoghq.com", "us"):
51+
self["api_host"] = "https://api.datadoghq.com"
5252
elif api_host in ("datadoghq.eu", "eu"):
53-
self["api_host"] = "https://datadoghq.eu"
53+
self["api_host"] = "https://api.datadoghq.eu"
5454
elif api_host in ("us3.datadoghq.com", "us3"):
55-
self["api_host"] = "https://us3.datadoghq.com"
55+
self["api_host"] = "https://api.us3.datadoghq.com"
5656
elif api_host in ("us5.datadoghq.com", "us5"):
57-
self["api_host"] = "https://us5.datadoghq.com"
57+
self["api_host"] = "https://api.us5.datadoghq.com"
5858
elif api_host in ("ap1.datadoghq.com", "ap1"):
59-
self["api_host"] = "https://ap1.datadoghq.com"
60-
59+
self["api_host"] = "https://api.ap1.datadoghq.com"
60+
elif api_host in ("ddog-gov.com", "gov"):
61+
self["api_host"] = "https://api.ddog-gov.com"
62+
else:
63+
self["api_host"] = api_host
6164
if api_key is not None and app_key is not None:
6265
self["api_key"] = api_key
6366
self["app_key"] = app_key

datadog/dogshell/wrap.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284,22 +284,11 @@ def parse_options(raw_args=None):
284284
"-s",
285285
"--site",
286286
action="store",
287-
type="choice",
287+
type="string",
288288
default="datadoghq.com",
289-
choices=[
290-
"datadoghq.com",
291-
"us",
292-
"datadoghq.eu",
293-
"eu",
294-
"us3.datadoghq.com",
295-
"us3",
296-
"us5.datadoghq.com",
297-
"us5",
298-
"ap1.datadoghq.com",
299-
"ap1"
300-
],
301289
help="The site to send data. Accepts us (datadoghq.com), eu (datadoghq.eu), \
302-
us3 (us3.datadoghq.com), us5 (us5.datadoghq.com), or ap1 (ap1.datadoghq.com). default: us",
290+
us3 (us3.datadoghq.com), us5 (us5.datadoghq.com), or ap1 (ap1.datadoghq.com), \
291+
gov (ddog-gov.com), or custom url. default: us",
303292
)
304293
parser.add_option(
305294
"-m",
@@ -430,16 +419,20 @@ def main():
430419
options.buffer_outs,
431420
)
432421

433-
if options.site in ("datadoghq.eu", "eu"):
422+
if options.site in ("datadoghq.com", "us"):
423+
api_host = "https://api.datadoghq.com"
424+
elif options.site in ("datadoghq.eu", "eu"):
434425
api_host = "https://api.datadoghq.eu"
435426
elif options.site in ("us3.datadoghq.com", "us3"):
436427
api_host = "https://api.us3.datadoghq.com"
437428
elif options.site in ("us5.datadoghq.com", "us5"):
438429
api_host = "https://api.us5.datadoghq.com"
439430
elif options.site in ("ap1.datadoghq.com", "ap1"):
440431
api_host = "https://api.ap1.datadoghq.com"
432+
elif options.site in ("ddog-gov.com", "gov"):
433+
api_host = "https://api.ddog-gov.com"
441434
else:
442-
api_host = "https://api.datadoghq.com"
435+
api_host = options.site
443436

444437
initialize(api_key=options.api_key, api_host=api_host)
445438
host = api._host_name

0 commit comments

Comments
 (0)