zendesk_sdk¶
Interface to Zendesk API.
Submodules¶
Exceptions¶
Raised when a ticket is closed. |
|
Raised when a safe update finds the ticket changed after |
Classes¶
A class wrapping Zendesk interaction. |
|
Attachment model. |
|
One page of the incremental ticket export for the caller to traverse. |
|
Ticket model. |
|
One update to a ticket: who made it, when, and what it changed. |
|
One thing an audit did to its ticket. |
|
One cursor page of a ticket's audits for the caller to traverse. |
|
One comment on a ticket, public or internal. |
|
One cursor page of ticket comments for the caller to traverse. |
|
A Zendesk user: an end user (requester) or a staff member. |
Package Contents¶
- class zendesk_sdk.ZendeskServices(base_url: str, client_id: str, client_secret: str, scope: str, timeout: float)[source]¶
A class wrapping Zendesk interaction.
- _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_ccsare 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.
- 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_atto replay a ticket’s history. The token needs the globalreadscope; Zendesk refusestickets:readfor 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:readscope (orread) 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_timeon the first call only, then theafter_cursorof the page before.end_of_streamsays 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_deletedkeeps deleted tickets (spam among them) in the export, with the statusdeleted; pass the same value on every page of one walk.
- exception zendesk_sdk.TicketUpdateConflictError[source]¶
Bases:
ExceptionRaised when a safe update finds the ticket changed after
updated_stamp.
- class zendesk_sdk.IncrementalTicketPage(/, **data: Any)[source]¶
Bases:
_BaseModelOne page of the incremental ticket export for the caller to traverse.
- class zendesk_sdk.Ticket(/, **data: Any)[source]¶
Bases:
_BaseModelTicket model.
- created_at: datetime.datetime[source]¶
- updated_at: datetime.datetime[source]¶
- class zendesk_sdk.TicketAudit(/, **data: Any)[source]¶
Bases:
_BaseModelOne update to a ticket: who made it, when, and what it changed.
author_idis whoever made the update. An update a trigger or an automation made names no user Zendesk can load, so look the id up before treating it as a person.metadatais Zendesk’s own record of where the update came from, passed through as sent. Zendesk documents itssystemandcustomobjects and not their keys, so read a key as optional.- created_at: datetime.datetime[source]¶
- events: list[TicketAuditEvent][source]¶
- class zendesk_sdk.TicketAuditEvent(/, **data: Any)[source]¶
Bases:
_BaseModelOne thing an audit did to its ticket.
typesays which:Createset a field as the ticket was opened,Changemoved one,Commentadded a comment, and Zendesk has many more. OnlyCreateandChangecarryfield_name, and onlyChangecarriesprevious_value. A value is normally a string, an id included ("360004442691"); tags are a list, and some fields are an object.
- class zendesk_sdk.TicketAuditPage(/, **data: Any)[source]¶
Bases:
_BaseModelOne cursor page of a ticket’s audits for the caller to traverse.
- audits: list[TicketAudit][source]¶
- class zendesk_sdk.TicketComment(/, **data: Any)[source]¶
Bases:
_BaseModelOne comment on a ticket, public or internal.
- attachments: list[Attachment][source]¶
- created_at: datetime.datetime | None[source]¶