コード例 #1
0
ファイル: update.py プロジェクト: Guliux10/bchacks_deepbreath
    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:
      The updated sink with its new destination.
    """
        sink_ref = util.GetTraceSinkResource(args.sink_name, args.project)
        sink_resource_name = sink_ref.RelativeName()

        sink_data = {'name': sink_resource_name}
        update_mask = []
        if args.IsSpecified('destination'):
            sink_data['outputConfig'] = {'destination': args.destination}
            update_mask.append('output_config.destination')

        if not update_mask:
            raise calliope_exceptions.MinimumArgumentException(
                'Please specify the destination to update')

        result = self.PatchSink(sink_resource_name, sink_data, update_mask)
        log.UpdatedResource(sink_ref)
        return util.FormatTraceSink(result)
コード例 #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:
      The created sink with its destination.
    """
        sink_resource_name = util.GetTraceSinkResource(
            args.sink_name, args.project).RelativeName()

        sink_data = {
            'name': sink_resource_name,
            'outputConfig': {
                'destination': args.destination
            }
        }

        result_sink = util.GetClient().projects_traceSinks.Create(
            util.GetMessages().CloudtraceProjectsTraceSinksCreateRequest(
                parent=util.GetProjectResource(args.project).RelativeName(),
                traceSink=util.GetMessages().TraceSink(**sink_data)))

        log.status.Print(
            'You can give permission to the service account by running the '
            'following command.\ngcloud projects add-iam-policy-binding '
            'bigquery-project \\\n--member serviceAccount:{0} \\\n--role '
            'roles/bigquery.dataEditor'.format(result_sink.writerIdentity))

        return util.FormatTraceSink(result_sink)
コード例 #3
0
ファイル: list.py プロジェクト: Guliux10/bchacks_deepbreath
  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.

    Yields:
      The list of sinks.
    """
    result = util.GetClient().projects_traceSinks.List(
        util.GetMessages().CloudtraceProjectsTraceSinksListRequest(
            parent=util.GetProjectResource(args.project).RelativeName()))
    for sink in result.sinks:
      yield util.FormatTraceSink(sink)
コード例 #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:
      The specified sink with its destination.
    """
        sink_resource_name = util.GetTraceSinkResource(
            args.sink_name, args.project).RelativeName()
        result_sink = util.GetClient().projects_traceSinks.Get(
            util.GetMessages().CloudtraceProjectsTraceSinksGetRequest(
                name=sink_resource_name))
        return util.FormatTraceSink(result_sink)