def create_metric_point(self, endpoint, metric_point, token): json_str = CachetApiV1.create_metric_point(endpoint, metric_point.get_metric_id(), metric_point.get_value(), metric_point.get_timestamp(), token) if json_str == None: raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1) json_object = json.loads(json_str) metric_point_json = json_object[CONST_DATA_JSON_ATTR] id = metric_point_json[CONST_ID_JSON_ATTR] return Metric(id=id)
def create_incident(self, endpoint, incident, token): json_str = CachetApiV1.create_intent(endpoint, incident.get_name(), incident.get_message(), incident.get_status(), incident.get_visible(), incident.get_component_id(), incident.get_component_status(), token) if json_str == None: raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1) json_object = json.loads(json_str) incident_json = json_object[CONST_DATA_JSON_ATTR] id = incident_json[CONST_ID_JSON_ATTR] name = incident_json[CONST_NAME_JSON_ATTR] return Incident(id=id, name=name)
def create_group_component(self, endpoint, group_component, token): json_str = CachetApiV1.create_group_component(endpoint, group_component.get_name(), token) if json_str == None: raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1) json_object = json.loads(json_str) group_component_json = json_object[CONST_DATA_JSON_ATTR] id = group_component_json[CONST_ID_JSON_ATTR] name = group_component_json[CONST_NAME_JSON_ATTR] return Component(id=id, name=name)
def create_metric(self, endpoint, metric, token): json_str = CachetApiV1.create_metric(endpoint, metric.get_name(), metric.get_suffix(), metric.get_description(), metric.get_default_value(), token) if json_str == None: raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1) json_object = json.loads(json_str) metric_json = json_object[CONST_DATA_JSON_ATTR] id = metric_json[CONST_ID_JSON_ATTR] name = metric_json[CONST_NAME_JSON_ATTR] return Metric(id=id, name=name)
def get_groups_component(self, endpoint): json_str = CachetApiV1.get_groups_component(endpoint) if json_str == None: raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1) json_object = json.loads(json_str) group_components_json_array = json_object[CONST_DATA_JSON_ATTR] groups_components = [] for group_component_json in group_components_json_array: name = group_component_json[CONST_NAME_JSON_ATTR] id = group_component_json[CONST_ID_JSON_ATTR] groups_components.append(GroupComponent(id, name)) return groups_components
def get_metrics(self, endpoint): json_str = CachetApiV1.get_metrics(endpoint) if json_str == None: raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1) json_object = json.loads(json_str) metrics_json_array = json_object[CONST_DATA_JSON_ATTR] metrics = [] for metric_json in metrics_json_array: name = metric_json[CONST_NAME_JSON_ATTR] id = metric_json[CONST_ID_JSON_ATTR] metrics.append(Metric(id=id, name=name)) return metrics
def test_create_metric_point(self): response = CachetApiV1.create_metric_point("http://wrong_url", "metric_id", "value_point", "timestamp", "token") self.assertIsNone(response)
def test_create_metric(self): response = CachetApiV1.create_metric("http://wrong_url", "name", "suffix", "description", "default_value", "token") self.assertIsNone(response)
def test_get_metrics(self): response = CachetApiV1.get_metrics("http://wrong_url") self.assertIsNone(response)
def test_create_intent_error(self): response = CachetApiV1.create_intent("http://wrong_url", "name", "message", "status", "visible", "componentId", "componentStatus", "token") self.assertIsNone(response)
def test_create_component_error(self): response = CachetApiV1.create_component("http://wrong_url", "id", 1, 1, "token") self.assertIsNone(response)
def test_get_component_error(self): response = CachetApiV1.get_component("http://wrong_url", "id") self.assertIsNone(response)
def test_delete_group_component_error(self): response = CachetApiV1.delete_group_component("http://wrong_url", "id", "token") self.assertIsNone(response)