コード例 #1
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)
コード例 #2
0
ファイル: __init__.py プロジェクト: GreyZmeem/zenpy
    def __init__(self,
                 subdomain,
                 email=None,
                 token=None,
                 oauth_token=None,
                 password=None,
                 session=None):
        session = self._init_session(email, token, oauth_token, password,
                                     session)
        endpoint = Endpoint()

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

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

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

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

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

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

        self.suspended_tickets = SuspendedTicketApi(
            subdomain, session=session, endpoint=endpoint.suspended_tickets)

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

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

        self.attachments = Api(subdomain,
                               session=session,
                               endpoint=endpoint.attachments,
                               object_type='attachment')

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

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

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

        self.satisfaction_ratings = Api(subdomain,
                                        session=session,
                                        endpoint=endpoint.satisfaction_ratings,
                                        object_type='satisfaction_rating')

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

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

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

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

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

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

        self.requests = RequestAPI(subdomain,
                                   session=session,
                                   endpoint=endpoint.requests)
コード例 #3
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')
コード例 #4
0
ファイル: __init__.py プロジェクト: kapoorabhish/zenpy
    def __init__(self,
                 subdomain,
                 email=None,
                 token=None,
                 oauth_token=None,
                 password=None,
                 session=None,
                 timeout=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.
        """

        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)

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

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

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

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

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

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

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

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

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

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

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

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

        self.satisfaction_ratings = Api(subdomain=subdomain,
                                        session=session,
                                        timeout=timeout,
                                        endpoint=endpoint.satisfaction_ratings,
                                        object_type='satisfaction_rating')

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

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

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

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

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

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

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