Skip to content

Commit

Permalink
Added iterable check for APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
bharel committed Mar 4, 2020
1 parent 87c9a91 commit 6ea6730
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion datadog/api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import time
import zlib

from collections.abc import Iterable

# datadog
from datadog.api import _api_version, _max_timeouts, _backoff_period
from datadog.api.exceptions import (
Expand Down Expand Up @@ -136,7 +138,7 @@ def submit(cls, method, path, api_version=None, body=None, attach_host_name=Fals
body['host'] = _host_name

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

Expand Down
4 changes: 3 additions & 1 deletion datadog/api/monitors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2015-Present Datadog, Inc
from collections.abc import Iterable

from datadog.api.resources import GetableAPIResource, CreateableAPIResource, \
UpdatableAPIResource, ListableAPIResource, DeletableAPIResource, \
ActionAPIResource
Expand Down Expand Up @@ -54,7 +56,7 @@ def get_all(cls, **params):
:returns: Dictionary representing the API's JSON response
"""
for p in ['group_states', 'tags', 'monitor_tags']:
if p in params and isinstance(params[p], list):
if p in params and isinstance(params[p], Iterable):
params[p] = ','.join(params[p])

return super(Monitor, cls).get_all(**params)
Expand Down
4 changes: 3 additions & 1 deletion datadog/api/synthetics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2015-Present Datadog, Inc
from collections.abc import Iterable

from datadog.api.exceptions import ApiError
from datadog.api.resources import (
CreateableAPIResource,
Expand Down Expand Up @@ -55,7 +57,7 @@ def get_all_tests(cls, **params):
"""

for p in ["locations", "tags"]:
if p in params and isinstance(params[p], list):
if p in params and isinstance(params[p], Iterable):
params[p] = ",".join(params[p])

# API path = "synthetics/tests"
Expand Down

0 comments on commit 6ea6730

Please sign in to comment.