def Run(self, args): """Issues the request to describe an External VPN gateway.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = external_vpn_gateways_utils.ExternalVpnGatewayHelper(holder) ref = _EXTERNAL_VPN_GATEWAY_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(holder.client)) return helper.Describe(ref)
def Run(self, args): """Issues the request to delete an external VPN gateway.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = external_vpn_gateways_utils.ExternalVpnGatewayHelper(holder) client = holder.client.apitools_client refs = _EXTERNAL_VPN_GATEWAY_ARG.ResolveAsResource( args, holder.resources) utils.PromptForDeletion(refs) operation_refs = [helper.Delete(ref) for ref in refs] wait_message = 'Deleting external VPN {}'.format( ('gateways' if (len(operation_refs) > 1) else 'gateway')) operation_poller = DeleteBatchPoller(holder.client, client.externalVpnGateways) return waiter.WaitFor(operation_poller, poller.OperationBatch(operation_refs), wait_message)
def Run(self, args): """Issues the request to create a new external VPN gateway.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) helper = external_vpn_gateways_utils.ExternalVpnGatewayHelper(holder) ref = self.EXTERNAL_VPN_GATEWAY_ARG.ResolveAsResource( args, holder.resources) messages = holder.client.messages interfaces = flags.ParseInterfaces(args.interfaces, messages) redundancy_type = flags.InferAndGetRedundancyType( args.interfaces, messages) external_vpn_gateway_to_insert = helper.GetExternalVpnGatewayForInsert( name=ref.Name(), description=args.description, interfaces=interfaces, redundancy_type=redundancy_type) operation_ref = helper.Create(ref, external_vpn_gateway_to_insert) ret = helper.WaitForOperation(ref, operation_ref, 'Creating external VPN Gateway') return ret
def Run(self, args): """Issues API requests to update a External VPN gateway. Args: args: argparse.Namespace, The arguments received by this command. Returns: [protorpc.messages.Message], A list of responses returned by the compute API. """ holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) messages = holder.client.messages helper = external_vpn_gateways_utils.ExternalVpnGatewayHelper(holder) external_gateway_ref = _EXTERNAL_VPN_GATEWAY_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(holder.client)) labels_diff = labels_util.Diff.FromUpdateArgs(args) if not labels_diff.MayHaveUpdates(): raise calliope_exceptions.RequiredArgumentException( 'LABELS', 'At least one of --update-labels or ' '--remove-labels must be specified.') external_vpn_gateway = helper.Describe(external_gateway_ref) labels_update = labels_diff.Apply( messages.GlobalSetLabelsRequest.LabelsValue, external_vpn_gateway.labels) if not labels_update.needs_update: return external_vpn_gateway operation_ref = helper.SetLabels(external_gateway_ref, external_vpn_gateway.labelFingerprint, labels_update.labels) return helper.WaitForOperation( external_gateway_ref, operation_ref, 'Updating labels of External VPN Gateway [{0}]'.format( external_gateway_ref.Name()))