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)
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)))
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)
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)
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)