text: # coding=utf-8
  """
  This code was generated by
  \ / _    _  _|   _  _
   | (_)\/(_)(_|\/| |(/_  v1.0.0
        /       /
  """
  
  from twilio.base import deserialize
  from twilio.base import serialize
  from twilio.base import values
  from twilio.base.instance_context import InstanceContext
  from twilio.base.instance_resource import InstanceResource
  from twilio.base.list_resource import ListResource
  from twilio.base.page import Page
  
  
  class WebhookList(ListResource):
      """ PLEASE NOTE that this class contains preview products that are subject
      to change. Use them with caution. If you currently do not have developer
      preview access, please contact help@twilio.com. """
  
      def __init__(self, version):
          """
          Initialize the WebhookList
  
          :param Version version: Version that contains the resource
  
          :returns: twilio.rest.messaging.v1.webhook.WebhookList
          :rtype: twilio.rest.messaging.v1.webhook.WebhookList
          """
          super(WebhookList, self).__init__(version)
  
          # Path Solution
          self._solution = {}
  
      def get(self):
          """
          Constructs a WebhookContext
  
          :returns: twilio.rest.messaging.v1.webhook.WebhookContext
          :rtype: twilio.rest.messaging.v1.webhook.WebhookContext
          """
          return WebhookContext(self._version, )
  
      def __call__(self):
          """
          Constructs a WebhookContext
  
          :returns: twilio.rest.messaging.v1.webhook.WebhookContext
          :rtype: twilio.rest.messaging.v1.webhook.WebhookContext
          """
          return WebhookContext(self._version, )
  
      def __repr__(self):
          """
          Provide a friendly representation
  
          :returns: Machine friendly representation
          :rtype: str
          """
          return '<Twilio.Messaging.V1.WebhookList>'
  
  
  class WebhookPage(Page):
      """ PLEASE NOTE that this class contains preview products that are subject
      to change. Use them with caution. If you currently do not have developer
      preview access, please contact help@twilio.com. """
  
      def __init__(self, version, response, solution):
          """
          Initialize the WebhookPage
  
          :param Version version: Version that contains the resource
          :param Response response: Response from the API
  
          :returns: twilio.rest.messaging.v1.webhook.WebhookPage
          :rtype: twilio.rest.messaging.v1.webhook.WebhookPage
          """
          super(WebhookPage, self).__init__(version, response)
  
          # Path Solution
          self._solution = solution
  
      def get_instance(self, payload):
          """
          Build an instance of WebhookInstance
  
          :param dict payload: Payload response from the API
  
          :returns: twilio.rest.messaging.v1.webhook.WebhookInstance
          :rtype: twilio.rest.messaging.v1.webhook.WebhookInstance
          """
          return WebhookInstance(self._version, payload, )
  
      def __repr__(self):
          """
          Provide a friendly representation
  
          :returns: Machine friendly representation
          :rtype: str
          """
          return '<Twilio.Messaging.V1.WebhookPage>'
  
  
  class WebhookContext(InstanceContext):
      """ PLEASE NOTE that this class contains preview products that are subject
      to change. Use them with caution. If you currently do not have developer
      preview access, please contact help@twilio.com. """
  
      def __init__(self, version):
          """
          Initialize the WebhookContext
  
          :param Version version: Version that contains the resource
  
          :returns: twilio.rest.messaging.v1.webhook.WebhookContext
          :rtype: twilio.rest.messaging.v1.webhook.WebhookContext
          """
          super(WebhookContext, self).__init__(version)
  
          # Path Solution
          self._solution = {}
          self._uri = '/Sessions/Webhooks'.format(**self._solution)
  
      def fetch(self):
          """
          Fetch a WebhookInstance
  
          :returns: Fetched WebhookInstance
          :rtype: twilio.rest.messaging.v1.webhook.WebhookInstance
          """
          params = values.of({})
  
          payload = self._version.fetch(
              'GET',
              self._uri,
              params=params,
          )
  
          return WebhookInstance(self._version, payload, )
  
      def update(self, webhook_method=values.unset, webhook_filters=values.unset,
                 pre_webhook_url=values.unset, post_webhook_url=values.unset,
                 pre_webhook_retry_count=values.unset,
                 post_webhook_retry_count=values.unset, target=values.unset):
          """
          Update the WebhookInstance
  
          :param unicode webhook_method: The HTTP method to be used when sending a webhook request.
          :param unicode webhook_filters: The list of webhook event triggers that are enabled for this Service.
          :param unicode pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
          :param unicode post_webhook_url: The absolute url the post-event webhook request should be sent to.
          :param unicode pre_webhook_retry_count: The number of retries in case of pre-event webhook request failures.
          :param unicode post_webhook_retry_count: The number of retries in case of post-event webhook request failures.
          :param WebhookInstance.Target target: The routing target of the webhook.
  
          :returns: Updated WebhookInstance
          :rtype: twilio.rest.messaging.v1.webhook.WebhookInstance
          """
          data = values.of({
              'WebhookMethod': webhook_method,
              'WebhookFilters': serialize.map(webhook_filters, lambda e: e),
              'PreWebhookUrl': pre_webhook_url,
              'PostWebhookUrl': post_webhook_url,
              'PreWebhookRetryCount': pre_webhook_retry_count,
              'PostWebhookRetryCount': post_webhook_retry_count,
              'Target': target,
          })
  
          payload = self._version.update(
              'POST',
              self._uri,
              data=data,
          )
  
          return WebhookInstance(self._version, payload, )
  
      def __repr__(self):
          """
          Provide a friendly representation
  
          :returns: Machine friendly representation
          :rtype: str
          """
          context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
          return '<Twilio.Messaging.V1.WebhookContext {}>'.format(context)
  
  
  class WebhookInstance(InstanceResource):
      """ PLEASE NOTE that this class contains preview products that are subject
      to change. Use them with caution. If you currently do not have developer
      preview access, please contact help@twilio.com. """
  
      class Target(object):
          WEBHOOK = "webhook"
          FLEX = "flex"
  
      def __init__(self, version, payload):
          """
          Initialize the WebhookInstance
  
          :returns: twilio.rest.messaging.v1.webhook.WebhookInstance
          :rtype: twilio.rest.messaging.v1.webhook.WebhookInstance
          """
          super(WebhookInstance, self).__init__(version)
  
          # Marshaled Properties
          self._properties = {
              'account_sid': payload['account_sid'],
              'service_sid': payload['service_sid'],
              'webhook_method': payload['webhook_method'],
              'webhook_filters': payload['webhook_filters'],
              'pre_webhook_url': payload['pre_webhook_url'],
              'post_webhook_url': payload['post_webhook_url'],
              'pre_webhook_retry_count': deserialize.integer(payload['pre_webhook_retry_count']),
              'post_webhook_retry_count': deserialize.integer(payload['post_webhook_retry_count']),
              'target': payload['target'],
              'url': payload['url'],
          }
  
          # Context
          self._context = None
          self._solution = {}
  
      @property
      def _proxy(self):
          """
          Generate an instance context for the instance, the context is capable of
          performing various actions.  All instance actions are proxied to the context
  
          :returns: WebhookContext for this WebhookInstance
          :rtype: twilio.rest.messaging.v1.webhook.WebhookContext
          """
          if self._context is None:
              self._context = WebhookContext(self._version, )
          return self._context
  
      @property
      def account_sid(self):
          """
          :returns: The unique id of the Account responsible for this session.
          :rtype: unicode
          """
          return self._properties['account_sid']
  
      @property
      def service_sid(self):
          """
          :returns: The unique id of the Chat Service this session belongs to.
          :rtype: unicode
          """
          return self._properties['service_sid']
  
      @property
      def webhook_method(self):
          """
          :returns: The HTTP method to be used when sending a webhook request.
          :rtype: unicode
          """
          return self._properties['webhook_method']
  
      @property
      def webhook_filters(self):
          """
          :returns: The list of webhook event triggers that are enabled for this Service.
          :rtype: unicode
          """
          return self._properties['webhook_filters']
  
      @property
      def pre_webhook_url(self):
          """
          :returns: The absolute url the pre-event webhook request should be sent to.
          :rtype: unicode
          """
          return self._properties['pre_webhook_url']
  
      @property
      def post_webhook_url(self):
          """
          :returns: The absolute url the post-event webhook request should be sent to.
          :rtype: unicode
          """
          return self._properties['post_webhook_url']
  
      @property
      def pre_webhook_retry_count(self):
          """
          :returns: The number of retries in case of pre-event webhook request failures.
          :rtype: unicode
          """
          return self._properties['pre_webhook_retry_count']
  
      @property
      def post_webhook_retry_count(self):
          """
          :returns: The number of retries in case of post-event webhook request failures.
          :rtype: unicode
          """
          return self._properties['post_webhook_retry_count']
  
      @property
      def target(self):
          """
          :returns: The routing target of the webhook.
          :rtype: WebhookInstance.Target
          """
          return self._properties['target']
  
      @property
      def url(self):
          """
          :returns: An absolute URL for this webhook.
          :rtype: unicode
          """
          return self._properties['url']
  
      def fetch(self):
          """
          Fetch a WebhookInstance
  
          :returns: Fetched WebhookInstance
          :rtype: twilio.rest.messaging.v1.webhook.WebhookInstance
          """
          return self._proxy.fetch()
  
      def update(self, webhook_method=values.unset, webhook_filters=values.unset,
                 pre_webhook_url=values.unset, post_webhook_url=values.unset,
                 pre_webhook_retry_count=values.unset,
                 post_webhook_retry_count=values.unset, target=values.unset):
          """
          Update the WebhookInstance
  
          :param unicode webhook_method: The HTTP method to be used when sending a webhook request.
          :param unicode webhook_filters: The list of webhook event triggers that are enabled for this Service.
          :param unicode pre_webhook_url: The absolute url the pre-event webhook request should be sent to.
          :param unicode post_webhook_url: The absolute url the post-event webhook request should be sent to.
          :param unicode pre_webhook_retry_count: The number of retries in case of pre-event webhook request failures.
          :param unicode post_webhook_retry_count: The number of retries in case of post-event webhook request failures.
          :param WebhookInstance.Target target: The routing target of the webhook.
  
          :returns: Updated WebhookInstance
          :rtype: twilio.rest.messaging.v1.webhook.WebhookInstance
          """
          return self._proxy.update(
              webhook_method=webhook_method,
              webhook_filters=webhook_filters,
              pre_webhook_url=pre_webhook_url,
              post_webhook_url=post_webhook_url,
              pre_webhook_retry_count=pre_webhook_retry_count,
              post_webhook_retry_count=post_webhook_retry_count,
              target=target,
          )
  
      def __repr__(self):
          """
          Provide a friendly representation
  
          :returns: Machine friendly representation
          :rtype: str
          """
          context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
          return '<Twilio.Messaging.V1.WebhookInstance {}>'.format(context)
  