- http_code, resp = self._http.post_cmd(endpoint='/test/message/alarm_request',
- postfields_dict=data)
- #print('HTTP CODE: {}'.format(http_code))
- #print('RESP: {}'.format(resp))
- if http_code in (200, 201, 202, 204):
- #resp = json.loads(resp)
- print('Alarm deleted')
- else:
- msg = ""
+ http_code, resp = self._http.post_cmd(
+ endpoint="/test/message/alarm_request", postfields_dict=data
+ )
+ # print('HTTP CODE: {}'.format(http_code))
+ # print('RESP: {}'.format(resp))
+ # if http_code in (200, 201, 202, 204):
+ # resp = json.loads(resp)
+ print("Alarm deleted")
+ # else:
+ # msg = ""
+ # if resp:
+ # try:
+ # msg = json.loads(resp)
+ # except ValueError:
+ # msg = resp
+ # raise ClientException('error: code: {}, resp: {}'.format(
+ # http_code, msg))
+ except ClientException as exc:
+ message = "failed to delete alarm: alarm {}\n{}".format(name, str(exc))
+ raise ClientException(message)
+
+ def get_alarm(self, project_name=None, ns_id=None, uuid=None):
+ self._client.get_token()
+ try:
+ self._apiName = "/nsfm"
+ self._apiResource = "/alarms"
+ self._apiBase = "{}{}{}".format(
+ self._apiName, self._apiVersion, self._apiResource
+ )
+ if uuid:
+ # if request is for any uuid
+ http_code, resp = self._http.get2_cmd(
+ "{}/{}".format(self._apiBase, uuid)
+ )
+ else: # if not uuid
+ http_code, resp = self._http.get2_cmd(
+ "{}/{}/{}/{}".format(self._apiBase, uuid, project_name, ns_id)
+ )
+ if http_code == 200: