def get(self):
     """Shows an HTML form."""
     template = JINJA2.get_template('pubsub.html')
     endpoint_url = re.sub('token=[^&]*', 'token=REDACTED',
                           pubsub_utils.get_app_endpoint_url())
     context = {
         'project': pubsub_utils.get_project_id(),
         'topic': pubsub_utils.get_app_topic_name(),
         'subscription': pubsub_utils.get_app_subscription_name(),
         'subscriptionEndpoint': endpoint_url
     }
     self.response.write(template.render(context))
Пример #2
0
 def get(self):
     """Creates a topic and a subscription if they do not exist."""
     template = JINJA2.get_template('pubsub.html')
     endpoint_url = re.sub('token=[^&]*', 'token=REDACTED',
                           pubsub_utils.get_app_endpoint_url())
     context = {
         'project': pubsub_utils.get_project_id(),
         'topic': pubsub_utils.get_app_topic_name(),
         'subscription': pubsub_utils.get_app_subscription_name(),
         'subscriptionEndpoint': endpoint_url
     }
     self.response.write(template.render(context))
Пример #3
0
 def get(self):
     """Shows an HTML form."""
     self.response.headers['Access-Control-Allow-Origin'] = '*'
     template = JINJA2.get_template('pubsub.html')
     endpoint_url = re.sub('token=[^&]*', 'token=REDACTED',
                           pubsub_utils.get_app_endpoint_url())
     context = {
         'project': pubsub_utils.get_project_id(),
         'topic': pubsub_utils.get_app_topic_name(),
         'subscription': pubsub_utils.get_app_subscription_name(),
         'subscriptionEndpoint': endpoint_url
     }
     self.response.write(template.render(context))
 def _setup_subscription(self):
     """Creates a subscription if it does not exist."""
     subscription_name = pubsub_utils.get_full_subscription_name()
     try:
         self.client.projects().subscriptions().get(
             subscription=subscription_name).execute()
     except errors.HttpError as e:
         if e.resp.status == 404:
             body = {
                 'topic': pubsub_utils.get_full_topic_name(),
                 'pushConfig': {
                     'pushEndpoint': pubsub_utils.get_app_endpoint_url()
                 }
             }
             self.client.projects().subscriptions().create(
                 name=subscription_name, body=body).execute()
         else:
             logging.exception(e)
             raise
Пример #5
0
 def _setup_subscription(self):
     """Creates a subscription if it does not exist."""
     subscription_name = pubsub_utils.get_full_subscription_name()
     try:
         subscription = self.client.subscriptions().get(
             subscription=subscription_name).execute()
     except errors.HttpError as e:
         if e.resp.status == 404:
             body = {
                 'name': subscription_name,
                 'topic': pubsub_utils.get_full_topic_name(),
                 'pushConfig': {
                     'pushEndpoint': pubsub_utils.get_app_endpoint_url()
                 }
             }
             self.client.subscriptions().create(body=body).execute()
         else:
             logging.exception(e)
             raise
Пример #6
0
 def _setup_subscription(self):
     """Creates a subscription if it does not exist."""
     self.response.headers['Access-Control-Allow-Origin'] = '*'
     subscription_name = pubsub_utils.get_full_subscription_name()
     try:
         self.client.projects().subscriptions().get(
             subscription=subscription_name).execute()
     except errors.HttpError as e:
         if e.resp.status == 404:
             body = {
                 'topic': pubsub_utils.get_full_topic_name(),
                 'pushConfig': {
                     'pushEndpoint': pubsub_utils.get_app_endpoint_url()
                 }
             }
             self.client.projects().subscriptions().create(
                 name=subscription_name, body=body).execute()
         else:
             logging.exception(e)
             raise