Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard list] Add new endpoints + dog cmd for dashboard lists #252

Merged
merged 5 commits into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datadog/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

# Resources
from datadog.api.comments import Comment
from datadog.api.dashboard_lists import DashboardList
from datadog.api.downtimes import Downtime
from datadog.api.timeboards import Timeboard
from datadog.api.events import Event
Expand Down
4 changes: 1 addition & 3 deletions datadog/api/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ class Comment(CreateableAPIResource, UpdatableAPIResource, DeletableAPIResource)
"""
A wrapper around Comment HTTP API.
"""
_class_name = 'comment'
_class_url = '/comments'
_json_name = 'comment'
_resource_name = 'comments'
21 changes: 21 additions & 0 deletions datadog/api/dashboard_lists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from datadog.api.resources import (
AddableAPISubResource,
CreateableAPIResource,
DeletableAPIResource,
DeletableAPISubResource,
GetableAPIResource,
ListableAPIResource,
ListableAPISubResource,
UpdatableAPIResource,
UpdatableAPISubResource
)


class DashboardList(AddableAPISubResource, CreateableAPIResource, DeletableAPIResource,
DeletableAPISubResource, GetableAPIResource, ListableAPIResource,
ListableAPISubResource, UpdatableAPIResource, UpdatableAPISubResource):
"""
A wrapper around Dashboard List HTTP API.
"""
_resource_name = 'dashboard/lists/manual'
_sub_resource_name = 'dashboards'
2 changes: 1 addition & 1 deletion datadog/api/downtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class Downtime(GetableAPIResource, CreateableAPIResource, UpdatableAPIResource,
"""
A wrapper around Monitor Downtiming HTTP API.
"""
_class_url = '/downtime'
_resource_name = 'downtime'
5 changes: 1 addition & 4 deletions datadog/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ class Event(GetableAPIResource, CreateableAPIResource, SearchableAPIResource, De
"""
A wrapper around Event HTTP API.
"""
_class_name = 'event'
_class_url = '/events'
_plural_class_name = 'events'
_json_name = 'event'
_resource_name = 'events'
_timestamp_keys = set(['start', 'end'])

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions datadog/api/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Graph(CreateableAPIResource, ActionAPIResource):
"""
A wrapper around Graph HTTP API.
"""
_class_url = '/graph/snapshot'
_resource_name = 'graph/snapshot'

@classmethod
def create(cls, **params):
Expand Down Expand Up @@ -56,7 +56,7 @@ class Embed(ListableAPIResource, GetableAPIResource, ActionAPIResource, Createab
"""
A wrapper around Embed HTTP API.
"""
_class_url = '/graph/embed'
_resource_name = 'graph/embed'

@classmethod
def enable(cls, embed_id):
Expand Down
6 changes: 3 additions & 3 deletions datadog/api/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ class Host(ActionAPIResource):
"""
A wrapper around Host HTTP API.
"""
_class_url = '/host'
_resource_name = 'host'

@classmethod
def mute(cls, host_name, **params):
def mute(cls, host_name, **body):
"""
Mute a host.

Expand All @@ -28,7 +28,7 @@ def mute(cls, host_name, **params):
:returns: Dictionary representing the API's JSON response

"""
return super(Host, cls)._trigger_class_action('POST', 'mute', host_name, **params)
return super(Host, cls)._trigger_class_action('POST', 'mute', host_name, **body)

@classmethod
def unmute(cls, host_name):
Expand Down
3 changes: 1 addition & 2 deletions datadog/api/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ class Infrastructure(SearchableAPIResource):
"""
A wrapper around Infrastructure HTTP API.
"""
_class_url = '/search'
_plural_class_name = 'results'
_resource_name = 'search'

@classmethod
def search(cls, **params):
Expand Down
3 changes: 1 addition & 2 deletions datadog/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class Metadata(GetableAPIResource, UpdatableAPIResource):
"""
A wrapper around Metric Metadata HTTP API
"""
_class_url = '/metrics'
_json_name = 'metrics'
_resource_name = 'metrics'

@classmethod
def get(cls, metric_name):
Expand Down
15 changes: 7 additions & 8 deletions datadog/api/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ class Metric(SearchableAPIResource, SendableAPIResource, ListableAPIResource):
"""
A wrapper around Metric HTTP API
"""
_class_url = None
_json_name = 'series'
_resource_name = None

_METRIC_QUERY_ENDPOINT = '/query'
_METRIC_SUBMIT_ENDPOINT = '/series'
_METRIC_LIST_ENDPOINT = '/metrics'
_METRIC_QUERY_ENDPOINT = 'query'
_METRIC_SUBMIT_ENDPOINT = 'series'
_METRIC_LIST_ENDPOINT = 'metrics'

@classmethod
def _process_points(cls, points):
Expand Down Expand Up @@ -75,7 +74,7 @@ def list(cls, from_epoch):
:returns: Dictionary containing a list of active metrics
"""

cls._class_url = cls._METRIC_LIST_ENDPOINT
cls._resource_name = cls._METRIC_LIST_ENDPOINT

try:
seconds = int(from_epoch)
Expand Down Expand Up @@ -119,7 +118,7 @@ def rename_metric_type(metric):
metric['type'] = metric.pop('metric_type')

# Set the right endpoint
cls._class_url = cls._METRIC_SUBMIT_ENDPOINT
cls._resource_name = cls._METRIC_SUBMIT_ENDPOINT

# Format the payload
try:
Expand Down Expand Up @@ -163,7 +162,7 @@ def query(cls, **params):
query='avg:system.cpu.idle{*}')
"""
# Set the right endpoint
cls._class_url = cls._METRIC_QUERY_ENDPOINT
cls._resource_name = cls._METRIC_QUERY_ENDPOINT

# `from` is a reserved keyword in Python, therefore
# `api.Metric.query(from=...)` is not permited
Expand Down
10 changes: 5 additions & 5 deletions datadog/api/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Monitor(GetableAPIResource, CreateableAPIResource, UpdatableAPIResource,
"""
A wrapper around Monitor HTTP API.
"""
_class_url = '/monitor'
_resource_name = 'monitor'

@classmethod
def get(cls, id, **params):
Expand Down Expand Up @@ -57,7 +57,7 @@ def get_all(cls, **params):
return super(Monitor, cls).get_all(**params)

@classmethod
def mute(cls, id, **params):
def mute(cls, id, **body):
"""
Mute a monitor.

Expand All @@ -70,10 +70,10 @@ def mute(cls, id, **params):

:returns: Dictionary representing the API's JSON response
"""
return super(Monitor, cls)._trigger_class_action('POST', 'mute', id, **params)
return super(Monitor, cls)._trigger_class_action('POST', 'mute', id, **body)

@classmethod
def unmute(cls, id, **params):
def unmute(cls, id, **body):
"""
Unmute a monitor.

Expand All @@ -85,7 +85,7 @@ def unmute(cls, id, **params):

:returns: Dictionary representing the API's JSON response
"""
return super(Monitor, cls)._trigger_class_action('POST', 'unmute', id, **params)
return super(Monitor, cls)._trigger_class_action('POST', 'unmute', id, **body)

@classmethod
def mute_all(cls):
Expand Down
Loading