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.Get(args.instance, args.backup, args.operation) if args.database: return database_operations.Get(args.instance, args.database, args.operation) return instance_operations.Get(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.Get(args.instance, args.database, args.operation) else: return instance_operations.Get(args.instance, args.operation)
def testGet(self): response = self.msgs.Operation() 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.Get.Expect( request=self.msgs. SpannerProjectsInstancesDatabasesOperationsGetRequest( name=ref.RelativeName()), response=response) self.assertEqual(database_operations.Get('insId', 'dbId', 'opId'), response)
def _CommonRun(args): """Performs run actions common to all Describe 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 describe 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.Get(args.instance, args.backup, args.operation) if args.database: return database_operations.Get(args.instance, args.database, args.operation) return instance_operations.Get(args.instance, args.operation)