def Run(self, args): """Run 'services disable'. Args: args: argparse.Namespace, The arguments that this command was invoked with. Returns: Nothing. """ project = properties.VALUES.core.project.Get(required=True) for service_name in args.service: service_name = arg_parsers.GetServiceNameFromArg(service_name) op = serviceusage.DisableApiCall(project, service_name, args.force) if op.done: return if args. async: cmd = OP_WAIT_CMD.format(op.name) log.status.Print('Asynchronous operation is in progress... ' 'Use the following command to wait for its ' 'completion:\n {0}'.format(cmd)) return op = services_util.WaitOperation(op.name, serviceusage.GetOperation) services_util.PrintOperation(op)
def Run(self, args): """Run 'services enable'. Args: args: argparse.Namespace, The arguments that this command was invoked with. Returns: Nothing. """ project = properties.VALUES.core.project.Get(required=True) if len(args.service) == 1: op = serviceusage.EnableApiCall(project, args.service[0]) else: op = serviceusage.BatchEnableApiCall(project, args.service) if op.done: return if args. async: cmd = _OP_WAIT_CMD.format(op.name) log.status.Print('Asynchronous operation is in progress... ' 'Use the following command to wait for its ' 'completion:\n {0}'.format(cmd)) return op = services_util.WaitOperation(op.name, serviceusage.GetOperation) services_util.PrintOperation(op)
def Run(self, args): """Run command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: The response from the Delete API call. """ client = apikeys.GetClientInstance() messages = client.MESSAGES_MODULE key_ref = args.CONCEPTS.key.Parse() request = messages.ApikeysProjectsKeysDeleteRequest( name=key_ref.RelativeName()) op = client.projects_keys.Delete(request) if not op.done: if args.async_: cmd = OP_WAIT_CMD.format(op.name) log.status.Print('Asynchronous operation is in progress... ' 'Use the following command to wait for its ' 'completion:\n {0}'.format(cmd)) return op op = services_util.WaitOperation(op.name, apikeys.GetOperation) services_util.PrintOperation(op)
def enable_service(): project = properties.VALUES.core.project.Get(required=True) service_name = 'anthosconfigmanagement.googleapis.com' op = serviceusage.EnableApiCall(project, service_name) log.status.Print('Enabling service {0}'.format(service_name)) if op.done: return op = services_util.WaitOperation(op.name, serviceusage.GetOperation) services_util.PrintOperation(op)
def Run(self, args): """Run 'services operations wait'. Args: args: argparse.Namespace, The arguments that this command was invoked with. Returns: Nothing. """ op = peering.WaitOperation(args.name) services_util.PrintOperation(op)
def Run(self, args): """Run 'services operations describe'. Args: args: argparse.Namespace, The arguments that this command was invoked with. Returns: The response from the operations.Get API call. """ op = serviceusage.GetOperation(args.operation) services_util.PrintOperation(op)
def Run(self, args): """Run 'endpoints quota delete'. Args: args: argparse.Namespace, The arguments that this command was invoked with. Returns: Nothing. """ op = scm.DeleteQuotaOverrideCall(args.service, args.consumer, args.metric, args.unit, args.override_id, args.force) if op.done: return op = services_util.WaitOperation(op.name, scm.GetOperation) services_util.PrintOperation(op)
def Run(self, args): """Run 'services vpc-peerings enable-vpc-service-controls'. Args: args: argparse.Namespace, The arguments that this command was invoked with. """ project = properties.VALUES.core.project.Get(required=True) project_number = _GetProjectNumber(project) op = peering.DisableVpcServiceControls(project_number, args.service, args.network) if args.async_: cmd = OP_WAIT_CMD.format(op.name) log.status.Print('Asynchronous operation is in progress... ' 'Use the following command to wait for its ' 'completion:\n {0}'.format(cmd)) return op = services_util.WaitOperation(op.name, peering.GetOperation) services_util.PrintOperation(op)
def Run(self, args): """Run 'services vpc-peerings connect'. Args: args: argparse.Namespace, The arguments that this command was invoked with. """ project = properties.VALUES.core.project.Get(required=True) project_number = _GetProjectNumber(project) ranges = args.ranges.split(',') op = peering.UpdateConnection(project_number, args.service, args.network, ranges, args.force) if args. async: cmd = OP_WAIT_CMD.format(op.name) log.status.Print('Asynchronous operation is in progress... ' 'Use the following command to wait for its ' 'completion:\n {0}'.format(cmd)) return op = peering.WaitOperation(op.name) services_util.PrintOperation(op)
def EnableService(project_id, service_name, is_async=False): """Enable a service without checking if it is already enabled. Args: project_id: The ID of the project for which to enable the service. service_name: The name of the service to enable on the project. is_async: bool, if True, print the operation ID and return immediately, without waiting for the op to complete. Raises: exceptions.EnableServicePermissionDeniedException: when enabling the API fails with a 403 or 404 error code. api_lib_exceptions.HttpException: Another miscellaneous error with the servicemanagement service. """ log.status.Print('Enabling service [{0}] on project [{1}]...'.format( service_name, project_id)) # Enable the service op = serviceusage.EnableApiCall(project_id, service_name) if not is_async and not op.done: op = services_util.WaitOperation(op.name, serviceusage.GetOperation) services_util.PrintOperation(op)
def DisableService(project, service_name, force=False): """Disable service. Args: project: The project for which to disable the service. service_name: The identifier of the service to disable, for example 'serviceusage.googleapis.com'. force: disable the service even if there are enabled services which depend on it. This also disables the services which depend on the service to be disabled. Raises: exceptions.EnableServicePermissionDeniedException: when disabling API fails. apitools_exceptions.HttpError: Another miscellaneous error with the service. Returns: The service configuration. """ op = serviceusage.DisableApiCall(project, service_name, force) if op.done: return op = services_util.WaitOperation(op.name, serviceusage.GetOperation) services_util.PrintOperation(op)
def Run(self, args): """Run 'services peered-dns-domains create'. Args: args: argparse.Namespace, The arguments that this command was invoked with. """ project = properties.VALUES.core.project.Get(required=True) project_number = _GetProjectNumber(project) op = peering.CreatePeeredDnsDomain( project_number, args.service, args.network, args.name, args.dns_suffix, ) if args.async_: cmd = _OP_WAIT_CMD.format(op.name) log.status.Print('Asynchronous operation is in progress... ' 'Use the following command to wait for its ' 'completion:\n {0}'.format(cmd)) return op = services_util.WaitOperation(op.name, peering.GetOperation) services_util.PrintOperation(op)
def Run(self, args): """Run 'services disable'. Args: args: argparse.Namespace, The arguments that this command was invoked with. Returns: Nothing. """ project = properties.VALUES.core.project.Get(required=True) for service_name in args.service: service_name = arg_parsers.GetServiceNameFromArg(service_name) protected_msg = serviceusage.GetProtectedServiceWarning( service_name) if protected_msg: if args.IsSpecified('quiet'): raise console_io.RequiredPromptError() do_disable = console_io.PromptContinue( protected_msg, default=False, throw_if_unattended=True) if not do_disable: continue op = serviceusage.DisableApiCall(project, service_name, args.force) if op.done: continue if args.async_: cmd = OP_WAIT_CMD.format(op.name) log.status.Print('Asynchronous operation is in progress... ' 'Use the following command to wait for its ' 'completion:\n {0}'.format(cmd)) continue op = services_util.WaitOperation(op.name, serviceusage.GetOperation) services_util.PrintOperation(op)