コード例 #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:
      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)
コード例 #2
0
ファイル: update.py プロジェクト: Guliux10/bchacks_deepbreath
 def PatchSink(self, sink_name, sink_data, update_mask):
     """Patches a sink specified by the arguments."""
     messages = util.GetMessages()
     return util.GetClient().projects_traceSinks.Patch(
         messages.CloudtraceProjectsTraceSinksPatchRequest(
             name=sink_name,
             traceSink=messages.TraceSink(**sink_data),
             updateMask=','.join(update_mask)))
コード例 #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)
コード例 #5
0
ファイル: delete.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.
    """
        console_io.PromptContinue('Really delete sink [%s]?' % args.sink_name,
                                  cancel_on_no=True,
                                  default=False)

        sink_ref = util.GetTraceSinkResource(args.sink_name, args.project)

        sink_resource_name = sink_ref.RelativeName()

        util.GetClient().projects_traceSinks.Delete(
            util.GetMessages().CloudtraceProjectsTraceSinksDeleteRequest(
                name=sink_resource_name))

        log.DeletedResource(sink_ref)