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)
Ejemplo n.º 2
0
  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.
    """
    console_io.PromptContinue(
        message='Delete database [{1}] in instance [{0}]. Are you sure?'.format(
            args.instance, args.database),
        cancel_on_no=True)
    return databases.Delete(args.instance, args.database)
Ejemplo n.º 3
0
 def testDelete(self):
     response = self.msgs.Empty()
     ref = resources.REGISTRY.Parse(
         'dbId',
         params={
             'instancesId': 'insId',
             'projectsId': self.Project(),
         },
         collection='spanner.projects.instances.databases')
     self.client.projects_instances_databases.DropDatabase.Expect(
         request=self.msgs.
         SpannerProjectsInstancesDatabasesDropDatabaseRequest(
             database=ref.RelativeName()),
         response=response)
     self.assertEqual(response, databases.Delete(ref))
Ejemplo n.º 4
0
    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()
        console_io.PromptContinue(
            'You are about to delete database: [{}]'.format(
                database_ref.Name()),
            throw_if_unattended=True,
            cancel_on_no=True)
        return databases.Delete(database_ref)