def CreateReference(self, args):
   ref = self._BACKEND_SERVICE_ARG.ResolveAsResource(
       args,
       self.resources,
       default_scope=backend_services_utils.GetDefaultScope(args))
   self.regional = backend_services_utils.IsRegionalRequest(args)
   return ref
Exemple #2
0
 def GetReference(self, holder, args):
     """Override. Don't assume a default scope."""
     return self._BACKEND_SERVICE_ARG.ResolveAsResource(
         args,
         holder.resources,
         default_scope=backend_services_utils.GetDefaultScope(),
         scope_lister=compute_flags.GetDefaultScopeLister(holder.client))
Exemple #3
0
 def CreateReference(self, args):
   # TODO(b/35133484): remove once base classes are refactored away
   if not self.ref:
     self.ref = self._BACKEND_SERVICE_ARG.ResolveAsResource(
         args,
         self.resources,
         default_scope=backend_services_utils.GetDefaultScope(),
         scope_lister=compute_flags.GetDefaultScopeLister(self.compute_client))
     self.regional = self.ref.Collection() == 'compute.regionBackendServices'
   return self.ref
Exemple #4
0
    def Run(self, args):
        holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
        refs = self._BACKEND_SERVICE_ARG.ResolveAsResource(
            args,
            holder.resources,
            default_scope=backend_services_utils.GetDefaultScope())
        utils.PromptForDeletion(refs)

        requests = []
        for ref in refs:
            backend_service = client.BackendService(
                ref, compute_client=holder.client)
            requests.extend(backend_service.Delete(only_generate_request=True))

        errors = []
        resources = holder.client.MakeRequests(requests, errors)

        if errors:
            utils.RaiseToolException(errors)
        return resources
Exemple #5
0
  def Run(self, args):
    holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
    client = holder.client

    backend_service_ref = self._BACKEND_SERVICE_ARG.ResolveAsResource(
        args,
        holder.resources,
        default_scope=backend_services_utils.GetDefaultScope(),
        scope_lister=compute_flags.GetDefaultScopeLister(client))
    get_request = self.GetGetRequest(client, backend_service_ref)

    objects = client.MakeRequests([get_request])

    original_object = objects[0]
    original_record = encoding.MessageToDict(original_object)

    # Selects only the fields that can be modified.
    field_selector = property_selector.PropertySelector(properties=[
        'backends',
        'description',
        'enableCDN',
        'healthChecks',
        'iap.enabled',
        'iap.oauth2ClientId',
        'iap.oauth2ClientSecret',
        'port',
        'portName',
        'protocol',
        'timeoutSec',
    ])
    modifiable_record = field_selector.Apply(original_record)

    file_contents = self.BuildFileContents(args, client, original_record,
                                           modifiable_record)
    resource_list = self.EditResource(args, backend_service_ref, file_contents,
                                      holder, modifiable_record,
                                      original_object, original_record)

    for resource in resource_list:
      yield resource