@@ -124,36 +124,68 @@ func (c *Client) NewGraphiteAnnotation(gfa *GraphiteAnnotation) (int64, error) {
124124 return result .ID , err
125125}
126126
127- // UpdateAnnotation updates an existing annotation with the Annotation it is passed
128- func (c * Client ) UpdateAnnotation (a * Annotation ) (int64 , error ) {
129- path := fmt .Sprintf ("/api/annotations/%d" , a . ID )
127+ // UpdateAnnotation updates all properties an existing annotation with the Annotation it is passed.
128+ func (c * Client ) UpdateAnnotation (id int64 , a * Annotation ) (string , error ) {
129+ path := fmt .Sprintf ("/api/annotations/%d" , id )
130130 data , err := json .Marshal (a )
131131 if err != nil {
132- return 0 , err
132+ return "" , err
133133 }
134134 req , err := c .newRequest ("PUT" , path , nil , bytes .NewBuffer (data ))
135135 if err != nil {
136- return 0 , err
136+ return "" , err
137137 }
138138
139139 resp , err := c .Do (req )
140140 if err != nil {
141- return 0 , err
141+ return "" , err
142142 }
143143 if resp .StatusCode != 200 {
144- return 0 , errors .New (resp .Status )
144+ return "" , errors .New (resp .Status )
145145 }
146146
147147 data , err = ioutil .ReadAll (resp .Body )
148148 if err != nil {
149- return 0 , err
149+ return "" , err
150150 }
151151
152152 result := struct {
153- ID int64 `json:"id "`
153+ Message string `json:"message "`
154154 }{}
155155 err = json .Unmarshal (data , & result )
156- return result .ID , err
156+ return result .Message , err
157+ }
158+
159+ // PatchAnnotation updates one or more properties of an existing annotation that matches the specified ID.
160+ func (c * Client ) PatchAnnotation (id int64 , a * Annotation ) (string , error ) {
161+ path := fmt .Sprintf ("/api/annotations/%d" , id )
162+ data , err := json .Marshal (a )
163+ if err != nil {
164+ return "" , err
165+ }
166+ req , err := c .newRequest ("PATCH" , path , nil , bytes .NewBuffer (data ))
167+ if err != nil {
168+ return "" , err
169+ }
170+
171+ resp , err := c .Do (req )
172+ if err != nil {
173+ return "" , err
174+ }
175+ if resp .StatusCode != 200 {
176+ return "" , errors .New (resp .Status )
177+ }
178+
179+ data , err = ioutil .ReadAll (resp .Body )
180+ if err != nil {
181+ return "" , err
182+ }
183+
184+ result := struct {
185+ Message string `json:"message"`
186+ }{}
187+ err = json .Unmarshal (data , & result )
188+ return result .Message , err
157189}
158190
159191// DeleteAnnotation deletes the annotation of the ID it is passed
0 commit comments