def testAwait(self): result = self.msgs.Operation.ResponseValue() ref = resources.REGISTRY.Parse( 'opId', params={ 'instancesId': 'insId', 'databasesId': 'dbId', 'projectsId': self.Project(), }, collection='spanner.projects.instances.databases.operations') not_done = self.msgs.Operation(name=ref.RelativeName()) done = self.msgs.Operation(name=ref.RelativeName(), done=True, response=result) self.client.projects_instances_databases_operations.Get.Expect( request=self.msgs. SpannerProjectsInstancesDatabasesOperationsGetRequest( name=ref.RelativeName()), response=not_done) self.client.projects_instances_databases_operations.Get.Expect( request=self.msgs. SpannerProjectsInstancesDatabasesOperationsGetRequest( name=ref.RelativeName()), response=done) self.assertEqual(database_operations.Await(not_done, ''), result)
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.UpdateDdl( args.instance, args.database, flags.FixDdl(args.ddl or [])) if args.async: return op return database_operations.Await(op, 'DDL updating')
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.UpdateDdl(args.CONCEPTS.database.Parse(), flags.SplitDdlIntoStatements(args.ddl or [])) if args.async_: return log.status.Print( 'Schema update in progress. Operation name={}'.format(op.name)) return database_operations.Await(op, 'Schema updating')
def Run(self, args): """This is what gets called when the user runs this command.""" backup_ref = args.CONCEPTS.source.Parse() database_ref = args.CONCEPTS.destination.Parse() encryption_type = resource_args.GetRestoreDbEncryptionType(args) kms_key = resource_args.GetAndValidateKmsKeyName(args) op = databases.Restore(database_ref, backup_ref, encryption_type, kms_key) if args.async_: return log.status.Print( 'Restore database in progress. Operation name={}'.format( op.name)) return database_operations.Await( op, 'Restoring backup {0} to database {1}'.format( backup_ref.Name(), database_ref.Name()))
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')
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: A message indicating database is restoring or when async, the operation. """ backup_ref = args.CONCEPTS.source.Parse() database_ref = args.CONCEPTS.destination.Parse() op = databases.Restore(database_ref, backup_ref) if args.async_: return log.status.Print( 'Restore database in progress. Operation name={}'.format( op.name)) return database_operations.Await( op, 'Restoring backup {0} to database {1}'.format( backup_ref.Name(), database_ref.Name()))