Alert

Alerts client module.

peak.resources.alerts.get_client(session=None)

Returns a Alert client, If no session is provided, a default session is used.

Parameters:

session (Optional[Session]) – A Session Object. Default is None.

Returns:

The alert client object.

Return type:

Alert

Alert Client

class peak.resources.alerts.Alert(session=None)

Client class for interacting with alerts resource.

Parameters:

session (Session) –

describe_email(email_id)

Retrieve the details of a specific email.

REFERENCE:

🔗 API Documentation

Parameters:

email_id (int) – The ID of the email to retrieve.

Returns:

A dictionary containing the details of the email.

Return type:

Dict[str, Any]

Raises:
  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – Email with the given ID does not exist.

  • UnprocessableEntityException – The server was unable to process the request.

  • InternalServerErrorException – The server failed to process the request.

describe_template(template_name)

Retrieve the details of a specific template.

REFERENCE:

🔗 API Documentation

Parameters:

template_name (str) – The name of the template to retrieve.

Returns:

A dictionary containing the details of the template.

Return type:

Dict[str, Any]

Raises:
  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – Email with the given ID does not exist.

  • UnprocessableEntityException – The server was unable to process the request.

  • InternalServerErrorException – The server failed to process the request.

list_emails(date_from: str | None = None, date_to: str | None = None, page_size: int | None = None, page_number: int | None = None, count: int | None = None, *, return_iterator: Literal[False]) Dict[str, Any]
list_emails(date_from: str | None = None, date_to: str | None = None, page_size: int | None = None, page_number: int | None = None, count: int | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]

Retrieve the history of emails sent.

REFERENCE:

🔗 API Documentation

Parameters:
  • date_from (str | None) – The date after which the emails should be included (in ISO format). It is 90 days from current date by default.

  • date_to (str | None) – The date till which the emails should be included (in ISO format). It is current date by default.

  • page_size (int | None) – Number of emails to retrieve per page. It is 25 by default.

  • page_number (int | None) – Page number to retrieve. Only used when return_iterator is False.

  • count (int | None) – Number of emails required (Ordered by latest to earliest). For example, if 5 is provided, it will return last 5 emails. It is -1 by default which means it will return all the available emails within the given dates.

  • return_iterator (bool) – Whether to return an iterator object or list of emails for a specified page number, defaults to True.

Returns:

an iterator object which returns an element per iteration, until there are no more elements to return. If return_iterator is set to False, a dictionary containing the list and pagination details is returned instead.

Set return_iterator to True if you want automatic client-side pagination, or False if you want server-side pagination.

Return type:

Iterator[Dict[str, Any]] | Dict[str, Any]

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • InternalServerErrorException – The server failed to process the request.

list_templates(page_size: int | None = None, page_number: int | None = None, name: str | None = None, scope: List[str] | None = None, *, return_iterator: Literal[False]) Dict[str, Any]
list_templates(page_size: int | None = None, page_number: int | None = None, name: str | None = None, scope: List[str] | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]

Retrieve the history of emails sent.

REFERENCE:

🔗 API Documentation

Parameters:
  • name (str | None) – The name of the email template

  • scope (List[str] | None) – Filter out on the basis of the type of the template - global or custom.

  • page_size (int | None) – Number of emails to retrieve per page. It is 25 by default.

  • page_number (int | None) – Page number to retrieve. Only used when return_iterator is False.

  • return_iterator (bool) – Whether to return an iterator object or list of emails for a specified page number, defaults to True.

Returns:

an iterator object which returns an element per iteration, until there are no more elements to return. If return_iterator is set to False, a dictionary containing the list and pagination details is returned instead.

Set return_iterator to True if you want automatic client-side pagination, or False if you want server-side pagination.

Return type:

Iterator[Dict[str, Any]] | Dict[str, Any]

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • InternalServerErrorException – The server failed to process the request.

send_email(body)

Send an email to the specified recipients using the specified template.

REFERENCE:

🔗 API Documentation

Parameters:

body (Dict[str, Any]) – A dictionary containing the details of the email to send.

Returns:

A dictionary containing the ID of the email sent.

Return type:

Dict[str, Any]

SCHEMA:
{
    "recipients": ["string"],
    "cc": ["string"],
    "bcc": ["string"],
    "subject": "string",
    "templateName": "string",
    "templateParameters": {
        "string": "string"
    }
}
Raises:
  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – The given feature does not exist.

  • UnprocessableEntityException – The server was unable to process the request.

  • InternalServerErrorException – The server failed to process the request.

Parameters:

body (Dict[str, Any]) –

Return type:

Dict[str, Any]