Example #1
0
    def Run(self, args):
        """Run 'type-providers delete'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    """
        type_provider_ref = type_providers.GetReference(
            self.resources, args.provider_name)
        if not args.quiet:
            prompt_message = 'Are you sure you want to delete [{0}]?'.format(
                type_provider_ref.typeProvider)
            if not console_io.PromptContinue(message=prompt_message,
                                             default=False):
                raise exceptions.OperationError('Deletion aborted by user.')

        request = self.messages.DeploymentmanagerTypeProvidersDeleteRequest(
            project=type_provider_ref.project,
            typeProvider=type_provider_ref.typeProvider)

        dm_write.Execute(self.client, self.messages, self.resources, request,
                         args. async, self.client.typeProviders.Delete,
                         LogResource)
Example #2
0
  def Run(self, args):
    """Run 'type-providers update'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    """
    type_provider_ref = type_providers.GetReference(self.resources,
                                                    args.provider_name)
    project = type_provider_ref.project
    name = type_provider_ref.typeProvider
    get_request = self.messages.DeploymentmanagerTypeProvidersGetRequest(
        project=project,
        typeProvider=name)

    existing_tp = self.client.typeProviders.Get(get_request)

    labels = dm_labels.UpdateLabels(
        existing_tp.labels,
        self.messages.TypeProviderLabelEntry,
        labels_util.GetUpdateLabelsDictFromArgs(args),
        labels_util.GetRemoveLabelsListFromArgs(args))
    type_provider = self.messages.TypeProvider(name=name,
                                               description=args.description,
                                               descriptorUrl=(args.
                                                              descriptor_url),
                                               labels=labels)
    type_providers.AddOptions(self.messages,
                              args.api_options_file,
                              type_provider)

    update_request = self.messages.DeploymentmanagerTypeProvidersUpdateRequest(
        project=project,
        typeProvider=args.provider_name,
        typeProviderResource=type_provider)

    dm_write.Execute(self.client,
                     self.messages,
                     self.resources,
                     update_request,
                     args.async_,
                     self.client.typeProviders.Update,
                     LogResource)