Subscribers

Resource

Methods

Subscriber.__init__(manager, data)

Resource initializer.

Parameters
  • manager – The manager this resource belongs to

  • data – The raw json data

Subscriber.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

Subscriber.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.

Subscriber.delete() → None

Deletes the resource from the server

Attributes

Subscriber.attrs

The raw json response from the server

Type

dict

Subscriber.id

Resource ID

Type

int

Subscriber.email

email address

Type

str

Subscriber.verify_code

Auto generated unique verify code

Type

str

Subscriber.is_global

Is the user subscribed to all components?

Type

bool

Subscriber.created_at

When the subscription was created

Type

datetime

Subscriber.updated_at

Last time the subscription was updated

Type

datetime

Subscriber.verified_at

When the subscription was verified. None if not verified

Type

datetime

Manager

Methods

SubscriberManager.__init__(http_client: cachetclient.httpclient.HttpClient)

Manager initializer.

Parameters

http_client – The httpclient

SubscriberManager.create(*, email: str, components: List[int] = None, verify: bool = True) → cachetclient.v1.subscribers.Subscriber

Create a subscriber. If a subscriber already exists the existing one will be returned. Note that this endoint cannot be used to edit the user.

Keyword Arguments
  • email (str) – Email address to subscribe

  • components (List[int]) – The components to subscribe to. If omitted all components are subscribed.

  • verify (bool) – Verification status. If False a verification email is sent to the user

Returns

Subscriber instance

SubscriberManager.list(page: int = 1, per_page: int = 20) → Generator[cachetclient.v1.subscribers.Subscriber, None, None]

List all subscribers

Keyword Arguments
  • page (int) – The page to start listing

  • per_page – Number of entries per page

Returns

Generator of Subscriber instances

SubscriberManager.delete(subscriber_id: int) → None

Delete a specific subscriber id

Parameters

subscriber_id (int) – Subscriber id to delete

Raises

requests.exceptions.HttpError – if subscriber do not exist

SubscriberManager.count() → int

Count the total number of subscribers

Returns

Number of subscribers

Return type

int

SubscriberManager.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

SubscriberManager.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

SubscriberManager.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

Attributes

SubscriberManager.path = 'subscribers'
SubscriberManager.resource_class = <class 'cachetclient.v1.subscribers.Subscriber'>