Components¶
Resource¶
Methods¶
-
Component.
__init__
(manager, data)¶ Resource initializer.
- Parameters
manager – The manager this resource belongs to
data – The raw json data
-
Component.
add_tag
(name: str) → None¶ Add a new tag.
- Parameters
name (str) – Name of the tag
-
Component.
del_tag
(name: str) → None¶ Delete a tag.
- Parameters
name (str) – Name of tag to remove
- Raises
KeyError – if tag does not exist
-
Component.
has_tag
(name: str) → bool¶ Check if a tag exists.
- Parameters
name (str) – Tag name
- Returns
If the tag exists
- Return type
bool
-
Component.
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
-
Component.
get
(name) → Union[int, str, float, bool]¶ 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.
-
Component.
delete
() → None¶ Deletes the resource from the server
Attributes¶
-
Component.
attrs
¶ The raw json response from the server
- Type
dict
-
Component.
id
¶ The unique ID of the component
- Type
int
-
Component.
name
¶ Get or set name of the component
- Type
str
-
Component.
description
¶ Get or set component description
- Type
str
-
Component.
link
¶ Get or set http link to the component
- Type
str
-
Component.
status
¶ Get or set status id of the component (see
enums
)- Type
int
-
Component.
status_name
¶ Human readable status representation
- Type
str
-
Component.
order
¶ Get or set order of the component in a group
- Type
int
-
Component.
group_id
¶ Get or set the component group id
- Type
int
-
Component.
enabled
¶ Get or set enabled state
- Type
bool
-
Component.
created_at
¶ When the component was created
- Type
datetime
-
Component.
updated_at
¶ Last time the component was updated
- Type
datetime
Manager¶
Methods¶
-
ComponentManager.
__init__
(http_client: cachetclient.httpclient.HttpClient)¶ Manager initializer.
- Parameters
http_client – The httpclient
-
ComponentManager.
create
(*, name: str, status: int, description: str = None, link: str = None, order: int = None, group_id: int = None, enabled: bool = True, tags: Set[str] = None)¶ Create a component.
- Keyword Arguments
name (str) – Name of the component
status (int) – Status if of the component (see enums module)
description (str) – Description of the component (required)
link (str) – Link to the component
order (int) – Order of the component in its group
group_id (int) – The group it belongs to
enabled (bool) – Enabled status
tags (list) – String tags
- Returns
Component
instance
-
ComponentManager.
update
(component_id: int, *, status: int, name: str = None, description: str = None, link: str = None, order: int = None, group_id: int = None, enabled: bool = None, tags: Set[str] = None, **kwargs) → cachetclient.v1.components.Component¶ Update a component by id.
- Parameters
component_id (int) – The component to update
- Keyword Arguments
status (int) – Status of the component (see enums)
name (str) – New name
description (str) – New description
link (str) – Link to component
order (int) – Order in component group
group_id (int) – Component group id
enabled (bool) – Enable status of component
tags (list) – List of strings
- Returns
Updated Component from server
-
ComponentManager.
list
(page: int = 1, per_page: int = 20) → Generator[cachetclient.v1.components.Component, None, None]¶ List all components
- Keyword Arguments
page (int) – The page to start listing
per_page (int) – Number of entries per page
- Returns
Generator of Component instances
-
ComponentManager.
get
(component_id: int) → cachetclient.v1.components.Component¶ Get a component by id
- Parameters
component_id (int) – Id of the component
- Returns
Component instance
- Raises
HttpError – if not found
-
ComponentManager.
count
() → int¶ Count the number of components
- Returns
Total number of components
- Return type
int
-
ComponentManager.
delete
(component_id: int) → None¶ Delete a component
- Parameters
component_id (int) – Id of the component
- Raises
HTTPError – if component do not exist
-
ComponentManager.
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
-
ComponentManager.
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
-
ComponentManager.
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