def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: None Raises: FunctionsError: If the user doesn't confirm on prompt. """ client = self.context['functions_client'] messages = self.context['functions_messages'] project = properties.VALUES.core.project.Get(required=True) name = 'projects/{0}/regions/{1}/functions/{2}'.format( project, args.region, args.name) prompt_message = 'Resource [{0}] will be deleted.'.format(name) if not console_io.PromptContinue(message=prompt_message): raise exceptions.FunctionsError('Deletion aborted by user.') # TODO(user): Use resources.py here after b/21908671 is fixed. op = client.projects_regions_functions.Delete( messages.CloudfunctionsProjectsRegionsFunctionsDeleteRequest( name=name)) operations.Wait(op, messages, client) log.DeletedResource(name)
def _UpdateFunction(self, unused_location, function): client = self.context['functions_client'] messages = self.context['functions_messages'] # TODO(user): Use resources.py here after b/21908671 is fixed. op = client.projects_regions_functions.Update(function) operations.Wait(op, messages, client) return self._GetExistingFunction(function.name)
def _CreateFunction(self, location, function): client = self.context['functions_client'] messages = self.context['functions_messages'] # TODO(user): Use resources.py here after b/21908671 is fixed. op = client.projects_regions_functions.Create( messages.CloudfunctionsProjectsRegionsFunctionsCreateRequest( location=location, hostedFunction=function)) operations.Wait(op, messages, client) return self._GetExistingFunction(function.name)
def _UpdateFunction(self, unused_location, function): client = self.context['functions_client'] messages = self.context['functions_messages'] try: # TODO(user): Use resources.py here after b/21908671 is fixed. op = client.projects_regions_functions.Update(function) operations.Wait(op, messages, client) return self._GetExistingFunction(function.name) except apitools_base.HttpError as error: raise base_exceptions.HttpException(util.GetError(error))
def _CreateFunction(self, location, function): client = self.context['functions_client'] messages = self.context['functions_messages'] try: # TODO(user): Use resources.py here after b/21908671 is fixed. op = client.projects_regions_functions.Create( messages.CloudfunctionsProjectsRegionsFunctionsCreateRequest( location=location, hostedFunction=function)) operations.Wait(op, messages, client) return self._GetExistingFunction(function.name) except apitools_base.HttpError as error: raise base_exceptions.HttpException(util.GetError(error))