Skip to content

Commit

Permalink
add annotation APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
DheerajDang committed Jun 27, 2019
1 parent 1a8c629 commit 90813f6
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions grafana_api/api/annotations.py
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

0 comments on commit 90813f6

Please sign in to comment.