def testCreate(self): response = self.msgs.Operation() extra_ddl = ['a', 'b'] ref = resources.REGISTRY.Parse('insId', params={'projectsId': self.Project()}, collection='spanner.projects.instances') self.client.projects_instances_databases.Create.Expect( request=self.msgs.SpannerProjectsInstancesDatabasesCreateRequest( parent=ref.RelativeName(), createDatabaseRequest=self.msgs.CreateDatabaseRequest( createStatement='CREATE DATABASE `dbId`', extraStatements=extra_ddl)), response=response) self.assertEqual(response, databases.Create(ref, 'dbId', extra_ddl))
def _CreateDatabase(self, database, schema): """Create the sample database. Args: database: String. The database name. schema: String. The schema used for the sample database. Returns: Get Request from the Await operation. """ op = databases.Create(self._instance, database, flags.SplitDdlIntoStatements([schema])) return database_operations.Await(op, 'Creating sample database')
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. """ op = databases.Create(args.instance, args.database, flags.FixDdl(args.ddl or [])) if args. async: return op return database_operations.Await(op, 'Creating database')
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. """ database_ref = args.CONCEPTS.database.Parse() instance_ref = database_ref.Parent() op = databases.Create(instance_ref, args.database, flags.SplitDdlIntoStatements(args.ddl or [])) if args. async: return op return database_operations.Await(op, 'Creating database')