Incidents¶
Resource¶
Methods¶
-
Incident.
__init__
(manager, data)¶ Resource initializer.
- Parameters
manager – The manager this resource belongs to
data – The raw json data
-
Incident.
updates
() → Generator[cachetclient.v1.incidents.Incident, None, None]¶ Generator[‘Incident’, None, None]: Incident updates for this issue
-
Incident.
update
()¶ Posts the values in the resource to the server.
Example:
# Change an attribute and save the resource >> resource.value = something >> updated_resource = resource.update()
- Returns
The updated resource from the server
-
Incident.
get
(name) → Any¶ Safely obtain any attribute name for the resource
- Parameters
name (str) – Key name in json response
- Returns
Value from the raw json response. If the key doesn’t exist
None
is returned.
-
Incident.
delete
() → None¶ Deletes the resource from the server.
- Raises
HTTPException if the resource don't exist. –
Attributes¶
-
Incident.
attrs
¶ The raw json response from the server
- Type
dict
-
Incident.
id
¶ unique id of the incident
- Type
int
-
Incident.
component_id
¶ Get or set component id for this incident
- Type
int
-
Incident.
name
¶ Get or set name/title of the incident
- Type
str
-
Incident.
message
¶ Get or set message
- Type
str
-
Incident.
notify
¶ Get or set notification flag
- Type
bool
-
Incident.
status
¶ Get or set status. See
enums
- Type
int
-
Incident.
human_status
¶ Human representation of the status
- Type
str
-
Incident.
visible
¶ Get or set visibility of the incident
- Type
bool
-
Incident.
stickied
¶ Get or set sticky value of the incident (cachet 2.4)
- Type
bool
-
Incident.
scheduled_at
¶ Scheduled time. This is used for scheduled events like maintenance in Cachet 2.3 were incident status is
INCIDENT_SCHEDULED
. 2.4 has its own schedule resource and endpoints.- Type
datetime
-
Incident.
created_at
¶ When the issue was created
- Type
datetime
-
Incident.
occurred_at
¶ When the issue was occurred
- Type
datetime
-
Incident.
updated_at
¶ Last time the issue was updated
- Type
datetime
-
Incident.
deleted_at
¶ When the issue was deleted
- Type
datetime
Manager¶
Methods¶
-
IncidentManager.
__init__
(http_client: cachetclient.httpclient.HttpClient, incident_update_manager: cachetclient.v1.incident_updates.IncidentUpdatesManager)¶ Manager initializer.
- Parameters
http_client – The httpclient
-
IncidentManager.
create
(*, name: str, message: str, status: int, visible: bool = True, stickied: bool = False, component_id: int = None, component_status: int = None, notify: bool = True, created_at: datetime.datetime = None, occurred_at: datetime.datetime = None, template: str = None, template_vars: List[str] = None) → cachetclient.v1.incidents.Incident¶ Create and general issue or issue for a component. component_id and component_status must be supplied when making a component issue.
- Keyword Arguments
name (str) – Name/title of the issue
message (str) – Mesage body for the issue
status (int) – Status of the incident (see enums)
visible (bool) – Publicly visible incident
stickied (bool) – Stickied incident
component_id (int) – The component to update
component_status (int) – The status to apply on component
notify (bool) – If users should be notified
occurred_at – when the incident occurred (cachet 2.4)
created_at – when the incident was created (cachet 2.3)
template (str) – Slug of template to use
template_vars (list) – Variables to the template
- Returns
Incident instance
-
IncidentManager.
update
(incident_id: int, name: str = None, message: str = None, status: int = None, visible: bool = None, stickied: bool = False, component_id: int = None, component_status: int = None, notify: bool = True, occurred_at: datetime.datetime = None, template: str = None, template_vars: List[str] = None, **kwargs) → cachetclient.v1.incidents.Incident¶ Update an incident.
- Parameters
incident_id (int) – The incident to update
- Keyword Arguments
name (str) – Name/title of the issue
message (str) – Mesage body for the issue
status (int) – Status of the incident (see enums)
visible (bool) – Publicly visible incident
stickied (bool) – Stickied incident
component_id (int) – The component to update
component_status (int) – The status to apply on component
notify (bool) – If users should be notified
occurred_at (datetime) – when the incident was occurred
template (str) – Slug of template to use
template_vars (list) – Variables to the template
- Returns
Updated incident Instance
-
IncidentManager.
list
(page: int = 1, per_page: int = 1) → Generator[cachetclient.v1.incidents.Incident, None, None]¶ List all incidents paginated
- Keyword Arguments
page (int) – Page to start on
per_page (int) – entries per page
- Returns
Generator of :py:data:`Incident`s
-
IncidentManager.
get
(incident_id: int) → cachetclient.v1.incidents.Incident¶ Get a single incident
- Parameters
incident_id (int) – The incident id to get
- Returns
Incident
instance- Raises
requests.exception.HttpError – if incident do not exist
-
IncidentManager.
count
() → int¶ Count the number of incidents
- Returns
Total number of incidents
- Return type
int
-
IncidentManager.
delete
(incident_id: int) → None¶ Delete an incident
- Parameters
incident_id (int) – The incident id
-
IncidentManager.
instance_from_dict
(data: dict) → cachetclient.base.Resource¶ Creates a resource instance from a dictionary.
This doesn’t hit any endpoints in cachet, but rather enables us to create a resource class instance from dictionary data. This can be useful when caching data from cachet in memcache or databases.
- Parameters
data (dict) – dictionary containing the instance data
- Returns
The resource class instance
- Return type
Resource
-
IncidentManager.
instance_from_json
(data: str) → cachetclient.base.Resource¶ Creates a resource instance from a json string.
This doesn’t hit any endpoints in cachet, but rather enables us to create a resource class instance from json data. This can be useful when caching data from cachet in memcache or databases.
- Parameters
data (str) – json string containing the instance data
- Returns
The resource class instance
- Return type
Resource
-
IncidentManager.
instance_list_from_json
(data: str) → List[cachetclient.base.Resource]¶ Creates a resource instance list from a json string.
This doesn’t hit any endpoints in cachet, but rather enables us to create a resource class instances from json data. This can be useful when caching data from cachet in memcache or databases.
- Parameters
data (str) – json string containing the instance data
- Returns
The resource class instance
- Return type
Resource
- Raises
ValueError – if json data do not deserialize into a list