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