def Run(self, args): """Issues the request to describe a SSL policy.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = ssl_policies_utils.SslPolicyHelper(holder) ref = _SSL_POLICY_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(holder.client)) return helper.Describe(ref)
def Run(self, args): """Issues the request to list available SSL policy features.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = ssl_policies_utils.SslPolicyHelper(holder) project = properties.VALUES.core.project.GetOrFail() if self._regional_ssl_policies: return helper.ListAvailableFeatures( project, args.region if args.IsSpecified('region') else None) else: return helper.ListAvailableFeatures(project, None)
def Run(self, args): """Issues the request to delete a SSL policy.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = ssl_policies_utils.SslPolicyHelper(holder) client = holder.client.apitools_client refs = _SSL_POLICY_ARG.ResolveAsResource(args, holder.resources) utils.PromptForDeletion(refs) operation_refs = [helper.Delete(ref) for ref in refs] wait_message = 'Deleting SSL {}'.format( ('policies' if (len(operation_refs) > 1) else 'policy')) operation_poller = DeleteBatchPoller(holder.client, client.sslPolicies) return waiter.WaitFor(operation_poller, poller.OperationBatch(operation_refs), wait_message)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = ssl_policies_utils.SslPolicyHelper(holder) client = holder.client ssl_policy_ref = self.SSL_POLICY_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(holder.client), default_scope=compute_scope.ScopeEnum.GLOBAL) data = console_io.ReadFromFileOrStdin(args.source or '-', binary=False) try: ssl_policy = export_util.Import( message_type=client.messages.SslPolicy, stream=data, schema_path=self.GetSchemaPath()) except yaml_validator.ValidationError as e: raise compute_exceptions.ValidationError(str(e)) # Get existing SSL policy. try: ssl_policy_old = helper.Describe(ssl_policy_ref) except apitools_exceptions.HttpError as error: if error.status_code != 404: raise error # SSL policy does not exist, create a new one. operation_ref = helper.Create(ssl_policy_ref, ssl_policy) return helper.WaitForOperation(ssl_policy_ref, operation_ref, 'Creating SSL policy') # No change, do not send requests to server. if ssl_policy_old == ssl_policy: return console_io.PromptContinue( message=('SSL Policy [{0}] will be overwritten.').format( ssl_policy_ref.Name()), cancel_on_no=True) # Populate id and fingerprint fields. These two fields are manually # removed from the schema files. ssl_policy.id = ssl_policy_old.id ssl_policy.fingerprint = ssl_policy_old.fingerprint operation_ref = helper.Patch(ssl_policy_ref, ssl_policy, False) return helper.WaitForOperation(ssl_policy_ref, operation_ref, 'Updating SSL policy')
def Run(self, args): """Issues the request to create a new SSL policy.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = ssl_policies_utils.SslPolicyHelper(holder) ssl_policy_ref = _SSL_POLICY_ARG.ResolveAsResource(args, holder.resources) custom_features = args.custom_features if args.IsSpecified( 'custom_features') else [] ssl_policy_to_insert = helper.GetSslPolicyForInsert( name=ssl_policy_ref.Name(), description=args.description, profile=args.profile, min_tls_version=flags.ParseTlsVersion(args.min_tls_version), custom_features=custom_features) operation_ref = helper.Create(ssl_policy_ref, ssl_policy_to_insert) return helper.WaitForOperation(ssl_policy_ref, operation_ref, 'Creating SSL policy')
def Run(self, args): """Issues the request to update a SSL policy.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = ssl_policies_utils.SslPolicyHelper(holder) ssl_policy_ref = _SSL_POLICY_ARG.ResolveAsResource(args, holder.resources) include_custom_features, custom_features = Update._GetCustomFeatures(args) existing_ssl_policy = helper.Describe(ssl_policy_ref) patch_ssl_policy = helper.GetSslPolicyForPatch( fingerprint=existing_ssl_policy.fingerprint, profile=args.profile, min_tls_version=flags.ParseTlsVersion(args.min_tls_version), custom_features=custom_features) operation_ref = helper.Patch( ssl_policy_ref, patch_ssl_policy, include_custom_features and not custom_features) return helper.WaitForOperation(ssl_policy_ref, operation_ref, 'Updating SSL policy')
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = ssl_policies_utils.SslPolicyHelper(holder) client = holder.client ssl_policy_ref = self.SSL_POLICY_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(client), default_scope=compute_scope.ScopeEnum.GLOBAL) ssl_policy = helper.Describe(ssl_policy_ref) if args.destination: with files.FileWriter(args.destination) as stream: export_util.Export(message=ssl_policy, stream=stream, schema_path=self.GetSchemaPath()) else: export_util.Export(message=ssl_policy, stream=sys.stdout, schema_path=self.GetSchemaPath())
def Run(self, args): """Issues the request to list available SSL policy features.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = ssl_policies_utils.SslPolicyHelper(holder) project = properties.VALUES.core.project.GetOrFail() return helper.ListAvailableFeatures(project)