コード例 #1
0
    def Run(self, args):
        """Run 'runtime-configs variables set'.

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

    Returns:
      The new variable.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    """
        variable_client = util.VariableClient()
        messages = util.Messages()

        var_resource = util.ParseVariableName(args.name, args)

        try:
            variable_client.Delete(
                messages.RuntimeconfigProjectsConfigsVariablesDeleteRequest(
                    name=var_resource.RelativeName(),
                    recursive=args.recursive,
                ))

            log.DeletedResource(var_resource)

        except apitools_exceptions.HttpNotFoundError:
            # Raise this failure if the user requested it.
            if args.fail_if_absent:
                raise
コード例 #2
0
ファイル: list.py プロジェクト: hiroshiyoshida1980/jpopjam
  def Run(self, args):
    """Run 'runtime-configs variables list'.

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

    Yields:
      The list of variables.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    """
    variable_client = util.VariableClient()
    messages = util.Messages()

    config_resource = util.ParseConfigName(util.ConfigName(args))

    self._display_values = args.values

    request = messages.RuntimeconfigProjectsConfigsVariablesListRequest(
        parent=config_resource.RelativeName(),
        returnValues=self._display_values)

    page_size = args.page_size or self.DEFAULT_PAGE_SIZE

    results = list_pager.YieldFromList(
        variable_client, request, field='variables',
        batch_size_attribute='pageSize', limit=args.limit,
        batch_size=page_size
    )

    for result in results:
      yield util.FormatVariable(result, self._display_values)
コード例 #3
0
ファイル: watch.py プロジェクト: eduardofacanha/Robin
    def Run(self, args):
        """Run a command that watches a variable.

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

    Returns:
      The WatchVariable response.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    """
        # Disable retries and configure the timeout.
        variable_client = util.VariableClient(num_retries=0,
                                              timeout=args.max_wait)
        messages = util.Messages()

        var_resource = util.ParseVariableName(args.name, args)

        if args.newer_than:
            newer_than = times.FormatDateTime(args.newer_than)
        else:
            newer_than = None

        with progress_tracker.ProgressTracker(
                'Waiting for variable [{0}] to change'.format(
                    var_resource.Name())):
            try:
                return util.FormatVariable(
                    variable_client.Watch(
                        messages.
                        RuntimeconfigProjectsConfigsVariablesWatchRequest(
                            name=var_resource.RelativeName(),
                            watchVariableRequest=messages.WatchVariableRequest(
                                newerThan=newer_than, ))))

            except apitools_exceptions.HttpError as error:
                # For deadline exceeded or bad gateway errors,
                # we return a status code of 2.
                # In some cases, the GFE will timeout before the backend
                # responds with a 504 Gateway Timeout (DEADLINE_EXCEEDED).
                # In that scenario, GFE responds first with a 502 BAD GATEWAY error.
                if util.IsDeadlineExceededError(
                        error) or util.IsBadGatewayError(error):
                    _RaiseTimeout()
                raise

            except socket.error as error:
                if util.IsSocketTimeout(error):
                    _RaiseTimeout()
                raise
コード例 #4
0
ファイル: set.py プロジェクト: Silentsoul04/bias_crawler
    def _Update(self, args, var_resource, value):
        variable_client = util.VariableClient()
        messages = util.Messages()

        result = variable_client.Update(
            messages.Variable(
                name=var_resource.RelativeName(),
                value=value if not args.is_text else None,
                text=value if args.is_text else None,
            ))

        log.UpdatedResource(var_resource)
        return util.FormatVariable(result)
コード例 #5
0
ファイル: set.py プロジェクト: Silentsoul04/bias_crawler
    def _Create(self, args, var_resource, value):
        variable_client = util.VariableClient()
        messages = util.Messages()

        project = var_resource.projectsId
        config = var_resource.configsId

        result = variable_client.Create(
            messages.RuntimeconfigProjectsConfigsVariablesCreateRequest(
                parent=util.ConfigPath(project, config),
                variable=messages.Variable(
                    name=var_resource.RelativeName(),
                    value=value if not args.is_text else None,
                    text=value if args.is_text else None,
                )))

        log.CreatedResource(var_resource)
        return util.FormatVariable(result)
コード例 #6
0
ファイル: base_commands.py プロジェクト: barber223/AudioApp
    def Run(self, args):
        """Run a command that retrieves a variable.

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

    Returns:
      The requested variable.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    """
        variable_client = util.VariableClient()
        messages = util.Messages()

        var_resource = util.ParseVariableName(args.name, args)

        return variable_client.Get(
            messages.RuntimeconfigProjectsConfigsVariablesGetRequest(
                name=var_resource.RelativeName(), ))