Пример #1
0
def _CommonRun(args):
    """Performs run actions common to all Cancel 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 cancel 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.Cancel(args.instance, args.backup,
                                        args.operation)

    if args.database:
        return database_operations.Cancel(args.instance, args.database,
                                          args.operation)
    else:
        return instance_operations.Cancel(args.instance, args.operation)
Пример #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.
    """
        # 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.Cancel(args.instance, args.backup,
                                            args.operation)

        if args.database:
            return database_operations.Cancel(args.instance, args.database,
                                              args.operation)
        else:
            return instance_operations.Cancel(args.instance, args.operation)
Пример #3
0
 def testCancel(self):
     response = self.msgs.Empty()
     ref = resources.REGISTRY.Parse(
         'opId',
         params={
             'instancesId': 'insId',
             'projectsId': self.Project(),
         },
         collection='spanner.projects.instances.operations')
     self.client.projects_instances_operations.Cancel.Expect(
         request=self.msgs.SpannerProjectsInstancesOperationsCancelRequest(
             name=ref.RelativeName()),
         response=response)
     self.assertEqual(instance_operations.Cancel('insId', 'opId'), response)
Пример #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.
    """
        if args.database:
            return database_operations.Cancel(args.instance, args.database,
                                              args.operation)
        else:
            return instance_operations.Cancel(args.instance, args.operation)