Skip to content

Commit d755544

Browse files
committed
feat(contact-point): support retrieval by name
1 parent aa572c2 commit d755544

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

grafana_api/alerting_provisioning.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,30 @@ def get_all_contact_points(self) -> list:
226226
else:
227227
return api_call
228228

229+
def get_contact_point(self, name: str) -> list:
230+
"""Return contact points that exactly match the given name.
231+
232+
This method does not support partial matching — the `name` value must
233+
match exactly.
234+
235+
Raises:
236+
Exception: If an unspecified error occurs during the API call.
237+
238+
Returns:
239+
list: A list of contact points whose `name` property exactly matches
240+
the provided `name`.
241+
"""
242+
243+
api_call: list = Api(self.grafana_api_model).call_the_api(
244+
f"{APIEndpoints.ALERTING_PROVISIONING.value}/contact-points?name={name}"
245+
)
246+
247+
if api_call == list():
248+
logging.error(f"Check the error: {api_call}.")
249+
raise Exception
250+
else:
251+
return api_call
252+
229253
def add_contact_point(
230254
self,
231255
embedded_contact_point: EmbeddedContactPoint,

0 commit comments

Comments
 (0)