Example #1
0
    def __init__(self,
                 subdomain=None,
                 email=None,
                 token=None,
                 oauth_token=None,
                 password=None,
                 session=None,
                 timeout=None,
                 ratelimit_budget=None,
                 proactive_ratelimit=None,
                 proactive_ratelimit_request_interval=10,
                 disable_cache=False):
        """
        Python Wrapper for the Zendesk API.

        There are several ways to authenticate with the Zendesk API:
            * Email and password
            * Email and Zendesk API token
            * Email and OAuth token
            * Existing authenticated Requests Session object.


        :param subdomain: your Zendesk subdomain
        :param email: email address
        :param token: Zendesk API token
        :param oauth_token: OAuth token
        :param password: Zendesk password
        :param session: existing Requests Session object
        :param timeout: global timeout on API requests.
        :param ratelimit_budget: maximum time to spend being rate limited
        :param proactive_ratelimit: user specified rate limit.
        :param proactive_ratelimit_request_interval: seconds to wait when over proactive_ratelimit.
        :param disable_cache: disable caching of objects
        """

        session = self._init_session(email, token, oauth_token, password,
                                     session)

        timeout = timeout or self.DEFAULT_TIMEOUT

        self.cache = ZenpyCacheManager(disable_cache)

        config = dict(subdomain=subdomain,
                      session=session,
                      timeout=timeout,
                      ratelimit=int(proactive_ratelimit)
                      if proactive_ratelimit is not None else None,
                      ratelimit_budget=int(ratelimit_budget)
                      if ratelimit_budget is not None else None,
                      ratelimit_request_interval=int(
                          proactive_ratelimit_request_interval),
                      cache=self.cache)

        self.users = UserApi(config)
        self.user_fields = Api(config, object_type='user_field')
        self.groups = GroupApi(config)
        self.macros = MacroApi(config)
        self.organizations = OrganizationApi(config)
        self.organization_memberships = OrganizationMembershipApi(config)
        self.organization_fields = OrganizationFieldsApi(config)
        self.tickets = TicketApi(config)
        self.suspended_tickets = SuspendedTicketApi(
            config, object_type='suspended_ticket')
        self.search = Api(config,
                          object_type='results',
                          endpoint=EndpointFactory('search'))
        self.topics = Api(config, object_type='topic')
        self.attachments = AttachmentApi(config)
        self.brands = BrandApi(config, object_type='brand')
        self.job_status = Api(config,
                              object_type='job_status',
                              endpoint=EndpointFactory('job_statuses'))
        self.jira_links = JiraLinkApi(config)
        self.tags = Api(config, object_type='tag')
        self.satisfaction_ratings = SatisfactionRatingApi(config)
        self.sharing_agreements = SharingAgreementAPI(config)
        self.skips = SkipApi(config)
        self.activities = Api(config, object_type='activity')
        self.group_memberships = GroupMembershipApi(config)
        self.end_user = EndUserApi(config)
        self.ticket_metrics = Api(config, object_type='ticket_metric')
        self.ticket_metric_events = Api(config,
                                        object_type='ticket_metric_events')
        self.ticket_fields = TicketFieldApi(config)
        self.ticket_forms = TicketFormApi(config, object_type='ticket_form')
        self.ticket_import = TicketImportAPI(config)
        self.requests = RequestAPI(config)
        self.chats = ChatApi(config, endpoint=EndpointFactory('chats'))
        self.views = ViewApi(config)
        self.sla_policies = SlaPolicyApi(config)
        self.help_center = HelpCentreApi(config)
        self.recipient_addresses = RecipientAddressApi(config)
        self.nps = NpsApi(config)
        self.triggers = TriggerApi(config, object_type='trigger')
        self.automations = AutomationApi(config, object_type='automation')
        self.dynamic_content = DynamicContentApi(config)
        self.targets = TargetApi(config, object_type='target')
        self.talk = TalkApi(config)
        self.custom_agent_roles = CustomAgentRolesApi(
            config, object_type='custom_agent_role')
Example #2
0
    def __init__(self,
                 subdomain=None,
                 domain=None,
                 email=None,
                 token=None,
                 oauth_token=None,
                 password=None,
                 session=None,
                 timeout=None,
                 ratelimit=None,
                 ratelimit_budget=None):
        """
        Python Wrapper for the Zendesk API.

        There are several ways to authenticate with the Zendesk API:
            * Email and password
            * Email and Zendesk API token
            * Email and OAuth token
            * Existing authenticated Requests Session object.


        :param subdomain: your Zendesk subdomain
        :param domain: a custom Zendesk domain
        :param email: email address
        :param token: Zendesk API token
        :param oauth_token: OAuth token
        :param password: Zendesk password
        :param session: existing Requests Session object
        :param timeout: global timeout on API requests.
        :param ratelimit: user specified rate limit
        :param ratelimit_budget: maximum time to spend being rate limited
        """

        session = self._init_session(email, token, oauth_token, password,
                                     session)

        timeout = timeout or self.DEFAULT_TIMEOUT

        config = dict(subdomain=subdomain,
                      domain=domain,
                      session=session,
                      timeout=timeout,
                      ratelimit=ratelimit,
                      ratelimit_budget=ratelimit_budget)

        self.users = UserApi(config)
        self.user_fields = Api(config, object_type='user_field')
        self.groups = GroupApi(config)
        self.macros = MacroApi(config)
        self.organizations = OrganizationApi(config)
        self.organization_memberships = OrganizationMembershipApi(config)
        self.tickets = TicketApi(config)
        self.suspended_tickets = SuspendedTicketApi(
            config, object_type='suspended_ticket')
        self.search = Api(config,
                          object_type='results',
                          endpoint=EndpointFactory('search'))
        self.topics = Api(config, object_type='topic')
        self.attachments = AttachmentApi(config)
        self.brands = Api(config, object_type='brand')
        self.job_status = Api(config,
                              object_type='job_status',
                              endpoint=EndpointFactory('job_statuses'))
        self.tags = Api(config, object_type='tag')
        self.satisfaction_ratings = SatisfactionRatingApi(config)
        self.sharing_agreements = SharingAgreementAPI(config)
        self.activities = Api(config, object_type='activity')
        self.group_memberships = GroupMembershipApi(config)
        self.end_user = EndUserApi(config)
        self.ticket_metrics = Api(config, object_type='ticket_metric')
        self.ticket_fields = TicketFieldApi(config, object_type='ticket_field')
        self.ticket_forms = Api(config, object_type='ticket_form')
        self.ticket_import = TicketImportAPI(config)
        self.requests = RequestAPI(config)
        self.chats = ChatApi(config, endpoint=EndpointFactory('chats'))
        self.views = ViewApi(config)
        self.sla_policies = SlaPolicyApi(config)
        self.help_center = HelpCentreApi(config)
        self.recipient_addresses = RecipientAddressApi(config)
        self.nps = NpsApi(config)
Example #3
0
    def __init__(self, subdomain, email=None, token=None, oauth_token=None, password=None, session=None, timeout=None, ratelimit=None):
        """
        Python Wrapper for the Zendesk API.

        There are several ways to authenticate with the Zendesk API:
            * Email and password
            * Email and Zendesk API token
            * Email and OAuth token
            * Existing authenticated Requests Session object.


        :param subdomain: your Zendesk subdomain
        :param email: email address
        :param token: Zendesk API token
        :param oauth_token: OAuth token
        :param password: Zendesk password
        :param session: Existing Requests Session object
        :param timeout: Global timeout on API requests.
        :param ratelimit: User specified rate limit
        """

        session = self._init_session(email, token, oauth_token, password, session)

        timeout = timeout or self.DEFAULT_TIMEOUT
        endpoint = Endpoint()

        self.users = UserApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.users,
            ratelimit=ratelimit
        )

        self.user_fields = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.user_fields,
            object_type='user_field',
            ratelimit=ratelimit
        )

        self.groups = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.groups,
            object_type='group',
            ratelimit=ratelimit
        )

        self.macros = MacroApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            ratelimit=ratelimit
        )

        self.organizations = OrganizationApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.organizations,
            ratelimit=ratelimit
        )

        self.organization_memberships = OrganizationMembershipApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.organization_memberships,
            ratelimit=ratelimit
        )

        self.tickets = TicketApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.tickets,
            ratelimit=ratelimit
        )

        self.suspended_tickets = SuspendedTicketApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            object_type='suspended_ticket',
            endpoint=endpoint.suspended_tickets,
            ratelimit=ratelimit
        )

        self.search = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.search,
            object_type='results',
            ratelimit=ratelimit
        )

        self.topics = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.topics,
            object_type='topic',
            ratelimit=ratelimit
        )

        self.attachments = AttachmentApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.attachments,
            ratelimit=ratelimit
        )

        self.brands = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.brands,
            object_type='brand',
            ratelimit=ratelimit
        )

        self.job_status = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.job_statuses,
            object_type='job_status',
            ratelimit=ratelimit
        )

        self.tags = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.tags,
            object_type='tag',
            ratelimit=ratelimit
        )

        self.satisfaction_ratings = SatisfactionRatingApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.satisfaction_ratings,
            ratelimit=ratelimit
        )

        self.sharing_agreements = SharingAgreementAPI(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.sharing_agreements,
            ratelimit=ratelimit
        )

        self.activities = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.activities,
            object_type='activity',
            ratelimit=ratelimit
        )

        self.group_memberships = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.group_memberships,
            object_type='group_membership',
            ratelimit=ratelimit
        )

        self.end_user = EndUserApi(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.end_user,
            ratelimit=ratelimit
        )

        self.ticket_metrics = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.ticket_metrics,
            object_type='ticket_metric',
            ratelimit=ratelimit
        )

        self.ticket_fields = Api(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.ticket_fields,
            object_type='ticket_field',
            ratelimit=ratelimit
        )

        self.ticket_import = TicketImportAPI(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.ticket_import,
            ratelimit=ratelimit
        )

        self.requests = RequestAPI(
            subdomain=subdomain,
            session=session,
            timeout=timeout,
            endpoint=endpoint.requests,
            ratelimit=ratelimit
        )