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: Database delete response, which is empty. Raises: HttpException when the database is not found. """ database_ref = args.CONCEPTS.database.Parse() console_io.PromptContinue( 'You are about to delete database: [{}]'.format( database_ref.Name()), throw_if_unattended=True, cancel_on_no=True) # The delete API returns a 200 regardless of whether the database being # deleted exists. In order to show users feedback for incorrectly # entered database names, we have to make a request to check if the database # exists. If the database exists, it's deleted, otherwise, we display the # error from databases.Get. database = databases.Get(database_ref) if database: return databases.Delete(database_ref)
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. """ return databases.Get(args.CONCEPTS.database.Parse())
def testGet(self): response = self.msgs.Database() ref = resources.REGISTRY.Parse( 'dbId', params={ 'instancesId': 'insId', 'projectsId': self.Project(), }, collection='spanner.projects.instances.databases') self.client.projects_instances_databases.Get.Expect( request=self.msgs.SpannerProjectsInstancesDatabasesGetRequest( name=ref.RelativeName()), response=response) self.assertEqual(response, databases.Get(ref))