zendesk_sdk.client

Zendesk API client.

Attributes

Classes

ZendeskServices

A class wrapping Zendesk interaction.

Module Contents

zendesk_sdk.client.SHOW_MANY_LIMIT = 100[source]
zendesk_sdk.client.EMAIL_CCS_LIMIT = 48[source]
zendesk_sdk.client.TOKEN_EXPIRY_MARGIN[source]
class zendesk_sdk.client.ZendeskServices(base_url: str, client_id: str, client_secret: str, scope: str, timeout: float)[source]

A class wrapping Zendesk interaction.

client[source]
_client_id[source]
_client_secret[source]
_scope[source]
_access_token: str | None = None[source]
_access_token_expires_at[source]
_get_access_token() → str[source]

Return an access token, requesting a new one when the cached one has expired.

_make_request(method: str, path: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, headers: dict[str, str] | None = None) → niquests.Response[source]

Make a request to Zendesk.

search(type_: Literal['ticket', 'user', 'organization'] = 'ticket', statuses: list[Literal['new', 'open', 'pending', 'hold', 'solved', 'closed']] | None = None, tags: list[str] | None = None) → list[zendesk_sdk.models.Ticket][source]

Search.

get_ticket(ticket_id: int) → zendesk_sdk.models.Ticket[source]

Find and load to base64.

create_ticket(subject: str, body: str, *, requester_email: str, requester_name: str, email_ccs: list[str] | None = None, tags: list[str] | None = None, group_id: int | None = None, priority: Literal['urgent', 'high', 'normal', 'low'] = 'normal', external_id: str | None = None, idempotency_key: str | None = None, comment_is_public: bool = True) → zendesk_sdk.models.Ticket[source]

Create a ticket on behalf of a requester.

email_ccs are the addresses copied on the ticket besides the requester. They are sent as given, so the caller decides what counts as a duplicate.

update_ticket(ticket_id: int, status: Literal['new', 'open', 'pending', 'hold', 'solved', 'closed'] | None = None, comment: str | None = None, comment_is_public: bool = True, *, updated_stamp: datetime.datetime | None = None) → zendesk_sdk.models.Ticket[source]

Update a ticket, checking for concurrent changes when updated_stamp is provided.

add_tags_to_ticket(ticket_id: int, tags: list[str]) → list[str][source]

Add tags to a ticket.

get_ticket_comments(ticket_id: int) → collections.abc.Iterator[zendesk_sdk.models.TicketComment][source]

Yield a ticket’s comments, fetching the next page only when the caller reaches it.

get_ticket_comments_page(ticket_id: int, *, after_cursor: str | None = None) → zendesk_sdk.models.TicketCommentPage[source]

Return one cursor page of comments; the caller follows after_cursor if has_more.

get_ticket_audits(ticket_id: int) → collections.abc.Iterator[zendesk_sdk.models.TicketAudit][source]

Yield a ticket’s audits, fetching the next page only when the caller reaches it.

An audit is one update to the ticket: its author, its time and the events it made, a field’s old and new value among them. Zendesk documents no order for them, so sort by created_at to replay a ticket’s history. The token needs the global read scope; Zendesk refuses tickets:read for audits.

get_ticket_audits_page(ticket_id: int, *, after_cursor: str | None = None) → zendesk_sdk.models.TicketAuditPage[source]

Return one cursor page of audits; the caller follows after_cursor if has_more.

Zendesk does not paginate the audits of an archived ticket: it answers them all with no pagination metadata, which is read as a last page.

get_users(user_ids: list[int]) → list[zendesk_sdk.models.User][source]

Return the users with these ids, in one request; unknown ids are left out.

download_attachment(attachment: zendesk_sdk.models.Attachment) → bytes[source]

Return an attachment’s bytes, read from its content_url.

Zendesk answers with a redirect to a signed download, which is followed. The token needs the ticket_attachments:read scope (or read) when the account keeps attachments private.

get_incremental_tickets_page(*, start_time: datetime.datetime | None = None, cursor: str | None = None, include_deleted: bool = False) → zendesk_sdk.models.IncrementalTicketPage[source]

Return one page of tickets changed since start_time, or since a previous page’s cursor.

Pass start_time on the first call only, then the after_cursor of the page before. end_of_stream says the caller has caught up; keep the cursor and ask again later. Zendesk allows this export to admins only, about ten requests a minute.

include_deleted keeps deleted tickets (spam among them) in the export, with the status deleted; pass the same value on every page of one walk.