def _CommonRun(args): """Performs run actions common to all Cancel stages. Args: args: The arguments that were provided to this command invocation. Returns: (Operation) The response message. """ # TODO(b/215646847): Remove Common Run from the cancel after instance-config # flag is present in all (GA/Beta/Alpha) stages. Currently, it is only present # in the Alpha stage. # Checks that user only specified either database or backup flag. if (args.IsSpecified('database') and args.IsSpecified('backup')): raise c_exceptions.InvalidArgumentException( '--database or --backup', 'Must specify either --database or --backup.') if args.backup: return backup_operations.Cancel(args.instance, args.backup, args.operation) if args.database: return database_operations.Cancel(args.instance, args.database, args.operation) else: return instance_operations.Cancel(args.instance, args.operation)
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ # Checks that user only specified either database or backup flag. if (args.IsSpecified('database') and args.IsSpecified('backup')): raise c_exceptions.InvalidArgumentException( '--database or --backup', 'Must specify either --database or --backup.') if args.backup: return backup_operations.Cancel(args.instance, args.backup, args.operation) if args.database: return database_operations.Cancel(args.instance, args.database, args.operation) else: return instance_operations.Cancel(args.instance, args.operation)
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ if args.database: return database_operations.Cancel(args.instance, args.database, args.operation) else: return instance_operations.Cancel(args.instance, args.operation)
def testCancel(self): response = self.msgs.Empty() ref = resources.REGISTRY.Parse( 'opId', params={ 'instancesId': 'insId', 'databasesId': 'dbId', 'projectsId': self.Project(), }, collection='spanner.projects.instances.databases.operations') self.client.projects_instances_databases_operations.Cancel.Expect( request=self.msgs. SpannerProjectsInstancesDatabasesOperationsCancelRequest( name=ref.RelativeName()), response=response) self.assertEqual(database_operations.Cancel('insId', 'dbId', 'opId'), response)