forked from m0nhawk/grafana_api
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a8c629
commit 90813f6
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from .base import Base | ||
|
||
|
||
class Annotations(Base): | ||
|
||
def __init__(self, api): | ||
super(Annotations, self).__init__(api) | ||
self.api = api | ||
|
||
def list_annotations(self): | ||
""" | ||
Method to list all annotations | ||
:return: response | ||
""" | ||
path = '/annotations' | ||
r = self.api.GET(path) | ||
return r | ||
|
||
def create_annotation(self, annotation): | ||
""" | ||
Method to create a new annotation | ||
:param annotation: annotation json request | ||
:return: response | ||
""" | ||
path = '/annotations' | ||
r = self.api.POST(path, json=annotation) | ||
return r | ||
|
||
def create_annotation_in_graphite(self, annotation): | ||
""" | ||
Method to create annotation in graphite format | ||
:param annotation: annotation json request | ||
:return: response | ||
""" | ||
path = 'annotations/graphite' | ||
r = self.api.POST(path, json=annotation) | ||
return r | ||
|
||
def update_annotation(self, annotation_id, annotation): | ||
""" | ||
Method to update annotation | ||
:param annotation_id: id of annotation | ||
:param annotation: json body of annotation | ||
:return: response | ||
""" | ||
path = '/annotations/%s' % annotation_id | ||
r = self.api.PUT(path, json=annotation) | ||
return r | ||
|
||
def delete_annotation(self, annotation_id): | ||
""" | ||
Method to delete annotation | ||
:param annotation_id: id of annotation | ||
:return: response | ||
""" | ||
path = '/annotations/%s' % annotation_id | ||
r = self.api.DELETE(path) | ||
return r | ||
|
||
def delete_region_annotations(self, region_id): | ||
""" | ||
Method to delete region annotations | ||
:param region_id: ID of region | ||
:return: response | ||
""" | ||
path = 'annotations/region/%s' % region_id | ||
r = self.api.DELETE(path) | ||
return r |