func Deploymentmanager_alpha_DeploymentsUpdate(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("deployment")) if len(pathParams) != 0 { if strings.Contains("{project}/global/deployments/{deployment}", "+") { usageBits += " @" + strings.Join(pathParams, "@") } else { usageBits += " " + strings.Join(pathParams, "/") } } usageBits += " [REQUEST_FILE|-] [--REQUEST_KEY=VALUE]*" usageBits += " [--createPolicy=VALUE]" usageBits += " [--deletePolicy=VALUE]" usageBits += " [--preview=VALUE]" fmt.Fprintf(os.Stderr, "Usage:\n\t%s\n", usageBits) commands_util.PrintRequestExample(&api_client.Deployment{}) os.Exit(1) } api_service, err := api_client.New(context.Client) if err != nil { return err } service := api_client.NewDeploymentsService(api_service) queryParamNames := map[string]bool{ "createPolicy": false, "deletePolicy": false, "preview": 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) == 0 || len(args) > 2 { usageFunc() } request := &api_client.Deployment{} if len(args) == 2 { err = commands_util.PopulateRequestFromFilename(&request, args[1]) if err != nil { return err } } // Any flags that aren't query parameters are applied to the request. keyValues := map[string]string{} for k, v := range flagValues { if _, ok := queryParamNames[k]; !ok { keyValues[k] = v } } err = commands_util.OverwriteRequestWithValues(&request, keyValues) if err != nil { return err } expectedParams := []string{ "project", "deployment", } 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_deployment, err := commands_util.ConvertValue_string(paramValues[1]) if err != nil { return err } call := service.Update(param_project, param_deployment, request, ) // Set query parameters. if value, ok := flagValues["createPolicy"]; ok { query_createPolicy, err := commands_util.ConvertValue_string(value) if err != nil { return err } call.CreatePolicy(query_createPolicy) } if value, ok := flagValues["deletePolicy"]; ok { query_deletePolicy, err := commands_util.ConvertValue_string(value) if err != nil { return err } call.DeletePolicy(query_deletePolicy) } if value, ok := flagValues["preview"]; ok { query_preview, err := commands_util.ConvertValue_bool(value) if err != nil { return err } call.Preview(query_preview) } response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }
func Deploymentmanager_alpha_DeploymentsList(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")) if len(pathParams) != 0 { if strings.Contains("{project}/global/deployments", "+") { usageBits += " @" + strings.Join(pathParams, "@") } else { usageBits += " " + strings.Join(pathParams, "/") } } usageBits += " [--filter=VALUE]" usageBits += " [--maxResults=VALUE]" usageBits += " [--orderBy=VALUE]" usageBits += " [--pageToken=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.NewDeploymentsService(api_service) queryParamNames := map[string]bool{ "filter": false, "maxResults": false, "orderBy": false, "pageToken": 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", } 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 } call := service.List(param_project) // Set query parameters. if value, ok := flagValues["filter"]; ok { query_filter, err := commands_util.ConvertValue_string(value) if err != nil { return err } call.Filter(query_filter) } 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["orderBy"]; ok { query_orderBy, err := commands_util.ConvertValue_string(value) if err != nil { return err } call.OrderBy(query_orderBy) } if value, ok := flagValues["pageToken"]; ok { query_pageToken, err := commands_util.ConvertValue_string(value) if err != nil { return err } call.PageToken(query_pageToken) } response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }
func Deploymentmanager_alpha_DeploymentsTestIamPermissions(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("resource")) if len(pathParams) != 0 { if strings.Contains("{project}/global/deployments/{resource}/testIamPermissions", "+") { 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.TestPermissionsRequest{}) os.Exit(1) } api_service, err := api_client.New(context.Client) if err != nil { return err } service := api_client.NewDeploymentsService(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.TestPermissionsRequest{} 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", "resource", } 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_resource, err := commands_util.ConvertValue_string(paramValues[1]) if err != nil { return err } call := service.TestIamPermissions(param_project, param_resource, request, ) response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }
func Deploymentmanager_alpha_DeploymentsGetIamPolicy(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("resource")) if len(pathParams) != 0 { if strings.Contains("{project}/global/deployments/{resource}/getIamPolicy", "+") { 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.NewDeploymentsService(api_service) // Only positional arguments should remain in args. if len(args) != 1 { usageFunc() } expectedParams := []string{ "project", "resource", } 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_resource, err := commands_util.ConvertValue_string(paramValues[1]) if err != nil { return err } call := service.GetIamPolicy(param_project, param_resource) response, err := call.Do() if err != nil { return err } err = commands_util.PrintResponse(response) if err != nil { return err } return nil }