Ejemplo n.º 1
0
 def Run(self, args):
     """Run the update command."""
     client = triggers.TriggersClient()
     trigger_ref = args.CONCEPTS.trigger.Parse()
     service_account_ref = args.CONCEPTS.service_account.Parse()
     update_mask = triggers.BuildUpdateMask(
         matching_criteria=args.matching_criteria is not None,
         service_account=(service_account_ref is not None)
         or args.clear_service_account,
         destination_run_service=args.destination_run_service is not None,
         destination_run_path=(args.destination_run_path is not None)
         or args.clear_destination_run_path,
         destination_run_region=args.destination_run_region is not None)
     old_trigger = client.Get(trigger_ref)
     # The type can't be updated, so it's safe to use the old trigger's type.
     # In the async case, this is the only way to get the type.
     self._event_type = types.MatchingCriteriaMessageToType(
         old_trigger.matchingCriteria)
     operation = client.Patch(trigger_ref, args.matching_criteria,
                              service_account_ref,
                              args.destination_run_service,
                              args.destination_run_path,
                              args.destination_run_region, update_mask)
     if args.async_:
         return operation
     return client.WaitFor(operation)
Ejemplo n.º 2
0
 def Run(self, args):
     """Run the delete command."""
     client = triggers.TriggersClient()
     trigger_ref = args.CONCEPTS.trigger.Parse()
     operation = client.Delete(trigger_ref)
     if args.async_:
         return operation
     return client.WaitFor(operation)
Ejemplo n.º 3
0
 def Run(self, args):
     """Run the describe command."""
     client = triggers.TriggersClient()
     trigger_ref = args.CONCEPTS.trigger.Parse()
     trigger = client.Get(trigger_ref)
     event_type = types.MatchingCriteriaMessageToType(
         trigger.matchingCriteria)
     self._active_time = triggers.TriggerActiveTime(event_type,
                                                    trigger.updateTime)
     return trigger
Ejemplo n.º 4
0
 def Run(self, args):
     """Run the create command."""
     client = triggers.TriggersClient()
     trigger_ref = args.CONCEPTS.trigger.Parse()
     service_account_ref = args.CONCEPTS.service_account.Parse()
     operation = client.Create(trigger_ref, args.matching_criteria,
                               service_account_ref,
                               args.destination_run_service,
                               args.destination_run_path,
                               args.destination_run_region)
     self._event_type = args.matching_criteria['type']
     if args.async_:
         return operation
     response = client.WaitFor(operation)
     trigger_dict = encoding.MessageToPyValue(response)
     if types.IsPubsubType(self._event_type):
         log.status.Print('Created Pub/Sub topic [{}].'.format(
             trigger_dict['transport']['pubsub']['topic']))
         log.status.Print(
             'Publish to this topic to receive events in Cloud Run service [{}].'
             .format(args.destination_run_service))
     return response
Ejemplo n.º 5
0
 def Run(self, args):
     """Run the list command."""
     client = triggers.TriggersClient()
     location_ref = args.CONCEPTS.location.Parse()
     return client.List(location_ref, args.limit, args.page_size)