Skip to content

Commit 6ea6730

Browse files
committed
Added iterable check for APIs
1 parent 87c9a91 commit 6ea6730

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

datadog/api/api_client.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import time
88
import zlib
99

10+
from collections.abc import Iterable
11+
1012
# datadog
1113
from datadog.api import _api_version, _max_timeouts, _backoff_period
1214
from datadog.api.exceptions import (
@@ -136,7 +138,7 @@ def submit(cls, method, path, api_version=None, body=None, attach_host_name=Fals
136138
body['host'] = _host_name
137139

138140
# If defined, make sure tags are defined as a comma-separated string
139-
if 'tags' in params and isinstance(params['tags'], list):
141+
if 'tags' in params and isinstance(params['tags'], Iterable):
140142
tag_list = normalize_tags(params['tags'])
141143
params['tags'] = ','.join(tag_list)
142144

datadog/api/monitors.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
22
# This product includes software developed at Datadog (https://www.datadoghq.com/).
33
# Copyright 2015-Present Datadog, Inc
4+
from collections.abc import Iterable
5+
46
from datadog.api.resources import GetableAPIResource, CreateableAPIResource, \
57
UpdatableAPIResource, ListableAPIResource, DeletableAPIResource, \
68
ActionAPIResource
@@ -54,7 +56,7 @@ def get_all(cls, **params):
5456
:returns: Dictionary representing the API's JSON response
5557
"""
5658
for p in ['group_states', 'tags', 'monitor_tags']:
57-
if p in params and isinstance(params[p], list):
59+
if p in params and isinstance(params[p], Iterable):
5860
params[p] = ','.join(params[p])
5961

6062
return super(Monitor, cls).get_all(**params)

datadog/api/synthetics.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
22
# This product includes software developed at Datadog (https://www.datadoghq.com/).
33
# Copyright 2015-Present Datadog, Inc
4+
from collections.abc import Iterable
5+
46
from datadog.api.exceptions import ApiError
57
from datadog.api.resources import (
68
CreateableAPIResource,
@@ -55,7 +57,7 @@ def get_all_tests(cls, **params):
5557
"""
5658

5759
for p in ["locations", "tags"]:
58-
if p in params and isinstance(params[p], list):
60+
if p in params and isinstance(params[p], Iterable):
5961
params[p] = ",".join(params[p])
6062

6163
# API path = "synthetics/tests"

0 commit comments

Comments
 (0)