Ejemplo n.º 1
0
 def Run(self, args):
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue)
   configs = parsers.ParseCreateOrUpdateQueueArgs(
       args, constants.PULL_QUEUE, queues_client.api.messages)
   update_response = queues_client.Patch(queue_ref, *configs)
   log.status.Print('Updated queue [{}].'.format(queue_ref.Name()))
   return update_response
Ejemplo n.º 2
0
 def Run(self, args):
   queues_client = queues.Queues()
   queues_messages = queues_client.api.messages
   queue_ref = parsers.ParseQueue(args.queue)
   self.context['iam-messages'] = queues_messages
   policy = iam_util.ParsePolicyFile(args.policy_file, queues_messages.Policy)
   response = queues_client.SetIamPolicy(queue_ref, policy)
   log.status.Print('Set IAM policy for queue [{}].'.format(queue_ref.Name()))
   return response
Ejemplo n.º 3
0
 def Run(self, args):
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue, args.location)
   console_io.PromptContinue(
       cancel_on_no=True,
       prompt_string='Are you sure you want to purge: [{}]'.format(
           queue_ref.RelativeName()))
   queues_client.Purge(queue_ref)
   log.status.Print('Purged queue [{}].'.format(queue_ref.Name()))
Ejemplo n.º 4
0
 def Run(self, args):
     queues_client = queues.Queues()
     queue_ref = parsers.ParseQueue(args.queue, args.location)
     policy = queues_client.GetIamPolicy(queue_ref)
     iam_util.RemoveBindingFromIamPolicy(policy, args.member, args.role)
     response = queues_client.SetIamPolicy(queue_ref, policy)
     log.status.Print('Updated IAM policy for queue [{}].'.format(
         queue_ref.Name()))
     return response
Ejemplo n.º 5
0
 def Run(self, args):
     queues_client = queues.Queues()
     queue_ref = parsers.ParseQueue(args.id)
     location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref)
     configs = parsers.ParseCreateOrUpdateQueueArgs(
         args, constants.PULL_QUEUE, queues_client.api.messages)
     create_response = queues_client.Create(location_ref, queue_ref,
                                            *configs)
     log.CreatedResource(queue_ref.Name(), 'queue')
     return create_response
Ejemplo n.º 6
0
 def Run(self, args):
     queues_client = queues.Queues()
     queue_ref = parsers.ParseQueue(args.queue)
     log.warn(constants.QUEUE_MANAGEMENT_WARNING)
     console_io.PromptContinue(
         cancel_on_no=True,
         prompt_string='Are you sure you want to delete: [{}]'.format(
             queue_ref.RelativeName()))
     queues_client.Delete(queue_ref)
     log.DeletedResource(queue_ref.Name(), 'queue')
Ejemplo n.º 7
0
 def Run(self, args):
   parsers.CheckUpdateArgsSpecified(args, constants.PULL_QUEUE)
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue, args.location)
   queue_config = parsers.ParseCreateOrUpdateQueueArgs(
       args, constants.PULL_QUEUE, queues_client.api.messages, is_update=True)
   log.warning(constants.QUEUE_MANAGEMENT_WARNING)
   update_response = queues_client.Patch(
       queue_ref, retry_config=queue_config.retryConfig)
   log.status.Print('Updated queue [{}].'.format(queue_ref.Name()))
   return update_response
 def Run(self, args):
     queues_client = queues.Queues()
     queues_messages = queues_client.api.messages
     queue_ref = parsers.ParseQueue(args.queue, args.location)
     try:
         policy = queues_client.GetIamPolicy(queue_ref)
     except apitools_exceptions.HttpNotFoundError:
         # If the error is a 404, no IAM policy exists, so just create a blank one.
         policy = queues_messages.Policy()
     iam_util.AddBindingToIamPolicy(queues_messages.Binding, policy,
                                    args.member, args.role)
     response = queues_client.SetIamPolicy(queue_ref, policy)
     return response
 def Run(self, args):
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue, args.location)
   location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref)
   queue_config = parsers.ParseCreateOrUpdateQueueArgs(
       args, constants.PULL_QUEUE, queues_client.api.messages)
   log.warning(constants.QUEUE_MANAGEMENT_WARNING)
   create_response = queues_client.Create(
       location_ref, queue_ref,
       retry_config=queue_config.retryConfig,
       rate_limits=queue_config.rateLimits,
       pull_target=queue_config.pullTarget)
   log.CreatedResource(queue_ref.Name(), 'queue')
   return create_response
Ejemplo n.º 10
0
 def Run(self, args):
     queues_client = queues.Queues()
     queue_ref = parsers.ParseQueue(args.id)
     location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref)
     queue_config = parsers.ParseCreateOrUpdateQueueArgs(
         args, constants.APP_ENGINE_QUEUE, queues_client.api.messages)
     log.warn(constants.QUEUE_MANAGEMENT_WARNING)
     create_response = queues_client.Create(
         location_ref,
         queue_ref,
         retry_config=queue_config.retryConfig,
         rate_limits=queue_config.rateLimits,
         app_engine_http_target=queue_config.appEngineHttpTarget)
     log.CreatedResource(queue_ref.Name(), 'queue')
     return create_response
Ejemplo n.º 11
0
 def Run(self, args):
   parsers.CheckUpdateArgsSpecified(args, constants.APP_ENGINE_QUEUE)
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue, args.location)
   queue_config = parsers.ParseCreateOrUpdateQueueArgs(
       args, constants.APP_ENGINE_QUEUE, queues_client.api.messages,
       is_update=True)
   app_engine_routing_override = (
       queue_config.appEngineHttpTarget.appEngineRoutingOverride if
       queue_config.appEngineHttpTarget is not None else
       None)
   log.warning(constants.QUEUE_MANAGEMENT_WARNING)
   update_response = queues_client.Patch(
       queue_ref,
       retry_config=queue_config.retryConfig,
       rate_limits=queue_config.rateLimits,
       app_engine_routing_override=app_engine_routing_override)
   log.status.Print('Updated queue [{}].'.format(queue_ref.Name()))
   return update_response
Ejemplo n.º 12
0
 def Run(self, args):
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue, args.location)
   return queues_client.GetIamPolicy(queue_ref)
Ejemplo n.º 13
0
 def Run(self, args):
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue)
   return queues_client.Get(queue_ref)
 def Run(self, args):
   queues_client = queues.Queues()
   app_location = args.location or app.ResolveAppLocation()
   region_ref = parsers.ParseLocation(app_location)
   return queues_client.List(region_ref, args.limit, args.page_size)
Ejemplo n.º 15
0
 def Run(self, args):
     queues_client = queues.Queues()
     queue_ref = parsers.ParseQueue(args.queue)
     log.warn(constants.QUEUE_MANAGEMENT_WARNING)
     queues_client.Pause(queue_ref)
     log.status.Print('Paused queue [{}].'.format(queue_ref.Name()))
Ejemplo n.º 16
0
 def Run(self, args):
     queues_client = queues.Queues()
     queue_ref = parsers.ParseQueue(args.queue, args.location)
     log.warning(constants.QUEUE_MANAGEMENT_WARNING)
     queues_client.Resume(queue_ref)
     log.status.Print('Resumed queue [{}].'.format(queue_ref.Name()))
Ejemplo n.º 17
0
 def Run(self, args):
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue)
   queues_client.Pause(queue_ref)
   log.status.Print('Paused queue [{}].'.format(queue_ref.Name()))
Ejemplo n.º 18
0
 def __init__(self):
     super(GaApiAdapter, self).__init__(GA_API_VERSION)
     self.queues = queues.Queues(self.client.MESSAGES_MODULE,
                                 self.client.projects_locations_queues)
     self.tasks = tasks.Tasks(self.client.MESSAGES_MODULE,
                              self.client.projects_locations_queues_tasks)
Ejemplo n.º 19
0
 def Run(self, args):
   queues_client = queues.Queues()
   queue_ref = parsers.ParseQueue(args.queue)
   queues_client.Delete(queue_ref)
   log.DeletedResource(queue_ref.Name(), 'queue')