func Dns_v1_ChangesList(context Context, args ...string) error { usageFunc := func() { usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod) var pathParams []string pathParams = append(pathParams, commands_util.AngrySnakes("project")) pathParams = append(pathParams, commands_util.AngrySnakes("managedZone")) if len(pathParams) != 0 { if strings.Contains("{project}/managedZones/{managedZone}/changes", "+") { usageBits += " @" + strings.Join(pathParams, "@") } else { usageBits += " " + strings.Join(pathParams, "/") } } usageBits += " [--maxResults=VALUE]" usageBits += " [--pageToken=VALUE]" usageBits += " [--sortBy=VALUE]" usageBits += " [--sortOrder=VALUE]" 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.NewChangesService(api_service) queryParamNames := map[string]bool{ "maxResults": false, "pageToken": false, "sortBy": false, "sortOrder": false, } args, flagValues, err := commands_util.ExtractFlagValues(args) if err != nil { return err } for k, r := range queryParamNames { if _, ok := flagValues[k]; r && !ok { return fmt.Errorf("missing required flag %q", "--"+k) } } // Only positional arguments should remain in args. if len(args) != 1 { usageFunc() } expectedParams := []string{ "project", "managedZone", } paramValues := commands_util.SplitParamValues(args[0]) if len(paramValues) != len(expectedParams) { return commands_util.ErrForWrongParams(expectedParams, paramValues, args) } param_project, err := commands_util.ConvertValue_string(paramValues[0]) if err != nil { return err } param_managedZone, err := commands_util.ConvertValue_string(paramValues[1]) if err != nil { return err } call := service.List(param_project, param_managedZone) // Set query parameters. if value, ok := flagValues["maxResults"]; ok { query_maxResults, err := commands_util.ConvertValue_int64(value) if err != nil { return err } call.MaxResults(query_maxResults) } if value, ok := flagValues["pageToken"]; ok { query_pageToken, err := commands_util.ConvertValue_string(value) if err != nil { return err } call.PageToken(query_pageToken) } if value, ok := flagValues["sortBy"]; ok { query_sortBy, err := commands_util.ConvertValue_string(value) if err != nil { return err } call.SortBy(query_sortBy) } if value, ok := flagValues["sortOrder"]; ok { query_sortOrder, err := commands_util.ConvertValue_string(value) if err != nil { return err } call.SortOrder(query_sortOrder) } response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }
func Dns_v1_ChangesCreate(context Context, args ...string) error { usageFunc := func() { usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod) var pathParams []string pathParams = append(pathParams, commands_util.AngrySnakes("project")) pathParams = append(pathParams, commands_util.AngrySnakes("managedZone")) if len(pathParams) != 0 { if strings.Contains("{project}/managedZones/{managedZone}/changes", "+") { 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.Change{}) os.Exit(1) } api_service, err := api_client.New(context.Client) if err != nil { return err } service := api_client.NewChangesService(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.Change{} 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{ "project", "managedZone", } paramValues := commands_util.SplitParamValues(args[0]) if len(paramValues) != len(expectedParams) { return commands_util.ErrForWrongParams(expectedParams, paramValues, args) } param_project, err := commands_util.ConvertValue_string(paramValues[0]) if err != nil { return err } param_managedZone, err := commands_util.ConvertValue_string(paramValues[1]) if err != nil { return err } call := service.Create(param_project, param_managedZone, request, ) response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }
func Dns_v1_ChangesGet(context Context, args ...string) error { usageFunc := func() { usageBits := fmt.Sprintf("gcloud_apis %s", context.InvocationMethod) var pathParams []string pathParams = append(pathParams, commands_util.AngrySnakes("project")) pathParams = append(pathParams, commands_util.AngrySnakes("managedZone")) pathParams = append(pathParams, commands_util.AngrySnakes("changeId")) if len(pathParams) != 0 { if strings.Contains("{project}/managedZones/{managedZone}/changes/{changeId}", "+") { 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.NewChangesService(api_service) // Only positional arguments should remain in args. if len(args) != 1 { usageFunc() } expectedParams := []string{ "project", "managedZone", "changeId", } paramValues := commands_util.SplitParamValues(args[0]) if len(paramValues) != len(expectedParams) { return commands_util.ErrForWrongParams(expectedParams, paramValues, args) } param_project, err := commands_util.ConvertValue_string(paramValues[0]) if err != nil { return err } param_managedZone, err := commands_util.ConvertValue_string(paramValues[1]) if err != nil { return err } param_changeId, err := commands_util.ConvertValue_string(paramValues[2]) if err != nil { return err } call := service.Get(param_project, param_managedZone, param_changeId) response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }