Пример #1
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.Get(args.instance, args.backup,
                                         args.operation)

        if args.database:
            return database_operations.Get(args.instance, args.database,
                                           args.operation)

        return instance_operations.Get(args.instance, args.operation)
Пример #2
0
 def testGet(self):
     response = self.msgs.Operation()
     ref = resources.REGISTRY.Parse(
         'opId',
         params={
             'instancesId': 'insId',
             'projectsId': self.Project(),
         },
         collection='spanner.projects.instances.operations')
     self.client.projects_instances_operations.Get.Expect(
         request=self.msgs.SpannerProjectsInstancesOperationsGetRequest(
             name=ref.RelativeName()),
         response=response)
     self.assertEqual(instance_operations.Get('insId', 'opId'), response)
Пример #3
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.Get(args.instance, args.database,
                                           args.operation)
        else:
            return instance_operations.Get(args.instance, args.operation)
def _CommonRun(args):
  """Performs run actions common to all Describe 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 describe 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.Get(args.instance, args.backup, args.operation)

  if args.database:
    return database_operations.Get(args.instance, args.database, args.operation)

  return instance_operations.Get(args.instance, args.operation)