func Cloudbuild_v1_ProjectsTriggersList(context Context, args ...string) error { usageFunc := func() { usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod) var pathParams []string pathParams = append(pathParams, commands_util.AngrySnakes("projectId")) if len(pathParams) != 0 { if strings.Contains("v1/projects/{projectId}/triggers", "+") { usageBits += " @" + strings.Join(pathParams, "@") } else { usageBits += " " + strings.Join(pathParams, "/") } } fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits) os.Exit(1) } api_service, err := api_client.New(context.Client) if err != nil { return err } service := api_client.NewProjectsTriggersService(api_service) // Only positional arguments should remain in args. if len(args) != 1 { usageFunc() } expectedParams := []string{ "projectId", } paramValues := commands_util.SplitParamValues(args[0]) if len(paramValues) != len(expectedParams) { return commands_util.ErrForWrongParams(expectedParams, paramValues, args) } param_projectId, err := commands_util.ConvertValue_string(paramValues[0]) if err != nil { return err } call := service.List(param_projectId) response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }
func Cloudbuild_v1_ProjectsTriggersPatch(context Context, args ...string) error { usageFunc := func() { usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod) var pathParams []string pathParams = append(pathParams, commands_util.AngrySnakes("projectId")) pathParams = append(pathParams, commands_util.AngrySnakes("triggerId")) if len(pathParams) != 0 { if strings.Contains("v1/projects/{projectId}/triggers/{triggerId}", "+") { usageBits += " @" + strings.Join(pathParams, "@") } else { usageBits += " " + strings.Join(pathParams, "/") } } usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*" fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits) commands_util.PrintRequestExample(&api_client.BuildTrigger{}) os.Exit(1) } api_service, err := api_client.New(context.Client) if err != nil { return err } service := api_client.NewProjectsTriggersService(api_service) args, flagValues, err := commands_util.ExtractFlagValues(args) if err != nil { return err } // Only positional arguments should remain in args. if len(args) == 0 || len(args) > 2 { usageFunc() } request := &api_client.BuildTrigger{} if len(args) == 2 { err = commands_util.PopulateRequestFromFilename(&request, args[1]) if err != nil { return err } } keyValues := flagValues err = commands_util.OverwriteRequestWithValues(&request, keyValues) if err != nil { return err } expectedParams := []string{ "projectId", "triggerId", } paramValues := commands_util.SplitParamValues(args[0]) if len(paramValues) != len(expectedParams) { return commands_util.ErrForWrongParams(expectedParams, paramValues, args) } param_projectId, err := commands_util.ConvertValue_string(paramValues[0]) if err != nil { return err } param_triggerId, err := commands_util.ConvertValue_string(paramValues[1]) if err != nil { return err } call := service.Patch(param_projectId, param_triggerId, request, ) response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }