コード例 #1
0
ファイル: disable.py プロジェクト: camidagreat/music_game_poc
    def Run(self, args):
        """Run 'services disable'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      Nothing.
    """
        project = properties.VALUES.core.project.Get(required=True)
        for service_name in args.service:
            service_name = arg_parsers.GetServiceNameFromArg(service_name)
            op = serviceusage.DisableApiCall(project, service_name, args.force)
            if op.done:
                return
            if args. async:
                cmd = OP_WAIT_CMD.format(op.name)
                log.status.Print('Asynchronous operation is in progress... '
                                 'Use the following command to wait for its '
                                 'completion:\n {0}'.format(cmd))
                return
            op = services_util.WaitOperation(op.name,
                                             serviceusage.GetOperation)
            services_util.PrintOperation(op)
コード例 #2
0
  def Run(self, args):
    """Run 'services operations list'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      The list of operations for this project.
    """
    messages = services_util.GetMessagesModule()
    client = services_util.GetClientInstance()
    service = arg_parsers.GetServiceNameFromArg(args.service)

    msg_filter = 'serviceName="{0}"'.format(service)
    if args.filter:
      msg_filter += ' AND ({0})'.format(args.filter)
      args.filter = None  # We don't want Display() to handle the filter.

    msg = messages.ServicemanagementOperationsListRequest(filter=msg_filter)

    return list_pager.YieldFromList(
        client.operations,
        msg,
        limit=args.limit,
        batch_size_attribute='pageSize',
        batch_size=args.page_size,
        field='operations')
コード例 #3
0
    def Run(self, args):
        """Run 'services enable'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      Nothing.
    """
        project = properties.VALUES.core.project.Get(required=True)
        for service_name in args.service:
            service_name = arg_parsers.GetServiceNameFromArg(service_name)
            operation = enable_api.EnableServiceApiCall(project, service_name)
            services_util.ProcessOperationResult(operation, args. async)
コード例 #4
0
  def Run(self, args):
    """Run 'service-management disable'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      Nothing.
    """
    messages = services_util.GetMessagesModule()
    client = services_util.GetClientInstance()

    project = properties.VALUES.core.project.Get(required=True)
    for service_name in args.service:
      service_name = arg_parsers.GetServiceNameFromArg(service_name)
      request = messages.ServicemanagementServicesDisableRequest(
          serviceName=service_name,
          disableServiceRequest=messages.DisableServiceRequest(
              consumerId='project:' + project))
      operation = client.services.Disable(request)
      services_util.ProcessOperationResult(operation, args.async)
コード例 #5
0
    def Run(self, args):
        """Run 'services disable'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      Nothing.
    """
        project = properties.VALUES.core.project.Get(required=True)
        for service_name in args.service:
            service_name = arg_parsers.GetServiceNameFromArg(service_name)

            protected_msg = serviceusage.GetProtectedServiceWarning(
                service_name)
            if protected_msg:
                if args.IsSpecified('quiet'):
                    raise console_io.RequiredPromptError()
                do_disable = console_io.PromptContinue(
                    protected_msg, default=False, throw_if_unattended=True)
                if not do_disable:
                    continue

            op = serviceusage.DisableApiCall(project, service_name, args.force)
            if op.done:
                continue
            if args.async_:
                cmd = OP_WAIT_CMD.format(op.name)
                log.status.Print('Asynchronous operation is in progress... '
                                 'Use the following command to wait for its '
                                 'completion:\n {0}'.format(cmd))
                continue
            op = services_util.WaitOperation(op.name,
                                             serviceusage.GetOperation)
            services_util.PrintOperation(op)
コード例 #6
0
 def testGetServiceNameFromArgNonetypeInput(self):
     expected = None
     actual = arg_parsers.GetServiceNameFromArg(None)
     self.assertEqual(expected, actual)
コード例 #7
0
 def testGetServiceNameFromArgSimpleInput(self):
     expected = 'myservice'
     actual = arg_parsers.GetServiceNameFromArg('myservice')
     self.assertEqual(expected, actual)