From c0f7869401bda8105445e2533b852d6f00821dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 11:23:48 +0200 Subject: [PATCH 01/98] fix: add proper error and nil handling in config read/write --- cmd/cycloid/login/login.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index e4521ade..681daf4d 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -46,9 +46,16 @@ func NewCommands() *cobra.Command { } func login(org, key string) error { + conf, err := config.Read() + if err != nil { + return errors.Wrap(err, "unable to read config") + } - // we save the new token and remove the previous one - conf, _ := config.Read() + // Check for a nil map. + // This can be the case if the config file is empty + if conf.Organizations == nil { + conf.Organizations = make(map[string]config.Organization) + } conf.Organizations[org] = config.Organization{ Token: key, From 342a396c29c32d9dbe5463c51d9417ee67855912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 11:24:08 +0200 Subject: [PATCH 02/98] fix: change config file permissions to 0600 --- config/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index a03ee743..2bc6ee3d 100644 --- a/config/config.go +++ b/config/config.go @@ -2,7 +2,7 @@ package config import ( "fmt" - "io/ioutil" + "os" "github.com/adrg/xdg" "github.com/pkg/errors" @@ -38,7 +38,7 @@ func Read() (*Config, error) { Organizations: make(map[string]Organization), }, errors.Wrap(err, "unable to find XDG config path") } - content, err := ioutil.ReadFile(configFilePath) + content, err := os.ReadFile(configFilePath) if err != nil { // we return an empty Config in case it's the first time we try to access // the config and it does not exist yet @@ -65,5 +65,5 @@ func Write(c *Config) error { return errors.Wrap(err, "unable to find XDG config path") } - return ioutil.WriteFile(configFilePath, content, 0644) + return os.WriteFile(configFilePath, content, 0600) } From e9bcd5fa40541e4092ccfd65894cb1d12130ee4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 11:43:30 +0200 Subject: [PATCH 03/98] fix: error handling on config open --- cmd/cycloid/login/login.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index 681daf4d..21539443 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -46,10 +46,8 @@ func NewCommands() *cobra.Command { } func login(org, key string) error { - conf, err := config.Read() - if err != nil { - return errors.Wrap(err, "unable to read config") - } + conf, _ := config.Read() + // If err != nil, the file does not exist, we create it anyway // Check for a nil map. // This can be the case if the config file is empty From 7b866f47cd7cb30469f36534e8b1d0ac3887d20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Mon, 27 May 2024 11:46:14 +0200 Subject: [PATCH 04/98] fix(deprecation): move ioutil to os ReadFile command --- cmd/cycloid/projects/create-env.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 06123f4f..864204eb 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -2,7 +2,7 @@ package projects import ( "fmt" - "io/ioutil" + "os" strfmt "github.com/go-openapi/strfmt" "github.com/pkg/errors" @@ -135,13 +135,13 @@ func createEnv(cmd *cobra.Command, args []string) error { // CREATE PIPELINE // - rawPipeline, err := ioutil.ReadFile(pipelinePath) + rawPipeline, err := os.ReadFile(pipelinePath) if err != nil { return errors.Wrap(err, "unable to read pipeline file") } pipelineTemplate := string(rawPipeline) - rawVars, err := ioutil.ReadFile(varsPath) + rawVars, err := os.ReadFile(varsPath) if err != nil { return errors.Wrap(err, "unable to read variables file") } @@ -170,7 +170,7 @@ func createEnv(cmd *cobra.Command, args []string) error { for fp, dest := range configs { var c strfmt.Base64 - c, err = ioutil.ReadFile(fp) + c, err = os.ReadFile(fp) if err != nil { return errors.Wrap(err, "unable to read config file") } From 763a7b032c3c4f37ec144ace45015ea949a82f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 28 May 2024 22:49:51 +0200 Subject: [PATCH 05/98] func: move old command to create-raw-env --- cmd/cycloid/projects/create-env.go | 46 ++++-- cmd/cycloid/projects/create-raw-env.go | 204 +++++++++++++++++++++++++ 2 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 cmd/cycloid/projects/create-raw-env.go diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 864204eb..d59046f9 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -12,34 +12,50 @@ import ( "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" "github.com/cycloidio/cycloid-cli/cmd/cycloid/middleware" - "github.com/cycloidio/cycloid-cli/cmd/cycloid/pipelines" "github.com/cycloidio/cycloid-cli/printer" "github.com/cycloidio/cycloid-cli/printer/factory" ) func NewCreateEnvCommand() *cobra.Command { var cmd = &cobra.Command{ - Use: "create-env", - Short: "create an environment within a project", + Use: "create-stackforms-env", + Short: "create an environment within a project using StackForms.", + Long: ` +You can provide stackforms variables via files, env var and the --vars flag +The precedence order for variable provisioning is as follows: +- --var-file flag +- env vars +- --vars flag + +--vars accept json encoded values. + +You can provide values fron stdin using the '--var-file -' flag. +`, Example: ` - # create 'prod' environment in 'my-project' - cy --org my-org project create-env \ - --project my-project \ - --env prod \ - --usecase usecase-1 \ - --pipeline /my/pipeline.yml \ - --vars /my/pipeline/vars.yml \ - --config /path/to/config=/path/in/config_repo +# create 'prod' environment in 'my-project' + cy --org my-org project create-raw-env \ + --project my-project \ + --env prod \ + --usecase usecase-1 \ + --var-file vars.yml \ + --vars '{"myRaw": "vars"}' `, - PreRunE: internal.CheckAPIAndCLIVersion, - RunE: createEnv, + PreRunE: func(cmd *cobra.Command, args []string) error { + internal.Warning(cmd.ErrOrStderr(), + "This command will replace `cy project create-env` soon.\n"+ + "Please see https://github.com/cycloidio/cycloid-cli/issues/268 for more information.\n") + return internal.CheckAPIAndCLIVersion(cmd, args) + }, + + RunE: createEnv, } + common.RequiredPersistentFlag(common.WithFlagProject, cmd) common.RequiredPersistentFlag(common.WithFlagEnv, cmd) - common.RequiredFlag(WithFlagPipeline, cmd) - common.RequiredFlag(WithFlagVars, cmd) WithFlagConfig(cmd) WithFlagUsecase(cmd) + cmd.PersistentFlags().StringArrayP("var-file", "f", nil, "path to a JSON file containing variables, can be '-' for stdin") + cmd.PersistentFlags().StringArray("vars", nil, "JSON string containing variables") return cmd } diff --git a/cmd/cycloid/projects/create-raw-env.go b/cmd/cycloid/projects/create-raw-env.go new file mode 100644 index 00000000..1f0bebe3 --- /dev/null +++ b/cmd/cycloid/projects/create-raw-env.go @@ -0,0 +1,204 @@ +package projects + +import ( + "fmt" + "os" + + strfmt "github.com/go-openapi/strfmt" + "github.com/pkg/errors" + "github.com/spf13/cobra" + + "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" + "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" + "github.com/cycloidio/cycloid-cli/cmd/cycloid/middleware" + "github.com/cycloidio/cycloid-cli/cmd/cycloid/pipelines" + "github.com/cycloidio/cycloid-cli/printer" + "github.com/cycloidio/cycloid-cli/printer/factory" +) + +func NewCreateRawEnvCommand() *cobra.Command { + var cmd = &cobra.Command{ + Use: "create-raw-env", + Short: "create an environment within a project with the old configuration format.", + Aliases: []string{"create-env"}, + Example: ` + # create 'prod' environment in 'my-project' + cy --org my-org project create-raw-env \ + --project my-project \ + --env prod \ + --usecase usecase-1 \ + --pipeline /my/pipeline.yml \ + --vars /my/pipeline/vars.yml \ + --config /path/to/config=/path/in/config_repo +`, + PreRunE: func(cmd *cobra.Command, args []string) error { + internal.Warning(cmd.ErrOrStderr(), + "This command will be changed to use stackforms in the future.\n"+ + "If your still want to use this command as is, use `cy project create-raw-env` instead.\n"+ + "Please see https://github.com/cycloidio/cycloid-cli/issues/268 for more information.\n") + return internal.CheckAPIAndCLIVersion(cmd, args) + }, + RunE: createRawEnv, + } + common.RequiredPersistentFlag(common.WithFlagProject, cmd) + common.RequiredPersistentFlag(common.WithFlagEnv, cmd) + common.RequiredFlag(WithFlagPipeline, cmd) + common.RequiredFlag(WithFlagVars, cmd) + WithFlagConfig(cmd) + WithFlagUsecase(cmd) + + return cmd +} + +func createRawEnv(cmd *cobra.Command, args []string) error { + api := common.NewAPI() + m := middleware.NewMiddleware(api) + + var err error + + org, err := cmd.Flags().GetString("org") + if err != nil { + return err + } + project, err := cmd.Flags().GetString("project") + if err != nil { + return err + } + env, err := cmd.Flags().GetString("env") + if err != nil { + return err + } + usecase, err := cmd.Flags().GetString("usecase") + if err != nil { + return err + } + varsPath, err := cmd.Flags().GetString("vars") + if err != nil { + return err + } + pipelinePath, err := cmd.Flags().GetString("pipeline") + if err != nil { + return err + } + configs, err := cmd.Flags().GetStringToString("config") + if err != nil { + return err + } + + projectData, err := m.GetProject(org, project) + if err != nil { + return err + } + output, err := cmd.Flags().GetString("output") + if err != nil { + return errors.Wrap(err, "unable to get output flag") + } + + // fetch the printer from the factory + p, err := factory.GetPrinter(output) + if err != nil { + return errors.Wrap(err, "unable to get printer") + } + + // need to conver the environment to "new environment" as required + // by the API + envs := make([]*models.NewEnvironment, len(projectData.Environments)) + + for i, e := range projectData.Environments { + if *e.Canonical == env { + return fmt.Errorf("environment %s exists already in %s", env, project) + } + envs[i] = &models.NewEnvironment{ + Canonical: e.Canonical, + } + } + + // finally add the new environment + envs = append(envs, &models.NewEnvironment{ + // TODO: https://github.com/cycloidio/cycloid-cli/issues/67 + Canonical: &env, + }) + + // + // UPDATE PROJECT + // + resp, err := m.UpdateProject(org, + *projectData.Name, + project, + envs, + projectData.Description, + *projectData.ServiceCatalog.Ref, + *projectData.Owner.Username, + projectData.ConfigRepositoryCanonical, + *projectData.UpdatedAt) + + err = printer.SmartPrint(p, nil, err, "unable to update project", printer.Options{}, cmd.OutOrStdout()) + if err != nil { + return err + } + + // + // CREATE PIPELINE + // + + rawPipeline, err := os.ReadFile(pipelinePath) + if err != nil { + return errors.Wrap(err, "unable to read pipeline file") + } + pipelineTemplate := string(rawPipeline) + + rawVars, err := os.ReadFile(varsPath) + if err != nil { + return errors.Wrap(err, "unable to read variables file") + } + + variables := string(rawVars) + + newPP, err := m.CreatePipeline(org, project, env, pipelineTemplate, variables, usecase) + err = printer.SmartPrint(p, nil, err, "unable to create pipeline", printer.Options{}, cmd.OutOrStdout()) + if err != nil { + return err + } + + // + // PUSH CONFIG If project creation succeeded we push the config files + // + // Pipeline vars file + crVarsPath, err := pipelines.GetPipelineVarsPath(m, org, project, *newPP.UseCase) + if err != nil { + printer.SmartPrint(p, nil, err, "unable to get pipeline variables destination path", printer.Options{}, cmd.OutOrStdout()) + } + cfs := make(map[string]strfmt.Base64) + cfs[crVarsPath] = rawVars + + // Additionals config files + if len(configs) > 0 { + + for fp, dest := range configs { + var c strfmt.Base64 + c, err = os.ReadFile(fp) + if err != nil { + return errors.Wrap(err, "unable to read config file") + } + cfs[dest] = c + } + } + + err = m.PushConfig(org, project, env, cfs) + err = printer.SmartPrint(p, nil, err, "unable to push config", printer.Options{}, cmd.OutOrStdout()) + if err != nil { + return err + } + + // + // PIPELINE UNPAUSE + // + err = m.UnpausePipeline(org, project, env) + err = printer.SmartPrint(p, nil, err, "unable to unpause pipeline", printer.Options{}, cmd.OutOrStdout()) + if err != nil { + return err + } + + return printer.SmartPrint(p, resp, err, "", printer.Options{}, cmd.OutOrStdout()) +} From 38e2fd93377331d375b80ca1aee4b1e91b42ef8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 28 May 2024 22:51:31 +0200 Subject: [PATCH 06/98] func(internal): add Debug function and make Warning function public --- cmd/cycloid/internal/version.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cmd/cycloid/internal/version.go b/cmd/cycloid/internal/version.go index a6610ce4..e716bf78 100644 --- a/cmd/cycloid/internal/version.go +++ b/cmd/cycloid/internal/version.go @@ -3,6 +3,7 @@ package internal import ( "fmt" "io" + "os" "regexp" "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" @@ -12,13 +13,27 @@ import ( "github.com/spf13/viper" ) -func warning(out io.Writer, msg string) { +func Warning(out io.Writer, msg string) { switch viper.GetString("verbosity") { case "info", "debug", "warning": // This is still dirty, we should detect if the current // terminal is able to support colors // But that would be for another PR. - fmt.Fprintf(out, "\033[1;35m%s\033[0m\n", msg) + fmt.Fprintf(out, "\033[1;35mwarning:\033[0m %s", msg) + break + default: + break + } +} + +func Debug(msg ...any) { + switch viper.GetString("verbosity") { + case "debug": + // This is still dirty, we should detect if the current + // terminal is able to support colors + // But that would be for another PR. + fmt.Fprintf(os.Stderr, "\033[1;34mdebug:\033[0m ") + fmt.Fprintln(os.Stderr, msg...) break default: break @@ -33,7 +48,7 @@ func CheckAPIAndCLIVersion(cmd *cobra.Command, args []string) error { d, err := m.GetAppVersion() if err != nil { - warning(cmd.ErrOrStderr(), "Warning: Unable to get the API version\n") + Warning(cmd.ErrOrStderr(), "Unable to get the API version\n") return nil } @@ -42,7 +57,7 @@ func CheckAPIAndCLIVersion(cmd *cobra.Command, args []string) error { apiVersion = reg.ReplaceAllString(apiVersion, "${1}") if cliVersion != apiVersion { - warning(cmd.ErrOrStderr(), fmt.Sprintf("Warning: CLI version %s does not match the API version. You should consider to download CLI version %s\n", cliVersion, apiVersion)) + Warning(cmd.ErrOrStderr(), fmt.Sprintf("CLI version %s does not match the API version. You should consider to download CLI version %s\n", cliVersion, apiVersion)) } return nil } From b3d01d4e4e100108ef29d5ef96921e4fc0f10af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 28 May 2024 22:52:30 +0200 Subject: [PATCH 07/98] wip: add first draft of create-env command. --- cmd/cycloid/projects/create-env.go | 174 +++++++++++++++++------------ 1 file changed, 105 insertions(+), 69 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index d59046f9..70baee37 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -1,10 +1,14 @@ package projects import ( + "encoding/json" "fmt" + "io" + "log" + "maps" "os" + "time" - strfmt "github.com/go-openapi/strfmt" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -70,35 +74,104 @@ func createEnv(cmd *cobra.Command, args []string) error { if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err } + env, err := cmd.Flags().GetString("env") if err != nil { return err } + usecase, err := cmd.Flags().GetString("usecase") if err != nil { return err } - varsPath, err := cmd.Flags().GetString("vars") + + varsFiles, err := cmd.Flags().GetStringArray("var-file") if err != nil { return err } - pipelinePath, err := cmd.Flags().GetString("pipeline") - if err != nil { - return err + + // init the final variable map + // TODO: We need to implement a recursive merge function + // To be able to merge submaps + var vars = make(map[string]interface{}) + + // Fetch vars from files and stdin + for _, varFile := range varsFiles { + internal.Debug("found var file", varFile) + var decoder *json.Decoder + if varFile == "-" { + decoder = json.NewDecoder(os.Stdin) + } else { + reader, err := os.Open(varFile) + if err != nil { + return fmt.Errorf("failed to read input vars from stdin: %v", err) + } + defer reader.Close() + decoder = json.NewDecoder(reader) + } + + // Files can contain one or more object, so we scan for all with a decoder + for { + var extractedVars = make(map[string]interface{}) + err := decoder.Decode(&extractedVars) + if err == io.EOF { + internal.Debug("finished reading input vars from", varFile) + break + } + if err != nil { + log.Fatalf("failed to read input vars from "+varFile+": %v", err) + break + } + maps.Copy(vars, extractedVars) + } } - configs, err := cmd.Flags().GetStringToString("config") + + internal.Debug("found theses vars via files:", vars) + + // Get vars via the CY_CREATE_ENV_VARS env var + envConfig, exists := os.LookupEnv("CY_CREATE_ENV_VARS") + if exists { + internal.Debug("found config via env var", envConfig) + var envVars = make(map[string]interface{}) + err := json.Unmarshal([]byte(envConfig), &envVars) + + // TODO: does this should error if parsing fail, of should we just put a warning ? + if err != nil { + return fmt.Errorf("failed to parse env var config '"+envConfig+"' as JSON: %s", err) + } + + maps.Copy(vars, envVars) + } + + // Get variables via CLI arguments + cliVars, err := cmd.Flags().GetStringArray("vars") if err != nil { return err } + for _, varInput := range cliVars { + internal.Debug("found var input", varInput) + var extractedVars = make(map[string]interface{}) + err = json.Unmarshal([]byte(varInput), &extractedVars) + if err != nil { + return fmt.Errorf("failed to parse var input '"+varInput+"' as JSON: %s", err) + } + + maps.Copy(vars, extractedVars) + } + + internal.Debug("vars after CLI merge:", vars) + projectData, err := m.GetProject(org, project) if err != nil { return err } + output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") @@ -129,10 +202,22 @@ func createEnv(cmd *cobra.Command, args []string) error { Canonical: &env, }) + inputs := models.FormInputs{ + Inputs: []models.FormInput{ + { + EnvironmentCanonical: &env, + UseCase: &usecase, + Vars: vars, + }, + }, + ServiceCatalogRef: &projectData.ServiceCatalog.Ref, + } // // UPDATE PROJECT // - resp, err := m.UpdateProject(org, + // TODO: Add support for resource pool canonical in case of resource quotas + timestamp := time.Now() + _, err = m.UpdateProject(org, *projectData.Name, project, envs, @@ -140,74 +225,25 @@ func createEnv(cmd *cobra.Command, args []string) error { *projectData.ServiceCatalog.Ref, *projectData.Owner.Username, projectData.ConfigRepositoryCanonical, - *projectData.UpdatedAt) + inputs, + timestamp, + ) err = printer.SmartPrint(p, nil, err, "unable to update project", printer.Options{}, cmd.OutOrStdout()) if err != nil { return err } - // - // CREATE PIPELINE - // - - rawPipeline, err := os.ReadFile(pipelinePath) - if err != nil { - return errors.Wrap(err, "unable to read pipeline file") - } - pipelineTemplate := string(rawPipeline) - - rawVars, err := os.ReadFile(varsPath) - if err != nil { - return errors.Wrap(err, "unable to read variables file") - } - - variables := string(rawVars) - - newPP, err := m.CreatePipeline(org, project, env, pipelineTemplate, variables, usecase) - err = printer.SmartPrint(p, nil, err, "unable to create pipeline", printer.Options{}, cmd.OutOrStdout()) - if err != nil { - return err - } - - // - // PUSH CONFIG If project creation succeeded we push the config files - // - // Pipeline vars file - crVarsPath, err := pipelines.GetPipelineVarsPath(m, org, project, *newPP.UseCase) - if err != nil { - printer.SmartPrint(p, nil, err, "unable to get pipeline variables destination path", printer.Options{}, cmd.OutOrStdout()) - } - cfs := make(map[string]strfmt.Base64) - cfs[crVarsPath] = rawVars - - // Additionals config files - if len(configs) > 0 { - - for fp, dest := range configs { - var c strfmt.Base64 - c, err = os.ReadFile(fp) - if err != nil { - return errors.Wrap(err, "unable to read config file") - } - cfs[dest] = c - } - } - - err = m.PushConfig(org, project, env, cfs) - err = printer.SmartPrint(p, nil, err, "unable to push config", printer.Options{}, cmd.OutOrStdout()) - if err != nil { - return err - } + return nil + // // + // // PIPELINE UNPAUSE + // // + // err = m.UnpausePipeline(org, project, env) + // err = printer.SmartPrint(p, nil, err, "unable to unpause pipeline", printer.Options{}, cmd.OutOrStdout()) + // if err != nil { + // return err + // } // - // PIPELINE UNPAUSE - // - err = m.UnpausePipeline(org, project, env) - err = printer.SmartPrint(p, nil, err, "unable to unpause pipeline", printer.Options{}, cmd.OutOrStdout()) - if err != nil { - return err - } - - return printer.SmartPrint(p, resp, err, "", printer.Options{}, cmd.OutOrStdout()) + // return printer.SmartPrint(p, resp, err, "", printer.Options{}, cmd.OutOrStdout()) } From b14af5f68b8f28b5f9503a12b2348948fcbc6050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 28 May 2024 22:52:59 +0200 Subject: [PATCH 08/98] wip: update of the middleware to support forms input --- cmd/cycloid/middleware/middleware.go | 2 +- cmd/cycloid/middleware/project.go | 4 ++-- cmd/cycloid/projects/cmd.go | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/cycloid/middleware/middleware.go b/cmd/cycloid/middleware/middleware.go index 4ae4b172..5497fd4f 100644 --- a/cmd/cycloid/middleware/middleware.go +++ b/cmd/cycloid/middleware/middleware.go @@ -80,7 +80,7 @@ type Middleware interface { DeleteProject(org, project string) error GetProject(org string, project string) (*models.Project, error) ListProjects(org string) ([]*models.Project, error) - UpdateProject(org, projectName, projectCanonical string, envs []*models.NewEnvironment, description, stackRef, owner, configRepo string, updatedAt uint64) (*models.Project, error) + UpdateProject(org, projectName, projectCanonical string, envs []*models.NewEnvironment, description, stackRef, owner, configRepo string, inputs []*models.FormInput, updatedAt uint64) (*models.Project, error) DeleteRole(org, role string) error GetRole(org, role string) (*models.Role, error) diff --git a/cmd/cycloid/middleware/project.go b/cmd/cycloid/middleware/project.go index 9696ff97..4fb7727b 100644 --- a/cmd/cycloid/middleware/project.go +++ b/cmd/cycloid/middleware/project.go @@ -121,8 +121,7 @@ func (m *middleware) CreateProject(org, projectName, projectCanonical, env, pipe return d, err } -func (m *middleware) UpdateProject(org, projectName, projectCanonical string, envs []*models.NewEnvironment, description, stackRef, owner, configRepo string, updatedAt uint64) (*models.Project, error) { - +func (m *middleware) UpdateProject(org, projectName, projectCanonical string, envs []*models.NewEnvironment, description, stackRef, owner, configRepo string, inputs []*models.FormInput, updatedAt uint64) (*models.Project, error) { params := organization_projects.NewUpdateProjectParams() params.SetOrganizationCanonical(org) params.SetProjectCanonical(projectCanonical) @@ -134,6 +133,7 @@ func (m *middleware) UpdateProject(org, projectName, projectCanonical string, en ConfigRepositoryCanonical: configRepo, Environments: envs, Owner: owner, + Inputs: inputs, UpdatedAt: &updatedAt, } diff --git a/cmd/cycloid/projects/cmd.go b/cmd/cycloid/projects/cmd.go index c3eea99f..a98b1658 100644 --- a/cmd/cycloid/projects/cmd.go +++ b/cmd/cycloid/projects/cmd.go @@ -21,6 +21,7 @@ func NewCommands() *cobra.Command { NewListCommand(), NewDeleteEnvCommand(), NewCreateEnvCommand(), + NewCreateRawEnvCommand(), NewGetCommand()) return cmd From 8417ab80da4337983a8b67fea7baf6b43e86e00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 28 May 2024 22:53:26 +0200 Subject: [PATCH 09/98] misc: add draft of test for create-env, will integrate real tests later --- test.json | 3 +++ test.sh | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test.json create mode 100644 test.sh diff --git a/test.json b/test.json new file mode 100644 index 00000000..3130770d --- /dev/null +++ b/test.json @@ -0,0 +1,3 @@ +{ + "file3": "tuti" +} diff --git a/test.sh b/test.sh new file mode 100644 index 00000000..386cefc7 --- /dev/null +++ b/test.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +org=cycloid-sandbox + + +export CY_CREATE_ENV_VARS='{"viaEnv": "ok", "file4": "overriden", "subMap": {"two": 2}}' +echo -e '{\n"file1": "titi",\n"toto": "toto"\n}{"file4": 3, "subMap": {"one": 1}}' | go run . projects create-stackforms-env \ + --verbosity debug \ + --org $org \ + --project "test-env" \ + --env "test" \ + --vars '{"toto": "vars1"}' \ + --var-file '-' \ + --var-file <(echo '{"file2": "tata"}') From de83bff71071135874fd5c9eede92d7be1a748dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 28 May 2024 23:45:51 +0200 Subject: [PATCH 10/98] fix: fixed UpdateProject Middleware --- cmd/cycloid/projects/create-env.go | 25 ++++++++++++------------- cmd/cycloid/projects/create-raw-env.go | 1 + 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 70baee37..2e6e3ae2 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -7,7 +7,6 @@ import ( "log" "maps" "os" - "time" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -57,7 +56,7 @@ You can provide values fron stdin using the '--var-file -' flag. common.RequiredPersistentFlag(common.WithFlagProject, cmd) common.RequiredPersistentFlag(common.WithFlagEnv, cmd) WithFlagConfig(cmd) - WithFlagUsecase(cmd) + cmd.PersistentFlags().String("use-case", "", "the selected use case of the stack") cmd.PersistentFlags().StringArrayP("var-file", "f", nil, "path to a JSON file containing variables, can be '-' for stdin") cmd.PersistentFlags().StringArray("vars", nil, "JSON string containing variables") @@ -85,9 +84,11 @@ func createEnv(cmd *cobra.Command, args []string) error { return err } - usecase, err := cmd.Flags().GetString("usecase") + usecase, err := cmd.Flags().GetString("use-case") if err != nil { return err + } else if usecase == "" { + return errors.New("--use-case flag is required") } varsFiles, err := cmd.Flags().GetStringArray("var-file") @@ -202,21 +203,19 @@ func createEnv(cmd *cobra.Command, args []string) error { Canonical: &env, }) - inputs := models.FormInputs{ - Inputs: []models.FormInput{ - { - EnvironmentCanonical: &env, - UseCase: &usecase, - Vars: vars, - }, + inputs := []*models.FormInput{ + { + EnvironmentCanonical: &env, + UseCase: &usecase, + Vars: vars, }, - ServiceCatalogRef: &projectData.ServiceCatalog.Ref, } + // // UPDATE PROJECT // // TODO: Add support for resource pool canonical in case of resource quotas - timestamp := time.Now() + // timestamp := time.Now().Unix() _, err = m.UpdateProject(org, *projectData.Name, project, @@ -226,7 +225,7 @@ func createEnv(cmd *cobra.Command, args []string) error { *projectData.Owner.Username, projectData.ConfigRepositoryCanonical, inputs, - timestamp, + *projectData.UpdatedAt, ) err = printer.SmartPrint(p, nil, err, "unable to update project", printer.Options{}, cmd.OutOrStdout()) diff --git a/cmd/cycloid/projects/create-raw-env.go b/cmd/cycloid/projects/create-raw-env.go index 1f0bebe3..6861ca09 100644 --- a/cmd/cycloid/projects/create-raw-env.go +++ b/cmd/cycloid/projects/create-raw-env.go @@ -131,6 +131,7 @@ func createRawEnv(cmd *cobra.Command, args []string) error { *projectData.ServiceCatalog.Ref, *projectData.Owner.Username, projectData.ConfigRepositoryCanonical, + nil, *projectData.UpdatedAt) err = printer.SmartPrint(p, nil, err, "unable to update project", printer.Options{}, cmd.OutOrStdout()) From 82dfec037f82fe7b2055d880c312c7f8bffe86c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 28 May 2024 23:46:04 +0200 Subject: [PATCH 11/98] misc: add real 'test' --- test.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/test.sh b/test.sh index 386cefc7..8b9f05c8 100644 --- a/test.sh +++ b/test.sh @@ -3,12 +3,68 @@ org=cycloid-sandbox -export CY_CREATE_ENV_VARS='{"viaEnv": "ok", "file4": "overriden", "subMap": {"two": 2}}' -echo -e '{\n"file1": "titi",\n"toto": "toto"\n}{"file4": 3, "subMap": {"one": 1}}' | go run . projects create-stackforms-env \ +echo -e ' +{ + "Cloud provider": { + "Terraform": { + "gcp_credentials_json": "((gcp.json_key))", + "gcp_project": "($ .organization_canonical $)", + "gcp_region": "europe-west1", + "gcp_zone": "europe-west1-b", + "terraform_storage_bucket_name": "($ .organization_canonical $)-terraform-remote-state" + } + }, + "Instance": { + "Boot-disk": { + "module.vm.boot_disk_auto_delete": true, + "module.vm.boot_disk_device_name": "", + "module.vm.boot_disk_image": "debian-cloud/debian-12", + "module.vm.boot_disk_size": 5, + "module.vm.boot_disk_type": "pd-standard" + }, + "Details": { + "module.vm.allow_stopping_for_update": true, + "module.vm.file_content": "", + "module.vm.instance_name": "${var.customer}-${var.project}-${var.env}-vm", + "module.vm.instance_tags": [ + "${var.customer}-${var.project}-${var.env}-network-tag" + ], + "module.vm.machine_type": "e2-small" + }, + "Firewall-egress": { + "module.vm.egress_allow_protocol": "", + "module.vm.egress_disabled": true, + "module.vm.egress_firewall_name": "" + }, + "Firewall-ingress": { + "module.vm.ingress_allow_ports": [ + "22" + ], + "module.vm.ingress_allow_protocol": "tcp", + "module.vm.ingress_disabled": false, + "module.vm.ingress_firewall_name": "${var.customer}-${var.project}-${var.env}-ingress" + }, + "Network": { + "module.vm.network": "qscqsc", + "module.vm.network_ip": "" + } + } +} +' | go run . projects create-stackforms-env \ --verbosity debug \ --org $org \ --project "test-env" \ - --env "test" \ - --vars '{"toto": "vars1"}' \ - --var-file '-' \ - --var-file <(echo '{"file2": "tata"}') + --env "test2" \ + --use-case "gcp-gce" \ + --var-file '-' + + +# export CY_CREATE_ENV_VARS='{"viaEnv": "ok", "file4": "overriden", "subMap": {"two": 2}}' +# echo -e '{\n"file1": "titi",\n"toto": "toto"\n}{"file4": 3, "subMap": {"one": 1}}' | go run . projects create-stackforms-env \ +# --verbosity debug \ +# --org $org \ +# --project "test-env" \ +# --env "test" \ +# --vars '{"toto": "vars1"}' \ +# --var-file '-' \ +# --var-file <(echo '{"file2": "tata"}') From 9ca080a669683c8dc742d73c0f6509840e7999f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 4 Jun 2024 18:47:35 +0200 Subject: [PATCH 12/98] func: add create-stackforms-env, move create-env to create-raw-env --- cmd/cycloid/projects/create-env.go | 163 ++++++++++++++++----- cmd/cycloid/projects/create-raw-env.go | 3 + go.mod | 47 +++--- go.sum | 191 +++++++++---------------- 4 files changed, 225 insertions(+), 179 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 2e6e3ae2..5278e9a9 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -5,10 +5,13 @@ import ( "fmt" "io" "log" - "maps" "os" + "reflect" + "strings" + "dario.cat/mergo" "github.com/pkg/errors" + "github.com/sanity-io/litter" "github.com/spf13/cobra" "github.com/cycloidio/cycloid-cli/client/models" @@ -27,7 +30,7 @@ func NewCreateEnvCommand() *cobra.Command { You can provide stackforms variables via files, env var and the --vars flag The precedence order for variable provisioning is as follows: - --var-file flag -- env vars +- env vars CY_STACKFORMS_VAR - --vars flag --vars accept json encoded values. @@ -39,7 +42,7 @@ You can provide values fron stdin using the '--var-file -' flag. cy --org my-org project create-raw-env \ --project my-project \ --env prod \ - --usecase usecase-1 \ + --use-case usecase-1 \ --var-file vars.yml \ --vars '{"myRaw": "vars"}' `, @@ -59,6 +62,8 @@ You can provide values fron stdin using the '--var-file -' flag. cmd.PersistentFlags().String("use-case", "", "the selected use case of the stack") cmd.PersistentFlags().StringArrayP("var-file", "f", nil, "path to a JSON file containing variables, can be '-' for stdin") cmd.PersistentFlags().StringArray("vars", nil, "JSON string containing variables") + cmd.PersistentFlags().BoolP("update", "u", false, "if true, existing environment will be updated, default: false") + cmd.PersistentFlags().StringToStringP("extra-var", "e", nil, "extra variable to be added to the environment in the -e key=value,key=value format") return cmd } @@ -91,14 +96,27 @@ func createEnv(cmd *cobra.Command, args []string) error { return errors.New("--use-case flag is required") } + update, err := cmd.Flags().GetBool("update") + if err != nil { + return err + } + varsFiles, err := cmd.Flags().GetStringArray("var-file") if err != nil { return err } - // init the final variable map - // TODO: We need to implement a recursive merge function - // To be able to merge submaps + extraVar, err := cmd.Flags().GetStringToString("extra-var") + if err != nil { + return err + } + + internal.Debug("extraVar:", extraVar) + + // + // Variable merge + // + var vars = make(map[string]interface{}) // Fetch vars from files and stdin @@ -128,14 +146,17 @@ func createEnv(cmd *cobra.Command, args []string) error { log.Fatalf("failed to read input vars from "+varFile+": %v", err) break } - maps.Copy(vars, extractedVars) + + if err := mergo.Merge(&vars, extractedVars, mergo.WithOverride); err != nil { + log.Fatalf("failed to merge input vars from "+varFile+": %v", err) + } } } internal.Debug("found theses vars via files:", vars) - // Get vars via the CY_CREATE_ENV_VARS env var - envConfig, exists := os.LookupEnv("CY_CREATE_ENV_VARS") + // Get vars via the CY_STACKFORMS_VARS env var + envConfig, exists := os.LookupEnv("CY_STACKFORMS_VARS") if exists { internal.Debug("found config via env var", envConfig) var envVars = make(map[string]interface{}) @@ -146,10 +167,12 @@ func createEnv(cmd *cobra.Command, args []string) error { return fmt.Errorf("failed to parse env var config '"+envConfig+"' as JSON: %s", err) } - maps.Copy(vars, envVars) + if err := mergo.Merge(&vars, envVars, mergo.WithOverride); err != nil { + log.Fatalf("failed to merge input vars from environment: %v", err) + } } - // Get variables via CLI arguments + // Get variables via CLI arguments --vars cliVars, err := cmd.Flags().GetStringArray("vars") if err != nil { return err @@ -163,7 +186,14 @@ func createEnv(cmd *cobra.Command, args []string) error { return fmt.Errorf("failed to parse var input '"+varInput+"' as JSON: %s", err) } - maps.Copy(vars, extractedVars) + if err := mergo.Merge(&vars, extractedVars, mergo.WithOverride); err != nil { + log.Fatalf("failed to merge input vars from environment: %v", err) + } + } + + // Merge key/val from extraVar + for k, v := range extraVar { + updateMapField(k, v, vars) } internal.Debug("vars after CLI merge:", vars) @@ -188,19 +218,69 @@ func createEnv(cmd *cobra.Command, args []string) error { // by the API envs := make([]*models.NewEnvironment, len(projectData.Environments)) + litter.Dump(projectData.Environments) + for i, e := range projectData.Environments { - if *e.Canonical == env { - return fmt.Errorf("environment %s exists already in %s", env, project) + if *e.Canonical == env && !update { + return fmt.Errorf("environment %s exists already in %s\nIf you want to update it, add the --update flag.", env, project) + } + + if e.Canonical == nil { + return fmt.Errorf("missing canonical for environment %v", e) + } + + cloudProviderCanonical := "" + if e.CloudProvider != nil { + cloudProviderCanonical = *e.CloudProvider.Canonical } + + color := "default" + if e.Color != nil { + color = *e.Color + } + + icon := "extension" + if e.Icon != nil { + icon = *e.Icon + } + envs[i] = &models.NewEnvironment{ - Canonical: e.Canonical, + Canonical: e.Canonical, + CloudProviderCanonical: cloudProviderCanonical, + Color: color, + Icon: icon, } } + litter.Dump(envs) + + var cloudProviderCanonical, icon, color string + switch strings.ToLower(usecase) { + case "aws": + cloudProviderCanonical = "aws" + icon = "mdi-aws" + color = "staging" + case "azure": + cloudProviderCanonical = "azure" + icon = "mdi-azure" + color = "prod" + case "gcp": + cloudProviderCanonical = "google" + icon = "mdi-google-cloud" + color = "dev" + default: + cloudProviderCanonical = "" + icon = "extension" + color = "default" + } + // finally add the new environment envs = append(envs, &models.NewEnvironment{ // TODO: https://github.com/cycloidio/cycloid-cli/issues/67 - Canonical: &env, + Canonical: &env, + CloudProviderCanonical: cloudProviderCanonical, + Color: color, + Icon: icon, }) inputs := []*models.FormInput{ @@ -211,12 +291,9 @@ func createEnv(cmd *cobra.Command, args []string) error { }, } - // - // UPDATE PROJECT - // + // Send the updateProject call // TODO: Add support for resource pool canonical in case of resource quotas - // timestamp := time.Now().Unix() - _, err = m.UpdateProject(org, + resp, err := m.UpdateProject(org, *projectData.Name, project, envs, @@ -228,21 +305,41 @@ func createEnv(cmd *cobra.Command, args []string) error { *projectData.UpdatedAt, ) - err = printer.SmartPrint(p, nil, err, "unable to update project", printer.Options{}, cmd.OutOrStdout()) + return printer.SmartPrint(p, resp, err, "", printer.Options{}, cmd.OutOrStdout()) +} + +// Update map 'm' with field 'field' to 'value' +// the field must be in dot notation +// e.g. field='one.nested.key' value='myValue' +// If the map is nil, it will be created +func updateMapField(field string, value any, m map[string]any) error { + keys := strings.Split(field, ".") + + if m == nil { + m = make(map[string]any) + } + + if len(keys) == 1 { + m[keys[0]] = value + return nil + } + + child, exists := m[keys[0]] + if exists && reflect.ValueOf(child).Kind() == reflect.Map { + childMap, ok := child.(map[string]any) + if !ok { + return fmt.Errorf("failed to parse nested map: %v\n%v", child, childMap) + } + return updateMapField(strings.Join(keys[1:], "."), value, childMap) + } + + child = make(map[string]any) + err := updateMapField(strings.Join(keys[1:], "."), value, child.(map[string]any)) if err != nil { return err } - return nil + m[keys[0]] = child - // // - // // PIPELINE UNPAUSE - // // - // err = m.UnpausePipeline(org, project, env) - // err = printer.SmartPrint(p, nil, err, "unable to unpause pipeline", printer.Options{}, cmd.OutOrStdout()) - // if err != nil { - // return err - // } - // - // return printer.SmartPrint(p, resp, err, "", printer.Options{}, cmd.OutOrStdout()) + return nil } diff --git a/cmd/cycloid/projects/create-raw-env.go b/cmd/cycloid/projects/create-raw-env.go index 6861ca09..4f653efc 100644 --- a/cmd/cycloid/projects/create-raw-env.go +++ b/cmd/cycloid/projects/create-raw-env.go @@ -32,6 +32,9 @@ func NewCreateRawEnvCommand() *cobra.Command { --vars /my/pipeline/vars.yml \ --config /path/to/config=/path/in/config_repo `, + Deprecated: "This command will be changed to use stackforms in the future.\n" + + "If your still want to use this command as is, use `cy project create-env` instead.\n" + + "Please see https://github.com/cycloidio/cycloid-cli/issues/268 for more information.", PreRunE: func(cmd *cobra.Command, args []string) error { internal.Warning(cmd.ErrOrStderr(), "This command will be changed to use stackforms in the future.\n"+ diff --git a/go.mod b/go.mod index b009c31e..39f0dbf4 100644 --- a/go.mod +++ b/go.mod @@ -4,51 +4,56 @@ go 1.22 require ( github.com/adrg/xdg v0.4.0 - github.com/go-openapi/errors v0.20.2 - github.com/go-openapi/runtime v0.23.1 - github.com/go-openapi/strfmt v0.21.2 - github.com/go-openapi/swag v0.21.1 - github.com/go-openapi/validate v0.21.0 + github.com/go-openapi/errors v0.22.0 + github.com/go-openapi/runtime v0.28.0 + github.com/go-openapi/strfmt v0.23.0 + github.com/go-openapi/swag v0.23.0 + github.com/go-openapi/validate v0.24.0 github.com/olekukonko/tablewriter v0.0.5 github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.3.0 github.com/spf13/viper v1.10.1 - github.com/stretchr/testify v1.7.0 - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b + github.com/stretchr/testify v1.9.0 + gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect + dario.cat/mergo v1.0.0 // indirect + github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect - github.com/go-openapi/analysis v0.21.2 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.19.6 // indirect - github.com/go-openapi/loads v0.21.1 // indirect - github.com/go-openapi/spec v0.20.4 // indirect - github.com/go-stack/stack v1.8.1 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/analysis v0.23.0 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.21.0 // indirect + github.com/go-openapi/loads v0.22.0 // indirect + github.com/go-openapi/spec v0.21.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/magiconair/properties v1.8.5 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect - github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sanity-io/litter v1.5.5 // indirect github.com/spf13/afero v1.6.0 // indirect github.com/spf13/cast v1.4.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.2.0 // indirect - go.mongodb.org/mongo-driver v1.8.3 // indirect - golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + go.mongodb.org/mongo-driver v1.14.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect + golang.org/x/sync v0.6.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/text v0.14.0 // indirect gopkg.in/ini.v1 v1.66.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 64573891..436ce22c 100644 --- a/go.sum +++ b/go.sum @@ -45,15 +45,13 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -66,9 +64,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= @@ -97,11 +94,10 @@ github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWH github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -126,60 +122,32 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-openapi/analysis v0.21.2 h1:hXFrOYFHUAMQdu6zwAiKKJHJQ8kqZs1ux/ru1P1wLJU= -github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY= -github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.20.2 h1:dxy7PGTqEh94zj2E3h1cUmQQWiM1+aeCROfAr02EmK8= -github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= -github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= -github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= -github.com/go-openapi/loads v0.21.1 h1:Wb3nVZpdEzDTcly8S4HMkey6fjARRzb7iEaySimlDW0= -github.com/go-openapi/loads v0.21.1/go.mod h1:/DtAMXXneXFjbQMGEtbamCZb+4x7eGwkvZCvBmwUG+g= -github.com/go-openapi/runtime v0.23.1 h1:/Drg9R96eMmgKJHVWZADz78XbE39/6QiIiB45mc+epo= -github.com/go-openapi/runtime v0.23.1/go.mod h1:AKurw9fNre+h3ELZfk6ILsfvPN+bvvlaU/M9q/r9hpk= -github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= -github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= -github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= -github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= -github.com/go-openapi/strfmt v0.21.2 h1:5NDNgadiX1Vhemth/TH4gCGopWSTdDjxl60H3B7f+os= -github.com/go-openapi/strfmt v0.21.2/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU= -github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/validate v0.21.0 h1:+Wqk39yKOhfpLqNLEC0/eViCkzM5FVXVqrvt526+wcI= -github.com/go-openapi/validate v0.21.0/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC03zFCU= +github.com/go-openapi/analysis v0.23.0/go.mod h1:9mz9ZWaSlV8TvjQHLl2mUW2PbZtemkE8yA5v22ohupo= +github.com/go-openapi/errors v0.22.0 h1:c4xY/OLxUBSTiepAg3j/MHuAv5mJhnf53LLMWFB+u/w= +github.com/go-openapi/errors v0.22.0/go.mod h1:J3DmZScxCDufmIMsdOuDHxJbdOGC0xtUynjIx092vXE= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= +github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= +github.com/go-openapi/loads v0.22.0 h1:ECPGd4jX1U6NApCGG1We+uEozOAvXvJSF4nnwHZ8Aco= +github.com/go-openapi/loads v0.22.0/go.mod h1:yLsaTCS92mnSAZX5WWoxszLj0u+Ojl+Zs5Stn1oF+rs= +github.com/go-openapi/runtime v0.28.0 h1:gpPPmWSNGo214l6n8hzdXYhPuJcGtziTOgUpvsFWGIQ= +github.com/go-openapi/runtime v0.28.0/go.mod h1:QN7OzcS+XuYmkQLw05akXk0jRH/eZ3kb18+1KwW9gyc= +github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY= +github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk= +github.com/go-openapi/strfmt v0.23.0 h1:nlUS6BCqcnAk0pyhi9Y+kdDVZdZMHfEKQiS4HaMgO/c= +github.com/go-openapi/strfmt v0.23.0/go.mod h1:NrtIpfKtWIygRkKVsxh7XQMDQW5HKQl6S5ik2elW+K4= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= +github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3BumrGD58= +github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= -github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= -github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= -github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= -github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= -github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= -github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= -github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= -github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= -github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= -github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= -github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= -github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= -github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= -github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= -github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= -github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -214,7 +182,6 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -229,8 +196,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -251,9 +219,9 @@ github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -295,7 +263,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -305,17 +272,15 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= -github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -323,13 +288,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= -github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -352,19 +312,15 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -373,7 +329,6 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -381,6 +336,7 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -398,16 +354,16 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= +github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= +github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= @@ -415,12 +371,10 @@ github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.3.0 h1:R7cSvGu+Vv+qX0gW5R/85dx2kmmJT5z5NM8ifdYjdn0= github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= @@ -428,22 +382,18 @@ github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -452,10 +402,8 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= -go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= -go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= -go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4= -go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= +go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= +go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -463,6 +411,14 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= +go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -470,15 +426,12 @@ go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -555,11 +508,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -581,7 +531,6 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -589,6 +538,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -597,13 +548,10 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -642,7 +590,6 @@ golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -659,11 +606,9 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -672,8 +617,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -683,13 +629,9 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -886,8 +828,8 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -900,10 +842,9 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 21f4333b4f97f525f3ef8f23fc8e4cfeb44cec94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:08:55 +0200 Subject: [PATCH 13/98] fix: fix client generation to includ bad section Organization Project --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 5a0434cc..22b6c9be 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,7 @@ SWAGGER_GENERATE = swagger generate client \ --tags="Organization pipelines jobs" \ --tags="Organization pipelines jobs build" \ --tags="Organization projects" \ + --tags="Organization Projects" \ --tags="Organization Roles" \ --tags="Organization Service Catalog Sources" \ --tags="Organization workers" \ From 047571f3ebaa524d3e9dcac6e4db5e1b5e903644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:09:24 +0200 Subject: [PATCH 14/98] func: add generated client method for getProjectConfig --- .../organization_projects_client.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/client/client/organization_projects/organization_projects_client.go b/client/client/organization_projects/organization_projects_client.go index 4ebdcc1d..6d7d2905 100644 --- a/client/client/organization_projects/organization_projects_client.go +++ b/client/client/organization_projects/organization_projects_client.go @@ -228,6 +228,40 @@ func (a *Client) GetProject(params *GetProjectParams, authInfo runtime.ClientAut return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +GetProjectConfig Fetch the current project's environment's configuration. +*/ +func (a *Client) GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter) (*GetProjectConfigOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetProjectConfigParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getProjectConfig", + Method: "GET", + PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/vnd.cycloid.io.v1+json", "application/x-www-form-urlencoded"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetProjectConfigReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetProjectConfigOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetProjectConfigDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* GetProjects Get list of projects of the organization. */ From 71a80334863a6818422e821acabb3dd74a82a02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:09:44 +0200 Subject: [PATCH 15/98] func: indent JSON printer and add newline at EOF to make it more readable --- printer/json/printer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/printer/json/printer.go b/printer/json/printer.go index bf1acf26..4fe8bf2e 100644 --- a/printer/json/printer.go +++ b/printer/json/printer.go @@ -14,10 +14,14 @@ type JSON struct{} // Print will write the object in the writer using the given options func (j JSON) Print(obj interface{}, opts printer.Options, w io.Writer) error { - payload, err := json.Marshal(obj) + payload, err := json.MarshalIndent(obj, "", " ") if err != nil { return errors.Wrap(err, "unable to marshal object") } + + // Add a newline to avoid ugly console output for user + payload = append(payload, '\n') + if _, err = w.Write(payload); err != nil { return errors.Wrap(err, "unable to write JSON in the writer") } From 9048b731c17548934770fca00ebe016062769c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:10:11 +0200 Subject: [PATCH 16/98] misc: change deprecated method --- cmd/cycloid/projects/create.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/cycloid/projects/create.go b/cmd/cycloid/projects/create.go index 8b012fd6..7c624535 100644 --- a/cmd/cycloid/projects/create.go +++ b/cmd/cycloid/projects/create.go @@ -1,7 +1,7 @@ package projects import ( - "io/ioutil" + "os" strfmt "github.com/go-openapi/strfmt" "github.com/pkg/errors" @@ -108,13 +108,13 @@ func create(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get printer") } - rawPipeline, err := ioutil.ReadFile(pipelinePath) + rawPipeline, err := os.ReadFile(pipelinePath) if err != nil { return errors.Wrap(err, "unable to read pipeline file") } pipelineTemplate := string(rawPipeline) - rawVars, err := ioutil.ReadFile(varsPath) + rawVars, err := os.ReadFile(varsPath) if err != nil { return errors.Wrap(err, "unable to read variables file") } @@ -141,7 +141,7 @@ func create(cmd *cobra.Command, args []string) error { if len(configs) > 0 { for fp, dest := range configs { var c strfmt.Base64 - c, err = ioutil.ReadFile(fp) + c, err = os.ReadFile(fp) if err != nil { return errors.Wrap(err, "unable to read config file") } From ac53b070df969ed7c2316996a4090c37e8814c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:10:29 +0200 Subject: [PATCH 17/98] func: add env creation command using stackforms --- cmd/cycloid/projects/create-env.go | 55 ++++-------------------------- 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 5278e9a9..2c2a94d2 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -6,12 +6,10 @@ import ( "io" "log" "os" - "reflect" "strings" "dario.cat/mergo" "github.com/pkg/errors" - "github.com/sanity-io/litter" "github.com/spf13/cobra" "github.com/cycloidio/cycloid-cli/client/models" @@ -32,10 +30,13 @@ The precedence order for variable provisioning is as follows: - --var-file flag - env vars CY_STACKFORMS_VAR - --vars flag +- --extra-var (-e) flag --vars accept json encoded values. You can provide values fron stdin using the '--var-file -' flag. + +The output will be the generated configuration of the project. `, Example: ` # create 'prod' environment in 'my-project' @@ -111,8 +112,6 @@ func createEnv(cmd *cobra.Command, args []string) error { return err } - internal.Debug("extraVar:", extraVar) - // // Variable merge // @@ -153,8 +152,6 @@ func createEnv(cmd *cobra.Command, args []string) error { } } - internal.Debug("found theses vars via files:", vars) - // Get vars via the CY_STACKFORMS_VARS env var envConfig, exists := os.LookupEnv("CY_STACKFORMS_VARS") if exists { @@ -193,11 +190,9 @@ func createEnv(cmd *cobra.Command, args []string) error { // Merge key/val from extraVar for k, v := range extraVar { - updateMapField(k, v, vars) + common.UpdateMapField(k, v, vars) } - internal.Debug("vars after CLI merge:", vars) - projectData, err := m.GetProject(org, project) if err != nil { return err @@ -218,8 +213,6 @@ func createEnv(cmd *cobra.Command, args []string) error { // by the API envs := make([]*models.NewEnvironment, len(projectData.Environments)) - litter.Dump(projectData.Environments) - for i, e := range projectData.Environments { if *e.Canonical == env && !update { return fmt.Errorf("environment %s exists already in %s\nIf you want to update it, add the --update flag.", env, project) @@ -252,8 +245,6 @@ func createEnv(cmd *cobra.Command, args []string) error { } } - litter.Dump(envs) - var cloudProviderCanonical, icon, color string switch strings.ToLower(usecase) { case "aws": @@ -291,6 +282,8 @@ func createEnv(cmd *cobra.Command, args []string) error { }, } + _, _ = m.CreateFormsConfig(org, project, *projectData.ServiceCatalog.Ref, inputs) + // Send the updateProject call // TODO: Add support for resource pool canonical in case of resource quotas resp, err := m.UpdateProject(org, @@ -307,39 +300,3 @@ func createEnv(cmd *cobra.Command, args []string) error { return printer.SmartPrint(p, resp, err, "", printer.Options{}, cmd.OutOrStdout()) } - -// Update map 'm' with field 'field' to 'value' -// the field must be in dot notation -// e.g. field='one.nested.key' value='myValue' -// If the map is nil, it will be created -func updateMapField(field string, value any, m map[string]any) error { - keys := strings.Split(field, ".") - - if m == nil { - m = make(map[string]any) - } - - if len(keys) == 1 { - m[keys[0]] = value - return nil - } - - child, exists := m[keys[0]] - if exists && reflect.ValueOf(child).Kind() == reflect.Map { - childMap, ok := child.(map[string]any) - if !ok { - return fmt.Errorf("failed to parse nested map: %v\n%v", child, childMap) - } - return updateMapField(strings.Join(keys[1:], "."), value, childMap) - } - - child = make(map[string]any) - err := updateMapField(strings.Join(keys[1:], "."), value, child.(map[string]any)) - if err != nil { - return err - } - - m[keys[0]] = child - - return nil -} From 11f09b60d9d61e0814da2dee3f20cda3034c5773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:10:56 +0200 Subject: [PATCH 18/98] misc: add createFormsConfig middleware implementation --- cmd/cycloid/middleware/stacks.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmd/cycloid/middleware/stacks.go b/cmd/cycloid/middleware/stacks.go index 7bf7ebe4..1e76171d 100644 --- a/cmd/cycloid/middleware/stacks.go +++ b/cmd/cycloid/middleware/stacks.go @@ -1,6 +1,8 @@ package middleware import ( + "fmt" + "github.com/cycloidio/cycloid-cli/client/client/organization_forms" "github.com/cycloidio/cycloid-cli/client/client/service_catalogs" @@ -149,3 +151,23 @@ func (m *middleware) ValidateForm(org string, rawForms []byte) (*models.FormsVal d := p.Data return d, nil } + +func (m *middleware) CreateFormsConfig(org string, project string, serviceCatalogRef string, inputs []*models.FormInput) (map[string]any, error) { + body := &models.FormInputs{ + ServiceCatalogRef: &serviceCatalogRef, + Inputs: inputs, + } + + params := organization_forms.NewCreateFormsConfigParams() + params.WithOrganizationCanonical(org) + params.WithProjectCanonical(project) + params.WithBody(body) + + resp, err := m.api.OrganizationForms.CreateFormsConfig(params, m.api.Credentials(&org)) + if err != nil { + return nil, NewApiError(err) + } + + fmt.Println(resp.GetPayload().Data) + return nil, nil +} From 6bba46d5a69dfe175bfc4624725f97c59644b365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:11:27 +0200 Subject: [PATCH 19/98] func: add get-env-config command --- cmd/cycloid/middleware/middleware.go | 3 +++ cmd/cycloid/middleware/project.go | 24 +++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cmd/cycloid/middleware/middleware.go b/cmd/cycloid/middleware/middleware.go index 5497fd4f..0bdd59da 100644 --- a/cmd/cycloid/middleware/middleware.go +++ b/cmd/cycloid/middleware/middleware.go @@ -40,6 +40,8 @@ type Middleware interface { GetRemoteTFExternalBackend(org string) (*models.ExternalBackend, error) UpdateExternalBackend(org string, externalBackendID uint32, purpose, cred string, def bool, ebConfig models.ExternalBackendConfiguration) (*models.ExternalBackend, error) + // Organization Forms + CreateFormsConfig(org string, project string, serviceCatalogRef string, inputs []*models.FormInput) (map[string]any, error) ValidateForm(org string, rawForms []byte) (*models.FormsValidationResult, error) DeleteMember(org string, name string) error @@ -79,6 +81,7 @@ type Middleware interface { DeleteProjectEnv(org, project, env string) error DeleteProject(org, project string) error GetProject(org string, project string) (*models.Project, error) + GetProjectConfig(org string, project string, environment string) (*models.ProjectEnvironmentConfig, error) ListProjects(org string) ([]*models.Project, error) UpdateProject(org, projectName, projectCanonical string, envs []*models.NewEnvironment, description, stackRef, owner, configRepo string, inputs []*models.FormInput, updatedAt uint64) (*models.Project, error) diff --git a/cmd/cycloid/middleware/project.go b/cmd/cycloid/middleware/project.go index 4fb7727b..47b380a2 100644 --- a/cmd/cycloid/middleware/project.go +++ b/cmd/cycloid/middleware/project.go @@ -32,7 +32,6 @@ func (m *middleware) ListProjects(org string) ([]*models.Project, error) { } func (m *middleware) GetProject(org, project string) (*models.Project, error) { - params := organization_projects.NewGetProjectParams() params.SetOrganizationCanonical(org) params.SetProjectCanonical(project) @@ -53,6 +52,27 @@ func (m *middleware) GetProject(org, project string) (*models.Project, error) { return d, nil } +func (m *middleware) GetProjectConfig(org string, project string, env string) (*models.ProjectEnvironmentConfig, error) { + params := organization_projects.NewGetProjectConfigParams() + params.WithOrganizationCanonical(org) + params.WithProjectCanonical(project) + params.WithEnvironmentCanonical(env) + params.SetContext(nil) + + resp, err := m.api.OrganizationProjects.GetProjectConfig(params, m.api.Credentials(&org)) + if err != nil { + return nil, NewApiError(err) + } + + payload := resp.GetPayload() + err = payload.Validate(strfmt.Default) + if err != nil { + return nil, err + } + + return payload.Data, nil +} + func (m *middleware) CreateProject(org, projectName, projectCanonical, env, pipelineTemplate, variables, description, stackRef, usecase, configRepo string) (*models.Project, error) { var body *models.NewProject @@ -159,7 +179,6 @@ func (m *middleware) UpdateProject(org, projectName, projectCanonical string, en } func (m *middleware) DeleteProjectEnv(org, project, env string) error { - params := organization_projects.NewDeleteProjectEnvironmentParams() params.SetOrganizationCanonical(org) params.SetProjectCanonical(project) @@ -173,7 +192,6 @@ func (m *middleware) DeleteProjectEnv(org, project, env string) error { } func (m *middleware) DeleteProject(org, project string) error { - params := organization_projects.NewDeleteProjectParams() params.SetOrganizationCanonical(org) params.SetProjectCanonical(project) From be152a6a8e4759b1cdcc8d592d8f1a63b77837be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:11:50 +0200 Subject: [PATCH 20/98] misc: add new command to cmd --- cmd/cycloid/projects/cmd.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/cycloid/projects/cmd.go b/cmd/cycloid/projects/cmd.go index a98b1658..9fe73b97 100644 --- a/cmd/cycloid/projects/cmd.go +++ b/cmd/cycloid/projects/cmd.go @@ -22,7 +22,11 @@ func NewCommands() *cobra.Command { NewDeleteEnvCommand(), NewCreateEnvCommand(), NewCreateRawEnvCommand(), - NewGetCommand()) + NewGetCommand(), + NewGetEnvCommand(), + //NewGetStackformsConfigCommand(), // needs implementation + NewGetStackformsConfigFromEnvCommand(), + ) return cmd } From 5d0c910830c57b1b6f8fcd7d4b3671aed5e90db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:12:00 +0200 Subject: [PATCH 21/98] func: add utility function for forms and arg/flag parsing --- cmd/cycloid/common/helpers.go | 194 ++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index 168984fa..43b1c04c 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -3,15 +3,18 @@ package common import ( "fmt" "os" + "reflect" "regexp" "strings" "net/url" "github.com/cycloidio/cycloid-cli/client/client" + "github.com/cycloidio/cycloid-cli/client/models" "github.com/cycloidio/cycloid-cli/config" "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" + "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -194,3 +197,194 @@ func GenerateCanonical(name string) string { return strings.ToLower(canonical) } + +// From a *models.FormEntity, retrieve a value associated with its type +// if getCurrent is true, we return the current value in priority +// otherwise, we get the default value +// if no default is set, we get a zeroed value of the correct type +// Return nil if the type is invalid. +// TODO: Could this be better with generics ? +func EntityGetValue(entity *models.FormEntity, getCurrent bool) any { + switch *entity.Type { + case "string": + if getCurrent { // Try to get current value if asked. + value, ok := entity.Current.(string) + if ok { + return value + } + } + + // Try to get the default value + value, ok := entity.Default.(string) + if ok { + return value + } + + // Else return a valid typed zeroed value + return "" + case "integer": + if getCurrent { // Try to get current value if asked. + value, ok := entity.Current.(int64) + if ok { + return value + } + } + + // Try to get the default value + value, ok := entity.Default.(int64) + if ok { + return value + } + + // Else return a valid typed zeroed value + return 0 + case "float": + if getCurrent { // Try to get current value if asked. + value, ok := entity.Current.(float64) + if ok { + return value + } + } + + // Try to get the default value + value, ok := entity.Default.(float64) + if ok { + return value + } + + // Else return a valid typed zeroed value + return 0 + case "boolean": + if getCurrent { // Try to get current value if asked. + value, ok := entity.Current.(bool) + if ok { + return value + } + } + + // Try to get the default value + value, ok := entity.Default.(bool) + if ok { + return value + } + + // Else return a valid typed zeroed value + return false + case "array": + if getCurrent { // Try to get current value if asked. + value, ok := entity.Current.([]any) + if ok { + return value + } + } + + // Try to get the default value + value, ok := entity.Default.([]any) + if ok { + return value + } + + // Else return a valid typed zeroed value + return []any{} + case "map": + if getCurrent { // Try to get current value if asked. + value, ok := entity.Current.(map[string]any) + if ok { + return value + } + } + + // Try to get the default value + value, ok := entity.Default.(map[string]any) + if ok { + return value + } + + // Else return a valid typed zeroed value + return make(map[string]any) + default: + return nil + } +} + +func ParseFormsConfig(conf *models.ProjectEnvironmentConfig, useCase string, getCurrent bool) (vars map[string]map[string]map[string]any, err error) { + form, err := GetFormsUseCase(conf.Forms.UseCases, useCase) + if err != nil { + return nil, errors.Wrap(err, "failed to extract forms data from project config.") + } + + vars = make(map[string]map[string]map[string]any) + for _, section := range form.Sections { + if section == nil { + continue + } + + var groups = make(map[string]map[string]any) + for _, group := range section.Groups { + vars := make(map[string]any) + + for _, varEntity := range group.Vars { + value := EntityGetValue(varEntity, getCurrent) + // We have to strings.ToLower() the keys otherwise, it will not be + // recognized as input for a create-env + vars[strings.ToLower(*varEntity.Name)] = value + } + + groups[strings.ToLower(*group.Name)] = vars + } + + vars[strings.ToLower(*section.Name)] = groups + } + + return vars, nil +} + +func GetFormsUseCase(formsUseCases []*models.FormUseCase, useCase string) (*models.FormUseCase, error) { + if formsUseCases == nil { + return nil, fmt.Errorf("got empty forms use case") + } + + for _, form := range formsUseCases { + if *form.Name == useCase { + return form, nil + } + } + + return nil, errors.New(fmt.Sprint("failed to find usecase:", useCase, "in form input:", formsUseCases)) +} + +// Update map 'm' with field 'field' to 'value' +// the field must be in dot notation +// e.g. field='one.nested.key' value='myValue' +// If the map is nil, it will be created +func UpdateMapField(field string, value any, m map[string]any) error { + keys := strings.Split(field, ".") + + if m == nil { + m = make(map[string]any) + } + + if len(keys) == 1 { + m[keys[0]] = value + return nil + } + + child, exists := m[keys[0]] + if exists && reflect.ValueOf(child).Kind() == reflect.Map { + childMap, ok := child.(map[string]any) + if !ok { + return fmt.Errorf("failed to parse nested map: %v\n%v", child, childMap) + } + return UpdateMapField(strings.Join(keys[1:], "."), value, childMap) + } + + child = make(map[string]any) + err := UpdateMapField(strings.Join(keys[1:], "."), value, child.(map[string]any)) + if err != nil { + return err + } + + m[keys[0]] = child + + return nil +} From e5df498909555044c27356f03509803929e87bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:12:26 +0200 Subject: [PATCH 22/98] misc: remove deprecated function --- e2e/helpers.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e/helpers.go b/e2e/helpers.go index a57ec48f..2a415e84 100644 --- a/e2e/helpers.go +++ b/e2e/helpers.go @@ -4,7 +4,8 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "ioutil" + "os" "regexp" "time" @@ -102,7 +103,7 @@ func AddNowTimestamp(txt string) string { } func WriteFile(path string, data []byte) { - err := ioutil.WriteFile(path, data, 0644) + err := os.WriteFile(path, data, 0644) if err != nil { panic(fmt.Sprintf("Test setup, unable to write file %s : %s", path, err.Error())) } From 54e39a2e05a99e3f8268743908adbd0d3f2fc676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:12:40 +0200 Subject: [PATCH 23/98] misc: add client file --- .../get_project_config_parameters.go | 178 +++++++++ .../get_project_config_responses.go | 351 ++++++++++++++++++ 2 files changed, 529 insertions(+) create mode 100644 client/client/organization_projects/get_project_config_parameters.go create mode 100644 client/client/organization_projects/get_project_config_responses.go diff --git a/client/client/organization_projects/get_project_config_parameters.go b/client/client/organization_projects/get_project_config_parameters.go new file mode 100644 index 00000000..1544fb32 --- /dev/null +++ b/client/client/organization_projects/get_project_config_parameters.go @@ -0,0 +1,178 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organization_projects + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetProjectConfigParams creates a new GetProjectConfigParams object +// with the default values initialized. +func NewGetProjectConfigParams() *GetProjectConfigParams { + var () + return &GetProjectConfigParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetProjectConfigParamsWithTimeout creates a new GetProjectConfigParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetProjectConfigParamsWithTimeout(timeout time.Duration) *GetProjectConfigParams { + var () + return &GetProjectConfigParams{ + + timeout: timeout, + } +} + +// NewGetProjectConfigParamsWithContext creates a new GetProjectConfigParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetProjectConfigParamsWithContext(ctx context.Context) *GetProjectConfigParams { + var () + return &GetProjectConfigParams{ + + Context: ctx, + } +} + +// NewGetProjectConfigParamsWithHTTPClient creates a new GetProjectConfigParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetProjectConfigParamsWithHTTPClient(client *http.Client) *GetProjectConfigParams { + var () + return &GetProjectConfigParams{ + HTTPClient: client, + } +} + +/*GetProjectConfigParams contains all the parameters to send to the API endpoint +for the get project config operation typically these are written to a http.Request +*/ +type GetProjectConfigParams struct { + + /*EnvironmentCanonical + The environment canonical to use as part of a path + + */ + EnvironmentCanonical string + /*OrganizationCanonical + A canonical of an organization. + + */ + OrganizationCanonical string + /*ProjectCanonical + A canonical of a project. + + */ + ProjectCanonical string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get project config params +func (o *GetProjectConfigParams) WithTimeout(timeout time.Duration) *GetProjectConfigParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get project config params +func (o *GetProjectConfigParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get project config params +func (o *GetProjectConfigParams) WithContext(ctx context.Context) *GetProjectConfigParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get project config params +func (o *GetProjectConfigParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get project config params +func (o *GetProjectConfigParams) WithHTTPClient(client *http.Client) *GetProjectConfigParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get project config params +func (o *GetProjectConfigParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnvironmentCanonical adds the environmentCanonical to the get project config params +func (o *GetProjectConfigParams) WithEnvironmentCanonical(environmentCanonical string) *GetProjectConfigParams { + o.SetEnvironmentCanonical(environmentCanonical) + return o +} + +// SetEnvironmentCanonical adds the environmentCanonical to the get project config params +func (o *GetProjectConfigParams) SetEnvironmentCanonical(environmentCanonical string) { + o.EnvironmentCanonical = environmentCanonical +} + +// WithOrganizationCanonical adds the organizationCanonical to the get project config params +func (o *GetProjectConfigParams) WithOrganizationCanonical(organizationCanonical string) *GetProjectConfigParams { + o.SetOrganizationCanonical(organizationCanonical) + return o +} + +// SetOrganizationCanonical adds the organizationCanonical to the get project config params +func (o *GetProjectConfigParams) SetOrganizationCanonical(organizationCanonical string) { + o.OrganizationCanonical = organizationCanonical +} + +// WithProjectCanonical adds the projectCanonical to the get project config params +func (o *GetProjectConfigParams) WithProjectCanonical(projectCanonical string) *GetProjectConfigParams { + o.SetProjectCanonical(projectCanonical) + return o +} + +// SetProjectCanonical adds the projectCanonical to the get project config params +func (o *GetProjectConfigParams) SetProjectCanonical(projectCanonical string) { + o.ProjectCanonical = projectCanonical +} + +// WriteToRequest writes these params to a swagger request +func (o *GetProjectConfigParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param environment_canonical + if err := r.SetPathParam("environment_canonical", o.EnvironmentCanonical); err != nil { + return err + } + + // path param organization_canonical + if err := r.SetPathParam("organization_canonical", o.OrganizationCanonical); err != nil { + return err + } + + // path param project_canonical + if err := r.SetPathParam("project_canonical", o.ProjectCanonical); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/client/organization_projects/get_project_config_responses.go b/client/client/organization_projects/get_project_config_responses.go new file mode 100644 index 00000000..f5b67398 --- /dev/null +++ b/client/client/organization_projects/get_project_config_responses.go @@ -0,0 +1,351 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package organization_projects + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/cycloidio/cycloid-cli/client/models" +) + +// GetProjectConfigReader is a Reader for the GetProjectConfig structure. +type GetProjectConfigReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetProjectConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetProjectConfigOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 403: + result := NewGetProjectConfigForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetProjectConfigNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewGetProjectConfigUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + result := NewGetProjectConfigDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetProjectConfigOK creates a GetProjectConfigOK with default headers values +func NewGetProjectConfigOK() *GetProjectConfigOK { + return &GetProjectConfigOK{} +} + +/*GetProjectConfigOK handles this case with default header values. + +Set of config to create the project / push onto repositories +*/ +type GetProjectConfigOK struct { + /*The length of the response body in octets (8-bit bytes). + */ + ContentLength uint64 + + Payload *GetProjectConfigOKBody +} + +func (o *GetProjectConfigOK) Error() string { + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigOK %+v", 200, o.Payload) +} + +func (o *GetProjectConfigOK) GetPayload() *GetProjectConfigOKBody { + return o.Payload +} + +func (o *GetProjectConfigOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header Content-Length + contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + } + o.ContentLength = contentLength + + o.Payload = new(GetProjectConfigOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetProjectConfigForbidden creates a GetProjectConfigForbidden with default headers values +func NewGetProjectConfigForbidden() *GetProjectConfigForbidden { + return &GetProjectConfigForbidden{} +} + +/*GetProjectConfigForbidden handles this case with default header values. + +The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. +*/ +type GetProjectConfigForbidden struct { + /*The length of the response body in octets (8-bit bytes). + */ + ContentLength uint64 + + Payload *models.ErrorPayload +} + +func (o *GetProjectConfigForbidden) Error() string { + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigForbidden %+v", 403, o.Payload) +} + +func (o *GetProjectConfigForbidden) GetPayload() *models.ErrorPayload { + return o.Payload +} + +func (o *GetProjectConfigForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header Content-Length + contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + } + o.ContentLength = contentLength + + o.Payload = new(models.ErrorPayload) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetProjectConfigNotFound creates a GetProjectConfigNotFound with default headers values +func NewGetProjectConfigNotFound() *GetProjectConfigNotFound { + return &GetProjectConfigNotFound{} +} + +/*GetProjectConfigNotFound handles this case with default header values. + +The response sent when any of the entities present in the path is not found. +*/ +type GetProjectConfigNotFound struct { + /*The length of the response body in octets (8-bit bytes). + */ + ContentLength uint64 + + Payload *models.ErrorPayload +} + +func (o *GetProjectConfigNotFound) Error() string { + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigNotFound %+v", 404, o.Payload) +} + +func (o *GetProjectConfigNotFound) GetPayload() *models.ErrorPayload { + return o.Payload +} + +func (o *GetProjectConfigNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header Content-Length + contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + } + o.ContentLength = contentLength + + o.Payload = new(models.ErrorPayload) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetProjectConfigUnprocessableEntity creates a GetProjectConfigUnprocessableEntity with default headers values +func NewGetProjectConfigUnprocessableEntity() *GetProjectConfigUnprocessableEntity { + return &GetProjectConfigUnprocessableEntity{} +} + +/*GetProjectConfigUnprocessableEntity handles this case with default header values. + +All the custom errors that are generated from the Cycloid API +*/ +type GetProjectConfigUnprocessableEntity struct { + /*The length of the response body in octets (8-bit bytes). + */ + ContentLength uint64 + + Payload *models.ErrorPayload +} + +func (o *GetProjectConfigUnprocessableEntity) Error() string { + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *GetProjectConfigUnprocessableEntity) GetPayload() *models.ErrorPayload { + return o.Payload +} + +func (o *GetProjectConfigUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header Content-Length + contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + } + o.ContentLength = contentLength + + o.Payload = new(models.ErrorPayload) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetProjectConfigDefault creates a GetProjectConfigDefault with default headers values +func NewGetProjectConfigDefault(code int) *GetProjectConfigDefault { + return &GetProjectConfigDefault{ + _statusCode: code, + } +} + +/*GetProjectConfigDefault handles this case with default header values. + +The response sent when an unexpected error happened, as known as an internal server error. +*/ +type GetProjectConfigDefault struct { + _statusCode int + + /*The length of the response body in octets (8-bit bytes). + */ + ContentLength uint64 + + Payload *models.ErrorPayload +} + +// Code gets the status code for the get project config default response +func (o *GetProjectConfigDefault) Code() int { + return o._statusCode +} + +func (o *GetProjectConfigDefault) Error() string { + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfig default %+v", o._statusCode, o.Payload) +} + +func (o *GetProjectConfigDefault) GetPayload() *models.ErrorPayload { + return o.Payload +} + +func (o *GetProjectConfigDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header Content-Length + contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + } + o.ContentLength = contentLength + + o.Payload = new(models.ErrorPayload) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*GetProjectConfigOKBody get project config o k body +swagger:model GetProjectConfigOKBody +*/ +type GetProjectConfigOKBody struct { + + // data + Data *models.ProjectEnvironmentConfig `json:"data,omitempty"` +} + +// Validate validates this get project config o k body +func (o *GetProjectConfigOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateData(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetProjectConfigOKBody) validateData(formats strfmt.Registry) error { + + if swag.IsZero(o.Data) { // not required + return nil + } + + if o.Data != nil { + if err := o.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getProjectConfigOK" + "." + "data") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *GetProjectConfigOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetProjectConfigOKBody) UnmarshalBinary(b []byte) error { + var res GetProjectConfigOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} From 185b772e71cdbc6d9f8bd7b65cb2312b88ecf640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 5 Jun 2024 18:13:36 +0200 Subject: [PATCH 24/98] func: add get-env-config from stackforms --- .../get-stackforms-config-from-env.go | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 cmd/cycloid/projects/get-stackforms-config-from-env.go diff --git a/cmd/cycloid/projects/get-stackforms-config-from-env.go b/cmd/cycloid/projects/get-stackforms-config-from-env.go new file mode 100644 index 00000000..60ca08b4 --- /dev/null +++ b/cmd/cycloid/projects/get-stackforms-config-from-env.go @@ -0,0 +1,122 @@ +package projects + +import ( + "fmt" + + "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" + "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" + "github.com/cycloidio/cycloid-cli/cmd/cycloid/middleware" + "github.com/cycloidio/cycloid-cli/printer" + "github.com/cycloidio/cycloid-cli/printer/factory" + "github.com/pkg/errors" + "github.com/spf13/cobra" +) + +func NewGetStackformsConfigFromEnvCommand() *cobra.Command { + var cmd = &cobra.Command{ + Use: "get-env-config ", + Short: "Get the default stackforms config of a project's env", + Long: ` +This command will fetch the configuration of an environment in a project. + +Output is in JSON by default. + +The output object will be the same format required as input for 'cy project create-stackform-env' like the following: + +{ + "mySection": { + "myGroup1": { + "myVar1": "myValue" + } + } +} + +The values are generated as following: + +- First we get the current env value if exists (unless you set --default) +- I no current value is present, we get the default +- If no default is set, we set a zeroed value in the correct type: ("", 0, [], {}) +`, + Example: ` +# Get the configuration as json (default) +cy --org my-org project get-env-config -p my-project-canonical -e my-env-canonical + +# Get the configuration as yaml +cy --org my-org project get-env-config my-project my-project use_case -o yaml +`, + PreRunE: internal.CheckAPIAndCLIVersion, + RunE: getStackFormsConfigFromEnv, + Args: cobra.RangeArgs(0, 2), + } + + common.WithFlagOrg(cmd) + cmd.Flags().StringP("project", "p", "", "specify the project") + cmd.Flags().StringP("env", "e", "", "specify the env") + cmd.Flags().BoolP("default-values", "d", false, "if set, will fetch the default value from the stack instead of the current ones.") + + // This will display flag in the order declared above + cmd.Flags().SortFlags = false + + return cmd +} + +func getStackFormsConfigFromEnv(cmd *cobra.Command, args []string) error { + // Flags have precedence over args + project, err := cmd.Flags().GetString("project") + if len(args) >= 1 && project == "" { + project = args[0] + } else if project == "" { + return fmt.Errorf("missing project argument") + } + + env, err := cmd.Flags().GetString("env") + if len(args) == 2 && env == "" { + env = args[1] + } else if env == "" { + return fmt.Errorf("missing use case argument") + } + + getDefault, err := cmd.Flags().GetBool("default-values") + if err != nil { + return err + } + + internal.Debug("project:", project, "| env:", env) + + api := common.NewAPI() + m := middleware.NewMiddleware(api) + + org, err := cmd.Flags().GetString("org") + if err != nil { + return err + } + + output, err := cmd.Flags().GetString("output") + if err != nil { + return errors.Wrap(err, "unable to get output flag") + } + + // output as yaml by default + if output == "table" { + output = "json" + } + + // fetch the printer from the factory + p, err := factory.GetPrinter(output) + if err != nil { + return errors.Wrap(err, "unable to get printer") + } + + resp, err := m.GetProjectConfig(org, project, env) + if err != nil || resp == nil { + return printer.SmartPrint(p, nil, err, fmt.Sprint("failed to fetch project '", project, "' config for env '", env, "' in org '", org, "'"), printer.Options{}, cmd.OutOrStderr()) + } + + formData, err := common.ParseFormsConfig(resp, *resp.UseCase, !getDefault) + if err != nil { + fmt.Println("failed to parse config data") + return printer.SmartPrint(p, nil, err, "failed to get stack config", printer.Options{}, cmd.OutOrStdout()) + } + + return printer.SmartPrint(p, formData, err, "failed to get stack config", printer.Options{}, cmd.OutOrStdout()) +} From ff4d4fa9f9b498bad242a4b2662171fae06de228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 6 Jun 2024 15:33:54 +0200 Subject: [PATCH 25/98] misc: add nixos dev env shinanigan --- .envrc | 2 ++ .gitignore | 6 +++++- flake.lock | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 30 ++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..bbc2d75f --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +watch_file flake.nix +use flake . -Lv --log-format raw diff --git a/.gitignore b/.gitignore index 9c4b277c..a78a98aa 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,8 @@ pkged.go # Intellij .idea/ -gst \ No newline at end of file +gst + +# direnv +.direnv + diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..79a8d67f --- /dev/null +++ b/flake.lock @@ -0,0 +1,57 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1696748673, + "narHash": "sha256-UbPHrH4dKN/66EpfFpoG4St4XZYDX9YcMVRQGWzAUNA=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..2ddc8f62 --- /dev/null +++ b/flake.nix @@ -0,0 +1,30 @@ +{ + description = "A basic dev shell for nix users"; + + inputs = { + nixpkgs = { url = "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz"; }; + flake-utils = { url = "github:numtide/flake-utils"; }; + }; + + outputs = inputs@{ self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + lib = pkgs.lib; + swaggerPython = (pkgs.python312.withPackages (p: with p; [ + pyyaml + ])); + in + { + devShells.default = pkgs.mkShell { + buildInputs = [ swaggerPython ] + ++ (with pkgs; [ + # You packages here + gnumake + + # Prod is built using go 1.18 rn + go_1_18 + ]); + }; + }); +} From e4f943e07d893950b77ced19e3c1849dce42d276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 6 Jun 2024 17:31:10 +0200 Subject: [PATCH 26/98] misc: remove dev stuff --- test.sh | 70 --------------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 test.sh diff --git a/test.sh b/test.sh deleted file mode 100644 index 8b9f05c8..00000000 --- a/test.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -org=cycloid-sandbox - - -echo -e ' -{ - "Cloud provider": { - "Terraform": { - "gcp_credentials_json": "((gcp.json_key))", - "gcp_project": "($ .organization_canonical $)", - "gcp_region": "europe-west1", - "gcp_zone": "europe-west1-b", - "terraform_storage_bucket_name": "($ .organization_canonical $)-terraform-remote-state" - } - }, - "Instance": { - "Boot-disk": { - "module.vm.boot_disk_auto_delete": true, - "module.vm.boot_disk_device_name": "", - "module.vm.boot_disk_image": "debian-cloud/debian-12", - "module.vm.boot_disk_size": 5, - "module.vm.boot_disk_type": "pd-standard" - }, - "Details": { - "module.vm.allow_stopping_for_update": true, - "module.vm.file_content": "", - "module.vm.instance_name": "${var.customer}-${var.project}-${var.env}-vm", - "module.vm.instance_tags": [ - "${var.customer}-${var.project}-${var.env}-network-tag" - ], - "module.vm.machine_type": "e2-small" - }, - "Firewall-egress": { - "module.vm.egress_allow_protocol": "", - "module.vm.egress_disabled": true, - "module.vm.egress_firewall_name": "" - }, - "Firewall-ingress": { - "module.vm.ingress_allow_ports": [ - "22" - ], - "module.vm.ingress_allow_protocol": "tcp", - "module.vm.ingress_disabled": false, - "module.vm.ingress_firewall_name": "${var.customer}-${var.project}-${var.env}-ingress" - }, - "Network": { - "module.vm.network": "qscqsc", - "module.vm.network_ip": "" - } - } -} -' | go run . projects create-stackforms-env \ - --verbosity debug \ - --org $org \ - --project "test-env" \ - --env "test2" \ - --use-case "gcp-gce" \ - --var-file '-' - - -# export CY_CREATE_ENV_VARS='{"viaEnv": "ok", "file4": "overriden", "subMap": {"two": 2}}' -# echo -e '{\n"file1": "titi",\n"toto": "toto"\n}{"file4": 3, "subMap": {"one": 1}}' | go run . projects create-stackforms-env \ -# --verbosity debug \ -# --org $org \ -# --project "test-env" \ -# --env "test" \ -# --vars '{"toto": "vars1"}' \ -# --var-file '-' \ -# --var-file <(echo '{"file2": "tata"}') From 1a1fbf4e7bcadc4dd78337555d64e1e86949ee47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 6 Jun 2024 17:31:19 +0200 Subject: [PATCH 27/98] func: add mergo dependency for recursive map merges --- go.mod | 5 ++--- go.sum | 11 ----------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 39f0dbf4..83b4de96 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,9 @@ module github.com/cycloidio/cycloid-cli -go 1.22 +go 1.18 require ( + dario.cat/mergo v1.0.0 github.com/adrg/xdg v0.4.0 github.com/go-openapi/errors v0.22.0 github.com/go-openapi/runtime v0.28.0 @@ -18,7 +19,6 @@ require ( ) require ( - dario.cat/mergo v1.0.0 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect @@ -41,7 +41,6 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sanity-io/litter v1.5.5 // indirect github.com/spf13/afero v1.6.0 // indirect github.com/spf13/cast v1.4.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect diff --git a/go.sum b/go.sum index 436ce22c..938c7c52 100644 --- a/go.sum +++ b/go.sum @@ -94,7 +94,6 @@ github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWH github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -198,7 +197,6 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -280,11 +278,9 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= @@ -336,7 +332,6 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -356,12 +351,9 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= -github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= -github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -382,7 +374,6 @@ github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -416,7 +407,6 @@ go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -829,7 +819,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= From 0e14edb538eb80b815954c375943cabe1caf0b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Mon, 10 Jun 2024 17:16:26 +0200 Subject: [PATCH 28/98] fix: regenerate client with new go version --- client/client/api_client_client.go | 264 --------- .../cost_estimate_forms_parameters.go | 64 +- .../cost_estimate_forms_responses.go | 241 ++++++-- .../cost_estimate_tf_plan_parameters.go | 57 +- .../cost_estimate_tf_plan_responses.go | 264 +++++++-- .../cost_estimation/cost_estimation_client.go | 116 +++- client/client/cycloid/cycloid_client.go | 158 ++++- .../cycloid/get_app_version_parameters.go | 47 +- .../cycloid/get_app_version_responses.go | 202 ++++++- .../client/cycloid/get_config_parameters.go | 47 +- client/client/cycloid/get_config_responses.go | 202 ++++++- .../cycloid/get_countries_parameters.go | 47 +- .../client/cycloid/get_countries_responses.go | 148 ++++- .../cycloid/get_service_status_parameters.go | 51 +- .../cycloid/get_service_status_responses.go | 149 ++++- .../client/cycloid/get_status_parameters.go | 47 +- client/client/cycloid/get_status_responses.go | 202 ++++++- .../create_api_key_parameters.go | 59 +- .../create_api_key_responses.go | 303 ++++++++-- .../delete_api_key_parameters.go | 56 +- .../delete_api_key_responses.go | 225 ++++++- .../get_api_key_parameters.go | 56 +- .../get_api_key_responses.go | 264 +++++++-- .../get_api_keys_parameters.go | 117 ++-- .../get_api_keys_responses.go | 357 +++++++++-- .../organization_api_keys_client.go | 158 ++++- .../update_a_p_ikey_parameters.go | 64 +- .../update_a_p_ikey_responses.go | 365 ++++++++++-- .../create_child_parameters.go | 59 +- .../create_child_responses.go | 87 ++- .../get_children_parameters.go | 133 +++-- .../get_children_responses.go | 357 +++++++++-- .../organization_children_client.go | 116 +++- ...ate_config_repository_config_parameters.go | 64 +- ...eate_config_repository_config_responses.go | 326 ++++++++-- .../create_config_repository_parameters.go | 59 +- .../create_config_repository_responses.go | 303 ++++++++-- .../delete_config_repository_parameters.go | 56 +- .../delete_config_repository_responses.go | 101 +++- .../get_config_repository_parameters.go | 112 ++-- .../get_config_repository_responses.go | 264 +++++++-- .../list_config_repositories_parameters.go | 126 ++-- .../list_config_repositories_responses.go | 272 +++++++-- ...organization_config_repositories_client.go | 172 +++++- .../update_config_repository_parameters.go | 64 +- .../update_config_repository_responses.go | 241 +++++++- .../create_credential_parameters.go | 59 +- .../create_credential_responses.go | 241 +++++++- .../delete_credential_parameters.go | 56 +- .../delete_credential_responses.go | 264 +++++++-- .../get_credential_options_parameters.go | 60 +- .../get_credential_options_responses.go | 241 ++++++-- .../get_credential_parameters.go | 56 +- .../get_credential_responses.go | 264 +++++++-- .../list_credentials_parameters.go | 152 +++-- .../list_credentials_responses.go | 295 ++++++++-- .../organization_credentials_client.go | 178 +++++- .../update_credential_parameters.go | 64 +- .../update_credential_responses.go | 365 ++++++++++-- .../create_external_backend_parameters.go | 143 +++-- .../create_external_backend_responses.go | 87 ++- .../delete_external_backend_parameters.go | 58 +- .../delete_external_backend_responses.go | 287 +++++++-- .../get_external_backend_parameters.go | 58 +- .../get_external_backend_responses.go | 264 +++++++-- .../get_external_backends_parameters.go | 135 +++-- .../get_external_backends_responses.go | 300 ++++++++-- .../organization_external_backends_client.go | 158 ++++- .../update_external_backend_parameters.go | 66 ++- .../update_external_backend_responses.go | 303 ++++++++-- .../create_forms_config_parameters.go | 64 +- .../create_forms_config_responses.go | 303 ++++++++-- .../organization_forms_client.go | 130 +++- .../validate_forms_file_parameters.go | 59 +- .../validate_forms_file_responses.go | 326 ++++++++-- .../values_ref_forms_parameters.go | 59 +- .../values_ref_forms_responses.go | 303 ++++++++-- .../create_infra_policy_parameters.go | 57 +- .../create_infra_policy_responses.go | 241 +++++++- .../delete_infra_policy_parameters.go | 56 +- .../delete_infra_policy_responses.go | 225 ++++++- .../get_infra_policies_parameters.go | 157 +++-- .../get_infra_policies_responses.go | 362 ++++++++++-- .../get_infra_policy_parameters.go | 56 +- .../get_infra_policy_responses.go | 264 +++++++-- ...nization_infrastructure_policies_client.go | 172 +++++- .../update_infra_policy_parameters.go | 64 +- .../update_infra_policy_responses.go | 326 ++++++++-- ...idate_project_infra_policies_parameters.go | 69 ++- ...lidate_project_infra_policies_responses.go | 331 +++++++++-- .../delete_invitation_parameters.go | 58 +- .../delete_invitation_responses.go | 225 ++++++- .../get_invitations_parameters.go | 133 +++-- .../get_invitations_responses.go | 357 +++++++++-- .../get_pending_invitation_parameters.go | 51 +- .../get_pending_invitation_responses.go | 202 ++++++- .../organization_invitations_client.go | 144 ++++- .../resend_invitation_parameters.go | 58 +- .../resend_invitation_responses.go | 225 ++++++- .../create_k_p_i_favorite_parameters.go | 56 +- .../create_k_p_i_favorite_responses.go | 287 +++++++-- .../create_kpi_parameters.go | 227 ++++--- .../organization_kpis/create_kpi_responses.go | 264 +++++++-- .../delete_k_p_i_favorite_parameters.go | 56 +- .../delete_k_p_i_favorite_responses.go | 225 ++++++- .../delete_kpi_parameters.go | 84 ++- .../organization_kpis/delete_kpi_responses.go | 225 ++++++- .../organization_kpis/get_kpi_parameters.go | 84 ++- .../organization_kpis/get_kpi_responses.go | 264 +++++++-- .../organization_kpis/get_kpis_parameters.go | 219 ++++--- .../organization_kpis/get_kpis_responses.go | 300 ++++++++-- .../organization_kpis_client.go | 186 +++++- .../update_kpi_parameters.go | 92 +-- .../organization_kpis/update_kpi_responses.go | 365 ++++++++++-- .../get_org_member_parameters.go | 56 +- .../get_org_member_responses.go | 264 +++++++-- .../get_org_members_parameters.go | 167 ++++-- .../get_org_members_responses.go | 357 +++++++++-- .../invite_user_to_org_member_parameters.go | 59 +- .../invite_user_to_org_member_responses.go | 264 +++++++-- .../organization_members_client.go | 158 ++++- .../remove_org_member_parameters.go | 56 +- .../remove_org_member_responses.go | 225 ++++++- .../update_org_member_parameters.go | 64 +- .../update_org_member_responses.go | 326 ++++++++-- .../create_pipeline_parameters.go | 64 +- .../create_pipeline_responses.go | 365 ++++++++++-- .../delete_pipeline_parameters.go | 61 +- .../delete_pipeline_responses.go | 225 ++++++- .../diff_pipeline_parameters.go | 64 +- .../diff_pipeline_responses.go | 365 ++++++++++-- .../get_pipeline_config_parameters.go | 61 +- .../get_pipeline_config_responses.go | 236 ++++++-- .../get_pipeline_parameters.go | 61 +- .../get_pipeline_responses.go | 264 +++++++-- .../get_pipeline_variables_parameters.go | 61 +- .../get_pipeline_variables_responses.go | 303 ++++++++-- .../get_pipelines_parameters.go | 210 ++++--- .../get_pipelines_responses.go | 295 ++++++++-- .../get_project_pipelines_parameters.go | 112 ++-- .../get_project_pipelines_responses.go | 295 ++++++++-- .../organization_pipelines_client.go | 270 +++++++-- .../pause_pipeline_parameters.go | 61 +- .../pause_pipeline_responses.go | 225 ++++++- .../rename_pipeline_parameters.go | 67 ++- .../rename_pipeline_responses.go | 225 ++++++- .../synced_pipeline_parameters.go | 56 +- .../synced_pipeline_responses.go | 365 ++++++++++-- .../unpause_pipeline_parameters.go | 61 +- .../unpause_pipeline_responses.go | 225 ++++++- .../update_pipeline_parameters.go | 69 ++- .../update_pipeline_responses.go | 365 ++++++++++-- .../clear_task_cache_parameters.go | 102 ++-- .../clear_task_cache_responses.go | 264 +++++++-- .../get_job_parameters.go | 66 ++- .../get_job_responses.go | 264 +++++++-- .../get_jobs_parameters.go | 117 ++-- .../get_jobs_responses.go | 357 +++++++++-- .../organization_pipelines_jobs_client.go | 158 ++++- .../pause_job_parameters.go | 66 ++- .../pause_job_responses.go | 225 ++++++- .../unpause_job_parameters.go | 66 ++- .../unpause_job_responses.go | 225 ++++++- .../abort_build_parameters.go | 71 ++- .../abort_build_responses.go | 225 ++++++- .../create_build_parameters.go | 66 ++- .../create_build_responses.go | 264 +++++++-- .../get_build_parameters.go | 71 ++- .../get_build_plan_parameters.go | 71 ++- .../get_build_plan_responses.go | 264 +++++++-- .../get_build_preparation_parameters.go | 71 ++- .../get_build_preparation_responses.go | 264 +++++++-- .../get_build_resources_parameters.go | 127 ++-- .../get_build_resources_responses.go | 264 +++++++-- .../get_build_responses.go | 264 +++++++-- .../get_builds_parameters.go | 144 +++-- .../get_builds_responses.go | 357 +++++++++-- ...rganization_pipelines_jobs_build_client.go | 200 +++++-- .../rerun_build_parameters.go | 71 ++- .../rerun_build_responses.go | 264 +++++++-- .../create_project_favorite_parameters.go | 56 +- .../create_project_favorite_responses.go | 287 +++++++-- .../create_project_parameters.go | 61 +- .../create_project_responses.go | 303 ++++++++-- .../delete_project_environment_parameters.go | 61 +- .../delete_project_environment_responses.go | 225 ++++++- .../delete_project_favorite_parameters.go | 56 +- .../delete_project_favorite_responses.go | 225 ++++++- .../delete_project_parameters.go | 56 +- .../delete_project_responses.go | 225 ++++++- .../get_project_config_parameters.go | 61 +- .../get_project_config_responses.go | 352 +++++++++-- .../get_project_parameters.go | 56 +- .../get_project_responses.go | 264 +++++++-- .../get_projects_parameters.go | 205 ++++--- .../get_projects_responses.go | 357 +++++++++-- .../organization_projects_client.go | 214 +++++-- .../update_project_parameters.go | 64 +- .../update_project_responses.go | 365 ++++++++++-- .../create_role_parameters.go | 59 +- .../create_role_responses.go | 326 ++++++++-- .../delete_role_parameters.go | 56 +- .../delete_role_responses.go | 225 ++++++- .../organization_roles/get_role_parameters.go | 56 +- .../organization_roles/get_role_responses.go | 264 +++++++-- .../get_roles_parameters.go | 107 ++-- .../organization_roles/get_roles_responses.go | 295 ++++++++-- .../organization_roles_client.go | 158 ++++- .../update_role_parameters.go | 64 +- .../update_role_responses.go | 326 ++++++++-- ...reate_service_catalog_source_parameters.go | 59 +- ...create_service_catalog_source_responses.go | 303 ++++++++-- ...elete_service_catalog_source_parameters.go | 56 +- ...delete_service_catalog_source_responses.go | 101 +++- .../get_service_catalog_source_parameters.go | 112 ++-- .../get_service_catalog_source_responses.go | 264 +++++++-- .../get_service_catalog_sources_parameters.go | 107 ++-- .../get_service_catalog_sources_responses.go | 272 +++++++-- ...nization_service_catalog_sources_client.go | 186 +++++- ...fresh_service_catalog_source_parameters.go | 56 +- ...efresh_service_catalog_source_responses.go | 303 ++++++++-- ...pdate_service_catalog_source_parameters.go | 64 +- ...update_service_catalog_source_responses.go | 241 +++++++- ...idate_service_catalog_source_parameters.go | 56 +- ...lidate_service_catalog_source_responses.go | 326 ++++++++-- .../get_workers_parameters.go | 107 ++-- .../get_workers_responses.go | 295 ++++++++-- .../organization_workers_client.go | 102 +++- .../client/organizations/can_do_parameters.go | 59 +- .../client/organizations/can_do_responses.go | 326 ++++++++-- .../organizations/create_org_parameters.go | 54 +- .../organizations/create_org_responses.go | 241 +++++++- .../organizations/delete_org_parameters.go | 51 +- .../organizations/delete_org_responses.go | 225 ++++++- .../organizations/get_ancestors_parameters.go | 51 +- .../organizations/get_ancestors_responses.go | 233 +++++++- .../organizations/get_events_parameters.go | 141 +++-- .../organizations/get_events_responses.go | 334 +++++++++-- .../get_events_tags_parameters.go | 51 +- .../get_events_tags_responses.go | 241 ++++++-- .../organizations/get_org_parameters.go | 51 +- .../client/organizations/get_org_responses.go | 264 +++++++-- .../organizations/get_orgs_parameters.go | 128 ++-- .../organizations/get_orgs_responses.go | 233 +++++++- .../get_repo_branches_parameters.go | 65 +- .../get_repo_branches_responses.go | 298 ++++++++-- .../organizations/get_summary_parameters.go | 51 +- .../organizations/get_summary_responses.go | 211 ++++++- .../organizations/organizations_client.go | 266 +++++++-- .../organizations/send_event_parameters.go | 59 +- .../organizations/send_event_responses.go | 273 +++++++-- .../organizations/update_org_parameters.go | 59 +- .../organizations/update_org_responses.go | 365 ++++++++++-- ...ervice_catalog_from_template_parameters.go | 64 +- ...service_catalog_from_template_responses.go | 326 ++++++++-- .../create_service_catalog_parameters.go | 59 +- .../create_service_catalog_responses.go | 326 ++++++++-- .../delete_service_catalog_parameters.go | 56 +- .../delete_service_catalog_responses.go | 211 ++++++- .../get_service_catalog_config_parameters.go | 140 +++-- .../get_service_catalog_config_responses.go | 241 ++++++-- .../get_service_catalog_parameters.go | 56 +- .../get_service_catalog_responses.go | 264 +++++++-- ...ce_catalog_terraform_diagram_parameters.go | 56 +- ...ice_catalog_terraform_diagram_responses.go | 246 ++++++-- ...vice_catalog_terraform_image_parameters.go | 56 +- ...rvice_catalog_terraform_image_responses.go | 264 +++++++-- ...et_service_catalog_terraform_parameters.go | 61 +- ...get_service_catalog_terraform_responses.go | 264 +++++++-- .../list_service_catalogs_parameters.go | 152 +++-- .../list_service_catalogs_responses.go | 233 +++++++- .../service_catalogs_client.go | 285 +++++++-- .../update_service_catalog_parameters.go | 64 +- .../update_service_catalog_responses.go | 326 ++++++++-- ...ce_catalog_terraform_diagram_parameters.go | 64 +- ...ice_catalog_terraform_diagram_responses.go | 287 +++++++-- ...vice_catalog_terraform_image_parameters.go | 64 +- ...rvice_catalog_terraform_image_responses.go | 225 ++++++- ...te_service_catalog_terraform_parameters.go | 69 ++- ...ate_service_catalog_terraform_responses.go | 287 +++++++-- ...service_catalog_dependencies_parameters.go | 56 +- ..._service_catalog_dependencies_responses.go | 264 +++++++-- .../user/create_o_auth_user_parameters.go | 59 +- .../user/create_o_auth_user_responses.go | 202 ++++++- .../user/delete_user_account_parameters.go | 47 +- .../user/delete_user_account_responses.go | 163 ++++- ..._authentication_verification_parameters.go | 51 +- ...l_authentication_verification_responses.go | 264 +++++++-- .../user/email_verification_parameters.go | 51 +- .../email_verification_resend_parameters.go | 54 +- .../email_verification_resend_responses.go | 163 ++++- .../user/email_verification_responses.go | 225 ++++++- .../client/user/get_o_auth_user_parameters.go | 57 +- .../client/user/get_o_auth_user_responses.go | 202 ++++++- .../user/get_user_account_parameters.go | 47 +- .../client/user/get_user_account_responses.go | 140 ++++- ...marketplace_user_entitlement_parameters.go | 47 +- ..._marketplace_user_entitlement_responses.go | 109 +++- client/client/user/login_parameters.go | 54 +- client/client/user/login_responses.go | 264 +++++++-- .../user/password_reset_req_parameters.go | 54 +- .../user/password_reset_req_responses.go | 163 ++++- .../user/password_reset_update_parameters.go | 54 +- .../user/password_reset_update_responses.go | 225 ++++++- .../client/user/refresh_token_parameters.go | 62 +- client/client/user/refresh_token_responses.go | 202 ++++++- .../sign_up_a_w_s_marketplace_parameters.go | 54 +- .../sign_up_a_w_s_marketplace_responses.go | 202 ++++++- client/client/user/sign_up_parameters.go | 54 +- client/client/user/sign_up_responses.go | 202 ++++++- .../user/update_user_account_parameters.go | 54 +- .../user/update_user_account_responses.go | 342 +++++++++-- .../user/update_user_guide_parameters.go | 54 +- .../user/update_user_guide_responses.go | 225 ++++++- client/client/user/user_client.go | 316 +++++++--- client/models/a_w_s_cloud_watch_logs.go | 23 +- .../a_w_s_infrastructure_resource_bucket.go | 1 + ..._s_infrastructure_resource_d_b_instance.go | 1 + ...astructure_resource_elasticache_cluster.go | 1 + .../a_w_s_infrastructure_resource_image.go | 1 + .../a_w_s_infrastructure_resource_instance.go | 1 + ...nfrastructure_resource_load_balancer_v1.go | 1 + ...nfrastructure_resource_load_balancer_v2.go | 1 + ..._infrastructure_resource_security_group.go | 1 + .../a_w_s_infrastructure_resource_snapshot.go | 1 + .../a_w_s_infrastructure_resource_subnet.go | 1 + .../a_w_s_infrastructure_resource_v_p_c.go | 1 + .../a_w_s_infrastructure_resource_volume.go | 1 + ..._s_infrastructure_resources_aggregation.go | 556 +++++++++++++++++- client/models/a_w_s_remote_t_f_state.go | 38 +- client/models/a_w_s_storage.go | 38 +- client/models/api_key.go | 84 ++- client/models/app_config.go | 37 +- client/models/app_version.go | 17 +- client/models/appearance.go | 85 ++- client/models/auth_config.go | 103 +++- client/models/auth_config_local_auth.go | 9 +- client/models/auth_config_o_auth.go | 23 +- client/models/auth_config_s_a_m_l.go | 9 +- client/models/azure_a_d_auth_config.go | 26 +- client/models/azure_cost_export.go | 29 +- client/models/azure_remote_t_f_state.go | 29 +- client/models/azure_storage.go | 29 +- client/models/build.go | 9 +- client/models/build_inputs_outputs.go | 77 ++- client/models/build_summary.go | 9 +- client/models/c_i_version.go | 12 +- client/models/can_do_input.go | 9 +- client/models/can_do_output.go | 9 +- client/models/check_report.go | 20 +- client/models/clear_task_cache.go | 9 +- .../models/cloud_cost_management_account.go | 123 +++- .../cloud_cost_management_account_parent.go | 59 +- client/models/cloud_cost_management_bucket.go | 46 +- .../models/cloud_cost_management_dashboard.go | 128 +++- .../cloud_cost_management_filter_values.go | 8 +- .../models/cloud_cost_management_histogram.go | 46 +- .../cloud_cost_management_linked_account.go | 10 +- ...t_management_project_provider_resources.go | 10 +- ...cloud_cost_management_project_resources.go | 45 +- ...loud_cost_management_projects_dashboard.go | 59 +- .../cloud_cost_management_provider_details.go | 66 ++- .../models/cloud_cost_management_providers.go | 38 +- .../cloud_cost_management_tag_mapping.go | 14 +- client/models/cloud_provider.go | 38 +- .../cloud_provider_a_w_s_configuration.go | 23 +- .../cloud_provider_azure_configuration.go | 26 +- client/models/cloud_provider_configuration.go | 24 +- .../cloud_provider_g_c_p_configuration.go | 26 +- ...provider_vm_ware_v_sphere_configuration.go | 26 +- client/models/config_file.go | 13 +- client/models/config_repository.go | 32 +- client/models/cost_estimation_component.go | 70 ++- .../models/cost_estimation_component_state.go | 9 +- .../cost_estimation_resource_estimate.go | 47 +- client/models/cost_estimation_result.go | 46 +- client/models/cost_group.go | 21 +- client/models/cost_group_definitions.go | 21 +- client/models/cost_result_by_time.go | 81 ++- client/models/cost_time_period.go | 21 +- client/models/country.go | 13 +- client/models/credential.go | 114 +++- client/models/credential_in_use.go | 110 +++- client/models/credential_raw.go | 17 +- client/models/credential_simple.go | 91 ++- client/models/elasticsearch_logs.go | 117 +++- client/models/ensure_plan.go | 60 +- client/models/environment.go | 67 ++- client/models/error_details_item.go | 9 +- client/models/error_payload.go | 45 +- client/models/event.go | 68 ++- client/models/external_backend.go | 71 ++- .../models/external_backend_configuration.go | 35 +- client/models/filters.go | 3 +- client/models/form_entity.go | 20 +- client/models/form_group.go | 46 +- client/models/form_input.go | 12 +- client/models/form_inputs.go | 45 +- client/models/form_section.go | 46 +- client/models/form_use_case.go | 46 +- client/models/forms_file_v2.go | 46 +- client/models/forms_validation.go | 16 +- client/models/forms_validation_result.go | 39 +- client/models/forms_values_ref.go | 11 +- client/models/g_c_p_cost_storage.go | 29 +- client/models/g_c_p_remote_t_f_state.go | 26 +- client/models/g_c_p_storage.go | 26 +- client/models/general_status.go | 52 +- client/models/get_plan.go | 55 +- client/models/git_hub_o_auth_config.go | 24 +- client/models/git_lab_http_storage.go | 23 +- client/models/google_o_auth_config.go | 24 +- client/models/group_config.go | 11 +- client/models/http_storage.go | 23 +- client/models/in_use_config_repository.go | 17 +- client/models/in_use_environment.go | 17 +- client/models/in_use_external_backend.go | 72 ++- client/models/in_use_project.go | 17 +- .../models/in_use_service_catalog_source.go | 17 +- client/models/infra_import.go | 20 +- client/models/infra_import_preset.go | 8 +- client/models/infra_import_resource.go | 8 +- client/models/infra_import_resource_body.go | 49 +- client/models/infra_import_resources_body.go | 49 +- .../infra_policies_validation_result.go | 111 +++- .../infra_policies_validation_result_item.go | 36 +- client/models/infra_policy.go | 57 +- client/models/infrastructure.go | 43 +- client/models/infrastructure_config.go | 3 +- client/models/infrastructure_graph.go | 79 ++- client/models/infrastructure_graph_edge.go | 11 +- client/models/infrastructure_graph_node.go | 39 +- ...frastructure_resources_aggregation_item.go | 9 +- client/models/inventory_resource.go | 30 +- client/models/inventory_resource_label.go | 17 +- client/models/invitation.go | 105 +++- client/models/job.go | 163 ++++- client/models/job_input.go | 42 +- client/models/job_output.go | 9 +- client/models/k_p_i.go | 52 +- client/models/licence.go | 21 +- client/models/log_source.go | 11 +- client/models/log_source_entry.go | 13 +- client/models/member_assignation.go | 15 +- client/models/member_org.go | 94 ++- client/models/member_team.go | 63 +- client/models/metadata_field.go | 11 +- .../new_a_w_s_marketplace_user_account.go | 32 +- client/models/new_api_key.go | 55 +- client/models/new_appearance.go | 73 ++- .../new_cloud_cost_management_account.go | 43 +- ...new_cloud_cost_management_account_child.go | 15 +- client/models/new_config_repository.go | 24 +- client/models/new_credential.go | 53 +- client/models/new_environment.go | 30 +- client/models/new_event.go | 68 ++- client/models/new_external_backend.go | 66 ++- client/models/new_infra_import.go | 156 ++++- .../new_infra_import_external_backend.go | 48 +- client/models/new_infra_import_project.go | 24 +- client/models/new_infra_policy.go | 29 +- client/models/new_inventory_resource.go | 22 +- client/models/new_k_p_i.go | 43 +- client/models/new_licence.go | 11 +- client/models/new_member_invitation.go | 15 +- client/models/new_o_auth_user.go | 30 +- client/models/new_organization.go | 18 +- client/models/new_pipeline.go | 50 +- client/models/new_project.go | 101 +++- client/models/new_quota.go | 29 +- client/models/new_resource_pool.go | 9 +- client/models/new_role.go | 57 +- client/models/new_rule.go | 14 +- client/models/new_service_catalog.go | 101 +++- .../new_service_catalog_from_template.go | 29 +- client/models/new_service_catalog_source.go | 25 +- client/models/new_subscription.go | 17 +- client/models/new_team.go | 25 +- client/models/new_team_member_assignation.go | 11 +- client/models/new_user_account.go | 33 +- client/models/on_failure_plan.go | 60 +- client/models/on_success_plan.go | 60 +- client/models/organization.go | 117 +++- client/models/page_concourse.go | 9 +- client/models/pagination.go | 15 +- client/models/pagination_a_w_s.go | 9 +- client/models/pagination_concourse.go | 60 +- client/models/pending_invite.go | 11 +- client/models/pin_comment.go | 11 +- client/models/pipeline.go | 133 ++++- client/models/pipeline_diff.go | 50 +- client/models/pipeline_diff_record.go | 11 +- client/models/pipeline_diffs.go | 145 ++++- client/models/pipeline_status.go | 47 +- client/models/pipeline_variables.go | 9 +- client/models/plan.go | 303 +++++++++- client/models/plan_config.go | 107 +++- client/models/policy.go | 23 +- client/models/preparation.go | 21 +- client/models/project.go | 156 ++++- client/models/project_environment_config.go | 36 +- .../models/project_environment_consumption.go | 70 ++- client/models/project_simple.go | 62 +- client/models/public_build_input.go | 15 +- client/models/public_build_output.go | 15 +- client/models/public_plan.go | 13 +- client/models/put_plan.go | 55 +- client/models/quota.go | 76 ++- client/models/resource.go | 42 +- client/models/resource_pool.go | 36 +- client/models/resource_version.go | 53 +- client/models/role.go | 64 +- client/models/rule.go | 18 +- client/models/s_c_config.go | 48 +- client/models/s_c_config_form_data.go | 45 +- client/models/s_c_config_path_config.go | 11 +- client/models/s_c_config_path_dest_config.go | 11 +- client/models/s_c_config_pipeline_config.go | 62 +- client/models/s_c_config_tech_config.go | 31 +- client/models/s_c_config_use_case_config.go | 129 +++- client/models/service_catalog.go | 108 +++- client/models/service_catalog_changes.go | 108 +++- client/models/service_catalog_config.go | 31 +- ..._catalog_dependencies_validation_result.go | 9 +- client/models/service_catalog_dependency.go | 11 +- client/models/service_catalog_source.go | 126 +++- client/models/service_catalog_technology.go | 11 +- client/models/simple_team.go | 56 +- client/models/state.go | 49 +- client/models/state_lock.go | 11 +- client/models/state_resource.go | 50 +- client/models/state_resource_instances.go | 11 +- client/models/subscription.go | 44 +- client/models/subscription_plan.go | 19 +- client/models/summary.go | 9 +- client/models/swift_remote_t_f_state.go | 32 +- client/models/swift_storage.go | 32 +- client/models/tag.go | 17 +- client/models/task_config.go | 75 ++- client/models/task_input_config.go | 9 +- client/models/task_plan.go | 75 ++- client/models/task_run_config.go | 12 +- client/models/team.go | 119 +++- client/models/terraform_h_c_l_config.go | 11 +- client/models/terraform_image.go | 11 +- client/models/terraform_json_config.go | 16 +- client/models/terraform_json_diagram.go | 3 +- client/models/terraform_plan_input.go | 9 +- client/models/terraform_provider.go | 19 +- client/models/terraform_provider_resource.go | 48 +- .../terraform_provider_resource_attributes.go | 11 +- .../terraform_provider_resource_simple.go | 44 +- client/models/terraform_provider_simple.go | 15 +- client/models/terraform_validation_result.go | 11 +- client/models/timeout_plan.go | 60 +- client/models/try_plan.go | 60 +- client/models/update_api_key.go | 10 +- .../update_cloud_cost_management_account.go | 37 +- ...te_cloud_cost_management_linked_account.go | 8 +- ...pdate_cloud_cost_management_tag_mapping.go | 11 +- client/models/update_config_repository.go | 17 +- client/models/update_credential.go | 52 +- client/models/update_external_backend.go | 69 ++- client/models/update_infra_policy.go | 18 +- client/models/update_organization.go | 11 +- client/models/update_pipeline.go | 9 +- client/models/update_project.go | 97 ++- client/models/update_quota.go | 17 +- .../models/update_service_catalog_source.go | 18 +- client/models/update_team.go | 24 +- client/models/update_user_account.go | 103 +++- client/models/update_user_account_email.go | 9 +- client/models/user.go | 35 +- client/models/user_account.go | 95 ++- client/models/user_account_email.go | 12 +- client/models/user_email.go | 11 +- client/models/user_guide.go | 3 +- client/models/user_login.go | 180 +++++- client/models/user_o_auth.go | 42 +- client/models/user_password_reset_req.go | 9 +- client/models/user_password_reset_update.go | 13 +- client/models/user_session.go | 46 +- client/models/v_mware_vsphere.go | 26 +- client/models/version_config.go | 9 +- client/models/versioned_resource_type.go | 25 +- client/models/worker.go | 9 +- client/version | 1 - 587 files changed, 53250 insertions(+), 11647 deletions(-) delete mode 100644 client/client/api_client_client.go delete mode 100644 client/version diff --git a/client/client/api_client_client.go b/client/client/api_client_client.go deleted file mode 100644 index 3b9ed30d..00000000 --- a/client/client/api_client_client.go +++ /dev/null @@ -1,264 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package client - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "github.com/go-openapi/runtime" - httptransport "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/cycloidio/cycloid-cli/client/client/cost_estimation" - "github.com/cycloidio/cycloid-cli/client/client/cycloid" - "github.com/cycloidio/cycloid-cli/client/client/organization_api_keys" - "github.com/cycloidio/cycloid-cli/client/client/organization_children" - "github.com/cycloidio/cycloid-cli/client/client/organization_config_repositories" - "github.com/cycloidio/cycloid-cli/client/client/organization_credentials" - "github.com/cycloidio/cycloid-cli/client/client/organization_external_backends" - "github.com/cycloidio/cycloid-cli/client/client/organization_forms" - "github.com/cycloidio/cycloid-cli/client/client/organization_infrastructure_policies" - "github.com/cycloidio/cycloid-cli/client/client/organization_invitations" - "github.com/cycloidio/cycloid-cli/client/client/organization_kpis" - "github.com/cycloidio/cycloid-cli/client/client/organization_members" - "github.com/cycloidio/cycloid-cli/client/client/organization_pipelines" - "github.com/cycloidio/cycloid-cli/client/client/organization_pipelines_jobs" - "github.com/cycloidio/cycloid-cli/client/client/organization_pipelines_jobs_build" - "github.com/cycloidio/cycloid-cli/client/client/organization_projects" - "github.com/cycloidio/cycloid-cli/client/client/organization_roles" - "github.com/cycloidio/cycloid-cli/client/client/organization_service_catalog_sources" - "github.com/cycloidio/cycloid-cli/client/client/organization_workers" - "github.com/cycloidio/cycloid-cli/client/client/organizations" - "github.com/cycloidio/cycloid-cli/client/client/service_catalogs" - "github.com/cycloidio/cycloid-cli/client/client/user" -) - -// Default API client HTTP client. -var Default = NewHTTPClient(nil) - -const ( - // DefaultHost is the default Host - // found in Meta (info) section of spec file - DefaultHost string = "http-api.cycloid.io" - // DefaultBasePath is the default BasePath - // found in Meta (info) section of spec file - DefaultBasePath string = "/" -) - -// DefaultSchemes are the default schemes found in Meta (info) section of spec file -var DefaultSchemes = []string{"https"} - -// NewHTTPClient creates a new API client HTTP client. -func NewHTTPClient(formats strfmt.Registry) *APIClient { - return NewHTTPClientWithConfig(formats, nil) -} - -// NewHTTPClientWithConfig creates a new API client HTTP client, -// using a customizable transport config. -func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *APIClient { - // ensure nullable parameters have default - if cfg == nil { - cfg = DefaultTransportConfig() - } - - // create transport and client - transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) - return New(transport, formats) -} - -// New creates a new API client client -func New(transport runtime.ClientTransport, formats strfmt.Registry) *APIClient { - // ensure nullable parameters have default - if formats == nil { - formats = strfmt.Default - } - - cli := new(APIClient) - cli.Transport = transport - - cli.CostEstimation = cost_estimation.New(transport, formats) - - cli.Cycloid = cycloid.New(transport, formats) - - cli.OrganizationAPIKeys = organization_api_keys.New(transport, formats) - - cli.OrganizationChildren = organization_children.New(transport, formats) - - cli.OrganizationConfigRepositories = organization_config_repositories.New(transport, formats) - - cli.OrganizationCredentials = organization_credentials.New(transport, formats) - - cli.OrganizationExternalBackends = organization_external_backends.New(transport, formats) - - cli.OrganizationForms = organization_forms.New(transport, formats) - - cli.OrganizationInfrastructurePolicies = organization_infrastructure_policies.New(transport, formats) - - cli.OrganizationInvitations = organization_invitations.New(transport, formats) - - cli.OrganizationKpis = organization_kpis.New(transport, formats) - - cli.OrganizationMembers = organization_members.New(transport, formats) - - cli.OrganizationPipelines = organization_pipelines.New(transport, formats) - - cli.OrganizationPipelinesJobs = organization_pipelines_jobs.New(transport, formats) - - cli.OrganizationPipelinesJobsBuild = organization_pipelines_jobs_build.New(transport, formats) - - cli.OrganizationProjects = organization_projects.New(transport, formats) - - cli.OrganizationRoles = organization_roles.New(transport, formats) - - cli.OrganizationServiceCatalogSources = organization_service_catalog_sources.New(transport, formats) - - cli.OrganizationWorkers = organization_workers.New(transport, formats) - - cli.Organizations = organizations.New(transport, formats) - - cli.ServiceCatalogs = service_catalogs.New(transport, formats) - - cli.User = user.New(transport, formats) - - return cli -} - -// DefaultTransportConfig creates a TransportConfig with the -// default settings taken from the meta section of the spec file. -func DefaultTransportConfig() *TransportConfig { - return &TransportConfig{ - Host: DefaultHost, - BasePath: DefaultBasePath, - Schemes: DefaultSchemes, - } -} - -// TransportConfig contains the transport related info, -// found in the meta section of the spec file. -type TransportConfig struct { - Host string - BasePath string - Schemes []string -} - -// WithHost overrides the default host, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithHost(host string) *TransportConfig { - cfg.Host = host - return cfg -} - -// WithBasePath overrides the default basePath, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { - cfg.BasePath = basePath - return cfg -} - -// WithSchemes overrides the default schemes, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { - cfg.Schemes = schemes - return cfg -} - -// APIClient is a client for API client -type APIClient struct { - CostEstimation *cost_estimation.Client - - Cycloid *cycloid.Client - - OrganizationAPIKeys *organization_api_keys.Client - - OrganizationChildren *organization_children.Client - - OrganizationConfigRepositories *organization_config_repositories.Client - - OrganizationCredentials *organization_credentials.Client - - OrganizationExternalBackends *organization_external_backends.Client - - OrganizationForms *organization_forms.Client - - OrganizationInfrastructurePolicies *organization_infrastructure_policies.Client - - OrganizationInvitations *organization_invitations.Client - - OrganizationKpis *organization_kpis.Client - - OrganizationMembers *organization_members.Client - - OrganizationPipelines *organization_pipelines.Client - - OrganizationPipelinesJobs *organization_pipelines_jobs.Client - - OrganizationPipelinesJobsBuild *organization_pipelines_jobs_build.Client - - OrganizationProjects *organization_projects.Client - - OrganizationRoles *organization_roles.Client - - OrganizationServiceCatalogSources *organization_service_catalog_sources.Client - - OrganizationWorkers *organization_workers.Client - - Organizations *organizations.Client - - ServiceCatalogs *service_catalogs.Client - - User *user.Client - - Transport runtime.ClientTransport -} - -// SetTransport changes the transport on the client and all its subresources -func (c *APIClient) SetTransport(transport runtime.ClientTransport) { - c.Transport = transport - - c.CostEstimation.SetTransport(transport) - - c.Cycloid.SetTransport(transport) - - c.OrganizationAPIKeys.SetTransport(transport) - - c.OrganizationChildren.SetTransport(transport) - - c.OrganizationConfigRepositories.SetTransport(transport) - - c.OrganizationCredentials.SetTransport(transport) - - c.OrganizationExternalBackends.SetTransport(transport) - - c.OrganizationForms.SetTransport(transport) - - c.OrganizationInfrastructurePolicies.SetTransport(transport) - - c.OrganizationInvitations.SetTransport(transport) - - c.OrganizationKpis.SetTransport(transport) - - c.OrganizationMembers.SetTransport(transport) - - c.OrganizationPipelines.SetTransport(transport) - - c.OrganizationPipelinesJobs.SetTransport(transport) - - c.OrganizationPipelinesJobsBuild.SetTransport(transport) - - c.OrganizationProjects.SetTransport(transport) - - c.OrganizationRoles.SetTransport(transport) - - c.OrganizationServiceCatalogSources.SetTransport(transport) - - c.OrganizationWorkers.SetTransport(transport) - - c.Organizations.SetTransport(transport) - - c.ServiceCatalogs.SetTransport(transport) - - c.User.SetTransport(transport) - -} diff --git a/client/client/cost_estimation/cost_estimate_forms_parameters.go b/client/client/cost_estimation/cost_estimate_forms_parameters.go index 8e6a4ec9..d015d5e9 100644 --- a/client/client/cost_estimation/cost_estimate_forms_parameters.go +++ b/client/client/cost_estimation/cost_estimate_forms_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCostEstimateFormsParams creates a new CostEstimateFormsParams object -// with the default values initialized. +// NewCostEstimateFormsParams creates a new CostEstimateFormsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCostEstimateFormsParams() *CostEstimateFormsParams { - var () return &CostEstimateFormsParams{ - timeout: cr.DefaultTimeout, } } // NewCostEstimateFormsParamsWithTimeout creates a new CostEstimateFormsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCostEstimateFormsParamsWithTimeout(timeout time.Duration) *CostEstimateFormsParams { - var () return &CostEstimateFormsParams{ - timeout: timeout, } } // NewCostEstimateFormsParamsWithContext creates a new CostEstimateFormsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCostEstimateFormsParamsWithContext(ctx context.Context) *CostEstimateFormsParams { - var () return &CostEstimateFormsParams{ - Context: ctx, } } // NewCostEstimateFormsParamsWithHTTPClient creates a new CostEstimateFormsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCostEstimateFormsParamsWithHTTPClient(client *http.Client) *CostEstimateFormsParams { - var () return &CostEstimateFormsParams{ HTTPClient: client, } } -/*CostEstimateFormsParams contains all the parameters to send to the API endpoint -for the cost estimate forms operation typically these are written to a http.Request +/* +CostEstimateFormsParams contains all the parameters to send to the API endpoint + + for the cost estimate forms operation. + + Typically these are written to a http.Request. */ type CostEstimateFormsParams struct { - /*Body - The information of the filled forms for a new project. + /* Body. + The information of the filled forms for a new project. */ Body *models.FormInputs - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -84,6 +86,21 @@ type CostEstimateFormsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the cost estimate forms params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CostEstimateFormsParams) WithDefaults() *CostEstimateFormsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the cost estimate forms params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CostEstimateFormsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the cost estimate forms params func (o *CostEstimateFormsParams) WithTimeout(timeout time.Duration) *CostEstimateFormsParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *CostEstimateFormsParams) WriteToRequest(r runtime.ClientRequest, reg st return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/cost_estimation/cost_estimate_forms_responses.go b/client/client/cost_estimation/cost_estimate_forms_responses.go index e2ff8b13..cf48da9c 100644 --- a/client/client/cost_estimation/cost_estimate_forms_responses.go +++ b/client/client/cost_estimation/cost_estimate_forms_responses.go @@ -6,17 +6,17 @@ package cost_estimation // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CostEstimateFormsReader is a Reader for the CostEstimateForms structure. @@ -62,7 +62,8 @@ func NewCostEstimateFormsOK() *CostEstimateFormsOK { return &CostEstimateFormsOK{} } -/*CostEstimateFormsOK handles this case with default header values. +/* +CostEstimateFormsOK describes a response with status code 200, with default header values. The result of estimating the costs of a stack. */ @@ -70,8 +71,44 @@ type CostEstimateFormsOK struct { Payload *CostEstimateFormsOKBody } +// IsSuccess returns true when this cost estimate forms o k response has a 2xx status code +func (o *CostEstimateFormsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this cost estimate forms o k response has a 3xx status code +func (o *CostEstimateFormsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this cost estimate forms o k response has a 4xx status code +func (o *CostEstimateFormsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this cost estimate forms o k response has a 5xx status code +func (o *CostEstimateFormsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this cost estimate forms o k response a status code equal to that given +func (o *CostEstimateFormsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the cost estimate forms o k response +func (o *CostEstimateFormsOK) Code() int { + return 200 +} + func (o *CostEstimateFormsOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsOK %s", 200, payload) +} + +func (o *CostEstimateFormsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsOK %s", 200, payload) } func (o *CostEstimateFormsOK) GetPayload() *CostEstimateFormsOKBody { @@ -95,20 +132,60 @@ func NewCostEstimateFormsForbidden() *CostEstimateFormsForbidden { return &CostEstimateFormsForbidden{} } -/*CostEstimateFormsForbidden handles this case with default header values. +/* +CostEstimateFormsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CostEstimateFormsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this cost estimate forms forbidden response has a 2xx status code +func (o *CostEstimateFormsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this cost estimate forms forbidden response has a 3xx status code +func (o *CostEstimateFormsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this cost estimate forms forbidden response has a 4xx status code +func (o *CostEstimateFormsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this cost estimate forms forbidden response has a 5xx status code +func (o *CostEstimateFormsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this cost estimate forms forbidden response a status code equal to that given +func (o *CostEstimateFormsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the cost estimate forms forbidden response +func (o *CostEstimateFormsForbidden) Code() int { + return 403 +} + func (o *CostEstimateFormsForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsForbidden %s", 403, payload) +} + +func (o *CostEstimateFormsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsForbidden %s", 403, payload) } func (o *CostEstimateFormsForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +194,16 @@ func (o *CostEstimateFormsForbidden) GetPayload() *models.ErrorPayload { func (o *CostEstimateFormsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +220,60 @@ func NewCostEstimateFormsUnprocessableEntity() *CostEstimateFormsUnprocessableEn return &CostEstimateFormsUnprocessableEntity{} } -/*CostEstimateFormsUnprocessableEntity handles this case with default header values. +/* +CostEstimateFormsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CostEstimateFormsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this cost estimate forms unprocessable entity response has a 2xx status code +func (o *CostEstimateFormsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this cost estimate forms unprocessable entity response has a 3xx status code +func (o *CostEstimateFormsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this cost estimate forms unprocessable entity response has a 4xx status code +func (o *CostEstimateFormsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this cost estimate forms unprocessable entity response has a 5xx status code +func (o *CostEstimateFormsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this cost estimate forms unprocessable entity response a status code equal to that given +func (o *CostEstimateFormsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the cost estimate forms unprocessable entity response +func (o *CostEstimateFormsUnprocessableEntity) Code() int { + return 422 +} + func (o *CostEstimateFormsUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsUnprocessableEntity %s", 422, payload) +} + +func (o *CostEstimateFormsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateFormsUnprocessableEntity %s", 422, payload) } func (o *CostEstimateFormsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +282,16 @@ func (o *CostEstimateFormsUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *CostEstimateFormsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +310,61 @@ func NewCostEstimateFormsDefault(code int) *CostEstimateFormsDefault { } } -/*CostEstimateFormsDefault handles this case with default header values. +/* +CostEstimateFormsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CostEstimateFormsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this cost estimate forms default response has a 2xx status code +func (o *CostEstimateFormsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this cost estimate forms default response has a 3xx status code +func (o *CostEstimateFormsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this cost estimate forms default response has a 4xx status code +func (o *CostEstimateFormsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this cost estimate forms default response has a 5xx status code +func (o *CostEstimateFormsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this cost estimate forms default response a status code equal to that given +func (o *CostEstimateFormsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the cost estimate forms default response func (o *CostEstimateFormsDefault) Code() int { return o._statusCode } func (o *CostEstimateFormsDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateForms default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateForms default %s", o._statusCode, payload) +} + +func (o *CostEstimateFormsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate][%d] costEstimateForms default %s", o._statusCode, payload) } func (o *CostEstimateFormsDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +373,16 @@ func (o *CostEstimateFormsDefault) GetPayload() *models.ErrorPayload { func (o *CostEstimateFormsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +394,8 @@ func (o *CostEstimateFormsDefault) readResponse(response runtime.ClientResponse, return nil } -/*CostEstimateFormsOKBody cost estimate forms o k body +/* +CostEstimateFormsOKBody cost estimate forms o k body swagger:model CostEstimateFormsOKBody */ type CostEstimateFormsOKBody struct { @@ -257,13 +421,18 @@ func (o *CostEstimateFormsOKBody) Validate(formats strfmt.Registry) error { func (o *CostEstimateFormsOKBody) validateData(formats strfmt.Registry) error { - if err := validate.Required("costEstimateFormsOK"+"."+"data", "body", o.Data); err != nil { - return err + if o.Data == nil { + return errors.Required("costEstimateFormsOK"+"."+"data", "body", nil) } return nil } +// ContextValidate validates this cost estimate forms o k body based on context it is used +func (o *CostEstimateFormsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *CostEstimateFormsOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/cost_estimation/cost_estimate_tf_plan_parameters.go b/client/client/cost_estimation/cost_estimate_tf_plan_parameters.go index 06859ea8..4127498a 100644 --- a/client/client/cost_estimation/cost_estimate_tf_plan_parameters.go +++ b/client/client/cost_estimation/cost_estimate_tf_plan_parameters.go @@ -13,61 +13,62 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCostEstimateTfPlanParams creates a new CostEstimateTfPlanParams object -// with the default values initialized. +// NewCostEstimateTfPlanParams creates a new CostEstimateTfPlanParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCostEstimateTfPlanParams() *CostEstimateTfPlanParams { - var () return &CostEstimateTfPlanParams{ - timeout: cr.DefaultTimeout, } } // NewCostEstimateTfPlanParamsWithTimeout creates a new CostEstimateTfPlanParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCostEstimateTfPlanParamsWithTimeout(timeout time.Duration) *CostEstimateTfPlanParams { - var () return &CostEstimateTfPlanParams{ - timeout: timeout, } } // NewCostEstimateTfPlanParamsWithContext creates a new CostEstimateTfPlanParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCostEstimateTfPlanParamsWithContext(ctx context.Context) *CostEstimateTfPlanParams { - var () return &CostEstimateTfPlanParams{ - Context: ctx, } } // NewCostEstimateTfPlanParamsWithHTTPClient creates a new CostEstimateTfPlanParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCostEstimateTfPlanParamsWithHTTPClient(client *http.Client) *CostEstimateTfPlanParams { - var () return &CostEstimateTfPlanParams{ HTTPClient: client, } } -/*CostEstimateTfPlanParams contains all the parameters to send to the API endpoint -for the cost estimate tf plan operation typically these are written to a http.Request +/* +CostEstimateTfPlanParams contains all the parameters to send to the API endpoint + + for the cost estimate tf plan operation. + + Typically these are written to a http.Request. */ type CostEstimateTfPlanParams struct { - /*Body*/ + // Body. Body *models.TerraformPlanInput - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -76,6 +77,21 @@ type CostEstimateTfPlanParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the cost estimate tf plan params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CostEstimateTfPlanParams) WithDefaults() *CostEstimateTfPlanParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the cost estimate tf plan params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CostEstimateTfPlanParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the cost estimate tf plan params func (o *CostEstimateTfPlanParams) WithTimeout(timeout time.Duration) *CostEstimateTfPlanParams { o.SetTimeout(timeout) @@ -138,7 +154,6 @@ func (o *CostEstimateTfPlanParams) WriteToRequest(r runtime.ClientRequest, reg s return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/cost_estimation/cost_estimate_tf_plan_responses.go b/client/client/cost_estimation/cost_estimate_tf_plan_responses.go index de4ff1fd..9d9d2179 100644 --- a/client/client/cost_estimation/cost_estimate_tf_plan_responses.go +++ b/client/client/cost_estimation/cost_estimate_tf_plan_responses.go @@ -6,17 +6,18 @@ package cost_estimation // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CostEstimateTfPlanReader is a Reader for the CostEstimateTfPlan structure. @@ -62,7 +63,8 @@ func NewCostEstimateTfPlanOK() *CostEstimateTfPlanOK { return &CostEstimateTfPlanOK{} } -/*CostEstimateTfPlanOK handles this case with default header values. +/* +CostEstimateTfPlanOK describes a response with status code 200, with default header values. The result of estimating the costs of a Terraform plan. */ @@ -70,8 +72,44 @@ type CostEstimateTfPlanOK struct { Payload *CostEstimateTfPlanOKBody } +// IsSuccess returns true when this cost estimate tf plan o k response has a 2xx status code +func (o *CostEstimateTfPlanOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this cost estimate tf plan o k response has a 3xx status code +func (o *CostEstimateTfPlanOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this cost estimate tf plan o k response has a 4xx status code +func (o *CostEstimateTfPlanOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this cost estimate tf plan o k response has a 5xx status code +func (o *CostEstimateTfPlanOK) IsServerError() bool { + return false +} + +// IsCode returns true when this cost estimate tf plan o k response a status code equal to that given +func (o *CostEstimateTfPlanOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the cost estimate tf plan o k response +func (o *CostEstimateTfPlanOK) Code() int { + return 200 +} + func (o *CostEstimateTfPlanOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanOK %s", 200, payload) +} + +func (o *CostEstimateTfPlanOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanOK %s", 200, payload) } func (o *CostEstimateTfPlanOK) GetPayload() *CostEstimateTfPlanOKBody { @@ -95,20 +133,60 @@ func NewCostEstimateTfPlanForbidden() *CostEstimateTfPlanForbidden { return &CostEstimateTfPlanForbidden{} } -/*CostEstimateTfPlanForbidden handles this case with default header values. +/* +CostEstimateTfPlanForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CostEstimateTfPlanForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this cost estimate tf plan forbidden response has a 2xx status code +func (o *CostEstimateTfPlanForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this cost estimate tf plan forbidden response has a 3xx status code +func (o *CostEstimateTfPlanForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this cost estimate tf plan forbidden response has a 4xx status code +func (o *CostEstimateTfPlanForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this cost estimate tf plan forbidden response has a 5xx status code +func (o *CostEstimateTfPlanForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this cost estimate tf plan forbidden response a status code equal to that given +func (o *CostEstimateTfPlanForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the cost estimate tf plan forbidden response +func (o *CostEstimateTfPlanForbidden) Code() int { + return 403 +} + func (o *CostEstimateTfPlanForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanForbidden %s", 403, payload) +} + +func (o *CostEstimateTfPlanForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanForbidden %s", 403, payload) } func (o *CostEstimateTfPlanForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *CostEstimateTfPlanForbidden) GetPayload() *models.ErrorPayload { func (o *CostEstimateTfPlanForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewCostEstimateTfPlanUnprocessableEntity() *CostEstimateTfPlanUnprocessable return &CostEstimateTfPlanUnprocessableEntity{} } -/*CostEstimateTfPlanUnprocessableEntity handles this case with default header values. +/* +CostEstimateTfPlanUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CostEstimateTfPlanUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this cost estimate tf plan unprocessable entity response has a 2xx status code +func (o *CostEstimateTfPlanUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this cost estimate tf plan unprocessable entity response has a 3xx status code +func (o *CostEstimateTfPlanUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this cost estimate tf plan unprocessable entity response has a 4xx status code +func (o *CostEstimateTfPlanUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this cost estimate tf plan unprocessable entity response has a 5xx status code +func (o *CostEstimateTfPlanUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this cost estimate tf plan unprocessable entity response a status code equal to that given +func (o *CostEstimateTfPlanUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the cost estimate tf plan unprocessable entity response +func (o *CostEstimateTfPlanUnprocessableEntity) Code() int { + return 422 +} + func (o *CostEstimateTfPlanUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanUnprocessableEntity %s", 422, payload) +} + +func (o *CostEstimateTfPlanUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlanUnprocessableEntity %s", 422, payload) } func (o *CostEstimateTfPlanUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *CostEstimateTfPlanUnprocessableEntity) GetPayload() *models.ErrorPayloa func (o *CostEstimateTfPlanUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewCostEstimateTfPlanDefault(code int) *CostEstimateTfPlanDefault { } } -/*CostEstimateTfPlanDefault handles this case with default header values. +/* +CostEstimateTfPlanDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CostEstimateTfPlanDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this cost estimate tf plan default response has a 2xx status code +func (o *CostEstimateTfPlanDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this cost estimate tf plan default response has a 3xx status code +func (o *CostEstimateTfPlanDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this cost estimate tf plan default response has a 4xx status code +func (o *CostEstimateTfPlanDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this cost estimate tf plan default response has a 5xx status code +func (o *CostEstimateTfPlanDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this cost estimate tf plan default response a status code equal to that given +func (o *CostEstimateTfPlanDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the cost estimate tf plan default response func (o *CostEstimateTfPlanDefault) Code() int { return o._statusCode } func (o *CostEstimateTfPlanDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlan default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlan default %s", o._statusCode, payload) +} + +func (o *CostEstimateTfPlanDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/cost_estimation/tfplan][%d] costEstimateTfPlan default %s", o._statusCode, payload) } func (o *CostEstimateTfPlanDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *CostEstimateTfPlanDefault) GetPayload() *models.ErrorPayload { func (o *CostEstimateTfPlanDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *CostEstimateTfPlanDefault) readResponse(response runtime.ClientResponse return nil } -/*CostEstimateTfPlanOKBody cost estimate tf plan o k body +/* +CostEstimateTfPlanOKBody cost estimate tf plan o k body swagger:model CostEstimateTfPlanOKBody */ type CostEstimateTfPlanOKBody struct { @@ -265,6 +430,39 @@ func (o *CostEstimateTfPlanOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("costEstimateTfPlanOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("costEstimateTfPlanOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cost estimate tf plan o k body based on the context it is used +func (o *CostEstimateTfPlanOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CostEstimateTfPlanOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("costEstimateTfPlanOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("costEstimateTfPlanOK" + "." + "data") } return err } diff --git a/client/client/cost_estimation/cost_estimation_client.go b/client/client/cost_estimation/cost_estimation_client.go index f54546ef..df1588dd 100644 --- a/client/client/cost_estimation/cost_estimation_client.go +++ b/client/client/cost_estimation/cost_estimation_client.go @@ -7,15 +7,40 @@ package cost_estimation import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new cost estimation API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new cost estimation API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new cost estimation API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for cost estimation API */ @@ -24,16 +49,76 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CostEstimateForms(params *CostEstimateFormsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CostEstimateFormsOK, error) + + CostEstimateTfPlan(params *CostEstimateTfPlanParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CostEstimateTfPlanOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CostEstimateForms Estimates the Cost from the Froms Inputs */ -func (a *Client) CostEstimateForms(params *CostEstimateFormsParams, authInfo runtime.ClientAuthInfoWriter) (*CostEstimateFormsOK, error) { +func (a *Client) CostEstimateForms(params *CostEstimateFormsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CostEstimateFormsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCostEstimateFormsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "costEstimateForms", Method: "POST", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/forms/estimate", @@ -45,7 +130,12 @@ func (a *Client) CostEstimateForms(params *CostEstimateFormsParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +151,12 @@ func (a *Client) CostEstimateForms(params *CostEstimateFormsParams, authInfo run /* CostEstimateTfPlan Estimate costs of a Terraform plan in JSON format. */ -func (a *Client) CostEstimateTfPlan(params *CostEstimateTfPlanParams, authInfo runtime.ClientAuthInfoWriter) (*CostEstimateTfPlanOK, error) { +func (a *Client) CostEstimateTfPlan(params *CostEstimateTfPlanParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CostEstimateTfPlanOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCostEstimateTfPlanParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "costEstimateTfPlan", Method: "POST", PathPattern: "/organizations/{organization_canonical}/cost_estimation/tfplan", @@ -79,7 +168,12 @@ func (a *Client) CostEstimateTfPlan(params *CostEstimateTfPlanParams, authInfo r AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/cycloid/cycloid_client.go b/client/client/cycloid/cycloid_client.go index 1bd8ab8a..e14e5e3b 100644 --- a/client/client/cycloid/cycloid_client.go +++ b/client/client/cycloid/cycloid_client.go @@ -9,15 +9,40 @@ import ( "fmt" "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new cycloid API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new cycloid API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new cycloid API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for cycloid API */ @@ -26,16 +51,82 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + GetAppVersion(params *GetAppVersionParams, opts ...ClientOption) (*GetAppVersionOK, error) + + GetConfig(params *GetConfigParams, opts ...ClientOption) (*GetConfigOK, error) + + GetCountries(params *GetCountriesParams, opts ...ClientOption) (*GetCountriesOK, error) + + GetServiceStatus(params *GetServiceStatusParams, opts ...ClientOption) (*GetServiceStatusOK, error) + + GetStatus(params *GetStatusParams, opts ...ClientOption) (*GetStatusOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* GetAppVersion Get the version of the Cycloid's API. */ -func (a *Client) GetAppVersion(params *GetAppVersionParams) (*GetAppVersionOK, error) { +func (a *Client) GetAppVersion(params *GetAppVersionParams, opts ...ClientOption) (*GetAppVersionOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetAppVersionParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getAppVersion", Method: "GET", PathPattern: "/version", @@ -46,7 +137,12 @@ func (a *Client) GetAppVersion(params *GetAppVersionParams) (*GetAppVersionOK, e Reader: &GetAppVersionReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -62,13 +158,12 @@ func (a *Client) GetAppVersion(params *GetAppVersionParams) (*GetAppVersionOK, e /* GetConfig Get the Cycloid configuration. */ -func (a *Client) GetConfig(params *GetConfigParams) (*GetConfigOK, error) { +func (a *Client) GetConfig(params *GetConfigParams, opts ...ClientOption) (*GetConfigOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetConfigParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getConfig", Method: "GET", PathPattern: "/config", @@ -79,7 +174,12 @@ func (a *Client) GetConfig(params *GetConfigParams) (*GetConfigOK, error) { Reader: &GetConfigReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +195,12 @@ func (a *Client) GetConfig(params *GetConfigParams) (*GetConfigOK, error) { /* GetCountries Get the Cycloid supported countries. */ -func (a *Client) GetCountries(params *GetCountriesParams) (*GetCountriesOK, error) { +func (a *Client) GetCountries(params *GetCountriesParams, opts ...ClientOption) (*GetCountriesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetCountriesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getCountries", Method: "GET", PathPattern: "/countries", @@ -112,7 +211,12 @@ func (a *Client) GetCountries(params *GetCountriesParams) (*GetCountriesOK, erro Reader: &GetCountriesReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -128,13 +232,12 @@ func (a *Client) GetCountries(params *GetCountriesParams) (*GetCountriesOK, erro /* GetServiceStatus Get the status of the Cycloid's service. It uses 200 and 500 to also identify the status */ -func (a *Client) GetServiceStatus(params *GetServiceStatusParams) (*GetServiceStatusOK, error) { +func (a *Client) GetServiceStatus(params *GetServiceStatusParams, opts ...ClientOption) (*GetServiceStatusOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetServiceStatusParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getServiceStatus", Method: "GET", PathPattern: "/status/{service_status_canonical}", @@ -145,7 +248,12 @@ func (a *Client) GetServiceStatus(params *GetServiceStatusParams) (*GetServiceSt Reader: &GetServiceStatusReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -162,13 +270,12 @@ func (a *Client) GetServiceStatus(params *GetServiceStatusParams) (*GetServiceSt /* GetStatus Get the status of the Cycloid's services. */ -func (a *Client) GetStatus(params *GetStatusParams) (*GetStatusOK, error) { +func (a *Client) GetStatus(params *GetStatusParams, opts ...ClientOption) (*GetStatusOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetStatusParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getStatus", Method: "GET", PathPattern: "/status", @@ -179,7 +286,12 @@ func (a *Client) GetStatus(params *GetStatusParams) (*GetStatusOK, error) { Reader: &GetStatusReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/cycloid/get_app_version_parameters.go b/client/client/cycloid/get_app_version_parameters.go index b1f6119d..c493ef09 100644 --- a/client/client/cycloid/get_app_version_parameters.go +++ b/client/client/cycloid/get_app_version_parameters.go @@ -13,51 +13,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetAppVersionParams creates a new GetAppVersionParams object -// with the default values initialized. +// NewGetAppVersionParams creates a new GetAppVersionParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetAppVersionParams() *GetAppVersionParams { - return &GetAppVersionParams{ - timeout: cr.DefaultTimeout, } } // NewGetAppVersionParamsWithTimeout creates a new GetAppVersionParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetAppVersionParamsWithTimeout(timeout time.Duration) *GetAppVersionParams { - return &GetAppVersionParams{ - timeout: timeout, } } // NewGetAppVersionParamsWithContext creates a new GetAppVersionParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetAppVersionParamsWithContext(ctx context.Context) *GetAppVersionParams { - return &GetAppVersionParams{ - Context: ctx, } } // NewGetAppVersionParamsWithHTTPClient creates a new GetAppVersionParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetAppVersionParamsWithHTTPClient(client *http.Client) *GetAppVersionParams { - return &GetAppVersionParams{ HTTPClient: client, } } -/*GetAppVersionParams contains all the parameters to send to the API endpoint -for the get app version operation typically these are written to a http.Request +/* +GetAppVersionParams contains all the parameters to send to the API endpoint + + for the get app version operation. + + Typically these are written to a http.Request. */ type GetAppVersionParams struct { timeout time.Duration @@ -65,6 +65,21 @@ type GetAppVersionParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get app version params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAppVersionParams) WithDefaults() *GetAppVersionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get app version params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAppVersionParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get app version params func (o *GetAppVersionParams) WithTimeout(timeout time.Duration) *GetAppVersionParams { o.SetTimeout(timeout) diff --git a/client/client/cycloid/get_app_version_responses.go b/client/client/cycloid/get_app_version_responses.go index 6901e035..e2bd4a34 100644 --- a/client/client/cycloid/get_app_version_responses.go +++ b/client/client/cycloid/get_app_version_responses.go @@ -6,17 +6,18 @@ package cycloid // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetAppVersionReader is a Reader for the GetAppVersion structure. @@ -56,7 +57,8 @@ func NewGetAppVersionOK() *GetAppVersionOK { return &GetAppVersionOK{} } -/*GetAppVersionOK handles this case with default header values. +/* +GetAppVersionOK describes a response with status code 200, with default header values. Application version. */ @@ -64,8 +66,44 @@ type GetAppVersionOK struct { Payload *GetAppVersionOKBody } +// IsSuccess returns true when this get app version o k response has a 2xx status code +func (o *GetAppVersionOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get app version o k response has a 3xx status code +func (o *GetAppVersionOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get app version o k response has a 4xx status code +func (o *GetAppVersionOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get app version o k response has a 5xx status code +func (o *GetAppVersionOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get app version o k response a status code equal to that given +func (o *GetAppVersionOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get app version o k response +func (o *GetAppVersionOK) Code() int { + return 200 +} + func (o *GetAppVersionOK) Error() string { - return fmt.Sprintf("[GET /version][%d] getAppVersionOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getAppVersionOK %s", 200, payload) +} + +func (o *GetAppVersionOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getAppVersionOK %s", 200, payload) } func (o *GetAppVersionOK) GetPayload() *GetAppVersionOKBody { @@ -89,20 +127,60 @@ func NewGetAppVersionUnprocessableEntity() *GetAppVersionUnprocessableEntity { return &GetAppVersionUnprocessableEntity{} } -/*GetAppVersionUnprocessableEntity handles this case with default header values. +/* +GetAppVersionUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetAppVersionUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get app version unprocessable entity response has a 2xx status code +func (o *GetAppVersionUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get app version unprocessable entity response has a 3xx status code +func (o *GetAppVersionUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get app version unprocessable entity response has a 4xx status code +func (o *GetAppVersionUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get app version unprocessable entity response has a 5xx status code +func (o *GetAppVersionUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get app version unprocessable entity response a status code equal to that given +func (o *GetAppVersionUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get app version unprocessable entity response +func (o *GetAppVersionUnprocessableEntity) Code() int { + return 422 +} + func (o *GetAppVersionUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /version][%d] getAppVersionUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getAppVersionUnprocessableEntity %s", 422, payload) +} + +func (o *GetAppVersionUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getAppVersionUnprocessableEntity %s", 422, payload) } func (o *GetAppVersionUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -111,12 +189,16 @@ func (o *GetAppVersionUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetAppVersionUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -135,27 +217,61 @@ func NewGetAppVersionDefault(code int) *GetAppVersionDefault { } } -/*GetAppVersionDefault handles this case with default header values. +/* +GetAppVersionDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetAppVersionDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get app version default response has a 2xx status code +func (o *GetAppVersionDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get app version default response has a 3xx status code +func (o *GetAppVersionDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get app version default response has a 4xx status code +func (o *GetAppVersionDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get app version default response has a 5xx status code +func (o *GetAppVersionDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get app version default response a status code equal to that given +func (o *GetAppVersionDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get app version default response func (o *GetAppVersionDefault) Code() int { return o._statusCode } func (o *GetAppVersionDefault) Error() string { - return fmt.Sprintf("[GET /version][%d] getAppVersion default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getAppVersion default %s", o._statusCode, payload) +} + +func (o *GetAppVersionDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getAppVersion default %s", o._statusCode, payload) } func (o *GetAppVersionDefault) GetPayload() *models.ErrorPayload { @@ -164,12 +280,16 @@ func (o *GetAppVersionDefault) GetPayload() *models.ErrorPayload { func (o *GetAppVersionDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -181,7 +301,8 @@ func (o *GetAppVersionDefault) readResponse(response runtime.ClientResponse, con return nil } -/*GetAppVersionOKBody get app version o k body +/* +GetAppVersionOKBody get app version o k body swagger:model GetAppVersionOKBody */ type GetAppVersionOKBody struct { @@ -215,6 +336,39 @@ func (o *GetAppVersionOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getAppVersionOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getAppVersionOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get app version o k body based on the context it is used +func (o *GetAppVersionOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetAppVersionOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getAppVersionOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getAppVersionOK" + "." + "data") } return err } diff --git a/client/client/cycloid/get_config_parameters.go b/client/client/cycloid/get_config_parameters.go index 2f38a623..a1ed11cb 100644 --- a/client/client/cycloid/get_config_parameters.go +++ b/client/client/cycloid/get_config_parameters.go @@ -13,51 +13,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetConfigParams creates a new GetConfigParams object -// with the default values initialized. +// NewGetConfigParams creates a new GetConfigParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetConfigParams() *GetConfigParams { - return &GetConfigParams{ - timeout: cr.DefaultTimeout, } } // NewGetConfigParamsWithTimeout creates a new GetConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetConfigParamsWithTimeout(timeout time.Duration) *GetConfigParams { - return &GetConfigParams{ - timeout: timeout, } } // NewGetConfigParamsWithContext creates a new GetConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetConfigParamsWithContext(ctx context.Context) *GetConfigParams { - return &GetConfigParams{ - Context: ctx, } } // NewGetConfigParamsWithHTTPClient creates a new GetConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetConfigParamsWithHTTPClient(client *http.Client) *GetConfigParams { - return &GetConfigParams{ HTTPClient: client, } } -/*GetConfigParams contains all the parameters to send to the API endpoint -for the get config operation typically these are written to a http.Request +/* +GetConfigParams contains all the parameters to send to the API endpoint + + for the get config operation. + + Typically these are written to a http.Request. */ type GetConfigParams struct { timeout time.Duration @@ -65,6 +65,21 @@ type GetConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetConfigParams) WithDefaults() *GetConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get config params func (o *GetConfigParams) WithTimeout(timeout time.Duration) *GetConfigParams { o.SetTimeout(timeout) diff --git a/client/client/cycloid/get_config_responses.go b/client/client/cycloid/get_config_responses.go index 7f11e580..327b521a 100644 --- a/client/client/cycloid/get_config_responses.go +++ b/client/client/cycloid/get_config_responses.go @@ -6,17 +6,18 @@ package cycloid // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetConfigReader is a Reader for the GetConfig structure. @@ -56,7 +57,8 @@ func NewGetConfigOK() *GetConfigOK { return &GetConfigOK{} } -/*GetConfigOK handles this case with default header values. +/* +GetConfigOK describes a response with status code 200, with default header values. Cycloid configuration, including available authentication methods. */ @@ -64,8 +66,44 @@ type GetConfigOK struct { Payload *GetConfigOKBody } +// IsSuccess returns true when this get config o k response has a 2xx status code +func (o *GetConfigOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get config o k response has a 3xx status code +func (o *GetConfigOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get config o k response has a 4xx status code +func (o *GetConfigOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get config o k response has a 5xx status code +func (o *GetConfigOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get config o k response a status code equal to that given +func (o *GetConfigOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get config o k response +func (o *GetConfigOK) Code() int { + return 200 +} + func (o *GetConfigOK) Error() string { - return fmt.Sprintf("[GET /config][%d] getConfigOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /config][%d] getConfigOK %s", 200, payload) +} + +func (o *GetConfigOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /config][%d] getConfigOK %s", 200, payload) } func (o *GetConfigOK) GetPayload() *GetConfigOKBody { @@ -89,20 +127,60 @@ func NewGetConfigUnprocessableEntity() *GetConfigUnprocessableEntity { return &GetConfigUnprocessableEntity{} } -/*GetConfigUnprocessableEntity handles this case with default header values. +/* +GetConfigUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetConfigUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get config unprocessable entity response has a 2xx status code +func (o *GetConfigUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get config unprocessable entity response has a 3xx status code +func (o *GetConfigUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get config unprocessable entity response has a 4xx status code +func (o *GetConfigUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get config unprocessable entity response has a 5xx status code +func (o *GetConfigUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get config unprocessable entity response a status code equal to that given +func (o *GetConfigUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get config unprocessable entity response +func (o *GetConfigUnprocessableEntity) Code() int { + return 422 +} + func (o *GetConfigUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /config][%d] getConfigUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /config][%d] getConfigUnprocessableEntity %s", 422, payload) +} + +func (o *GetConfigUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /config][%d] getConfigUnprocessableEntity %s", 422, payload) } func (o *GetConfigUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -111,12 +189,16 @@ func (o *GetConfigUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetConfigUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -135,27 +217,61 @@ func NewGetConfigDefault(code int) *GetConfigDefault { } } -/*GetConfigDefault handles this case with default header values. +/* +GetConfigDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetConfigDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get config default response has a 2xx status code +func (o *GetConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get config default response has a 3xx status code +func (o *GetConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get config default response has a 4xx status code +func (o *GetConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get config default response has a 5xx status code +func (o *GetConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get config default response a status code equal to that given +func (o *GetConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get config default response func (o *GetConfigDefault) Code() int { return o._statusCode } func (o *GetConfigDefault) Error() string { - return fmt.Sprintf("[GET /config][%d] getConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /config][%d] getConfig default %s", o._statusCode, payload) +} + +func (o *GetConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /config][%d] getConfig default %s", o._statusCode, payload) } func (o *GetConfigDefault) GetPayload() *models.ErrorPayload { @@ -164,12 +280,16 @@ func (o *GetConfigDefault) GetPayload() *models.ErrorPayload { func (o *GetConfigDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -181,7 +301,8 @@ func (o *GetConfigDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*GetConfigOKBody get config o k body +/* +GetConfigOKBody get config o k body swagger:model GetConfigOKBody */ type GetConfigOKBody struct { @@ -215,6 +336,39 @@ func (o *GetConfigOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getConfigOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get config o k body based on the context it is used +func (o *GetConfigOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetConfigOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getConfigOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getConfigOK" + "." + "data") } return err } diff --git a/client/client/cycloid/get_countries_parameters.go b/client/client/cycloid/get_countries_parameters.go index fa241387..6c6ead61 100644 --- a/client/client/cycloid/get_countries_parameters.go +++ b/client/client/cycloid/get_countries_parameters.go @@ -13,51 +13,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetCountriesParams creates a new GetCountriesParams object -// with the default values initialized. +// NewGetCountriesParams creates a new GetCountriesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetCountriesParams() *GetCountriesParams { - return &GetCountriesParams{ - timeout: cr.DefaultTimeout, } } // NewGetCountriesParamsWithTimeout creates a new GetCountriesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetCountriesParamsWithTimeout(timeout time.Duration) *GetCountriesParams { - return &GetCountriesParams{ - timeout: timeout, } } // NewGetCountriesParamsWithContext creates a new GetCountriesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetCountriesParamsWithContext(ctx context.Context) *GetCountriesParams { - return &GetCountriesParams{ - Context: ctx, } } // NewGetCountriesParamsWithHTTPClient creates a new GetCountriesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetCountriesParamsWithHTTPClient(client *http.Client) *GetCountriesParams { - return &GetCountriesParams{ HTTPClient: client, } } -/*GetCountriesParams contains all the parameters to send to the API endpoint -for the get countries operation typically these are written to a http.Request +/* +GetCountriesParams contains all the parameters to send to the API endpoint + + for the get countries operation. + + Typically these are written to a http.Request. */ type GetCountriesParams struct { timeout time.Duration @@ -65,6 +65,21 @@ type GetCountriesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get countries params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetCountriesParams) WithDefaults() *GetCountriesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get countries params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetCountriesParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get countries params func (o *GetCountriesParams) WithTimeout(timeout time.Duration) *GetCountriesParams { o.SetTimeout(timeout) diff --git a/client/client/cycloid/get_countries_responses.go b/client/client/cycloid/get_countries_responses.go index ee11a8d1..2901d4ad 100644 --- a/client/client/cycloid/get_countries_responses.go +++ b/client/client/cycloid/get_countries_responses.go @@ -6,18 +6,19 @@ package cycloid // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetCountriesReader is a Reader for the GetCountries structure. @@ -51,7 +52,8 @@ func NewGetCountriesOK() *GetCountriesOK { return &GetCountriesOK{} } -/*GetCountriesOK handles this case with default header values. +/* +GetCountriesOK describes a response with status code 200, with default header values. Cycloid supported countries */ @@ -59,8 +61,44 @@ type GetCountriesOK struct { Payload *GetCountriesOKBody } +// IsSuccess returns true when this get countries o k response has a 2xx status code +func (o *GetCountriesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get countries o k response has a 3xx status code +func (o *GetCountriesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get countries o k response has a 4xx status code +func (o *GetCountriesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get countries o k response has a 5xx status code +func (o *GetCountriesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get countries o k response a status code equal to that given +func (o *GetCountriesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get countries o k response +func (o *GetCountriesOK) Code() int { + return 200 +} + func (o *GetCountriesOK) Error() string { - return fmt.Sprintf("[GET /countries][%d] getCountriesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /countries][%d] getCountriesOK %s", 200, payload) +} + +func (o *GetCountriesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /countries][%d] getCountriesOK %s", 200, payload) } func (o *GetCountriesOK) GetPayload() *GetCountriesOKBody { @@ -86,27 +124,61 @@ func NewGetCountriesDefault(code int) *GetCountriesDefault { } } -/*GetCountriesDefault handles this case with default header values. +/* +GetCountriesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetCountriesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get countries default response has a 2xx status code +func (o *GetCountriesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get countries default response has a 3xx status code +func (o *GetCountriesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get countries default response has a 4xx status code +func (o *GetCountriesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get countries default response has a 5xx status code +func (o *GetCountriesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get countries default response a status code equal to that given +func (o *GetCountriesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get countries default response func (o *GetCountriesDefault) Code() int { return o._statusCode } func (o *GetCountriesDefault) Error() string { - return fmt.Sprintf("[GET /countries][%d] getCountries default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /countries][%d] getCountries default %s", o._statusCode, payload) +} + +func (o *GetCountriesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /countries][%d] getCountries default %s", o._statusCode, payload) } func (o *GetCountriesDefault) GetPayload() *models.ErrorPayload { @@ -115,12 +187,16 @@ func (o *GetCountriesDefault) GetPayload() *models.ErrorPayload { func (o *GetCountriesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -132,7 +208,8 @@ func (o *GetCountriesDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*GetCountriesOKBody get countries o k body +/* +GetCountriesOKBody get countries o k body swagger:model GetCountriesOKBody */ type GetCountriesOKBody struct { @@ -171,6 +248,47 @@ func (o *GetCountriesOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getCountriesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getCountriesOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this get countries o k body based on the context it is used +func (o *GetCountriesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetCountriesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getCountriesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getCountriesOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } diff --git a/client/client/cycloid/get_service_status_parameters.go b/client/client/cycloid/get_service_status_parameters.go index 9ff0f20e..b00fb512 100644 --- a/client/client/cycloid/get_service_status_parameters.go +++ b/client/client/cycloid/get_service_status_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetServiceStatusParams creates a new GetServiceStatusParams object -// with the default values initialized. +// NewGetServiceStatusParams creates a new GetServiceStatusParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetServiceStatusParams() *GetServiceStatusParams { - var () return &GetServiceStatusParams{ - timeout: cr.DefaultTimeout, } } // NewGetServiceStatusParamsWithTimeout creates a new GetServiceStatusParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetServiceStatusParamsWithTimeout(timeout time.Duration) *GetServiceStatusParams { - var () return &GetServiceStatusParams{ - timeout: timeout, } } // NewGetServiceStatusParamsWithContext creates a new GetServiceStatusParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetServiceStatusParamsWithContext(ctx context.Context) *GetServiceStatusParams { - var () return &GetServiceStatusParams{ - Context: ctx, } } // NewGetServiceStatusParamsWithHTTPClient creates a new GetServiceStatusParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetServiceStatusParamsWithHTTPClient(client *http.Client) *GetServiceStatusParams { - var () return &GetServiceStatusParams{ HTTPClient: client, } } -/*GetServiceStatusParams contains all the parameters to send to the API endpoint -for the get service status operation typically these are written to a http.Request +/* +GetServiceStatusParams contains all the parameters to send to the API endpoint + + for the get service status operation. + + Typically these are written to a http.Request. */ type GetServiceStatusParams struct { - /*ServiceStatusCanonical - The canonical of the service you want to get the status from + /* ServiceStatusCanonical. + The canonical of the service you want to get the status from */ ServiceStatusCanonical string @@ -72,6 +72,21 @@ type GetServiceStatusParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get service status params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceStatusParams) WithDefaults() *GetServiceStatusParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get service status params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceStatusParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get service status params func (o *GetServiceStatusParams) WithTimeout(timeout time.Duration) *GetServiceStatusParams { o.SetTimeout(timeout) diff --git a/client/client/cycloid/get_service_status_responses.go b/client/client/cycloid/get_service_status_responses.go index 06f804da..389f1c65 100644 --- a/client/client/cycloid/get_service_status_responses.go +++ b/client/client/cycloid/get_service_status_responses.go @@ -6,17 +6,18 @@ package cycloid // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetServiceStatusReader is a Reader for the GetServiceStatus structure. @@ -39,9 +40,8 @@ func (o *GetServiceStatusReader) ReadResponse(response runtime.ClientResponse, c return nil, err } return nil, result - default: - return nil, runtime.NewAPIError("unknown error", response, response.Code()) + return nil, runtime.NewAPIError("[GET /status/{service_status_canonical}] getServiceStatus", response, response.Code()) } } @@ -50,7 +50,8 @@ func NewGetServiceStatusOK() *GetServiceStatusOK { return &GetServiceStatusOK{} } -/*GetServiceStatusOK handles this case with default header values. +/* +GetServiceStatusOK describes a response with status code 200, with default header values. General application status and services statuses. */ @@ -58,8 +59,44 @@ type GetServiceStatusOK struct { Payload *GetServiceStatusOKBody } +// IsSuccess returns true when this get service status o k response has a 2xx status code +func (o *GetServiceStatusOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get service status o k response has a 3xx status code +func (o *GetServiceStatusOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service status o k response has a 4xx status code +func (o *GetServiceStatusOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service status o k response has a 5xx status code +func (o *GetServiceStatusOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get service status o k response a status code equal to that given +func (o *GetServiceStatusOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get service status o k response +func (o *GetServiceStatusOK) Code() int { + return 200 +} + func (o *GetServiceStatusOK) Error() string { - return fmt.Sprintf("[GET /status/{service_status_canonical}][%d] getServiceStatusOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status/{service_status_canonical}][%d] getServiceStatusOK %s", 200, payload) +} + +func (o *GetServiceStatusOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status/{service_status_canonical}][%d] getServiceStatusOK %s", 200, payload) } func (o *GetServiceStatusOK) GetPayload() *GetServiceStatusOKBody { @@ -83,20 +120,60 @@ func NewGetServiceStatusInternalServerError() *GetServiceStatusInternalServerErr return &GetServiceStatusInternalServerError{} } -/*GetServiceStatusInternalServerError handles this case with default header values. +/* +GetServiceStatusInternalServerError describes a response with status code 500, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetServiceStatusInternalServerError struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service status internal server error response has a 2xx status code +func (o *GetServiceStatusInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service status internal server error response has a 3xx status code +func (o *GetServiceStatusInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service status internal server error response has a 4xx status code +func (o *GetServiceStatusInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service status internal server error response has a 5xx status code +func (o *GetServiceStatusInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get service status internal server error response a status code equal to that given +func (o *GetServiceStatusInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get service status internal server error response +func (o *GetServiceStatusInternalServerError) Code() int { + return 500 +} + func (o *GetServiceStatusInternalServerError) Error() string { - return fmt.Sprintf("[GET /status/{service_status_canonical}][%d] getServiceStatusInternalServerError %+v", 500, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status/{service_status_canonical}][%d] getServiceStatusInternalServerError %s", 500, payload) +} + +func (o *GetServiceStatusInternalServerError) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status/{service_status_canonical}][%d] getServiceStatusInternalServerError %s", 500, payload) } func (o *GetServiceStatusInternalServerError) GetPayload() *models.ErrorPayload { @@ -105,12 +182,16 @@ func (o *GetServiceStatusInternalServerError) GetPayload() *models.ErrorPayload func (o *GetServiceStatusInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -122,7 +203,8 @@ func (o *GetServiceStatusInternalServerError) readResponse(response runtime.Clie return nil } -/*GetServiceStatusOKBody get service status o k body +/* +GetServiceStatusOKBody get service status o k body swagger:model GetServiceStatusOKBody */ type GetServiceStatusOKBody struct { @@ -156,6 +238,39 @@ func (o *GetServiceStatusOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getServiceStatusOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceStatusOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get service status o k body based on the context it is used +func (o *GetServiceStatusOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetServiceStatusOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getServiceStatusOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceStatusOK" + "." + "data") } return err } diff --git a/client/client/cycloid/get_status_parameters.go b/client/client/cycloid/get_status_parameters.go index 611be3cb..4e4ce6f4 100644 --- a/client/client/cycloid/get_status_parameters.go +++ b/client/client/cycloid/get_status_parameters.go @@ -13,51 +13,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetStatusParams creates a new GetStatusParams object -// with the default values initialized. +// NewGetStatusParams creates a new GetStatusParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetStatusParams() *GetStatusParams { - return &GetStatusParams{ - timeout: cr.DefaultTimeout, } } // NewGetStatusParamsWithTimeout creates a new GetStatusParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetStatusParamsWithTimeout(timeout time.Duration) *GetStatusParams { - return &GetStatusParams{ - timeout: timeout, } } // NewGetStatusParamsWithContext creates a new GetStatusParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetStatusParamsWithContext(ctx context.Context) *GetStatusParams { - return &GetStatusParams{ - Context: ctx, } } // NewGetStatusParamsWithHTTPClient creates a new GetStatusParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetStatusParamsWithHTTPClient(client *http.Client) *GetStatusParams { - return &GetStatusParams{ HTTPClient: client, } } -/*GetStatusParams contains all the parameters to send to the API endpoint -for the get status operation typically these are written to a http.Request +/* +GetStatusParams contains all the parameters to send to the API endpoint + + for the get status operation. + + Typically these are written to a http.Request. */ type GetStatusParams struct { timeout time.Duration @@ -65,6 +65,21 @@ type GetStatusParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get status params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetStatusParams) WithDefaults() *GetStatusParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get status params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetStatusParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get status params func (o *GetStatusParams) WithTimeout(timeout time.Duration) *GetStatusParams { o.SetTimeout(timeout) diff --git a/client/client/cycloid/get_status_responses.go b/client/client/cycloid/get_status_responses.go index 9652d7f5..abecdc77 100644 --- a/client/client/cycloid/get_status_responses.go +++ b/client/client/cycloid/get_status_responses.go @@ -6,17 +6,18 @@ package cycloid // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetStatusReader is a Reader for the GetStatus structure. @@ -56,7 +57,8 @@ func NewGetStatusOK() *GetStatusOK { return &GetStatusOK{} } -/*GetStatusOK handles this case with default header values. +/* +GetStatusOK describes a response with status code 200, with default header values. General application status and services statuses. */ @@ -64,8 +66,44 @@ type GetStatusOK struct { Payload *GetStatusOKBody } +// IsSuccess returns true when this get status o k response has a 2xx status code +func (o *GetStatusOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get status o k response has a 3xx status code +func (o *GetStatusOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get status o k response has a 4xx status code +func (o *GetStatusOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get status o k response has a 5xx status code +func (o *GetStatusOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get status o k response a status code equal to that given +func (o *GetStatusOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get status o k response +func (o *GetStatusOK) Code() int { + return 200 +} + func (o *GetStatusOK) Error() string { - return fmt.Sprintf("[GET /status][%d] getStatusOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status][%d] getStatusOK %s", 200, payload) +} + +func (o *GetStatusOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status][%d] getStatusOK %s", 200, payload) } func (o *GetStatusOK) GetPayload() *GetStatusOKBody { @@ -89,20 +127,60 @@ func NewGetStatusUnprocessableEntity() *GetStatusUnprocessableEntity { return &GetStatusUnprocessableEntity{} } -/*GetStatusUnprocessableEntity handles this case with default header values. +/* +GetStatusUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetStatusUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get status unprocessable entity response has a 2xx status code +func (o *GetStatusUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get status unprocessable entity response has a 3xx status code +func (o *GetStatusUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get status unprocessable entity response has a 4xx status code +func (o *GetStatusUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get status unprocessable entity response has a 5xx status code +func (o *GetStatusUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get status unprocessable entity response a status code equal to that given +func (o *GetStatusUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get status unprocessable entity response +func (o *GetStatusUnprocessableEntity) Code() int { + return 422 +} + func (o *GetStatusUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /status][%d] getStatusUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status][%d] getStatusUnprocessableEntity %s", 422, payload) +} + +func (o *GetStatusUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status][%d] getStatusUnprocessableEntity %s", 422, payload) } func (o *GetStatusUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -111,12 +189,16 @@ func (o *GetStatusUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetStatusUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -135,27 +217,61 @@ func NewGetStatusDefault(code int) *GetStatusDefault { } } -/*GetStatusDefault handles this case with default header values. +/* +GetStatusDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetStatusDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get status default response has a 2xx status code +func (o *GetStatusDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get status default response has a 3xx status code +func (o *GetStatusDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get status default response has a 4xx status code +func (o *GetStatusDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get status default response has a 5xx status code +func (o *GetStatusDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get status default response a status code equal to that given +func (o *GetStatusDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get status default response func (o *GetStatusDefault) Code() int { return o._statusCode } func (o *GetStatusDefault) Error() string { - return fmt.Sprintf("[GET /status][%d] getStatus default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status][%d] getStatus default %s", o._statusCode, payload) +} + +func (o *GetStatusDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /status][%d] getStatus default %s", o._statusCode, payload) } func (o *GetStatusDefault) GetPayload() *models.ErrorPayload { @@ -164,12 +280,16 @@ func (o *GetStatusDefault) GetPayload() *models.ErrorPayload { func (o *GetStatusDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -181,7 +301,8 @@ func (o *GetStatusDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*GetStatusOKBody get status o k body +/* +GetStatusOKBody get status o k body swagger:model GetStatusOKBody */ type GetStatusOKBody struct { @@ -215,6 +336,39 @@ func (o *GetStatusOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getStatusOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getStatusOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get status o k body based on the context it is used +func (o *GetStatusOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetStatusOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getStatusOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getStatusOK" + "." + "data") } return err } diff --git a/client/client/organization_api_keys/create_api_key_parameters.go b/client/client/organization_api_keys/create_api_key_parameters.go index 490c2f13..c7ce70ce 100644 --- a/client/client/organization_api_keys/create_api_key_parameters.go +++ b/client/client/organization_api_keys/create_api_key_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateAPIKeyParams creates a new CreateAPIKeyParams object -// with the default values initialized. +// NewCreateAPIKeyParams creates a new CreateAPIKeyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateAPIKeyParams() *CreateAPIKeyParams { - var () return &CreateAPIKeyParams{ - timeout: cr.DefaultTimeout, } } // NewCreateAPIKeyParamsWithTimeout creates a new CreateAPIKeyParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateAPIKeyParamsWithTimeout(timeout time.Duration) *CreateAPIKeyParams { - var () return &CreateAPIKeyParams{ - timeout: timeout, } } // NewCreateAPIKeyParamsWithContext creates a new CreateAPIKeyParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateAPIKeyParamsWithContext(ctx context.Context) *CreateAPIKeyParams { - var () return &CreateAPIKeyParams{ - Context: ctx, } } // NewCreateAPIKeyParamsWithHTTPClient creates a new CreateAPIKeyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateAPIKeyParamsWithHTTPClient(client *http.Client) *CreateAPIKeyParams { - var () return &CreateAPIKeyParams{ HTTPClient: client, } } -/*CreateAPIKeyParams contains all the parameters to send to the API endpoint -for the create API key operation typically these are written to a http.Request +/* +CreateAPIKeyParams contains all the parameters to send to the API endpoint + + for the create API key operation. + + Typically these are written to a http.Request. */ type CreateAPIKeyParams struct { - /*Body - The information of the API key to create. + /* Body. + The information of the API key to create. */ Body *models.NewAPIKey - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type CreateAPIKeyParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create API key params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateAPIKeyParams) WithDefaults() *CreateAPIKeyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create API key params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateAPIKeyParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create API key params func (o *CreateAPIKeyParams) WithTimeout(timeout time.Duration) *CreateAPIKeyParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CreateAPIKeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_api_keys/create_api_key_responses.go b/client/client/organization_api_keys/create_api_key_responses.go index 5eda8cde..8edbf46d 100644 --- a/client/client/organization_api_keys/create_api_key_responses.go +++ b/client/client/organization_api_keys/create_api_key_responses.go @@ -6,17 +6,18 @@ package organization_api_keys // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateAPIKeyReader is a Reader for the CreateAPIKey structure. @@ -68,7 +69,8 @@ func NewCreateAPIKeyOK() *CreateAPIKeyOK { return &CreateAPIKeyOK{} } -/*CreateAPIKeyOK handles this case with default header values. +/* +CreateAPIKeyOK describes a response with status code 200, with default header values. API key created. The body contains the information of the new API key of the organization. */ @@ -76,8 +78,44 @@ type CreateAPIKeyOK struct { Payload *CreateAPIKeyOKBody } +// IsSuccess returns true when this create Api key o k response has a 2xx status code +func (o *CreateAPIKeyOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create Api key o k response has a 3xx status code +func (o *CreateAPIKeyOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create Api key o k response has a 4xx status code +func (o *CreateAPIKeyOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create Api key o k response has a 5xx status code +func (o *CreateAPIKeyOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create Api key o k response a status code equal to that given +func (o *CreateAPIKeyOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create Api key o k response +func (o *CreateAPIKeyOK) Code() int { + return 200 +} + func (o *CreateAPIKeyOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyOK %s", 200, payload) +} + +func (o *CreateAPIKeyOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyOK %s", 200, payload) } func (o *CreateAPIKeyOK) GetPayload() *CreateAPIKeyOKBody { @@ -101,20 +139,60 @@ func NewCreateAPIKeyNotFound() *CreateAPIKeyNotFound { return &CreateAPIKeyNotFound{} } -/*CreateAPIKeyNotFound handles this case with default header values. +/* +CreateAPIKeyNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateAPIKeyNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create Api key not found response has a 2xx status code +func (o *CreateAPIKeyNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create Api key not found response has a 3xx status code +func (o *CreateAPIKeyNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create Api key not found response has a 4xx status code +func (o *CreateAPIKeyNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create Api key not found response has a 5xx status code +func (o *CreateAPIKeyNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create Api key not found response a status code equal to that given +func (o *CreateAPIKeyNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create Api key not found response +func (o *CreateAPIKeyNotFound) Code() int { + return 404 +} + func (o *CreateAPIKeyNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyNotFound %s", 404, payload) +} + +func (o *CreateAPIKeyNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyNotFound %s", 404, payload) } func (o *CreateAPIKeyNotFound) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *CreateAPIKeyNotFound) GetPayload() *models.ErrorPayload { func (o *CreateAPIKeyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,15 +227,50 @@ func NewCreateAPIKeyLengthRequired() *CreateAPIKeyLengthRequired { return &CreateAPIKeyLengthRequired{} } -/*CreateAPIKeyLengthRequired handles this case with default header values. +/* +CreateAPIKeyLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreateAPIKeyLengthRequired struct { } +// IsSuccess returns true when this create Api key length required response has a 2xx status code +func (o *CreateAPIKeyLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create Api key length required response has a 3xx status code +func (o *CreateAPIKeyLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create Api key length required response has a 4xx status code +func (o *CreateAPIKeyLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create Api key length required response has a 5xx status code +func (o *CreateAPIKeyLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create Api key length required response a status code equal to that given +func (o *CreateAPIKeyLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create Api key length required response +func (o *CreateAPIKeyLengthRequired) Code() int { + return 411 +} + func (o *CreateAPIKeyLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyLengthRequired", 411) +} + +func (o *CreateAPIKeyLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyLengthRequired", 411) } func (o *CreateAPIKeyLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -166,20 +283,60 @@ func NewCreateAPIKeyUnprocessableEntity() *CreateAPIKeyUnprocessableEntity { return &CreateAPIKeyUnprocessableEntity{} } -/*CreateAPIKeyUnprocessableEntity handles this case with default header values. +/* +CreateAPIKeyUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateAPIKeyUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create Api key unprocessable entity response has a 2xx status code +func (o *CreateAPIKeyUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create Api key unprocessable entity response has a 3xx status code +func (o *CreateAPIKeyUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create Api key unprocessable entity response has a 4xx status code +func (o *CreateAPIKeyUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create Api key unprocessable entity response has a 5xx status code +func (o *CreateAPIKeyUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create Api key unprocessable entity response a status code equal to that given +func (o *CreateAPIKeyUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create Api key unprocessable entity response +func (o *CreateAPIKeyUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateAPIKeyUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyUnprocessableEntity %s", 422, payload) +} + +func (o *CreateAPIKeyUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createApiKeyUnprocessableEntity %s", 422, payload) } func (o *CreateAPIKeyUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -188,12 +345,16 @@ func (o *CreateAPIKeyUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *CreateAPIKeyUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -212,27 +373,61 @@ func NewCreateAPIKeyDefault(code int) *CreateAPIKeyDefault { } } -/*CreateAPIKeyDefault handles this case with default header values. +/* +CreateAPIKeyDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateAPIKeyDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create API key default response has a 2xx status code +func (o *CreateAPIKeyDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create API key default response has a 3xx status code +func (o *CreateAPIKeyDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create API key default response has a 4xx status code +func (o *CreateAPIKeyDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create API key default response has a 5xx status code +func (o *CreateAPIKeyDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create API key default response a status code equal to that given +func (o *CreateAPIKeyDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create API key default response func (o *CreateAPIKeyDefault) Code() int { return o._statusCode } func (o *CreateAPIKeyDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createAPIKey default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createAPIKey default %s", o._statusCode, payload) +} + +func (o *CreateAPIKeyDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/api_keys][%d] createAPIKey default %s", o._statusCode, payload) } func (o *CreateAPIKeyDefault) GetPayload() *models.ErrorPayload { @@ -241,12 +436,16 @@ func (o *CreateAPIKeyDefault) GetPayload() *models.ErrorPayload { func (o *CreateAPIKeyDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -258,7 +457,8 @@ func (o *CreateAPIKeyDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*CreateAPIKeyOKBody create API key o k body +/* +CreateAPIKeyOKBody create API key o k body swagger:model CreateAPIKeyOKBody */ type CreateAPIKeyOKBody struct { @@ -292,6 +492,39 @@ func (o *CreateAPIKeyOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createApiKeyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createApiKeyOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create API key o k body based on the context it is used +func (o *CreateAPIKeyOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateAPIKeyOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createApiKeyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createApiKeyOK" + "." + "data") } return err } diff --git a/client/client/organization_api_keys/delete_api_key_parameters.go b/client/client/organization_api_keys/delete_api_key_parameters.go index 0f770bf2..6e3f9d3c 100644 --- a/client/client/organization_api_keys/delete_api_key_parameters.go +++ b/client/client/organization_api_keys/delete_api_key_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteAPIKeyParams creates a new DeleteAPIKeyParams object -// with the default values initialized. +// NewDeleteAPIKeyParams creates a new DeleteAPIKeyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteAPIKeyParams() *DeleteAPIKeyParams { - var () return &DeleteAPIKeyParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteAPIKeyParamsWithTimeout creates a new DeleteAPIKeyParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteAPIKeyParamsWithTimeout(timeout time.Duration) *DeleteAPIKeyParams { - var () return &DeleteAPIKeyParams{ - timeout: timeout, } } // NewDeleteAPIKeyParamsWithContext creates a new DeleteAPIKeyParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteAPIKeyParamsWithContext(ctx context.Context) *DeleteAPIKeyParams { - var () return &DeleteAPIKeyParams{ - Context: ctx, } } // NewDeleteAPIKeyParamsWithHTTPClient creates a new DeleteAPIKeyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteAPIKeyParamsWithHTTPClient(client *http.Client) *DeleteAPIKeyParams { - var () return &DeleteAPIKeyParams{ HTTPClient: client, } } -/*DeleteAPIKeyParams contains all the parameters to send to the API endpoint -for the delete API key operation typically these are written to a http.Request +/* +DeleteAPIKeyParams contains all the parameters to send to the API endpoint + + for the delete API key operation. + + Typically these are written to a http.Request. */ type DeleteAPIKeyParams struct { - /*APIKeyCanonical - A canonical of an API key. + /* APIKeyCanonical. + A canonical of an API key. */ APIKeyCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type DeleteAPIKeyParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete API key params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteAPIKeyParams) WithDefaults() *DeleteAPIKeyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete API key params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteAPIKeyParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete API key params func (o *DeleteAPIKeyParams) WithTimeout(timeout time.Duration) *DeleteAPIKeyParams { o.SetTimeout(timeout) diff --git a/client/client/organization_api_keys/delete_api_key_responses.go b/client/client/organization_api_keys/delete_api_key_responses.go index 641d47e1..800de972 100644 --- a/client/client/organization_api_keys/delete_api_key_responses.go +++ b/client/client/organization_api_keys/delete_api_key_responses.go @@ -6,16 +6,16 @@ package organization_api_keys // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteAPIKeyReader is a Reader for the DeleteAPIKey structure. @@ -61,15 +61,50 @@ func NewDeleteAPIKeyNoContent() *DeleteAPIKeyNoContent { return &DeleteAPIKeyNoContent{} } -/*DeleteAPIKeyNoContent handles this case with default header values. +/* +DeleteAPIKeyNoContent describes a response with status code 204, with default header values. API key has been deleted. */ type DeleteAPIKeyNoContent struct { } +// IsSuccess returns true when this delete Api key no content response has a 2xx status code +func (o *DeleteAPIKeyNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete Api key no content response has a 3xx status code +func (o *DeleteAPIKeyNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete Api key no content response has a 4xx status code +func (o *DeleteAPIKeyNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete Api key no content response has a 5xx status code +func (o *DeleteAPIKeyNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete Api key no content response a status code equal to that given +func (o *DeleteAPIKeyNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete Api key no content response +func (o *DeleteAPIKeyNoContent) Code() int { + return 204 +} + func (o *DeleteAPIKeyNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyNoContent", 204) +} + +func (o *DeleteAPIKeyNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyNoContent", 204) } func (o *DeleteAPIKeyNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteAPIKeyForbidden() *DeleteAPIKeyForbidden { return &DeleteAPIKeyForbidden{} } -/*DeleteAPIKeyForbidden handles this case with default header values. +/* +DeleteAPIKeyForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteAPIKeyForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete Api key forbidden response has a 2xx status code +func (o *DeleteAPIKeyForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete Api key forbidden response has a 3xx status code +func (o *DeleteAPIKeyForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete Api key forbidden response has a 4xx status code +func (o *DeleteAPIKeyForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete Api key forbidden response has a 5xx status code +func (o *DeleteAPIKeyForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete Api key forbidden response a status code equal to that given +func (o *DeleteAPIKeyForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete Api key forbidden response +func (o *DeleteAPIKeyForbidden) Code() int { + return 403 +} + func (o *DeleteAPIKeyForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyForbidden %s", 403, payload) +} + +func (o *DeleteAPIKeyForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyForbidden %s", 403, payload) } func (o *DeleteAPIKeyForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteAPIKeyForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteAPIKeyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteAPIKeyNotFound() *DeleteAPIKeyNotFound { return &DeleteAPIKeyNotFound{} } -/*DeleteAPIKeyNotFound handles this case with default header values. +/* +DeleteAPIKeyNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteAPIKeyNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete Api key not found response has a 2xx status code +func (o *DeleteAPIKeyNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete Api key not found response has a 3xx status code +func (o *DeleteAPIKeyNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete Api key not found response has a 4xx status code +func (o *DeleteAPIKeyNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete Api key not found response has a 5xx status code +func (o *DeleteAPIKeyNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete Api key not found response a status code equal to that given +func (o *DeleteAPIKeyNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete Api key not found response +func (o *DeleteAPIKeyNotFound) Code() int { + return 404 +} + func (o *DeleteAPIKeyNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyNotFound %s", 404, payload) +} + +func (o *DeleteAPIKeyNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteApiKeyNotFound %s", 404, payload) } func (o *DeleteAPIKeyNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteAPIKeyNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteAPIKeyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteAPIKeyDefault(code int) *DeleteAPIKeyDefault { } } -/*DeleteAPIKeyDefault handles this case with default header values. +/* +DeleteAPIKeyDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteAPIKeyDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete API key default response has a 2xx status code +func (o *DeleteAPIKeyDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete API key default response has a 3xx status code +func (o *DeleteAPIKeyDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete API key default response has a 4xx status code +func (o *DeleteAPIKeyDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete API key default response has a 5xx status code +func (o *DeleteAPIKeyDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete API key default response a status code equal to that given +func (o *DeleteAPIKeyDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete API key default response func (o *DeleteAPIKeyDefault) Code() int { return o._statusCode } func (o *DeleteAPIKeyDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteAPIKey default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteAPIKey default %s", o._statusCode, payload) +} + +func (o *DeleteAPIKeyDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] deleteAPIKey default %s", o._statusCode, payload) } func (o *DeleteAPIKeyDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteAPIKeyDefault) GetPayload() *models.ErrorPayload { func (o *DeleteAPIKeyDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_api_keys/get_api_key_parameters.go b/client/client/organization_api_keys/get_api_key_parameters.go index b310b079..c20c5246 100644 --- a/client/client/organization_api_keys/get_api_key_parameters.go +++ b/client/client/organization_api_keys/get_api_key_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetAPIKeyParams creates a new GetAPIKeyParams object -// with the default values initialized. +// NewGetAPIKeyParams creates a new GetAPIKeyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetAPIKeyParams() *GetAPIKeyParams { - var () return &GetAPIKeyParams{ - timeout: cr.DefaultTimeout, } } // NewGetAPIKeyParamsWithTimeout creates a new GetAPIKeyParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetAPIKeyParamsWithTimeout(timeout time.Duration) *GetAPIKeyParams { - var () return &GetAPIKeyParams{ - timeout: timeout, } } // NewGetAPIKeyParamsWithContext creates a new GetAPIKeyParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetAPIKeyParamsWithContext(ctx context.Context) *GetAPIKeyParams { - var () return &GetAPIKeyParams{ - Context: ctx, } } // NewGetAPIKeyParamsWithHTTPClient creates a new GetAPIKeyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetAPIKeyParamsWithHTTPClient(client *http.Client) *GetAPIKeyParams { - var () return &GetAPIKeyParams{ HTTPClient: client, } } -/*GetAPIKeyParams contains all the parameters to send to the API endpoint -for the get API key operation typically these are written to a http.Request +/* +GetAPIKeyParams contains all the parameters to send to the API endpoint + + for the get API key operation. + + Typically these are written to a http.Request. */ type GetAPIKeyParams struct { - /*APIKeyCanonical - A canonical of an API key. + /* APIKeyCanonical. + A canonical of an API key. */ APIKeyCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type GetAPIKeyParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get API key params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAPIKeyParams) WithDefaults() *GetAPIKeyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get API key params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAPIKeyParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get API key params func (o *GetAPIKeyParams) WithTimeout(timeout time.Duration) *GetAPIKeyParams { o.SetTimeout(timeout) diff --git a/client/client/organization_api_keys/get_api_key_responses.go b/client/client/organization_api_keys/get_api_key_responses.go index 4298ea60..cb972dc5 100644 --- a/client/client/organization_api_keys/get_api_key_responses.go +++ b/client/client/organization_api_keys/get_api_key_responses.go @@ -6,17 +6,18 @@ package organization_api_keys // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetAPIKeyReader is a Reader for the GetAPIKey structure. @@ -62,7 +63,8 @@ func NewGetAPIKeyOK() *GetAPIKeyOK { return &GetAPIKeyOK{} } -/*GetAPIKeyOK handles this case with default header values. +/* +GetAPIKeyOK describes a response with status code 200, with default header values. The information of the API key of the organization which has the specified canonical. */ @@ -70,8 +72,44 @@ type GetAPIKeyOK struct { Payload *GetAPIKeyOKBody } +// IsSuccess returns true when this get Api key o k response has a 2xx status code +func (o *GetAPIKeyOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get Api key o k response has a 3xx status code +func (o *GetAPIKeyOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get Api key o k response has a 4xx status code +func (o *GetAPIKeyOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get Api key o k response has a 5xx status code +func (o *GetAPIKeyOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get Api key o k response a status code equal to that given +func (o *GetAPIKeyOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get Api key o k response +func (o *GetAPIKeyOK) Code() int { + return 200 +} + func (o *GetAPIKeyOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyOK %s", 200, payload) +} + +func (o *GetAPIKeyOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyOK %s", 200, payload) } func (o *GetAPIKeyOK) GetPayload() *GetAPIKeyOKBody { @@ -95,20 +133,60 @@ func NewGetAPIKeyForbidden() *GetAPIKeyForbidden { return &GetAPIKeyForbidden{} } -/*GetAPIKeyForbidden handles this case with default header values. +/* +GetAPIKeyForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetAPIKeyForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get Api key forbidden response has a 2xx status code +func (o *GetAPIKeyForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get Api key forbidden response has a 3xx status code +func (o *GetAPIKeyForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get Api key forbidden response has a 4xx status code +func (o *GetAPIKeyForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get Api key forbidden response has a 5xx status code +func (o *GetAPIKeyForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get Api key forbidden response a status code equal to that given +func (o *GetAPIKeyForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get Api key forbidden response +func (o *GetAPIKeyForbidden) Code() int { + return 403 +} + func (o *GetAPIKeyForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyForbidden %s", 403, payload) +} + +func (o *GetAPIKeyForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyForbidden %s", 403, payload) } func (o *GetAPIKeyForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetAPIKeyForbidden) GetPayload() *models.ErrorPayload { func (o *GetAPIKeyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetAPIKeyNotFound() *GetAPIKeyNotFound { return &GetAPIKeyNotFound{} } -/*GetAPIKeyNotFound handles this case with default header values. +/* +GetAPIKeyNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetAPIKeyNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get Api key not found response has a 2xx status code +func (o *GetAPIKeyNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get Api key not found response has a 3xx status code +func (o *GetAPIKeyNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get Api key not found response has a 4xx status code +func (o *GetAPIKeyNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get Api key not found response has a 5xx status code +func (o *GetAPIKeyNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get Api key not found response a status code equal to that given +func (o *GetAPIKeyNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get Api key not found response +func (o *GetAPIKeyNotFound) Code() int { + return 404 +} + func (o *GetAPIKeyNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyNotFound %s", 404, payload) +} + +func (o *GetAPIKeyNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getApiKeyNotFound %s", 404, payload) } func (o *GetAPIKeyNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetAPIKeyNotFound) GetPayload() *models.ErrorPayload { func (o *GetAPIKeyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetAPIKeyDefault(code int) *GetAPIKeyDefault { } } -/*GetAPIKeyDefault handles this case with default header values. +/* +GetAPIKeyDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetAPIKeyDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get API key default response has a 2xx status code +func (o *GetAPIKeyDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get API key default response has a 3xx status code +func (o *GetAPIKeyDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get API key default response has a 4xx status code +func (o *GetAPIKeyDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get API key default response has a 5xx status code +func (o *GetAPIKeyDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get API key default response a status code equal to that given +func (o *GetAPIKeyDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get API key default response func (o *GetAPIKeyDefault) Code() int { return o._statusCode } func (o *GetAPIKeyDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getAPIKey default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getAPIKey default %s", o._statusCode, payload) +} + +func (o *GetAPIKeyDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] getAPIKey default %s", o._statusCode, payload) } func (o *GetAPIKeyDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetAPIKeyDefault) GetPayload() *models.ErrorPayload { func (o *GetAPIKeyDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetAPIKeyDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*GetAPIKeyOKBody get API key o k body +/* +GetAPIKeyOKBody get API key o k body swagger:model GetAPIKeyOKBody */ type GetAPIKeyOKBody struct { @@ -265,6 +430,39 @@ func (o *GetAPIKeyOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getApiKeyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getApiKeyOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get API key o k body based on the context it is used +func (o *GetAPIKeyOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetAPIKeyOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getApiKeyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getApiKeyOK" + "." + "data") } return err } diff --git a/client/client/organization_api_keys/get_api_keys_parameters.go b/client/client/organization_api_keys/get_api_keys_parameters.go index 15d9e3e0..ae4afb3f 100644 --- a/client/client/organization_api_keys/get_api_keys_parameters.go +++ b/client/client/organization_api_keys/get_api_keys_parameters.go @@ -13,93 +13,84 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetAPIKeysParams creates a new GetAPIKeysParams object -// with the default values initialized. +// NewGetAPIKeysParams creates a new GetAPIKeysParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetAPIKeysParams() *GetAPIKeysParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetAPIKeysParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetAPIKeysParamsWithTimeout creates a new GetAPIKeysParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetAPIKeysParamsWithTimeout(timeout time.Duration) *GetAPIKeysParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetAPIKeysParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetAPIKeysParamsWithContext creates a new GetAPIKeysParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetAPIKeysParamsWithContext(ctx context.Context) *GetAPIKeysParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetAPIKeysParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetAPIKeysParamsWithHTTPClient creates a new GetAPIKeysParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetAPIKeysParamsWithHTTPClient(client *http.Client) *GetAPIKeysParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetAPIKeysParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetAPIKeysParams contains all the parameters to send to the API endpoint -for the get API keys operation typically these are written to a http.Request +/* +GetAPIKeysParams contains all the parameters to send to the API endpoint + + for the get API keys operation. + + Typically these are written to a http.Request. */ type GetAPIKeysParams struct { - /*MemberID - Search by entity's owner + /* MemberID. + Search by entity's owner + + Format: uint32 */ MemberID *uint32 - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -108,6 +99,35 @@ type GetAPIKeysParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get API keys params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAPIKeysParams) WithDefaults() *GetAPIKeysParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get API keys params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAPIKeysParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetAPIKeysParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get API keys params func (o *GetAPIKeysParams) WithTimeout(timeout time.Duration) *GetAPIKeysParams { o.SetTimeout(timeout) @@ -197,16 +217,17 @@ func (o *GetAPIKeysParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re // query param member_id var qrMemberID uint32 + if o.MemberID != nil { qrMemberID = *o.MemberID } qMemberID := swag.FormatUint32(qrMemberID) if qMemberID != "" { + if err := r.SetQueryParam("member_id", qMemberID); err != nil { return err } } - } // path param organization_canonical @@ -218,32 +239,34 @@ func (o *GetAPIKeysParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_api_keys/get_api_keys_responses.go b/client/client/organization_api_keys/get_api_keys_responses.go index 5d76a884..3b5120ce 100644 --- a/client/client/organization_api_keys/get_api_keys_responses.go +++ b/client/client/organization_api_keys/get_api_keys_responses.go @@ -6,18 +6,19 @@ package organization_api_keys // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetAPIKeysReader is a Reader for the GetAPIKeys structure. @@ -69,7 +70,8 @@ func NewGetAPIKeysOK() *GetAPIKeysOK { return &GetAPIKeysOK{} } -/*GetAPIKeysOK handles this case with default header values. +/* +GetAPIKeysOK describes a response with status code 200, with default header values. List of the API keys which the organization has. */ @@ -77,8 +79,44 @@ type GetAPIKeysOK struct { Payload *GetAPIKeysOKBody } +// IsSuccess returns true when this get Api keys o k response has a 2xx status code +func (o *GetAPIKeysOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get Api keys o k response has a 3xx status code +func (o *GetAPIKeysOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get Api keys o k response has a 4xx status code +func (o *GetAPIKeysOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get Api keys o k response has a 5xx status code +func (o *GetAPIKeysOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get Api keys o k response a status code equal to that given +func (o *GetAPIKeysOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get Api keys o k response +func (o *GetAPIKeysOK) Code() int { + return 200 +} + func (o *GetAPIKeysOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysOK %s", 200, payload) +} + +func (o *GetAPIKeysOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysOK %s", 200, payload) } func (o *GetAPIKeysOK) GetPayload() *GetAPIKeysOKBody { @@ -102,20 +140,60 @@ func NewGetAPIKeysForbidden() *GetAPIKeysForbidden { return &GetAPIKeysForbidden{} } -/*GetAPIKeysForbidden handles this case with default header values. +/* +GetAPIKeysForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetAPIKeysForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get Api keys forbidden response has a 2xx status code +func (o *GetAPIKeysForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get Api keys forbidden response has a 3xx status code +func (o *GetAPIKeysForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get Api keys forbidden response has a 4xx status code +func (o *GetAPIKeysForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get Api keys forbidden response has a 5xx status code +func (o *GetAPIKeysForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get Api keys forbidden response a status code equal to that given +func (o *GetAPIKeysForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get Api keys forbidden response +func (o *GetAPIKeysForbidden) Code() int { + return 403 +} + func (o *GetAPIKeysForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysForbidden %s", 403, payload) +} + +func (o *GetAPIKeysForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysForbidden %s", 403, payload) } func (o *GetAPIKeysForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetAPIKeysForbidden) GetPayload() *models.ErrorPayload { func (o *GetAPIKeysForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetAPIKeysNotFound() *GetAPIKeysNotFound { return &GetAPIKeysNotFound{} } -/*GetAPIKeysNotFound handles this case with default header values. +/* +GetAPIKeysNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetAPIKeysNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get Api keys not found response has a 2xx status code +func (o *GetAPIKeysNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get Api keys not found response has a 3xx status code +func (o *GetAPIKeysNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get Api keys not found response has a 4xx status code +func (o *GetAPIKeysNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get Api keys not found response has a 5xx status code +func (o *GetAPIKeysNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get Api keys not found response a status code equal to that given +func (o *GetAPIKeysNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get Api keys not found response +func (o *GetAPIKeysNotFound) Code() int { + return 404 +} + func (o *GetAPIKeysNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysNotFound %s", 404, payload) +} + +func (o *GetAPIKeysNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysNotFound %s", 404, payload) } func (o *GetAPIKeysNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetAPIKeysNotFound) GetPayload() *models.ErrorPayload { func (o *GetAPIKeysNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetAPIKeysUnprocessableEntity() *GetAPIKeysUnprocessableEntity { return &GetAPIKeysUnprocessableEntity{} } -/*GetAPIKeysUnprocessableEntity handles this case with default header values. +/* +GetAPIKeysUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetAPIKeysUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get Api keys unprocessable entity response has a 2xx status code +func (o *GetAPIKeysUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get Api keys unprocessable entity response has a 3xx status code +func (o *GetAPIKeysUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get Api keys unprocessable entity response has a 4xx status code +func (o *GetAPIKeysUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get Api keys unprocessable entity response has a 5xx status code +func (o *GetAPIKeysUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get Api keys unprocessable entity response a status code equal to that given +func (o *GetAPIKeysUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get Api keys unprocessable entity response +func (o *GetAPIKeysUnprocessableEntity) Code() int { + return 422 +} + func (o *GetAPIKeysUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysUnprocessableEntity %s", 422, payload) +} + +func (o *GetAPIKeysUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getApiKeysUnprocessableEntity %s", 422, payload) } func (o *GetAPIKeysUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetAPIKeysUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetAPIKeysUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetAPIKeysDefault(code int) *GetAPIKeysDefault { } } -/*GetAPIKeysDefault handles this case with default header values. +/* +GetAPIKeysDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetAPIKeysDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get API keys default response has a 2xx status code +func (o *GetAPIKeysDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get API keys default response has a 3xx status code +func (o *GetAPIKeysDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get API keys default response has a 4xx status code +func (o *GetAPIKeysDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get API keys default response has a 5xx status code +func (o *GetAPIKeysDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get API keys default response a status code equal to that given +func (o *GetAPIKeysDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get API keys default response func (o *GetAPIKeysDefault) Code() int { return o._statusCode } func (o *GetAPIKeysDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getAPIKeys default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getAPIKeys default %s", o._statusCode, payload) +} + +func (o *GetAPIKeysDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/api_keys][%d] getAPIKeys default %s", o._statusCode, payload) } func (o *GetAPIKeysDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetAPIKeysDefault) GetPayload() *models.ErrorPayload { func (o *GetAPIKeysDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetAPIKeysDefault) readResponse(response runtime.ClientResponse, consum return nil } -/*GetAPIKeysOKBody get API keys o k body +/* +GetAPIKeysOKBody get API keys o k body swagger:model GetAPIKeysOKBody */ type GetAPIKeysOKBody struct { @@ -329,6 +538,8 @@ func (o *GetAPIKeysOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getApiKeysOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getApiKeysOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -349,6 +560,68 @@ func (o *GetAPIKeysOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getApiKeysOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getApiKeysOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get API keys o k body based on the context it is used +func (o *GetAPIKeysOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetAPIKeysOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getApiKeysOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getApiKeysOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetAPIKeysOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getApiKeysOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getApiKeysOK" + "." + "pagination") } return err } diff --git a/client/client/organization_api_keys/organization_api_keys_client.go b/client/client/organization_api_keys/organization_api_keys_client.go index dad3ab57..e0e99302 100644 --- a/client/client/organization_api_keys/organization_api_keys_client.go +++ b/client/client/organization_api_keys/organization_api_keys_client.go @@ -7,15 +7,40 @@ package organization_api_keys import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization api keys API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization api keys API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization api keys API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization api keys API */ @@ -24,16 +49,82 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateAPIKey(params *CreateAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateAPIKeyOK, error) + + DeleteAPIKey(params *DeleteAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteAPIKeyNoContent, error) + + GetAPIKey(params *GetAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIKeyOK, error) + + GetAPIKeys(params *GetAPIKeysParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIKeysOK, error) + + UpdateAPIkey(params *UpdateAPIkeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateAPIkeyOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateAPIKey Create a new API key in the organization. */ -func (a *Client) CreateAPIKey(params *CreateAPIKeyParams, authInfo runtime.ClientAuthInfoWriter) (*CreateAPIKeyOK, error) { +func (a *Client) CreateAPIKey(params *CreateAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateAPIKeyOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateAPIKeyParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createAPIKey", Method: "POST", PathPattern: "/organizations/{organization_canonical}/api_keys", @@ -45,7 +136,12 @@ func (a *Client) CreateAPIKey(params *CreateAPIKeyParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +157,12 @@ func (a *Client) CreateAPIKey(params *CreateAPIKeyParams, authInfo runtime.Clien /* DeleteAPIKey Delete an API key of the organization. */ -func (a *Client) DeleteAPIKey(params *DeleteAPIKeyParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteAPIKeyNoContent, error) { +func (a *Client) DeleteAPIKey(params *DeleteAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteAPIKeyNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteAPIKeyParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteAPIKey", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/api_keys/{api_key_canonical}", @@ -79,7 +174,12 @@ func (a *Client) DeleteAPIKey(params *DeleteAPIKeyParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +195,12 @@ func (a *Client) DeleteAPIKey(params *DeleteAPIKeyParams, authInfo runtime.Clien /* GetAPIKey Get an API key of the organization. */ -func (a *Client) GetAPIKey(params *GetAPIKeyParams, authInfo runtime.ClientAuthInfoWriter) (*GetAPIKeyOK, error) { +func (a *Client) GetAPIKey(params *GetAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIKeyOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetAPIKeyParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getAPIKey", Method: "GET", PathPattern: "/organizations/{organization_canonical}/api_keys/{api_key_canonical}", @@ -113,7 +212,12 @@ func (a *Client) GetAPIKey(params *GetAPIKeyParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +233,12 @@ func (a *Client) GetAPIKey(params *GetAPIKeyParams, authInfo runtime.ClientAuthI /* GetAPIKeys Get list of API keys of the organization. */ -func (a *Client) GetAPIKeys(params *GetAPIKeysParams, authInfo runtime.ClientAuthInfoWriter) (*GetAPIKeysOK, error) { +func (a *Client) GetAPIKeys(params *GetAPIKeysParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAPIKeysOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetAPIKeysParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getAPIKeys", Method: "GET", PathPattern: "/organizations/{organization_canonical}/api_keys", @@ -147,7 +250,12 @@ func (a *Client) GetAPIKeys(params *GetAPIKeysParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +271,12 @@ func (a *Client) GetAPIKeys(params *GetAPIKeysParams, authInfo runtime.ClientAut /* UpdateAPIkey Update the information of an API key of the organization. If the API key has some information on the fields which aren't required and they are not sent or set to their default values, which depend of their types, the information will be removed. */ -func (a *Client) UpdateAPIkey(params *UpdateAPIkeyParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateAPIkeyOK, error) { +func (a *Client) UpdateAPIkey(params *UpdateAPIkeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateAPIkeyOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateAPIkeyParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateAPIkey", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/api_keys/{api_key_canonical}", @@ -181,7 +288,12 @@ func (a *Client) UpdateAPIkey(params *UpdateAPIkeyParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_api_keys/update_a_p_ikey_parameters.go b/client/client/organization_api_keys/update_a_p_ikey_parameters.go index 2ff44dfa..b4edb190 100644 --- a/client/client/organization_api_keys/update_a_p_ikey_parameters.go +++ b/client/client/organization_api_keys/update_a_p_ikey_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateAPIkeyParams creates a new UpdateAPIkeyParams object -// with the default values initialized. +// NewUpdateAPIkeyParams creates a new UpdateAPIkeyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateAPIkeyParams() *UpdateAPIkeyParams { - var () return &UpdateAPIkeyParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateAPIkeyParamsWithTimeout creates a new UpdateAPIkeyParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateAPIkeyParamsWithTimeout(timeout time.Duration) *UpdateAPIkeyParams { - var () return &UpdateAPIkeyParams{ - timeout: timeout, } } // NewUpdateAPIkeyParamsWithContext creates a new UpdateAPIkeyParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateAPIkeyParamsWithContext(ctx context.Context) *UpdateAPIkeyParams { - var () return &UpdateAPIkeyParams{ - Context: ctx, } } // NewUpdateAPIkeyParamsWithHTTPClient creates a new UpdateAPIkeyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateAPIkeyParamsWithHTTPClient(client *http.Client) *UpdateAPIkeyParams { - var () return &UpdateAPIkeyParams{ HTTPClient: client, } } -/*UpdateAPIkeyParams contains all the parameters to send to the API endpoint -for the update a p ikey operation typically these are written to a http.Request +/* +UpdateAPIkeyParams contains all the parameters to send to the API endpoint + + for the update a p ikey operation. + + Typically these are written to a http.Request. */ type UpdateAPIkeyParams struct { - /*APIKeyCanonical - A canonical of an API key. + /* APIKeyCanonical. + A canonical of an API key. */ APIKeyCanonical string - /*Body - The information of the API key to update. + /* Body. + + The information of the API key to update. */ Body *models.UpdateAPIKey - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -84,6 +86,21 @@ type UpdateAPIkeyParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update a p ikey params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateAPIkeyParams) WithDefaults() *UpdateAPIkeyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update a p ikey params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateAPIkeyParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update a p ikey params func (o *UpdateAPIkeyParams) WithTimeout(timeout time.Duration) *UpdateAPIkeyParams { o.SetTimeout(timeout) @@ -162,7 +179,6 @@ func (o *UpdateAPIkeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. if err := r.SetPathParam("api_key_canonical", o.APIKeyCanonical); err != nil { return err } - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_api_keys/update_a_p_ikey_responses.go b/client/client/organization_api_keys/update_a_p_ikey_responses.go index 600d0a07..4d2b4995 100644 --- a/client/client/organization_api_keys/update_a_p_ikey_responses.go +++ b/client/client/organization_api_keys/update_a_p_ikey_responses.go @@ -6,17 +6,18 @@ package organization_api_keys // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateAPIkeyReader is a Reader for the UpdateAPIkey structure. @@ -74,7 +75,8 @@ func NewUpdateAPIkeyOK() *UpdateAPIkeyOK { return &UpdateAPIkeyOK{} } -/*UpdateAPIkeyOK handles this case with default header values. +/* +UpdateAPIkeyOK describes a response with status code 200, with default header values. API ey updated. The body contains information of the updated API key. */ @@ -82,8 +84,44 @@ type UpdateAPIkeyOK struct { Payload *UpdateAPIkeyOKBody } +// IsSuccess returns true when this update a p ikey o k response has a 2xx status code +func (o *UpdateAPIkeyOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update a p ikey o k response has a 3xx status code +func (o *UpdateAPIkeyOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update a p ikey o k response has a 4xx status code +func (o *UpdateAPIkeyOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update a p ikey o k response has a 5xx status code +func (o *UpdateAPIkeyOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update a p ikey o k response a status code equal to that given +func (o *UpdateAPIkeyOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update a p ikey o k response +func (o *UpdateAPIkeyOK) Code() int { + return 200 +} + func (o *UpdateAPIkeyOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyOK %s", 200, payload) +} + +func (o *UpdateAPIkeyOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyOK %s", 200, payload) } func (o *UpdateAPIkeyOK) GetPayload() *UpdateAPIkeyOKBody { @@ -107,20 +145,60 @@ func NewUpdateAPIkeyForbidden() *UpdateAPIkeyForbidden { return &UpdateAPIkeyForbidden{} } -/*UpdateAPIkeyForbidden handles this case with default header values. +/* +UpdateAPIkeyForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateAPIkeyForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update a p ikey forbidden response has a 2xx status code +func (o *UpdateAPIkeyForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update a p ikey forbidden response has a 3xx status code +func (o *UpdateAPIkeyForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update a p ikey forbidden response has a 4xx status code +func (o *UpdateAPIkeyForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update a p ikey forbidden response has a 5xx status code +func (o *UpdateAPIkeyForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update a p ikey forbidden response a status code equal to that given +func (o *UpdateAPIkeyForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update a p ikey forbidden response +func (o *UpdateAPIkeyForbidden) Code() int { + return 403 +} + func (o *UpdateAPIkeyForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyForbidden %s", 403, payload) +} + +func (o *UpdateAPIkeyForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyForbidden %s", 403, payload) } func (o *UpdateAPIkeyForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *UpdateAPIkeyForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateAPIkeyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewUpdateAPIkeyNotFound() *UpdateAPIkeyNotFound { return &UpdateAPIkeyNotFound{} } -/*UpdateAPIkeyNotFound handles this case with default header values. +/* +UpdateAPIkeyNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateAPIkeyNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update a p ikey not found response has a 2xx status code +func (o *UpdateAPIkeyNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update a p ikey not found response has a 3xx status code +func (o *UpdateAPIkeyNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update a p ikey not found response has a 4xx status code +func (o *UpdateAPIkeyNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update a p ikey not found response has a 5xx status code +func (o *UpdateAPIkeyNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update a p ikey not found response a status code equal to that given +func (o *UpdateAPIkeyNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update a p ikey not found response +func (o *UpdateAPIkeyNotFound) Code() int { + return 404 +} + func (o *UpdateAPIkeyNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyNotFound %s", 404, payload) +} + +func (o *UpdateAPIkeyNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyNotFound %s", 404, payload) } func (o *UpdateAPIkeyNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *UpdateAPIkeyNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateAPIkeyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewUpdateAPIkeyLengthRequired() *UpdateAPIkeyLengthRequired { return &UpdateAPIkeyLengthRequired{} } -/*UpdateAPIkeyLengthRequired handles this case with default header values. +/* +UpdateAPIkeyLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateAPIkeyLengthRequired struct { } +// IsSuccess returns true when this update a p ikey length required response has a 2xx status code +func (o *UpdateAPIkeyLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update a p ikey length required response has a 3xx status code +func (o *UpdateAPIkeyLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update a p ikey length required response has a 4xx status code +func (o *UpdateAPIkeyLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update a p ikey length required response has a 5xx status code +func (o *UpdateAPIkeyLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update a p ikey length required response a status code equal to that given +func (o *UpdateAPIkeyLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update a p ikey length required response +func (o *UpdateAPIkeyLengthRequired) Code() int { + return 411 +} + func (o *UpdateAPIkeyLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyLengthRequired", 411) +} + +func (o *UpdateAPIkeyLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyLengthRequired", 411) } func (o *UpdateAPIkeyLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewUpdateAPIkeyUnprocessableEntity() *UpdateAPIkeyUnprocessableEntity { return &UpdateAPIkeyUnprocessableEntity{} } -/*UpdateAPIkeyUnprocessableEntity handles this case with default header values. +/* +UpdateAPIkeyUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateAPIkeyUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update a p ikey unprocessable entity response has a 2xx status code +func (o *UpdateAPIkeyUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update a p ikey unprocessable entity response has a 3xx status code +func (o *UpdateAPIkeyUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update a p ikey unprocessable entity response has a 4xx status code +func (o *UpdateAPIkeyUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update a p ikey unprocessable entity response has a 5xx status code +func (o *UpdateAPIkeyUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update a p ikey unprocessable entity response a status code equal to that given +func (o *UpdateAPIkeyUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update a p ikey unprocessable entity response +func (o *UpdateAPIkeyUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateAPIkeyUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateAPIkeyUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkeyUnprocessableEntity %s", 422, payload) } func (o *UpdateAPIkeyUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *UpdateAPIkeyUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *UpdateAPIkeyUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewUpdateAPIkeyDefault(code int) *UpdateAPIkeyDefault { } } -/*UpdateAPIkeyDefault handles this case with default header values. +/* +UpdateAPIkeyDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateAPIkeyDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update a p ikey default response has a 2xx status code +func (o *UpdateAPIkeyDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update a p ikey default response has a 3xx status code +func (o *UpdateAPIkeyDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update a p ikey default response has a 4xx status code +func (o *UpdateAPIkeyDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update a p ikey default response has a 5xx status code +func (o *UpdateAPIkeyDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update a p ikey default response a status code equal to that given +func (o *UpdateAPIkeyDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update a p ikey default response func (o *UpdateAPIkeyDefault) Code() int { return o._statusCode } func (o *UpdateAPIkeyDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkey default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkey default %s", o._statusCode, payload) +} + +func (o *UpdateAPIkeyDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/api_keys/{api_key_canonical}][%d] updateAPIkey default %s", o._statusCode, payload) } func (o *UpdateAPIkeyDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *UpdateAPIkeyDefault) GetPayload() *models.ErrorPayload { func (o *UpdateAPIkeyDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *UpdateAPIkeyDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*UpdateAPIkeyOKBody update a p ikey o k body +/* +UpdateAPIkeyOKBody update a p ikey o k body swagger:model UpdateAPIkeyOKBody */ type UpdateAPIkeyOKBody struct { @@ -342,6 +586,39 @@ func (o *UpdateAPIkeyOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateAPIkeyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateAPIkeyOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update a p ikey o k body based on the context it is used +func (o *UpdateAPIkeyOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateAPIkeyOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateAPIkeyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateAPIkeyOK" + "." + "data") } return err } diff --git a/client/client/organization_children/create_child_parameters.go b/client/client/organization_children/create_child_parameters.go index cbb58e06..753d09fe 100644 --- a/client/client/organization_children/create_child_parameters.go +++ b/client/client/organization_children/create_child_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateChildParams creates a new CreateChildParams object -// with the default values initialized. +// NewCreateChildParams creates a new CreateChildParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateChildParams() *CreateChildParams { - var () return &CreateChildParams{ - timeout: cr.DefaultTimeout, } } // NewCreateChildParamsWithTimeout creates a new CreateChildParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateChildParamsWithTimeout(timeout time.Duration) *CreateChildParams { - var () return &CreateChildParams{ - timeout: timeout, } } // NewCreateChildParamsWithContext creates a new CreateChildParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateChildParamsWithContext(ctx context.Context) *CreateChildParams { - var () return &CreateChildParams{ - Context: ctx, } } // NewCreateChildParamsWithHTTPClient creates a new CreateChildParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateChildParamsWithHTTPClient(client *http.Client) *CreateChildParams { - var () return &CreateChildParams{ HTTPClient: client, } } -/*CreateChildParams contains all the parameters to send to the API endpoint -for the create child operation typically these are written to a http.Request +/* +CreateChildParams contains all the parameters to send to the API endpoint + + for the create child operation. + + Typically these are written to a http.Request. */ type CreateChildParams struct { - /*Body - The information of the organization to create. + /* Body. + The information of the organization to create. */ Body *models.NewOrganization - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type CreateChildParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create child params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateChildParams) WithDefaults() *CreateChildParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create child params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateChildParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create child params func (o *CreateChildParams) WithTimeout(timeout time.Duration) *CreateChildParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CreateChildParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_children/create_child_responses.go b/client/client/organization_children/create_child_responses.go index caac5b53..b8c81392 100644 --- a/client/client/organization_children/create_child_responses.go +++ b/client/client/organization_children/create_child_responses.go @@ -6,17 +6,18 @@ package organization_children // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateChildReader is a Reader for the CreateChild structure. @@ -33,9 +34,8 @@ func (o *CreateChildReader) ReadResponse(response runtime.ClientResponse, consum return nil, err } return result, nil - default: - return nil, runtime.NewAPIError("unknown error", response, response.Code()) + return nil, runtime.NewAPIError("[POST /organizations/{organization_canonical}/children] createChild", response, response.Code()) } } @@ -44,7 +44,8 @@ func NewCreateChildOK() *CreateChildOK { return &CreateChildOK{} } -/*CreateChildOK handles this case with default header values. +/* +CreateChildOK describes a response with status code 200, with default header values. Organization created. The body contains the information of the new created organization. */ @@ -52,8 +53,44 @@ type CreateChildOK struct { Payload *CreateChildOKBody } +// IsSuccess returns true when this create child o k response has a 2xx status code +func (o *CreateChildOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create child o k response has a 3xx status code +func (o *CreateChildOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create child o k response has a 4xx status code +func (o *CreateChildOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create child o k response has a 5xx status code +func (o *CreateChildOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create child o k response a status code equal to that given +func (o *CreateChildOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create child o k response +func (o *CreateChildOK) Code() int { + return 200 +} + func (o *CreateChildOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/children][%d] createChildOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/children][%d] createChildOK %s", 200, payload) +} + +func (o *CreateChildOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/children][%d] createChildOK %s", 200, payload) } func (o *CreateChildOK) GetPayload() *CreateChildOKBody { @@ -72,7 +109,8 @@ func (o *CreateChildOK) readResponse(response runtime.ClientResponse, consumer r return nil } -/*CreateChildOKBody create child o k body +/* +CreateChildOKBody create child o k body swagger:model CreateChildOKBody */ type CreateChildOKBody struct { @@ -106,6 +144,39 @@ func (o *CreateChildOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createChildOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createChildOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create child o k body based on the context it is used +func (o *CreateChildOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateChildOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createChildOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createChildOK" + "." + "data") } return err } diff --git a/client/client/organization_children/get_children_parameters.go b/client/client/organization_children/get_children_parameters.go index 45e907c7..31569d17 100644 --- a/client/client/organization_children/get_children_parameters.go +++ b/client/client/organization_children/get_children_parameters.go @@ -13,104 +13,97 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetChildrenParams creates a new GetChildrenParams object -// with the default values initialized. +// NewGetChildrenParams creates a new GetChildrenParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetChildrenParams() *GetChildrenParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetChildrenParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetChildrenParamsWithTimeout creates a new GetChildrenParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetChildrenParamsWithTimeout(timeout time.Duration) *GetChildrenParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetChildrenParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetChildrenParamsWithContext creates a new GetChildrenParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetChildrenParamsWithContext(ctx context.Context) *GetChildrenParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetChildrenParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetChildrenParamsWithHTTPClient creates a new GetChildrenParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetChildrenParamsWithHTTPClient(client *http.Client) *GetChildrenParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetChildrenParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetChildrenParams contains all the parameters to send to the API endpoint -for the get children operation typically these are written to a http.Request +/* +GetChildrenParams contains all the parameters to send to the API endpoint + + for the get children operation. + + Typically these are written to a http.Request. */ type GetChildrenParams struct { - /*OrderBy - Allows to order the list of items. Example usage: field_name:asc + /* OrderBy. + Allows to order the list of items. Example usage: field_name:asc */ OrderBy *string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*OrganizationCreatedAt - Search by organization's creation date + /* OrganizationCreatedAt. + + Search by organization's creation date + + Format: date-time */ OrganizationCreatedAt *strfmt.DateTime - /*OrganizationName - Search by the organization's name + /* OrganizationName. + + Search by the organization's name */ OrganizationName *string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -119,6 +112,35 @@ type GetChildrenParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get children params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetChildrenParams) WithDefaults() *GetChildrenParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get children params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetChildrenParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetChildrenParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get children params func (o *GetChildrenParams) WithTimeout(timeout time.Duration) *GetChildrenParams { o.SetTimeout(timeout) @@ -230,16 +252,17 @@ func (o *GetChildrenParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R // query param order_by var qrOrderBy string + if o.OrderBy != nil { qrOrderBy = *o.OrderBy } qOrderBy := qrOrderBy if qOrderBy != "" { + if err := r.SetQueryParam("order_by", qOrderBy); err != nil { return err } } - } // path param organization_canonical @@ -251,64 +274,68 @@ func (o *GetChildrenParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R // query param organization_created_at var qrOrganizationCreatedAt strfmt.DateTime + if o.OrganizationCreatedAt != nil { qrOrganizationCreatedAt = *o.OrganizationCreatedAt } qOrganizationCreatedAt := qrOrganizationCreatedAt.String() if qOrganizationCreatedAt != "" { + if err := r.SetQueryParam("organization_created_at", qOrganizationCreatedAt); err != nil { return err } } - } if o.OrganizationName != nil { // query param organization_name var qrOrganizationName string + if o.OrganizationName != nil { qrOrganizationName = *o.OrganizationName } qOrganizationName := qrOrganizationName if qOrganizationName != "" { + if err := r.SetQueryParam("organization_name", qOrganizationName); err != nil { return err } } - } if o.PageIndex != nil { // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_children/get_children_responses.go b/client/client/organization_children/get_children_responses.go index 3e556f02..d442d08a 100644 --- a/client/client/organization_children/get_children_responses.go +++ b/client/client/organization_children/get_children_responses.go @@ -6,18 +6,19 @@ package organization_children // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetChildrenReader is a Reader for the GetChildren structure. @@ -69,7 +70,8 @@ func NewGetChildrenOK() *GetChildrenOK { return &GetChildrenOK{} } -/*GetChildrenOK handles this case with default header values. +/* +GetChildrenOK describes a response with status code 200, with default header values. List of the children organizations which the authenticated user has access. */ @@ -77,8 +79,44 @@ type GetChildrenOK struct { Payload *GetChildrenOKBody } +// IsSuccess returns true when this get children o k response has a 2xx status code +func (o *GetChildrenOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get children o k response has a 3xx status code +func (o *GetChildrenOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get children o k response has a 4xx status code +func (o *GetChildrenOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get children o k response has a 5xx status code +func (o *GetChildrenOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get children o k response a status code equal to that given +func (o *GetChildrenOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get children o k response +func (o *GetChildrenOK) Code() int { + return 200 +} + func (o *GetChildrenOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenOK %s", 200, payload) +} + +func (o *GetChildrenOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenOK %s", 200, payload) } func (o *GetChildrenOK) GetPayload() *GetChildrenOKBody { @@ -102,20 +140,60 @@ func NewGetChildrenForbidden() *GetChildrenForbidden { return &GetChildrenForbidden{} } -/*GetChildrenForbidden handles this case with default header values. +/* +GetChildrenForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetChildrenForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get children forbidden response has a 2xx status code +func (o *GetChildrenForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get children forbidden response has a 3xx status code +func (o *GetChildrenForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get children forbidden response has a 4xx status code +func (o *GetChildrenForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get children forbidden response has a 5xx status code +func (o *GetChildrenForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get children forbidden response a status code equal to that given +func (o *GetChildrenForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get children forbidden response +func (o *GetChildrenForbidden) Code() int { + return 403 +} + func (o *GetChildrenForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenForbidden %s", 403, payload) +} + +func (o *GetChildrenForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenForbidden %s", 403, payload) } func (o *GetChildrenForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetChildrenForbidden) GetPayload() *models.ErrorPayload { func (o *GetChildrenForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetChildrenNotFound() *GetChildrenNotFound { return &GetChildrenNotFound{} } -/*GetChildrenNotFound handles this case with default header values. +/* +GetChildrenNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetChildrenNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get children not found response has a 2xx status code +func (o *GetChildrenNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get children not found response has a 3xx status code +func (o *GetChildrenNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get children not found response has a 4xx status code +func (o *GetChildrenNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get children not found response has a 5xx status code +func (o *GetChildrenNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get children not found response a status code equal to that given +func (o *GetChildrenNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get children not found response +func (o *GetChildrenNotFound) Code() int { + return 404 +} + func (o *GetChildrenNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenNotFound %s", 404, payload) +} + +func (o *GetChildrenNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenNotFound %s", 404, payload) } func (o *GetChildrenNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetChildrenNotFound) GetPayload() *models.ErrorPayload { func (o *GetChildrenNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetChildrenUnprocessableEntity() *GetChildrenUnprocessableEntity { return &GetChildrenUnprocessableEntity{} } -/*GetChildrenUnprocessableEntity handles this case with default header values. +/* +GetChildrenUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetChildrenUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get children unprocessable entity response has a 2xx status code +func (o *GetChildrenUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get children unprocessable entity response has a 3xx status code +func (o *GetChildrenUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get children unprocessable entity response has a 4xx status code +func (o *GetChildrenUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get children unprocessable entity response has a 5xx status code +func (o *GetChildrenUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get children unprocessable entity response a status code equal to that given +func (o *GetChildrenUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get children unprocessable entity response +func (o *GetChildrenUnprocessableEntity) Code() int { + return 422 +} + func (o *GetChildrenUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenUnprocessableEntity %s", 422, payload) +} + +func (o *GetChildrenUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildrenUnprocessableEntity %s", 422, payload) } func (o *GetChildrenUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetChildrenUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetChildrenUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetChildrenDefault(code int) *GetChildrenDefault { } } -/*GetChildrenDefault handles this case with default header values. +/* +GetChildrenDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetChildrenDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get children default response has a 2xx status code +func (o *GetChildrenDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get children default response has a 3xx status code +func (o *GetChildrenDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get children default response has a 4xx status code +func (o *GetChildrenDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get children default response has a 5xx status code +func (o *GetChildrenDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get children default response a status code equal to that given +func (o *GetChildrenDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get children default response func (o *GetChildrenDefault) Code() int { return o._statusCode } func (o *GetChildrenDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildren default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildren default %s", o._statusCode, payload) +} + +func (o *GetChildrenDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/children][%d] getChildren default %s", o._statusCode, payload) } func (o *GetChildrenDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetChildrenDefault) GetPayload() *models.ErrorPayload { func (o *GetChildrenDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetChildrenDefault) readResponse(response runtime.ClientResponse, consu return nil } -/*GetChildrenOKBody get children o k body +/* +GetChildrenOKBody get children o k body swagger:model GetChildrenOKBody */ type GetChildrenOKBody struct { @@ -329,6 +538,8 @@ func (o *GetChildrenOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getChildrenOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getChildrenOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -349,6 +560,68 @@ func (o *GetChildrenOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getChildrenOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getChildrenOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get children o k body based on the context it is used +func (o *GetChildrenOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetChildrenOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getChildrenOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getChildrenOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetChildrenOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getChildrenOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getChildrenOK" + "." + "pagination") } return err } diff --git a/client/client/organization_children/organization_children_client.go b/client/client/organization_children/organization_children_client.go index e7773d10..bf8827cc 100644 --- a/client/client/organization_children/organization_children_client.go +++ b/client/client/organization_children/organization_children_client.go @@ -9,15 +9,40 @@ import ( "fmt" "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization children API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization children API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization children API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization children API */ @@ -26,16 +51,76 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateChild(params *CreateChildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateChildOK, error) + + GetChildren(params *GetChildrenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetChildrenOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateChild Create a new organization child, making the authenticated user the owner of it. */ -func (a *Client) CreateChild(params *CreateChildParams, authInfo runtime.ClientAuthInfoWriter) (*CreateChildOK, error) { +func (a *Client) CreateChild(params *CreateChildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateChildOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateChildParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createChild", Method: "POST", PathPattern: "/organizations/{organization_canonical}/children", @@ -47,7 +132,12 @@ func (a *Client) CreateChild(params *CreateChildParams, authInfo runtime.ClientA AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -64,13 +154,12 @@ func (a *Client) CreateChild(params *CreateChildParams, authInfo runtime.ClientA /* GetChildren Get the children organizations that the authenticated user has access. */ -func (a *Client) GetChildren(params *GetChildrenParams, authInfo runtime.ClientAuthInfoWriter) (*GetChildrenOK, error) { +func (a *Client) GetChildren(params *GetChildrenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetChildrenOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetChildrenParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getChildren", Method: "GET", PathPattern: "/organizations/{organization_canonical}/children", @@ -82,7 +171,12 @@ func (a *Client) GetChildren(params *GetChildrenParams, authInfo runtime.ClientA AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_config_repositories/create_config_repository_config_parameters.go b/client/client/organization_config_repositories/create_config_repository_config_parameters.go index bf3ed469..9d3e4cb3 100644 --- a/client/client/organization_config_repositories/create_config_repository_config_parameters.go +++ b/client/client/organization_config_repositories/create_config_repository_config_parameters.go @@ -13,70 +13,72 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateConfigRepositoryConfigParams creates a new CreateConfigRepositoryConfigParams object -// with the default values initialized. +// NewCreateConfigRepositoryConfigParams creates a new CreateConfigRepositoryConfigParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateConfigRepositoryConfigParams() *CreateConfigRepositoryConfigParams { - var () return &CreateConfigRepositoryConfigParams{ - timeout: cr.DefaultTimeout, } } // NewCreateConfigRepositoryConfigParamsWithTimeout creates a new CreateConfigRepositoryConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateConfigRepositoryConfigParamsWithTimeout(timeout time.Duration) *CreateConfigRepositoryConfigParams { - var () return &CreateConfigRepositoryConfigParams{ - timeout: timeout, } } // NewCreateConfigRepositoryConfigParamsWithContext creates a new CreateConfigRepositoryConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateConfigRepositoryConfigParamsWithContext(ctx context.Context) *CreateConfigRepositoryConfigParams { - var () return &CreateConfigRepositoryConfigParams{ - Context: ctx, } } // NewCreateConfigRepositoryConfigParamsWithHTTPClient creates a new CreateConfigRepositoryConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateConfigRepositoryConfigParamsWithHTTPClient(client *http.Client) *CreateConfigRepositoryConfigParams { - var () return &CreateConfigRepositoryConfigParams{ HTTPClient: client, } } -/*CreateConfigRepositoryConfigParams contains all the parameters to send to the API endpoint -for the create config repository config operation typically these are written to a http.Request +/* +CreateConfigRepositoryConfigParams contains all the parameters to send to the API endpoint + + for the create config repository config operation. + + Typically these are written to a http.Request. */ type CreateConfigRepositoryConfigParams struct { - /*Body - The body contains Service Catalog's config files and paths where they'll be created in the Config Repository. + /* Body. + The body contains Service Catalog's config files and paths where they'll be created in the Config Repository. */ Body *models.SCConfig - /*ConfigRepositoryCanonical - Organization Config Repositories canonical + /* ConfigRepositoryCanonical. + + Organization Config Repositories canonical */ ConfigRepositoryCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -85,6 +87,21 @@ type CreateConfigRepositoryConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create config repository config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateConfigRepositoryConfigParams) WithDefaults() *CreateConfigRepositoryConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create config repository config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateConfigRepositoryConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create config repository config params func (o *CreateConfigRepositoryConfigParams) WithTimeout(timeout time.Duration) *CreateConfigRepositoryConfigParams { o.SetTimeout(timeout) @@ -158,7 +175,6 @@ func (o *CreateConfigRepositoryConfigParams) WriteToRequest(r runtime.ClientRequ return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_config_repositories/create_config_repository_config_responses.go b/client/client/organization_config_repositories/create_config_repository_config_responses.go index 8accdd2f..94065418 100644 --- a/client/client/organization_config_repositories/create_config_repository_config_responses.go +++ b/client/client/organization_config_repositories/create_config_repository_config_responses.go @@ -6,16 +6,16 @@ package organization_config_repositories // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateConfigRepositoryConfigReader is a Reader for the CreateConfigRepositoryConfig structure. @@ -73,15 +73,50 @@ func NewCreateConfigRepositoryConfigNoContent() *CreateConfigRepositoryConfigNoC return &CreateConfigRepositoryConfigNoContent{} } -/*CreateConfigRepositoryConfigNoContent handles this case with default header values. +/* +CreateConfigRepositoryConfigNoContent describes a response with status code 204, with default header values. SC config files have been created successfully */ type CreateConfigRepositoryConfigNoContent struct { } +// IsSuccess returns true when this create config repository config no content response has a 2xx status code +func (o *CreateConfigRepositoryConfigNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create config repository config no content response has a 3xx status code +func (o *CreateConfigRepositoryConfigNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository config no content response has a 4xx status code +func (o *CreateConfigRepositoryConfigNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this create config repository config no content response has a 5xx status code +func (o *CreateConfigRepositoryConfigNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository config no content response a status code equal to that given +func (o *CreateConfigRepositoryConfigNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the create config repository config no content response +func (o *CreateConfigRepositoryConfigNoContent) Code() int { + return 204 +} + func (o *CreateConfigRepositoryConfigNoContent) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigNoContent ", 204) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigNoContent", 204) +} + +func (o *CreateConfigRepositoryConfigNoContent) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigNoContent", 204) } func (o *CreateConfigRepositoryConfigNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -94,20 +129,60 @@ func NewCreateConfigRepositoryConfigForbidden() *CreateConfigRepositoryConfigFor return &CreateConfigRepositoryConfigForbidden{} } -/*CreateConfigRepositoryConfigForbidden handles this case with default header values. +/* +CreateConfigRepositoryConfigForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateConfigRepositoryConfigForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create config repository config forbidden response has a 2xx status code +func (o *CreateConfigRepositoryConfigForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create config repository config forbidden response has a 3xx status code +func (o *CreateConfigRepositoryConfigForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository config forbidden response has a 4xx status code +func (o *CreateConfigRepositoryConfigForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create config repository config forbidden response has a 5xx status code +func (o *CreateConfigRepositoryConfigForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository config forbidden response a status code equal to that given +func (o *CreateConfigRepositoryConfigForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create config repository config forbidden response +func (o *CreateConfigRepositoryConfigForbidden) Code() int { + return 403 +} + func (o *CreateConfigRepositoryConfigForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigForbidden %s", 403, payload) +} + +func (o *CreateConfigRepositoryConfigForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigForbidden %s", 403, payload) } func (o *CreateConfigRepositoryConfigForbidden) GetPayload() *models.ErrorPayload { @@ -116,12 +191,16 @@ func (o *CreateConfigRepositoryConfigForbidden) GetPayload() *models.ErrorPayloa func (o *CreateConfigRepositoryConfigForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -138,20 +217,60 @@ func NewCreateConfigRepositoryConfigNotFound() *CreateConfigRepositoryConfigNotF return &CreateConfigRepositoryConfigNotFound{} } -/*CreateConfigRepositoryConfigNotFound handles this case with default header values. +/* +CreateConfigRepositoryConfigNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateConfigRepositoryConfigNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create config repository config not found response has a 2xx status code +func (o *CreateConfigRepositoryConfigNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create config repository config not found response has a 3xx status code +func (o *CreateConfigRepositoryConfigNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository config not found response has a 4xx status code +func (o *CreateConfigRepositoryConfigNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create config repository config not found response has a 5xx status code +func (o *CreateConfigRepositoryConfigNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository config not found response a status code equal to that given +func (o *CreateConfigRepositoryConfigNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create config repository config not found response +func (o *CreateConfigRepositoryConfigNotFound) Code() int { + return 404 +} + func (o *CreateConfigRepositoryConfigNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigNotFound %s", 404, payload) +} + +func (o *CreateConfigRepositoryConfigNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigNotFound %s", 404, payload) } func (o *CreateConfigRepositoryConfigNotFound) GetPayload() *models.ErrorPayload { @@ -160,12 +279,16 @@ func (o *CreateConfigRepositoryConfigNotFound) GetPayload() *models.ErrorPayload func (o *CreateConfigRepositoryConfigNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -182,15 +305,50 @@ func NewCreateConfigRepositoryConfigLengthRequired() *CreateConfigRepositoryConf return &CreateConfigRepositoryConfigLengthRequired{} } -/*CreateConfigRepositoryConfigLengthRequired handles this case with default header values. +/* +CreateConfigRepositoryConfigLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreateConfigRepositoryConfigLengthRequired struct { } +// IsSuccess returns true when this create config repository config length required response has a 2xx status code +func (o *CreateConfigRepositoryConfigLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create config repository config length required response has a 3xx status code +func (o *CreateConfigRepositoryConfigLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository config length required response has a 4xx status code +func (o *CreateConfigRepositoryConfigLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create config repository config length required response has a 5xx status code +func (o *CreateConfigRepositoryConfigLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository config length required response a status code equal to that given +func (o *CreateConfigRepositoryConfigLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create config repository config length required response +func (o *CreateConfigRepositoryConfigLengthRequired) Code() int { + return 411 +} + func (o *CreateConfigRepositoryConfigLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigLengthRequired", 411) +} + +func (o *CreateConfigRepositoryConfigLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigLengthRequired", 411) } func (o *CreateConfigRepositoryConfigLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -203,20 +361,60 @@ func NewCreateConfigRepositoryConfigUnprocessableEntity() *CreateConfigRepositor return &CreateConfigRepositoryConfigUnprocessableEntity{} } -/*CreateConfigRepositoryConfigUnprocessableEntity handles this case with default header values. +/* +CreateConfigRepositoryConfigUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateConfigRepositoryConfigUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create config repository config unprocessable entity response has a 2xx status code +func (o *CreateConfigRepositoryConfigUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create config repository config unprocessable entity response has a 3xx status code +func (o *CreateConfigRepositoryConfigUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository config unprocessable entity response has a 4xx status code +func (o *CreateConfigRepositoryConfigUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create config repository config unprocessable entity response has a 5xx status code +func (o *CreateConfigRepositoryConfigUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository config unprocessable entity response a status code equal to that given +func (o *CreateConfigRepositoryConfigUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create config repository config unprocessable entity response +func (o *CreateConfigRepositoryConfigUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateConfigRepositoryConfigUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigUnprocessableEntity %s", 422, payload) +} + +func (o *CreateConfigRepositoryConfigUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfigUnprocessableEntity %s", 422, payload) } func (o *CreateConfigRepositoryConfigUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -225,12 +423,16 @@ func (o *CreateConfigRepositoryConfigUnprocessableEntity) GetPayload() *models.E func (o *CreateConfigRepositoryConfigUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -249,27 +451,61 @@ func NewCreateConfigRepositoryConfigDefault(code int) *CreateConfigRepositoryCon } } -/*CreateConfigRepositoryConfigDefault handles this case with default header values. +/* +CreateConfigRepositoryConfigDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateConfigRepositoryConfigDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create config repository config default response has a 2xx status code +func (o *CreateConfigRepositoryConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create config repository config default response has a 3xx status code +func (o *CreateConfigRepositoryConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create config repository config default response has a 4xx status code +func (o *CreateConfigRepositoryConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create config repository config default response has a 5xx status code +func (o *CreateConfigRepositoryConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create config repository config default response a status code equal to that given +func (o *CreateConfigRepositoryConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create config repository config default response func (o *CreateConfigRepositoryConfigDefault) Code() int { return o._statusCode } func (o *CreateConfigRepositoryConfigDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfig default %s", o._statusCode, payload) +} + +func (o *CreateConfigRepositoryConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config][%d] createConfigRepositoryConfig default %s", o._statusCode, payload) } func (o *CreateConfigRepositoryConfigDefault) GetPayload() *models.ErrorPayload { @@ -278,12 +514,16 @@ func (o *CreateConfigRepositoryConfigDefault) GetPayload() *models.ErrorPayload func (o *CreateConfigRepositoryConfigDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_config_repositories/create_config_repository_parameters.go b/client/client/organization_config_repositories/create_config_repository_parameters.go index 95de491e..357006b9 100644 --- a/client/client/organization_config_repositories/create_config_repository_parameters.go +++ b/client/client/organization_config_repositories/create_config_repository_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateConfigRepositoryParams creates a new CreateConfigRepositoryParams object -// with the default values initialized. +// NewCreateConfigRepositoryParams creates a new CreateConfigRepositoryParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateConfigRepositoryParams() *CreateConfigRepositoryParams { - var () return &CreateConfigRepositoryParams{ - timeout: cr.DefaultTimeout, } } // NewCreateConfigRepositoryParamsWithTimeout creates a new CreateConfigRepositoryParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateConfigRepositoryParamsWithTimeout(timeout time.Duration) *CreateConfigRepositoryParams { - var () return &CreateConfigRepositoryParams{ - timeout: timeout, } } // NewCreateConfigRepositoryParamsWithContext creates a new CreateConfigRepositoryParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateConfigRepositoryParamsWithContext(ctx context.Context) *CreateConfigRepositoryParams { - var () return &CreateConfigRepositoryParams{ - Context: ctx, } } // NewCreateConfigRepositoryParamsWithHTTPClient creates a new CreateConfigRepositoryParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateConfigRepositoryParamsWithHTTPClient(client *http.Client) *CreateConfigRepositoryParams { - var () return &CreateConfigRepositoryParams{ HTTPClient: client, } } -/*CreateConfigRepositoryParams contains all the parameters to send to the API endpoint -for the create config repository operation typically these are written to a http.Request +/* +CreateConfigRepositoryParams contains all the parameters to send to the API endpoint + + for the create config repository operation. + + Typically these are written to a http.Request. */ type CreateConfigRepositoryParams struct { - /*Body - The information of the config repository to create. + /* Body. + The information of the config repository to create. */ Body *models.NewConfigRepository - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type CreateConfigRepositoryParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create config repository params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateConfigRepositoryParams) WithDefaults() *CreateConfigRepositoryParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create config repository params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateConfigRepositoryParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create config repository params func (o *CreateConfigRepositoryParams) WithTimeout(timeout time.Duration) *CreateConfigRepositoryParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CreateConfigRepositoryParams) WriteToRequest(r runtime.ClientRequest, r return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_config_repositories/create_config_repository_responses.go b/client/client/organization_config_repositories/create_config_repository_responses.go index 402f93d2..0c565b2f 100644 --- a/client/client/organization_config_repositories/create_config_repository_responses.go +++ b/client/client/organization_config_repositories/create_config_repository_responses.go @@ -6,17 +6,18 @@ package organization_config_repositories // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateConfigRepositoryReader is a Reader for the CreateConfigRepository structure. @@ -68,7 +69,8 @@ func NewCreateConfigRepositoryOK() *CreateConfigRepositoryOK { return &CreateConfigRepositoryOK{} } -/*CreateConfigRepositoryOK handles this case with default header values. +/* +CreateConfigRepositoryOK describes a response with status code 200, with default header values. Success creation */ @@ -76,8 +78,44 @@ type CreateConfigRepositoryOK struct { Payload *CreateConfigRepositoryOKBody } +// IsSuccess returns true when this create config repository o k response has a 2xx status code +func (o *CreateConfigRepositoryOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create config repository o k response has a 3xx status code +func (o *CreateConfigRepositoryOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository o k response has a 4xx status code +func (o *CreateConfigRepositoryOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create config repository o k response has a 5xx status code +func (o *CreateConfigRepositoryOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository o k response a status code equal to that given +func (o *CreateConfigRepositoryOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create config repository o k response +func (o *CreateConfigRepositoryOK) Code() int { + return 200 +} + func (o *CreateConfigRepositoryOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryOK %s", 200, payload) +} + +func (o *CreateConfigRepositoryOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryOK %s", 200, payload) } func (o *CreateConfigRepositoryOK) GetPayload() *CreateConfigRepositoryOKBody { @@ -101,20 +139,60 @@ func NewCreateConfigRepositoryNotFound() *CreateConfigRepositoryNotFound { return &CreateConfigRepositoryNotFound{} } -/*CreateConfigRepositoryNotFound handles this case with default header values. +/* +CreateConfigRepositoryNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateConfigRepositoryNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create config repository not found response has a 2xx status code +func (o *CreateConfigRepositoryNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create config repository not found response has a 3xx status code +func (o *CreateConfigRepositoryNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository not found response has a 4xx status code +func (o *CreateConfigRepositoryNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create config repository not found response has a 5xx status code +func (o *CreateConfigRepositoryNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository not found response a status code equal to that given +func (o *CreateConfigRepositoryNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create config repository not found response +func (o *CreateConfigRepositoryNotFound) Code() int { + return 404 +} + func (o *CreateConfigRepositoryNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryNotFound %s", 404, payload) +} + +func (o *CreateConfigRepositoryNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryNotFound %s", 404, payload) } func (o *CreateConfigRepositoryNotFound) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *CreateConfigRepositoryNotFound) GetPayload() *models.ErrorPayload { func (o *CreateConfigRepositoryNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,15 +227,50 @@ func NewCreateConfigRepositoryLengthRequired() *CreateConfigRepositoryLengthRequ return &CreateConfigRepositoryLengthRequired{} } -/*CreateConfigRepositoryLengthRequired handles this case with default header values. +/* +CreateConfigRepositoryLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreateConfigRepositoryLengthRequired struct { } +// IsSuccess returns true when this create config repository length required response has a 2xx status code +func (o *CreateConfigRepositoryLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create config repository length required response has a 3xx status code +func (o *CreateConfigRepositoryLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository length required response has a 4xx status code +func (o *CreateConfigRepositoryLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create config repository length required response has a 5xx status code +func (o *CreateConfigRepositoryLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository length required response a status code equal to that given +func (o *CreateConfigRepositoryLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create config repository length required response +func (o *CreateConfigRepositoryLengthRequired) Code() int { + return 411 +} + func (o *CreateConfigRepositoryLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryLengthRequired", 411) +} + +func (o *CreateConfigRepositoryLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryLengthRequired", 411) } func (o *CreateConfigRepositoryLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -166,20 +283,60 @@ func NewCreateConfigRepositoryUnprocessableEntity() *CreateConfigRepositoryUnpro return &CreateConfigRepositoryUnprocessableEntity{} } -/*CreateConfigRepositoryUnprocessableEntity handles this case with default header values. +/* +CreateConfigRepositoryUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateConfigRepositoryUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create config repository unprocessable entity response has a 2xx status code +func (o *CreateConfigRepositoryUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create config repository unprocessable entity response has a 3xx status code +func (o *CreateConfigRepositoryUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create config repository unprocessable entity response has a 4xx status code +func (o *CreateConfigRepositoryUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create config repository unprocessable entity response has a 5xx status code +func (o *CreateConfigRepositoryUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create config repository unprocessable entity response a status code equal to that given +func (o *CreateConfigRepositoryUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create config repository unprocessable entity response +func (o *CreateConfigRepositoryUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateConfigRepositoryUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryUnprocessableEntity %s", 422, payload) +} + +func (o *CreateConfigRepositoryUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepositoryUnprocessableEntity %s", 422, payload) } func (o *CreateConfigRepositoryUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -188,12 +345,16 @@ func (o *CreateConfigRepositoryUnprocessableEntity) GetPayload() *models.ErrorPa func (o *CreateConfigRepositoryUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -212,27 +373,61 @@ func NewCreateConfigRepositoryDefault(code int) *CreateConfigRepositoryDefault { } } -/*CreateConfigRepositoryDefault handles this case with default header values. +/* +CreateConfigRepositoryDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateConfigRepositoryDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create config repository default response has a 2xx status code +func (o *CreateConfigRepositoryDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create config repository default response has a 3xx status code +func (o *CreateConfigRepositoryDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create config repository default response has a 4xx status code +func (o *CreateConfigRepositoryDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create config repository default response has a 5xx status code +func (o *CreateConfigRepositoryDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create config repository default response a status code equal to that given +func (o *CreateConfigRepositoryDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create config repository default response func (o *CreateConfigRepositoryDefault) Code() int { return o._statusCode } func (o *CreateConfigRepositoryDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepository default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepository default %s", o._statusCode, payload) +} + +func (o *CreateConfigRepositoryDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/config_repositories][%d] createConfigRepository default %s", o._statusCode, payload) } func (o *CreateConfigRepositoryDefault) GetPayload() *models.ErrorPayload { @@ -241,12 +436,16 @@ func (o *CreateConfigRepositoryDefault) GetPayload() *models.ErrorPayload { func (o *CreateConfigRepositoryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -258,7 +457,8 @@ func (o *CreateConfigRepositoryDefault) readResponse(response runtime.ClientResp return nil } -/*CreateConfigRepositoryOKBody create config repository o k body +/* +CreateConfigRepositoryOKBody create config repository o k body swagger:model CreateConfigRepositoryOKBody */ type CreateConfigRepositoryOKBody struct { @@ -292,6 +492,39 @@ func (o *CreateConfigRepositoryOKBody) validateData(formats strfmt.Registry) err if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createConfigRepositoryOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createConfigRepositoryOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create config repository o k body based on the context it is used +func (o *CreateConfigRepositoryOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateConfigRepositoryOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createConfigRepositoryOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createConfigRepositoryOK" + "." + "data") } return err } diff --git a/client/client/organization_config_repositories/delete_config_repository_parameters.go b/client/client/organization_config_repositories/delete_config_repository_parameters.go index 5ecb8e94..c1c90377 100644 --- a/client/client/organization_config_repositories/delete_config_repository_parameters.go +++ b/client/client/organization_config_repositories/delete_config_repository_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteConfigRepositoryParams creates a new DeleteConfigRepositoryParams object -// with the default values initialized. +// NewDeleteConfigRepositoryParams creates a new DeleteConfigRepositoryParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteConfigRepositoryParams() *DeleteConfigRepositoryParams { - var () return &DeleteConfigRepositoryParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteConfigRepositoryParamsWithTimeout creates a new DeleteConfigRepositoryParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteConfigRepositoryParamsWithTimeout(timeout time.Duration) *DeleteConfigRepositoryParams { - var () return &DeleteConfigRepositoryParams{ - timeout: timeout, } } // NewDeleteConfigRepositoryParamsWithContext creates a new DeleteConfigRepositoryParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteConfigRepositoryParamsWithContext(ctx context.Context) *DeleteConfigRepositoryParams { - var () return &DeleteConfigRepositoryParams{ - Context: ctx, } } // NewDeleteConfigRepositoryParamsWithHTTPClient creates a new DeleteConfigRepositoryParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteConfigRepositoryParamsWithHTTPClient(client *http.Client) *DeleteConfigRepositoryParams { - var () return &DeleteConfigRepositoryParams{ HTTPClient: client, } } -/*DeleteConfigRepositoryParams contains all the parameters to send to the API endpoint -for the delete config repository operation typically these are written to a http.Request +/* +DeleteConfigRepositoryParams contains all the parameters to send to the API endpoint + + for the delete config repository operation. + + Typically these are written to a http.Request. */ type DeleteConfigRepositoryParams struct { - /*ConfigRepositoryCanonical - Organization Config Repositories canonical + /* ConfigRepositoryCanonical. + Organization Config Repositories canonical */ ConfigRepositoryCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type DeleteConfigRepositoryParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete config repository params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteConfigRepositoryParams) WithDefaults() *DeleteConfigRepositoryParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete config repository params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteConfigRepositoryParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete config repository params func (o *DeleteConfigRepositoryParams) WithTimeout(timeout time.Duration) *DeleteConfigRepositoryParams { o.SetTimeout(timeout) diff --git a/client/client/organization_config_repositories/delete_config_repository_responses.go b/client/client/organization_config_repositories/delete_config_repository_responses.go index 3f523ed9..06295331 100644 --- a/client/client/organization_config_repositories/delete_config_repository_responses.go +++ b/client/client/organization_config_repositories/delete_config_repository_responses.go @@ -6,16 +6,16 @@ package organization_config_repositories // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteConfigRepositoryReader is a Reader for the DeleteConfigRepository structure. @@ -49,15 +49,50 @@ func NewDeleteConfigRepositoryNoContent() *DeleteConfigRepositoryNoContent { return &DeleteConfigRepositoryNoContent{} } -/*DeleteConfigRepositoryNoContent handles this case with default header values. +/* +DeleteConfigRepositoryNoContent describes a response with status code 204, with default header values. Organization Config repository has been deleted */ type DeleteConfigRepositoryNoContent struct { } +// IsSuccess returns true when this delete config repository no content response has a 2xx status code +func (o *DeleteConfigRepositoryNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete config repository no content response has a 3xx status code +func (o *DeleteConfigRepositoryNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete config repository no content response has a 4xx status code +func (o *DeleteConfigRepositoryNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete config repository no content response has a 5xx status code +func (o *DeleteConfigRepositoryNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete config repository no content response a status code equal to that given +func (o *DeleteConfigRepositoryNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete config repository no content response +func (o *DeleteConfigRepositoryNoContent) Code() int { + return 204 +} + func (o *DeleteConfigRepositoryNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] deleteConfigRepositoryNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] deleteConfigRepositoryNoContent", 204) +} + +func (o *DeleteConfigRepositoryNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] deleteConfigRepositoryNoContent", 204) } func (o *DeleteConfigRepositoryNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -72,27 +107,61 @@ func NewDeleteConfigRepositoryDefault(code int) *DeleteConfigRepositoryDefault { } } -/*DeleteConfigRepositoryDefault handles this case with default header values. +/* +DeleteConfigRepositoryDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteConfigRepositoryDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete config repository default response has a 2xx status code +func (o *DeleteConfigRepositoryDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete config repository default response has a 3xx status code +func (o *DeleteConfigRepositoryDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete config repository default response has a 4xx status code +func (o *DeleteConfigRepositoryDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete config repository default response has a 5xx status code +func (o *DeleteConfigRepositoryDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete config repository default response a status code equal to that given +func (o *DeleteConfigRepositoryDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete config repository default response func (o *DeleteConfigRepositoryDefault) Code() int { return o._statusCode } func (o *DeleteConfigRepositoryDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] deleteConfigRepository default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] deleteConfigRepository default %s", o._statusCode, payload) +} + +func (o *DeleteConfigRepositoryDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] deleteConfigRepository default %s", o._statusCode, payload) } func (o *DeleteConfigRepositoryDefault) GetPayload() *models.ErrorPayload { @@ -101,12 +170,16 @@ func (o *DeleteConfigRepositoryDefault) GetPayload() *models.ErrorPayload { func (o *DeleteConfigRepositoryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_config_repositories/get_config_repository_parameters.go b/client/client/organization_config_repositories/get_config_repository_parameters.go index a1a2e3b9..1be58be6 100644 --- a/client/client/organization_config_repositories/get_config_repository_parameters.go +++ b/client/client/organization_config_repositories/get_config_repository_parameters.go @@ -13,93 +13,82 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetConfigRepositoryParams creates a new GetConfigRepositoryParams object -// with the default values initialized. +// NewGetConfigRepositoryParams creates a new GetConfigRepositoryParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetConfigRepositoryParams() *GetConfigRepositoryParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetConfigRepositoryParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetConfigRepositoryParamsWithTimeout creates a new GetConfigRepositoryParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetConfigRepositoryParamsWithTimeout(timeout time.Duration) *GetConfigRepositoryParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetConfigRepositoryParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetConfigRepositoryParamsWithContext creates a new GetConfigRepositoryParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetConfigRepositoryParamsWithContext(ctx context.Context) *GetConfigRepositoryParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetConfigRepositoryParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetConfigRepositoryParamsWithHTTPClient creates a new GetConfigRepositoryParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetConfigRepositoryParamsWithHTTPClient(client *http.Client) *GetConfigRepositoryParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetConfigRepositoryParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetConfigRepositoryParams contains all the parameters to send to the API endpoint -for the get config repository operation typically these are written to a http.Request +/* +GetConfigRepositoryParams contains all the parameters to send to the API endpoint + + for the get config repository operation. + + Typically these are written to a http.Request. */ type GetConfigRepositoryParams struct { - /*ConfigRepositoryCanonical - Organization Config Repositories canonical + /* ConfigRepositoryCanonical. + Organization Config Repositories canonical */ ConfigRepositoryCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -108,6 +97,35 @@ type GetConfigRepositoryParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get config repository params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetConfigRepositoryParams) WithDefaults() *GetConfigRepositoryParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get config repository params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetConfigRepositoryParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetConfigRepositoryParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get config repository params func (o *GetConfigRepositoryParams) WithTimeout(timeout time.Duration) *GetConfigRepositoryParams { o.SetTimeout(timeout) @@ -207,32 +225,34 @@ func (o *GetConfigRepositoryParams) WriteToRequest(r runtime.ClientRequest, reg // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_config_repositories/get_config_repository_responses.go b/client/client/organization_config_repositories/get_config_repository_responses.go index acc1ee19..8818c906 100644 --- a/client/client/organization_config_repositories/get_config_repository_responses.go +++ b/client/client/organization_config_repositories/get_config_repository_responses.go @@ -6,17 +6,18 @@ package organization_config_repositories // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetConfigRepositoryReader is a Reader for the GetConfigRepository structure. @@ -62,7 +63,8 @@ func NewGetConfigRepositoryOK() *GetConfigRepositoryOK { return &GetConfigRepositoryOK{} } -/*GetConfigRepositoryOK handles this case with default header values. +/* +GetConfigRepositoryOK describes a response with status code 200, with default header values. Organization Config Repository. */ @@ -70,8 +72,44 @@ type GetConfigRepositoryOK struct { Payload *GetConfigRepositoryOKBody } +// IsSuccess returns true when this get config repository o k response has a 2xx status code +func (o *GetConfigRepositoryOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get config repository o k response has a 3xx status code +func (o *GetConfigRepositoryOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get config repository o k response has a 4xx status code +func (o *GetConfigRepositoryOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get config repository o k response has a 5xx status code +func (o *GetConfigRepositoryOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get config repository o k response a status code equal to that given +func (o *GetConfigRepositoryOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get config repository o k response +func (o *GetConfigRepositoryOK) Code() int { + return 200 +} + func (o *GetConfigRepositoryOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryOK %s", 200, payload) +} + +func (o *GetConfigRepositoryOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryOK %s", 200, payload) } func (o *GetConfigRepositoryOK) GetPayload() *GetConfigRepositoryOKBody { @@ -95,20 +133,60 @@ func NewGetConfigRepositoryForbidden() *GetConfigRepositoryForbidden { return &GetConfigRepositoryForbidden{} } -/*GetConfigRepositoryForbidden handles this case with default header values. +/* +GetConfigRepositoryForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetConfigRepositoryForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get config repository forbidden response has a 2xx status code +func (o *GetConfigRepositoryForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get config repository forbidden response has a 3xx status code +func (o *GetConfigRepositoryForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get config repository forbidden response has a 4xx status code +func (o *GetConfigRepositoryForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get config repository forbidden response has a 5xx status code +func (o *GetConfigRepositoryForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get config repository forbidden response a status code equal to that given +func (o *GetConfigRepositoryForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get config repository forbidden response +func (o *GetConfigRepositoryForbidden) Code() int { + return 403 +} + func (o *GetConfigRepositoryForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryForbidden %s", 403, payload) +} + +func (o *GetConfigRepositoryForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryForbidden %s", 403, payload) } func (o *GetConfigRepositoryForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetConfigRepositoryForbidden) GetPayload() *models.ErrorPayload { func (o *GetConfigRepositoryForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetConfigRepositoryUnprocessableEntity() *GetConfigRepositoryUnprocessab return &GetConfigRepositoryUnprocessableEntity{} } -/*GetConfigRepositoryUnprocessableEntity handles this case with default header values. +/* +GetConfigRepositoryUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetConfigRepositoryUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get config repository unprocessable entity response has a 2xx status code +func (o *GetConfigRepositoryUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get config repository unprocessable entity response has a 3xx status code +func (o *GetConfigRepositoryUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get config repository unprocessable entity response has a 4xx status code +func (o *GetConfigRepositoryUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get config repository unprocessable entity response has a 5xx status code +func (o *GetConfigRepositoryUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get config repository unprocessable entity response a status code equal to that given +func (o *GetConfigRepositoryUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get config repository unprocessable entity response +func (o *GetConfigRepositoryUnprocessableEntity) Code() int { + return 422 +} + func (o *GetConfigRepositoryUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryUnprocessableEntity %s", 422, payload) +} + +func (o *GetConfigRepositoryUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepositoryUnprocessableEntity %s", 422, payload) } func (o *GetConfigRepositoryUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetConfigRepositoryUnprocessableEntity) GetPayload() *models.ErrorPaylo func (o *GetConfigRepositoryUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetConfigRepositoryDefault(code int) *GetConfigRepositoryDefault { } } -/*GetConfigRepositoryDefault handles this case with default header values. +/* +GetConfigRepositoryDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetConfigRepositoryDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get config repository default response has a 2xx status code +func (o *GetConfigRepositoryDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get config repository default response has a 3xx status code +func (o *GetConfigRepositoryDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get config repository default response has a 4xx status code +func (o *GetConfigRepositoryDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get config repository default response has a 5xx status code +func (o *GetConfigRepositoryDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get config repository default response a status code equal to that given +func (o *GetConfigRepositoryDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get config repository default response func (o *GetConfigRepositoryDefault) Code() int { return o._statusCode } func (o *GetConfigRepositoryDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepository default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepository default %s", o._statusCode, payload) +} + +func (o *GetConfigRepositoryDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] getConfigRepository default %s", o._statusCode, payload) } func (o *GetConfigRepositoryDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetConfigRepositoryDefault) GetPayload() *models.ErrorPayload { func (o *GetConfigRepositoryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetConfigRepositoryDefault) readResponse(response runtime.ClientRespons return nil } -/*GetConfigRepositoryOKBody get config repository o k body +/* +GetConfigRepositoryOKBody get config repository o k body swagger:model GetConfigRepositoryOKBody */ type GetConfigRepositoryOKBody struct { @@ -265,6 +430,39 @@ func (o *GetConfigRepositoryOKBody) validateData(formats strfmt.Registry) error if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigRepositoryOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getConfigRepositoryOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get config repository o k body based on the context it is used +func (o *GetConfigRepositoryOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetConfigRepositoryOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getConfigRepositoryOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getConfigRepositoryOK" + "." + "data") } return err } diff --git a/client/client/organization_config_repositories/list_config_repositories_parameters.go b/client/client/organization_config_repositories/list_config_repositories_parameters.go index eae81fb8..7468c177 100644 --- a/client/client/organization_config_repositories/list_config_repositories_parameters.go +++ b/client/client/organization_config_repositories/list_config_repositories_parameters.go @@ -13,101 +13,82 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewListConfigRepositoriesParams creates a new ListConfigRepositoriesParams object -// with the default values initialized. +// NewListConfigRepositoriesParams creates a new ListConfigRepositoriesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewListConfigRepositoriesParams() *ListConfigRepositoriesParams { - var ( - defaultVarDefault = bool(false) - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &ListConfigRepositoriesParams{ - Default: &defaultVarDefault, - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewListConfigRepositoriesParamsWithTimeout creates a new ListConfigRepositoriesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewListConfigRepositoriesParamsWithTimeout(timeout time.Duration) *ListConfigRepositoriesParams { - var ( - defaultVarDefault = bool(false) - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &ListConfigRepositoriesParams{ - Default: &defaultVarDefault, - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewListConfigRepositoriesParamsWithContext creates a new ListConfigRepositoriesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewListConfigRepositoriesParamsWithContext(ctx context.Context) *ListConfigRepositoriesParams { - var ( - defaultDefault = bool(false) - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &ListConfigRepositoriesParams{ - Default: &defaultDefault, - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewListConfigRepositoriesParamsWithHTTPClient creates a new ListConfigRepositoriesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewListConfigRepositoriesParamsWithHTTPClient(client *http.Client) *ListConfigRepositoriesParams { - var ( - defaultDefault = bool(false) - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &ListConfigRepositoriesParams{ - Default: &defaultDefault, - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*ListConfigRepositoriesParams contains all the parameters to send to the API endpoint -for the list config repositories operation typically these are written to a http.Request +/* +ListConfigRepositoriesParams contains all the parameters to send to the API endpoint + + for the list config repositories operation. + + Typically these are written to a http.Request. */ type ListConfigRepositoriesParams struct { - /*Default - Value describing whether to return default + /* Default. + Value describing whether to return default */ Default *bool - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -116,6 +97,38 @@ type ListConfigRepositoriesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the list config repositories params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListConfigRepositoriesParams) WithDefaults() *ListConfigRepositoriesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list config repositories params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListConfigRepositoriesParams) SetDefaults() { + var ( + defaultVarDefault = bool(false) + + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := ListConfigRepositoriesParams{ + Default: &defaultVarDefault, + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the list config repositories params func (o *ListConfigRepositoriesParams) WithTimeout(timeout time.Duration) *ListConfigRepositoriesParams { o.SetTimeout(timeout) @@ -205,16 +218,17 @@ func (o *ListConfigRepositoriesParams) WriteToRequest(r runtime.ClientRequest, r // query param default var qrDefault bool + if o.Default != nil { qrDefault = *o.Default } qDefault := swag.FormatBool(qrDefault) if qDefault != "" { + if err := r.SetQueryParam("default", qDefault); err != nil { return err } } - } // path param organization_canonical @@ -226,32 +240,34 @@ func (o *ListConfigRepositoriesParams) WriteToRequest(r runtime.ClientRequest, r // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_config_repositories/list_config_repositories_responses.go b/client/client/organization_config_repositories/list_config_repositories_responses.go index ff47d7b8..cf396de3 100644 --- a/client/client/organization_config_repositories/list_config_repositories_responses.go +++ b/client/client/organization_config_repositories/list_config_repositories_responses.go @@ -6,18 +6,19 @@ package organization_config_repositories // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ListConfigRepositoriesReader is a Reader for the ListConfigRepositories structure. @@ -63,7 +64,8 @@ func NewListConfigRepositoriesOK() *ListConfigRepositoriesOK { return &ListConfigRepositoriesOK{} } -/*ListConfigRepositoriesOK handles this case with default header values. +/* +ListConfigRepositoriesOK describes a response with status code 200, with default header values. List of the config repositories. */ @@ -71,8 +73,44 @@ type ListConfigRepositoriesOK struct { Payload *ListConfigRepositoriesOKBody } +// IsSuccess returns true when this list config repositories o k response has a 2xx status code +func (o *ListConfigRepositoriesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list config repositories o k response has a 3xx status code +func (o *ListConfigRepositoriesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list config repositories o k response has a 4xx status code +func (o *ListConfigRepositoriesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list config repositories o k response has a 5xx status code +func (o *ListConfigRepositoriesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list config repositories o k response a status code equal to that given +func (o *ListConfigRepositoriesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list config repositories o k response +func (o *ListConfigRepositoriesOK) Code() int { + return 200 +} + func (o *ListConfigRepositoriesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesOK %s", 200, payload) +} + +func (o *ListConfigRepositoriesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesOK %s", 200, payload) } func (o *ListConfigRepositoriesOK) GetPayload() *ListConfigRepositoriesOKBody { @@ -96,20 +134,60 @@ func NewListConfigRepositoriesForbidden() *ListConfigRepositoriesForbidden { return &ListConfigRepositoriesForbidden{} } -/*ListConfigRepositoriesForbidden handles this case with default header values. +/* +ListConfigRepositoriesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ListConfigRepositoriesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this list config repositories forbidden response has a 2xx status code +func (o *ListConfigRepositoriesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list config repositories forbidden response has a 3xx status code +func (o *ListConfigRepositoriesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list config repositories forbidden response has a 4xx status code +func (o *ListConfigRepositoriesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this list config repositories forbidden response has a 5xx status code +func (o *ListConfigRepositoriesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this list config repositories forbidden response a status code equal to that given +func (o *ListConfigRepositoriesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the list config repositories forbidden response +func (o *ListConfigRepositoriesForbidden) Code() int { + return 403 +} + func (o *ListConfigRepositoriesForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesForbidden %s", 403, payload) +} + +func (o *ListConfigRepositoriesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesForbidden %s", 403, payload) } func (o *ListConfigRepositoriesForbidden) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *ListConfigRepositoriesForbidden) GetPayload() *models.ErrorPayload { func (o *ListConfigRepositoriesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewListConfigRepositoriesUnprocessableEntity() *ListConfigRepositoriesUnpro return &ListConfigRepositoriesUnprocessableEntity{} } -/*ListConfigRepositoriesUnprocessableEntity handles this case with default header values. +/* +ListConfigRepositoriesUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type ListConfigRepositoriesUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this list config repositories unprocessable entity response has a 2xx status code +func (o *ListConfigRepositoriesUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list config repositories unprocessable entity response has a 3xx status code +func (o *ListConfigRepositoriesUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list config repositories unprocessable entity response has a 4xx status code +func (o *ListConfigRepositoriesUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this list config repositories unprocessable entity response has a 5xx status code +func (o *ListConfigRepositoriesUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this list config repositories unprocessable entity response a status code equal to that given +func (o *ListConfigRepositoriesUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the list config repositories unprocessable entity response +func (o *ListConfigRepositoriesUnprocessableEntity) Code() int { + return 422 +} + func (o *ListConfigRepositoriesUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesUnprocessableEntity %s", 422, payload) +} + +func (o *ListConfigRepositoriesUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositoriesUnprocessableEntity %s", 422, payload) } func (o *ListConfigRepositoriesUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *ListConfigRepositoriesUnprocessableEntity) GetPayload() *models.ErrorPa func (o *ListConfigRepositoriesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewListConfigRepositoriesDefault(code int) *ListConfigRepositoriesDefault { } } -/*ListConfigRepositoriesDefault handles this case with default header values. +/* +ListConfigRepositoriesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ListConfigRepositoriesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this list config repositories default response has a 2xx status code +func (o *ListConfigRepositoriesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list config repositories default response has a 3xx status code +func (o *ListConfigRepositoriesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list config repositories default response has a 4xx status code +func (o *ListConfigRepositoriesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list config repositories default response has a 5xx status code +func (o *ListConfigRepositoriesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list config repositories default response a status code equal to that given +func (o *ListConfigRepositoriesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the list config repositories default response func (o *ListConfigRepositoriesDefault) Code() int { return o._statusCode } func (o *ListConfigRepositoriesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositories default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositories default %s", o._statusCode, payload) +} + +func (o *ListConfigRepositoriesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/config_repositories][%d] listConfigRepositories default %s", o._statusCode, payload) } func (o *ListConfigRepositoriesDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *ListConfigRepositoriesDefault) GetPayload() *models.ErrorPayload { func (o *ListConfigRepositoriesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *ListConfigRepositoriesDefault) readResponse(response runtime.ClientResp return nil } -/*ListConfigRepositoriesOKBody list config repositories o k body +/* +ListConfigRepositoriesOKBody list config repositories o k body swagger:model ListConfigRepositoriesOKBody */ type ListConfigRepositoriesOKBody struct { @@ -271,6 +436,47 @@ func (o *ListConfigRepositoriesOKBody) validateData(formats strfmt.Registry) err if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("listConfigRepositoriesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listConfigRepositoriesOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this list config repositories o k body based on the context it is used +func (o *ListConfigRepositoriesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListConfigRepositoriesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listConfigRepositoriesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listConfigRepositoriesOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } diff --git a/client/client/organization_config_repositories/organization_config_repositories_client.go b/client/client/organization_config_repositories/organization_config_repositories_client.go index 1a69ebc2..25da58d7 100644 --- a/client/client/organization_config_repositories/organization_config_repositories_client.go +++ b/client/client/organization_config_repositories/organization_config_repositories_client.go @@ -7,15 +7,40 @@ package organization_config_repositories import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization config repositories API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization config repositories API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization config repositories API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization config repositories API */ @@ -24,16 +49,84 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateConfigRepository(params *CreateConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateConfigRepositoryOK, error) + + CreateConfigRepositoryConfig(params *CreateConfigRepositoryConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateConfigRepositoryConfigNoContent, error) + + DeleteConfigRepository(params *DeleteConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteConfigRepositoryNoContent, error) + + GetConfigRepository(params *GetConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetConfigRepositoryOK, error) + + ListConfigRepositories(params *ListConfigRepositoriesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListConfigRepositoriesOK, error) + + UpdateConfigRepository(params *UpdateConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateConfigRepositoryOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateConfigRepository Creates a config repository */ -func (a *Client) CreateConfigRepository(params *CreateConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter) (*CreateConfigRepositoryOK, error) { +func (a *Client) CreateConfigRepository(params *CreateConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateConfigRepositoryOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateConfigRepositoryParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createConfigRepository", Method: "POST", PathPattern: "/organizations/{organization_canonical}/config_repositories", @@ -45,7 +138,12 @@ func (a *Client) CreateConfigRepository(params *CreateConfigRepositoryParams, au AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +159,12 @@ func (a *Client) CreateConfigRepository(params *CreateConfigRepositoryParams, au /* CreateConfigRepositoryConfig Create Service Catalog config files in the Config Repository. */ -func (a *Client) CreateConfigRepositoryConfig(params *CreateConfigRepositoryConfigParams, authInfo runtime.ClientAuthInfoWriter) (*CreateConfigRepositoryConfigNoContent, error) { +func (a *Client) CreateConfigRepositoryConfig(params *CreateConfigRepositoryConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateConfigRepositoryConfigNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateConfigRepositoryConfigParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createConfigRepositoryConfig", Method: "POST", PathPattern: "/organizations/{organization_canonical}/config_repositories/{config_repository_canonical}/config", @@ -79,7 +176,12 @@ func (a *Client) CreateConfigRepositoryConfig(params *CreateConfigRepositoryConf AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +197,12 @@ func (a *Client) CreateConfigRepositoryConfig(params *CreateConfigRepositoryConf /* DeleteConfigRepository delete a Config Repositories */ -func (a *Client) DeleteConfigRepository(params *DeleteConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteConfigRepositoryNoContent, error) { +func (a *Client) DeleteConfigRepository(params *DeleteConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteConfigRepositoryNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteConfigRepositoryParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteConfigRepository", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/config_repositories/{config_repository_canonical}", @@ -113,7 +214,12 @@ func (a *Client) DeleteConfigRepository(params *DeleteConfigRepositoryParams, au AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +235,12 @@ func (a *Client) DeleteConfigRepository(params *DeleteConfigRepositoryParams, au /* GetConfigRepository Return the Config Repository */ -func (a *Client) GetConfigRepository(params *GetConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter) (*GetConfigRepositoryOK, error) { +func (a *Client) GetConfigRepository(params *GetConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetConfigRepositoryOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetConfigRepositoryParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getConfigRepository", Method: "GET", PathPattern: "/organizations/{organization_canonical}/config_repositories/{config_repository_canonical}", @@ -147,7 +252,12 @@ func (a *Client) GetConfigRepository(params *GetConfigRepositoryParams, authInfo AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +273,12 @@ func (a *Client) GetConfigRepository(params *GetConfigRepositoryParams, authInfo /* ListConfigRepositories Return all the config repositories */ -func (a *Client) ListConfigRepositories(params *ListConfigRepositoriesParams, authInfo runtime.ClientAuthInfoWriter) (*ListConfigRepositoriesOK, error) { +func (a *Client) ListConfigRepositories(params *ListConfigRepositoriesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListConfigRepositoriesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewListConfigRepositoriesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "listConfigRepositories", Method: "GET", PathPattern: "/organizations/{organization_canonical}/config_repositories", @@ -181,7 +290,12 @@ func (a *Client) ListConfigRepositories(params *ListConfigRepositoriesParams, au AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -197,13 +311,12 @@ func (a *Client) ListConfigRepositories(params *ListConfigRepositoriesParams, au /* UpdateConfigRepository Update a config repository */ -func (a *Client) UpdateConfigRepository(params *UpdateConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateConfigRepositoryOK, error) { +func (a *Client) UpdateConfigRepository(params *UpdateConfigRepositoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateConfigRepositoryOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateConfigRepositoryParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateConfigRepository", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/config_repositories/{config_repository_canonical}", @@ -215,7 +328,12 @@ func (a *Client) UpdateConfigRepository(params *UpdateConfigRepositoryParams, au AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_config_repositories/update_config_repository_parameters.go b/client/client/organization_config_repositories/update_config_repository_parameters.go index a2a2b991..4dd55081 100644 --- a/client/client/organization_config_repositories/update_config_repository_parameters.go +++ b/client/client/organization_config_repositories/update_config_repository_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateConfigRepositoryParams creates a new UpdateConfigRepositoryParams object -// with the default values initialized. +// NewUpdateConfigRepositoryParams creates a new UpdateConfigRepositoryParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateConfigRepositoryParams() *UpdateConfigRepositoryParams { - var () return &UpdateConfigRepositoryParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateConfigRepositoryParamsWithTimeout creates a new UpdateConfigRepositoryParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateConfigRepositoryParamsWithTimeout(timeout time.Duration) *UpdateConfigRepositoryParams { - var () return &UpdateConfigRepositoryParams{ - timeout: timeout, } } // NewUpdateConfigRepositoryParamsWithContext creates a new UpdateConfigRepositoryParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateConfigRepositoryParamsWithContext(ctx context.Context) *UpdateConfigRepositoryParams { - var () return &UpdateConfigRepositoryParams{ - Context: ctx, } } // NewUpdateConfigRepositoryParamsWithHTTPClient creates a new UpdateConfigRepositoryParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateConfigRepositoryParamsWithHTTPClient(client *http.Client) *UpdateConfigRepositoryParams { - var () return &UpdateConfigRepositoryParams{ HTTPClient: client, } } -/*UpdateConfigRepositoryParams contains all the parameters to send to the API endpoint -for the update config repository operation typically these are written to a http.Request +/* +UpdateConfigRepositoryParams contains all the parameters to send to the API endpoint + + for the update config repository operation. + + Typically these are written to a http.Request. */ type UpdateConfigRepositoryParams struct { - /*Body - The information of the config repository to create. + /* Body. + The information of the config repository to create. */ Body *models.UpdateConfigRepository - /*ConfigRepositoryCanonical - Organization Config Repositories canonical + /* ConfigRepositoryCanonical. + + Organization Config Repositories canonical */ ConfigRepositoryCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -84,6 +86,21 @@ type UpdateConfigRepositoryParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update config repository params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateConfigRepositoryParams) WithDefaults() *UpdateConfigRepositoryParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update config repository params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateConfigRepositoryParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update config repository params func (o *UpdateConfigRepositoryParams) WithTimeout(timeout time.Duration) *UpdateConfigRepositoryParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateConfigRepositoryParams) WriteToRequest(r runtime.ClientRequest, r return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_config_repositories/update_config_repository_responses.go b/client/client/organization_config_repositories/update_config_repository_responses.go index 2bf11fea..a12c1923 100644 --- a/client/client/organization_config_repositories/update_config_repository_responses.go +++ b/client/client/organization_config_repositories/update_config_repository_responses.go @@ -6,17 +6,18 @@ package organization_config_repositories // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateConfigRepositoryReader is a Reader for the UpdateConfigRepository structure. @@ -62,7 +63,8 @@ func NewUpdateConfigRepositoryOK() *UpdateConfigRepositoryOK { return &UpdateConfigRepositoryOK{} } -/*UpdateConfigRepositoryOK handles this case with default header values. +/* +UpdateConfigRepositoryOK describes a response with status code 200, with default header values. Success creation */ @@ -70,8 +72,44 @@ type UpdateConfigRepositoryOK struct { Payload *UpdateConfigRepositoryOKBody } +// IsSuccess returns true when this update config repository o k response has a 2xx status code +func (o *UpdateConfigRepositoryOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update config repository o k response has a 3xx status code +func (o *UpdateConfigRepositoryOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update config repository o k response has a 4xx status code +func (o *UpdateConfigRepositoryOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update config repository o k response has a 5xx status code +func (o *UpdateConfigRepositoryOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update config repository o k response a status code equal to that given +func (o *UpdateConfigRepositoryOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update config repository o k response +func (o *UpdateConfigRepositoryOK) Code() int { + return 200 +} + func (o *UpdateConfigRepositoryOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryOK %s", 200, payload) +} + +func (o *UpdateConfigRepositoryOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryOK %s", 200, payload) } func (o *UpdateConfigRepositoryOK) GetPayload() *UpdateConfigRepositoryOKBody { @@ -95,20 +133,60 @@ func NewUpdateConfigRepositoryNotFound() *UpdateConfigRepositoryNotFound { return &UpdateConfigRepositoryNotFound{} } -/*UpdateConfigRepositoryNotFound handles this case with default header values. +/* +UpdateConfigRepositoryNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateConfigRepositoryNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update config repository not found response has a 2xx status code +func (o *UpdateConfigRepositoryNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update config repository not found response has a 3xx status code +func (o *UpdateConfigRepositoryNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update config repository not found response has a 4xx status code +func (o *UpdateConfigRepositoryNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update config repository not found response has a 5xx status code +func (o *UpdateConfigRepositoryNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update config repository not found response a status code equal to that given +func (o *UpdateConfigRepositoryNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update config repository not found response +func (o *UpdateConfigRepositoryNotFound) Code() int { + return 404 +} + func (o *UpdateConfigRepositoryNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryNotFound %s", 404, payload) +} + +func (o *UpdateConfigRepositoryNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryNotFound %s", 404, payload) } func (o *UpdateConfigRepositoryNotFound) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *UpdateConfigRepositoryNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateConfigRepositoryNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,15 +221,50 @@ func NewUpdateConfigRepositoryLengthRequired() *UpdateConfigRepositoryLengthRequ return &UpdateConfigRepositoryLengthRequired{} } -/*UpdateConfigRepositoryLengthRequired handles this case with default header values. +/* +UpdateConfigRepositoryLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateConfigRepositoryLengthRequired struct { } +// IsSuccess returns true when this update config repository length required response has a 2xx status code +func (o *UpdateConfigRepositoryLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update config repository length required response has a 3xx status code +func (o *UpdateConfigRepositoryLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update config repository length required response has a 4xx status code +func (o *UpdateConfigRepositoryLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update config repository length required response has a 5xx status code +func (o *UpdateConfigRepositoryLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update config repository length required response a status code equal to that given +func (o *UpdateConfigRepositoryLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update config repository length required response +func (o *UpdateConfigRepositoryLengthRequired) Code() int { + return 411 +} + func (o *UpdateConfigRepositoryLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryLengthRequired", 411) +} + +func (o *UpdateConfigRepositoryLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepositoryLengthRequired", 411) } func (o *UpdateConfigRepositoryLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -162,27 +279,61 @@ func NewUpdateConfigRepositoryDefault(code int) *UpdateConfigRepositoryDefault { } } -/*UpdateConfigRepositoryDefault handles this case with default header values. +/* +UpdateConfigRepositoryDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateConfigRepositoryDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update config repository default response has a 2xx status code +func (o *UpdateConfigRepositoryDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update config repository default response has a 3xx status code +func (o *UpdateConfigRepositoryDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update config repository default response has a 4xx status code +func (o *UpdateConfigRepositoryDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update config repository default response has a 5xx status code +func (o *UpdateConfigRepositoryDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update config repository default response a status code equal to that given +func (o *UpdateConfigRepositoryDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update config repository default response func (o *UpdateConfigRepositoryDefault) Code() int { return o._statusCode } func (o *UpdateConfigRepositoryDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepository default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepository default %s", o._statusCode, payload) +} + +func (o *UpdateConfigRepositoryDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/config_repositories/{config_repository_canonical}][%d] updateConfigRepository default %s", o._statusCode, payload) } func (o *UpdateConfigRepositoryDefault) GetPayload() *models.ErrorPayload { @@ -191,12 +342,16 @@ func (o *UpdateConfigRepositoryDefault) GetPayload() *models.ErrorPayload { func (o *UpdateConfigRepositoryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -208,7 +363,8 @@ func (o *UpdateConfigRepositoryDefault) readResponse(response runtime.ClientResp return nil } -/*UpdateConfigRepositoryOKBody update config repository o k body +/* +UpdateConfigRepositoryOKBody update config repository o k body swagger:model UpdateConfigRepositoryOKBody */ type UpdateConfigRepositoryOKBody struct { @@ -242,6 +398,39 @@ func (o *UpdateConfigRepositoryOKBody) validateData(formats strfmt.Registry) err if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateConfigRepositoryOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateConfigRepositoryOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update config repository o k body based on the context it is used +func (o *UpdateConfigRepositoryOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateConfigRepositoryOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateConfigRepositoryOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateConfigRepositoryOK" + "." + "data") } return err } diff --git a/client/client/organization_credentials/create_credential_parameters.go b/client/client/organization_credentials/create_credential_parameters.go index 8cd15d21..0766762d 100644 --- a/client/client/organization_credentials/create_credential_parameters.go +++ b/client/client/organization_credentials/create_credential_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateCredentialParams creates a new CreateCredentialParams object -// with the default values initialized. +// NewCreateCredentialParams creates a new CreateCredentialParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateCredentialParams() *CreateCredentialParams { - var () return &CreateCredentialParams{ - timeout: cr.DefaultTimeout, } } // NewCreateCredentialParamsWithTimeout creates a new CreateCredentialParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateCredentialParamsWithTimeout(timeout time.Duration) *CreateCredentialParams { - var () return &CreateCredentialParams{ - timeout: timeout, } } // NewCreateCredentialParamsWithContext creates a new CreateCredentialParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateCredentialParamsWithContext(ctx context.Context) *CreateCredentialParams { - var () return &CreateCredentialParams{ - Context: ctx, } } // NewCreateCredentialParamsWithHTTPClient creates a new CreateCredentialParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateCredentialParamsWithHTTPClient(client *http.Client) *CreateCredentialParams { - var () return &CreateCredentialParams{ HTTPClient: client, } } -/*CreateCredentialParams contains all the parameters to send to the API endpoint -for the create credential operation typically these are written to a http.Request +/* +CreateCredentialParams contains all the parameters to send to the API endpoint + + for the create credential operation. + + Typically these are written to a http.Request. */ type CreateCredentialParams struct { - /*Body - The information of the organization to create. + /* Body. + The information of the organization to create. */ Body *models.NewCredential - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type CreateCredentialParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create credential params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateCredentialParams) WithDefaults() *CreateCredentialParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create credential params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateCredentialParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create credential params func (o *CreateCredentialParams) WithTimeout(timeout time.Duration) *CreateCredentialParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CreateCredentialParams) WriteToRequest(r runtime.ClientRequest, reg str return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_credentials/create_credential_responses.go b/client/client/organization_credentials/create_credential_responses.go index 10c06e18..0bfd882f 100644 --- a/client/client/organization_credentials/create_credential_responses.go +++ b/client/client/organization_credentials/create_credential_responses.go @@ -6,17 +6,18 @@ package organization_credentials // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateCredentialReader is a Reader for the CreateCredential structure. @@ -62,7 +63,8 @@ func NewCreateCredentialOK() *CreateCredentialOK { return &CreateCredentialOK{} } -/*CreateCredentialOK handles this case with default header values. +/* +CreateCredentialOK describes a response with status code 200, with default header values. Credential created. The body contains the information of the new created Credential. */ @@ -70,8 +72,44 @@ type CreateCredentialOK struct { Payload *CreateCredentialOKBody } +// IsSuccess returns true when this create credential o k response has a 2xx status code +func (o *CreateCredentialOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create credential o k response has a 3xx status code +func (o *CreateCredentialOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create credential o k response has a 4xx status code +func (o *CreateCredentialOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create credential o k response has a 5xx status code +func (o *CreateCredentialOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create credential o k response a status code equal to that given +func (o *CreateCredentialOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create credential o k response +func (o *CreateCredentialOK) Code() int { + return 200 +} + func (o *CreateCredentialOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialOK %s", 200, payload) +} + +func (o *CreateCredentialOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialOK %s", 200, payload) } func (o *CreateCredentialOK) GetPayload() *CreateCredentialOKBody { @@ -95,15 +133,50 @@ func NewCreateCredentialLengthRequired() *CreateCredentialLengthRequired { return &CreateCredentialLengthRequired{} } -/*CreateCredentialLengthRequired handles this case with default header values. +/* +CreateCredentialLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreateCredentialLengthRequired struct { } +// IsSuccess returns true when this create credential length required response has a 2xx status code +func (o *CreateCredentialLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create credential length required response has a 3xx status code +func (o *CreateCredentialLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create credential length required response has a 4xx status code +func (o *CreateCredentialLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create credential length required response has a 5xx status code +func (o *CreateCredentialLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create credential length required response a status code equal to that given +func (o *CreateCredentialLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create credential length required response +func (o *CreateCredentialLengthRequired) Code() int { + return 411 +} + func (o *CreateCredentialLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialLengthRequired", 411) +} + +func (o *CreateCredentialLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialLengthRequired", 411) } func (o *CreateCredentialLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -116,20 +189,60 @@ func NewCreateCredentialUnprocessableEntity() *CreateCredentialUnprocessableEnti return &CreateCredentialUnprocessableEntity{} } -/*CreateCredentialUnprocessableEntity handles this case with default header values. +/* +CreateCredentialUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateCredentialUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create credential unprocessable entity response has a 2xx status code +func (o *CreateCredentialUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create credential unprocessable entity response has a 3xx status code +func (o *CreateCredentialUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create credential unprocessable entity response has a 4xx status code +func (o *CreateCredentialUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create credential unprocessable entity response has a 5xx status code +func (o *CreateCredentialUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create credential unprocessable entity response a status code equal to that given +func (o *CreateCredentialUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create credential unprocessable entity response +func (o *CreateCredentialUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateCredentialUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialUnprocessableEntity %s", 422, payload) +} + +func (o *CreateCredentialUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredentialUnprocessableEntity %s", 422, payload) } func (o *CreateCredentialUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -138,12 +251,16 @@ func (o *CreateCredentialUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *CreateCredentialUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -162,27 +279,61 @@ func NewCreateCredentialDefault(code int) *CreateCredentialDefault { } } -/*CreateCredentialDefault handles this case with default header values. +/* +CreateCredentialDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateCredentialDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create credential default response has a 2xx status code +func (o *CreateCredentialDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create credential default response has a 3xx status code +func (o *CreateCredentialDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create credential default response has a 4xx status code +func (o *CreateCredentialDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create credential default response has a 5xx status code +func (o *CreateCredentialDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create credential default response a status code equal to that given +func (o *CreateCredentialDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create credential default response func (o *CreateCredentialDefault) Code() int { return o._statusCode } func (o *CreateCredentialDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredential default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredential default %s", o._statusCode, payload) +} + +func (o *CreateCredentialDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/credentials][%d] createCredential default %s", o._statusCode, payload) } func (o *CreateCredentialDefault) GetPayload() *models.ErrorPayload { @@ -191,12 +342,16 @@ func (o *CreateCredentialDefault) GetPayload() *models.ErrorPayload { func (o *CreateCredentialDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -208,7 +363,8 @@ func (o *CreateCredentialDefault) readResponse(response runtime.ClientResponse, return nil } -/*CreateCredentialOKBody create credential o k body +/* +CreateCredentialOKBody create credential o k body swagger:model CreateCredentialOKBody */ type CreateCredentialOKBody struct { @@ -242,6 +398,39 @@ func (o *CreateCredentialOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createCredentialOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createCredentialOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create credential o k body based on the context it is used +func (o *CreateCredentialOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateCredentialOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createCredentialOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createCredentialOK" + "." + "data") } return err } diff --git a/client/client/organization_credentials/delete_credential_parameters.go b/client/client/organization_credentials/delete_credential_parameters.go index d0b84bd7..c34ae783 100644 --- a/client/client/organization_credentials/delete_credential_parameters.go +++ b/client/client/organization_credentials/delete_credential_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteCredentialParams creates a new DeleteCredentialParams object -// with the default values initialized. +// NewDeleteCredentialParams creates a new DeleteCredentialParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteCredentialParams() *DeleteCredentialParams { - var () return &DeleteCredentialParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteCredentialParamsWithTimeout creates a new DeleteCredentialParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteCredentialParamsWithTimeout(timeout time.Duration) *DeleteCredentialParams { - var () return &DeleteCredentialParams{ - timeout: timeout, } } // NewDeleteCredentialParamsWithContext creates a new DeleteCredentialParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteCredentialParamsWithContext(ctx context.Context) *DeleteCredentialParams { - var () return &DeleteCredentialParams{ - Context: ctx, } } // NewDeleteCredentialParamsWithHTTPClient creates a new DeleteCredentialParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteCredentialParamsWithHTTPClient(client *http.Client) *DeleteCredentialParams { - var () return &DeleteCredentialParams{ HTTPClient: client, } } -/*DeleteCredentialParams contains all the parameters to send to the API endpoint -for the delete credential operation typically these are written to a http.Request +/* +DeleteCredentialParams contains all the parameters to send to the API endpoint + + for the delete credential operation. + + Typically these are written to a http.Request. */ type DeleteCredentialParams struct { - /*CredentialCanonical - A Credential canonical + /* CredentialCanonical. + A Credential canonical */ CredentialCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type DeleteCredentialParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete credential params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteCredentialParams) WithDefaults() *DeleteCredentialParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete credential params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteCredentialParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete credential params func (o *DeleteCredentialParams) WithTimeout(timeout time.Duration) *DeleteCredentialParams { o.SetTimeout(timeout) diff --git a/client/client/organization_credentials/delete_credential_responses.go b/client/client/organization_credentials/delete_credential_responses.go index 18fe32bb..dbffb467 100644 --- a/client/client/organization_credentials/delete_credential_responses.go +++ b/client/client/organization_credentials/delete_credential_responses.go @@ -6,16 +6,16 @@ package organization_credentials // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteCredentialReader is a Reader for the DeleteCredential structure. @@ -67,15 +67,50 @@ func NewDeleteCredentialNoContent() *DeleteCredentialNoContent { return &DeleteCredentialNoContent{} } -/*DeleteCredentialNoContent handles this case with default header values. +/* +DeleteCredentialNoContent describes a response with status code 204, with default header values. Credential has been deleted. */ type DeleteCredentialNoContent struct { } +// IsSuccess returns true when this delete credential no content response has a 2xx status code +func (o *DeleteCredentialNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete credential no content response has a 3xx status code +func (o *DeleteCredentialNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete credential no content response has a 4xx status code +func (o *DeleteCredentialNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete credential no content response has a 5xx status code +func (o *DeleteCredentialNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete credential no content response a status code equal to that given +func (o *DeleteCredentialNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete credential no content response +func (o *DeleteCredentialNoContent) Code() int { + return 204 +} + func (o *DeleteCredentialNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialNoContent", 204) +} + +func (o *DeleteCredentialNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialNoContent", 204) } func (o *DeleteCredentialNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -88,20 +123,60 @@ func NewDeleteCredentialForbidden() *DeleteCredentialForbidden { return &DeleteCredentialForbidden{} } -/*DeleteCredentialForbidden handles this case with default header values. +/* +DeleteCredentialForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteCredentialForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete credential forbidden response has a 2xx status code +func (o *DeleteCredentialForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete credential forbidden response has a 3xx status code +func (o *DeleteCredentialForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete credential forbidden response has a 4xx status code +func (o *DeleteCredentialForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete credential forbidden response has a 5xx status code +func (o *DeleteCredentialForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete credential forbidden response a status code equal to that given +func (o *DeleteCredentialForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete credential forbidden response +func (o *DeleteCredentialForbidden) Code() int { + return 403 +} + func (o *DeleteCredentialForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialForbidden %s", 403, payload) +} + +func (o *DeleteCredentialForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialForbidden %s", 403, payload) } func (o *DeleteCredentialForbidden) GetPayload() *models.ErrorPayload { @@ -110,12 +185,16 @@ func (o *DeleteCredentialForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteCredentialForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -132,20 +211,60 @@ func NewDeleteCredentialNotFound() *DeleteCredentialNotFound { return &DeleteCredentialNotFound{} } -/*DeleteCredentialNotFound handles this case with default header values. +/* +DeleteCredentialNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteCredentialNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete credential not found response has a 2xx status code +func (o *DeleteCredentialNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete credential not found response has a 3xx status code +func (o *DeleteCredentialNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete credential not found response has a 4xx status code +func (o *DeleteCredentialNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete credential not found response has a 5xx status code +func (o *DeleteCredentialNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete credential not found response a status code equal to that given +func (o *DeleteCredentialNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete credential not found response +func (o *DeleteCredentialNotFound) Code() int { + return 404 +} + func (o *DeleteCredentialNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialNotFound %s", 404, payload) +} + +func (o *DeleteCredentialNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialNotFound %s", 404, payload) } func (o *DeleteCredentialNotFound) GetPayload() *models.ErrorPayload { @@ -154,12 +273,16 @@ func (o *DeleteCredentialNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteCredentialNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -176,15 +299,50 @@ func NewDeleteCredentialConflict() *DeleteCredentialConflict { return &DeleteCredentialConflict{} } -/*DeleteCredentialConflict handles this case with default header values. +/* +DeleteCredentialConflict describes a response with status code 409, with default header values. Credential deletion has internal conflict */ type DeleteCredentialConflict struct { } +// IsSuccess returns true when this delete credential conflict response has a 2xx status code +func (o *DeleteCredentialConflict) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete credential conflict response has a 3xx status code +func (o *DeleteCredentialConflict) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete credential conflict response has a 4xx status code +func (o *DeleteCredentialConflict) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete credential conflict response has a 5xx status code +func (o *DeleteCredentialConflict) IsServerError() bool { + return false +} + +// IsCode returns true when this delete credential conflict response a status code equal to that given +func (o *DeleteCredentialConflict) IsCode(code int) bool { + return code == 409 +} + +// Code gets the status code for the delete credential conflict response +func (o *DeleteCredentialConflict) Code() int { + return 409 +} + func (o *DeleteCredentialConflict) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialConflict ", 409) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialConflict", 409) +} + +func (o *DeleteCredentialConflict) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredentialConflict", 409) } func (o *DeleteCredentialConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -199,27 +357,61 @@ func NewDeleteCredentialDefault(code int) *DeleteCredentialDefault { } } -/*DeleteCredentialDefault handles this case with default header values. +/* +DeleteCredentialDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteCredentialDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete credential default response has a 2xx status code +func (o *DeleteCredentialDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete credential default response has a 3xx status code +func (o *DeleteCredentialDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete credential default response has a 4xx status code +func (o *DeleteCredentialDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete credential default response has a 5xx status code +func (o *DeleteCredentialDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete credential default response a status code equal to that given +func (o *DeleteCredentialDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete credential default response func (o *DeleteCredentialDefault) Code() int { return o._statusCode } func (o *DeleteCredentialDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredential default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredential default %s", o._statusCode, payload) +} + +func (o *DeleteCredentialDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] deleteCredential default %s", o._statusCode, payload) } func (o *DeleteCredentialDefault) GetPayload() *models.ErrorPayload { @@ -228,12 +420,16 @@ func (o *DeleteCredentialDefault) GetPayload() *models.ErrorPayload { func (o *DeleteCredentialDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_credentials/get_credential_options_parameters.go b/client/client/organization_credentials/get_credential_options_parameters.go index 407b7382..ab1a7a17 100644 --- a/client/client/organization_credentials/get_credential_options_parameters.go +++ b/client/client/organization_credentials/get_credential_options_parameters.go @@ -13,65 +13,67 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetCredentialOptionsParams creates a new GetCredentialOptionsParams object -// with the default values initialized. +// NewGetCredentialOptionsParams creates a new GetCredentialOptionsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetCredentialOptionsParams() *GetCredentialOptionsParams { - var () return &GetCredentialOptionsParams{ - timeout: cr.DefaultTimeout, } } // NewGetCredentialOptionsParamsWithTimeout creates a new GetCredentialOptionsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetCredentialOptionsParamsWithTimeout(timeout time.Duration) *GetCredentialOptionsParams { - var () return &GetCredentialOptionsParams{ - timeout: timeout, } } // NewGetCredentialOptionsParamsWithContext creates a new GetCredentialOptionsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetCredentialOptionsParamsWithContext(ctx context.Context) *GetCredentialOptionsParams { - var () return &GetCredentialOptionsParams{ - Context: ctx, } } // NewGetCredentialOptionsParamsWithHTTPClient creates a new GetCredentialOptionsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetCredentialOptionsParamsWithHTTPClient(client *http.Client) *GetCredentialOptionsParams { - var () return &GetCredentialOptionsParams{ HTTPClient: client, } } -/*GetCredentialOptionsParams contains all the parameters to send to the API endpoint -for the get credential options operation typically these are written to a http.Request +/* +GetCredentialOptionsParams contains all the parameters to send to the API endpoint + + for the get credential options operation. + + Typically these are written to a http.Request. */ type GetCredentialOptionsParams struct { - /*CredentialCanonical - A Credential canonical + /* CredentialCanonical. + A Credential canonical */ CredentialCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*Service*/ + + // Service. Service string timeout time.Duration @@ -79,6 +81,21 @@ type GetCredentialOptionsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get credential options params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetCredentialOptionsParams) WithDefaults() *GetCredentialOptionsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get credential options params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetCredentialOptionsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get credential options params func (o *GetCredentialOptionsParams) WithTimeout(timeout time.Duration) *GetCredentialOptionsParams { o.SetTimeout(timeout) @@ -167,6 +184,7 @@ func (o *GetCredentialOptionsParams) WriteToRequest(r runtime.ClientRequest, reg qrService := o.Service qService := qrService if qService != "" { + if err := r.SetQueryParam("service", qService); err != nil { return err } diff --git a/client/client/organization_credentials/get_credential_options_responses.go b/client/client/organization_credentials/get_credential_options_responses.go index ae0cfc96..ef5ee915 100644 --- a/client/client/organization_credentials/get_credential_options_responses.go +++ b/client/client/organization_credentials/get_credential_options_responses.go @@ -6,17 +6,17 @@ package organization_credentials // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetCredentialOptionsReader is a Reader for the GetCredentialOptions structure. @@ -62,7 +62,8 @@ func NewGetCredentialOptionsOK() *GetCredentialOptionsOK { return &GetCredentialOptionsOK{} } -/*GetCredentialOptionsOK handles this case with default header values. +/* +GetCredentialOptionsOK describes a response with status code 200, with default header values. Service-specific options for the Credential with the specified ID. */ @@ -70,8 +71,44 @@ type GetCredentialOptionsOK struct { Payload *GetCredentialOptionsOKBody } +// IsSuccess returns true when this get credential options o k response has a 2xx status code +func (o *GetCredentialOptionsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get credential options o k response has a 3xx status code +func (o *GetCredentialOptionsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get credential options o k response has a 4xx status code +func (o *GetCredentialOptionsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get credential options o k response has a 5xx status code +func (o *GetCredentialOptionsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get credential options o k response a status code equal to that given +func (o *GetCredentialOptionsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get credential options o k response +func (o *GetCredentialOptionsOK) Code() int { + return 200 +} + func (o *GetCredentialOptionsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsOK %s", 200, payload) +} + +func (o *GetCredentialOptionsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsOK %s", 200, payload) } func (o *GetCredentialOptionsOK) GetPayload() *GetCredentialOptionsOKBody { @@ -95,20 +132,60 @@ func NewGetCredentialOptionsForbidden() *GetCredentialOptionsForbidden { return &GetCredentialOptionsForbidden{} } -/*GetCredentialOptionsForbidden handles this case with default header values. +/* +GetCredentialOptionsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetCredentialOptionsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get credential options forbidden response has a 2xx status code +func (o *GetCredentialOptionsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get credential options forbidden response has a 3xx status code +func (o *GetCredentialOptionsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get credential options forbidden response has a 4xx status code +func (o *GetCredentialOptionsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get credential options forbidden response has a 5xx status code +func (o *GetCredentialOptionsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get credential options forbidden response a status code equal to that given +func (o *GetCredentialOptionsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get credential options forbidden response +func (o *GetCredentialOptionsForbidden) Code() int { + return 403 +} + func (o *GetCredentialOptionsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsForbidden %s", 403, payload) +} + +func (o *GetCredentialOptionsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsForbidden %s", 403, payload) } func (o *GetCredentialOptionsForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +194,16 @@ func (o *GetCredentialOptionsForbidden) GetPayload() *models.ErrorPayload { func (o *GetCredentialOptionsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +220,60 @@ func NewGetCredentialOptionsNotFound() *GetCredentialOptionsNotFound { return &GetCredentialOptionsNotFound{} } -/*GetCredentialOptionsNotFound handles this case with default header values. +/* +GetCredentialOptionsNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetCredentialOptionsNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get credential options not found response has a 2xx status code +func (o *GetCredentialOptionsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get credential options not found response has a 3xx status code +func (o *GetCredentialOptionsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get credential options not found response has a 4xx status code +func (o *GetCredentialOptionsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get credential options not found response has a 5xx status code +func (o *GetCredentialOptionsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get credential options not found response a status code equal to that given +func (o *GetCredentialOptionsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get credential options not found response +func (o *GetCredentialOptionsNotFound) Code() int { + return 404 +} + func (o *GetCredentialOptionsNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsNotFound %s", 404, payload) +} + +func (o *GetCredentialOptionsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptionsNotFound %s", 404, payload) } func (o *GetCredentialOptionsNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +282,16 @@ func (o *GetCredentialOptionsNotFound) GetPayload() *models.ErrorPayload { func (o *GetCredentialOptionsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +310,61 @@ func NewGetCredentialOptionsDefault(code int) *GetCredentialOptionsDefault { } } -/*GetCredentialOptionsDefault handles this case with default header values. +/* +GetCredentialOptionsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetCredentialOptionsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get credential options default response has a 2xx status code +func (o *GetCredentialOptionsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get credential options default response has a 3xx status code +func (o *GetCredentialOptionsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get credential options default response has a 4xx status code +func (o *GetCredentialOptionsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get credential options default response has a 5xx status code +func (o *GetCredentialOptionsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get credential options default response a status code equal to that given +func (o *GetCredentialOptionsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get credential options default response func (o *GetCredentialOptionsDefault) Code() int { return o._statusCode } func (o *GetCredentialOptionsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptions default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptions default %s", o._statusCode, payload) +} + +func (o *GetCredentialOptionsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}/options][%d] getCredentialOptions default %s", o._statusCode, payload) } func (o *GetCredentialOptionsDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +373,16 @@ func (o *GetCredentialOptionsDefault) GetPayload() *models.ErrorPayload { func (o *GetCredentialOptionsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +394,8 @@ func (o *GetCredentialOptionsDefault) readResponse(response runtime.ClientRespon return nil } -/*GetCredentialOptionsOKBody get credential options o k body +/* +GetCredentialOptionsOKBody get credential options o k body swagger:model GetCredentialOptionsOKBody */ type GetCredentialOptionsOKBody struct { @@ -257,13 +421,18 @@ func (o *GetCredentialOptionsOKBody) Validate(formats strfmt.Registry) error { func (o *GetCredentialOptionsOKBody) validateData(formats strfmt.Registry) error { - if err := validate.Required("getCredentialOptionsOK"+"."+"data", "body", o.Data); err != nil { - return err + if o.Data == nil { + return errors.Required("getCredentialOptionsOK"+"."+"data", "body", nil) } return nil } +// ContextValidate validates this get credential options o k body based on context it is used +func (o *GetCredentialOptionsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *GetCredentialOptionsOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/organization_credentials/get_credential_parameters.go b/client/client/organization_credentials/get_credential_parameters.go index 209b41f1..ca15f10f 100644 --- a/client/client/organization_credentials/get_credential_parameters.go +++ b/client/client/organization_credentials/get_credential_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetCredentialParams creates a new GetCredentialParams object -// with the default values initialized. +// NewGetCredentialParams creates a new GetCredentialParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetCredentialParams() *GetCredentialParams { - var () return &GetCredentialParams{ - timeout: cr.DefaultTimeout, } } // NewGetCredentialParamsWithTimeout creates a new GetCredentialParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetCredentialParamsWithTimeout(timeout time.Duration) *GetCredentialParams { - var () return &GetCredentialParams{ - timeout: timeout, } } // NewGetCredentialParamsWithContext creates a new GetCredentialParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetCredentialParamsWithContext(ctx context.Context) *GetCredentialParams { - var () return &GetCredentialParams{ - Context: ctx, } } // NewGetCredentialParamsWithHTTPClient creates a new GetCredentialParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetCredentialParamsWithHTTPClient(client *http.Client) *GetCredentialParams { - var () return &GetCredentialParams{ HTTPClient: client, } } -/*GetCredentialParams contains all the parameters to send to the API endpoint -for the get credential operation typically these are written to a http.Request +/* +GetCredentialParams contains all the parameters to send to the API endpoint + + for the get credential operation. + + Typically these are written to a http.Request. */ type GetCredentialParams struct { - /*CredentialCanonical - A Credential canonical + /* CredentialCanonical. + A Credential canonical */ CredentialCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type GetCredentialParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get credential params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetCredentialParams) WithDefaults() *GetCredentialParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get credential params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetCredentialParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get credential params func (o *GetCredentialParams) WithTimeout(timeout time.Duration) *GetCredentialParams { o.SetTimeout(timeout) diff --git a/client/client/organization_credentials/get_credential_responses.go b/client/client/organization_credentials/get_credential_responses.go index 6ce6d69b..5cae3076 100644 --- a/client/client/organization_credentials/get_credential_responses.go +++ b/client/client/organization_credentials/get_credential_responses.go @@ -6,17 +6,18 @@ package organization_credentials // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetCredentialReader is a Reader for the GetCredential structure. @@ -62,7 +63,8 @@ func NewGetCredentialOK() *GetCredentialOK { return &GetCredentialOK{} } -/*GetCredentialOK handles this case with default header values. +/* +GetCredentialOK describes a response with status code 200, with default header values. The information of the Credential which has the specified ID. */ @@ -70,8 +72,44 @@ type GetCredentialOK struct { Payload *GetCredentialOKBody } +// IsSuccess returns true when this get credential o k response has a 2xx status code +func (o *GetCredentialOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get credential o k response has a 3xx status code +func (o *GetCredentialOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get credential o k response has a 4xx status code +func (o *GetCredentialOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get credential o k response has a 5xx status code +func (o *GetCredentialOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get credential o k response a status code equal to that given +func (o *GetCredentialOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get credential o k response +func (o *GetCredentialOK) Code() int { + return 200 +} + func (o *GetCredentialOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialOK %s", 200, payload) +} + +func (o *GetCredentialOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialOK %s", 200, payload) } func (o *GetCredentialOK) GetPayload() *GetCredentialOKBody { @@ -95,20 +133,60 @@ func NewGetCredentialForbidden() *GetCredentialForbidden { return &GetCredentialForbidden{} } -/*GetCredentialForbidden handles this case with default header values. +/* +GetCredentialForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetCredentialForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get credential forbidden response has a 2xx status code +func (o *GetCredentialForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get credential forbidden response has a 3xx status code +func (o *GetCredentialForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get credential forbidden response has a 4xx status code +func (o *GetCredentialForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get credential forbidden response has a 5xx status code +func (o *GetCredentialForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get credential forbidden response a status code equal to that given +func (o *GetCredentialForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get credential forbidden response +func (o *GetCredentialForbidden) Code() int { + return 403 +} + func (o *GetCredentialForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialForbidden %s", 403, payload) +} + +func (o *GetCredentialForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialForbidden %s", 403, payload) } func (o *GetCredentialForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetCredentialForbidden) GetPayload() *models.ErrorPayload { func (o *GetCredentialForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetCredentialNotFound() *GetCredentialNotFound { return &GetCredentialNotFound{} } -/*GetCredentialNotFound handles this case with default header values. +/* +GetCredentialNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetCredentialNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get credential not found response has a 2xx status code +func (o *GetCredentialNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get credential not found response has a 3xx status code +func (o *GetCredentialNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get credential not found response has a 4xx status code +func (o *GetCredentialNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get credential not found response has a 5xx status code +func (o *GetCredentialNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get credential not found response a status code equal to that given +func (o *GetCredentialNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get credential not found response +func (o *GetCredentialNotFound) Code() int { + return 404 +} + func (o *GetCredentialNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialNotFound %s", 404, payload) +} + +func (o *GetCredentialNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredentialNotFound %s", 404, payload) } func (o *GetCredentialNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetCredentialNotFound) GetPayload() *models.ErrorPayload { func (o *GetCredentialNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetCredentialDefault(code int) *GetCredentialDefault { } } -/*GetCredentialDefault handles this case with default header values. +/* +GetCredentialDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetCredentialDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get credential default response has a 2xx status code +func (o *GetCredentialDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get credential default response has a 3xx status code +func (o *GetCredentialDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get credential default response has a 4xx status code +func (o *GetCredentialDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get credential default response has a 5xx status code +func (o *GetCredentialDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get credential default response a status code equal to that given +func (o *GetCredentialDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get credential default response func (o *GetCredentialDefault) Code() int { return o._statusCode } func (o *GetCredentialDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredential default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredential default %s", o._statusCode, payload) +} + +func (o *GetCredentialDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] getCredential default %s", o._statusCode, payload) } func (o *GetCredentialDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetCredentialDefault) GetPayload() *models.ErrorPayload { func (o *GetCredentialDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetCredentialDefault) readResponse(response runtime.ClientResponse, con return nil } -/*GetCredentialOKBody get credential o k body +/* +GetCredentialOKBody get credential o k body swagger:model GetCredentialOKBody */ type GetCredentialOKBody struct { @@ -265,6 +430,39 @@ func (o *GetCredentialOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getCredentialOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getCredentialOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get credential o k body based on the context it is used +func (o *GetCredentialOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetCredentialOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getCredentialOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getCredentialOK" + "." + "data") } return err } diff --git a/client/client/organization_credentials/list_credentials_parameters.go b/client/client/organization_credentials/list_credentials_parameters.go index f0be9b49..731422b2 100644 --- a/client/client/organization_credentials/list_credentials_parameters.go +++ b/client/client/organization_credentials/list_credentials_parameters.go @@ -13,100 +13,90 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewListCredentialsParams creates a new ListCredentialsParams object -// with the default values initialized. +// NewListCredentialsParams creates a new ListCredentialsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewListCredentialsParams() *ListCredentialsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &ListCredentialsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewListCredentialsParamsWithTimeout creates a new ListCredentialsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewListCredentialsParamsWithTimeout(timeout time.Duration) *ListCredentialsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &ListCredentialsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewListCredentialsParamsWithContext creates a new ListCredentialsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewListCredentialsParamsWithContext(ctx context.Context) *ListCredentialsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &ListCredentialsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewListCredentialsParamsWithHTTPClient creates a new ListCredentialsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewListCredentialsParamsWithHTTPClient(client *http.Client) *ListCredentialsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &ListCredentialsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*ListCredentialsParams contains all the parameters to send to the API endpoint -for the list credentials operation typically these are written to a http.Request +/* +ListCredentialsParams contains all the parameters to send to the API endpoint + + for the list credentials operation. + + Typically these are written to a http.Request. */ type ListCredentialsParams struct { - /*CredentialType - Deprecated. Please use credential_types. - A Credential type + /* CredentialType. + Deprecated. Please use credential_types. + A Credential type */ CredentialType *string - /*CredentialTypes - Multiple Credential types + /* CredentialTypes. + + Multiple Credential types */ CredentialTypes []string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -115,6 +105,35 @@ type ListCredentialsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the list credentials params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListCredentialsParams) WithDefaults() *ListCredentialsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list credentials params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListCredentialsParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := ListCredentialsParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the list credentials params func (o *ListCredentialsParams) WithTimeout(timeout time.Duration) *ListCredentialsParams { o.SetTimeout(timeout) @@ -215,24 +234,28 @@ func (o *ListCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strf // query param credential_type var qrCredentialType string + if o.CredentialType != nil { qrCredentialType = *o.CredentialType } qCredentialType := qrCredentialType if qCredentialType != "" { + if err := r.SetQueryParam("credential_type", qCredentialType); err != nil { return err } } - } - valuesCredentialTypes := o.CredentialTypes + if o.CredentialTypes != nil { - joinedCredentialTypes := swag.JoinByFormat(valuesCredentialTypes, "multi") - // query array param credential_types - if err := r.SetQueryParam("credential_types", joinedCredentialTypes...); err != nil { - return err + // binding items for credential_types + joinedCredentialTypes := o.bindParamCredentialTypes(reg) + + // query array param credential_types + if err := r.SetQueryParam("credential_types", joinedCredentialTypes...); err != nil { + return err + } } // path param organization_canonical @@ -244,32 +267,34 @@ func (o *ListCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strf // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { @@ -277,3 +302,20 @@ func (o *ListCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strf } return nil } + +// bindParamListCredentials binds the parameter credential_types +func (o *ListCredentialsParams) bindParamCredentialTypes(formats strfmt.Registry) []string { + credentialTypesIR := o.CredentialTypes + + var credentialTypesIC []string + for _, credentialTypesIIR := range credentialTypesIR { // explode []string + + credentialTypesIIV := credentialTypesIIR // string as string + credentialTypesIC = append(credentialTypesIC, credentialTypesIIV) + } + + // items.CollectionFormat: "multi" + credentialTypesIS := swag.JoinByFormat(credentialTypesIC, "multi") + + return credentialTypesIS +} diff --git a/client/client/organization_credentials/list_credentials_responses.go b/client/client/organization_credentials/list_credentials_responses.go index b48f2a0d..3b06d30e 100644 --- a/client/client/organization_credentials/list_credentials_responses.go +++ b/client/client/organization_credentials/list_credentials_responses.go @@ -6,18 +6,19 @@ package organization_credentials // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ListCredentialsReader is a Reader for the ListCredentials structure. @@ -63,7 +64,8 @@ func NewListCredentialsOK() *ListCredentialsOK { return &ListCredentialsOK{} } -/*ListCredentialsOK handles this case with default header values. +/* +ListCredentialsOK describes a response with status code 200, with default header values. List of the Credentials */ @@ -71,8 +73,44 @@ type ListCredentialsOK struct { Payload *ListCredentialsOKBody } +// IsSuccess returns true when this list credentials o k response has a 2xx status code +func (o *ListCredentialsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list credentials o k response has a 3xx status code +func (o *ListCredentialsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list credentials o k response has a 4xx status code +func (o *ListCredentialsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list credentials o k response has a 5xx status code +func (o *ListCredentialsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list credentials o k response a status code equal to that given +func (o *ListCredentialsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list credentials o k response +func (o *ListCredentialsOK) Code() int { + return 200 +} + func (o *ListCredentialsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsOK %s", 200, payload) +} + +func (o *ListCredentialsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsOK %s", 200, payload) } func (o *ListCredentialsOK) GetPayload() *ListCredentialsOKBody { @@ -96,20 +134,60 @@ func NewListCredentialsForbidden() *ListCredentialsForbidden { return &ListCredentialsForbidden{} } -/*ListCredentialsForbidden handles this case with default header values. +/* +ListCredentialsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ListCredentialsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this list credentials forbidden response has a 2xx status code +func (o *ListCredentialsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list credentials forbidden response has a 3xx status code +func (o *ListCredentialsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list credentials forbidden response has a 4xx status code +func (o *ListCredentialsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this list credentials forbidden response has a 5xx status code +func (o *ListCredentialsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this list credentials forbidden response a status code equal to that given +func (o *ListCredentialsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the list credentials forbidden response +func (o *ListCredentialsForbidden) Code() int { + return 403 +} + func (o *ListCredentialsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsForbidden %s", 403, payload) +} + +func (o *ListCredentialsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsForbidden %s", 403, payload) } func (o *ListCredentialsForbidden) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *ListCredentialsForbidden) GetPayload() *models.ErrorPayload { func (o *ListCredentialsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewListCredentialsNotFound() *ListCredentialsNotFound { return &ListCredentialsNotFound{} } -/*ListCredentialsNotFound handles this case with default header values. +/* +ListCredentialsNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type ListCredentialsNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this list credentials not found response has a 2xx status code +func (o *ListCredentialsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list credentials not found response has a 3xx status code +func (o *ListCredentialsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list credentials not found response has a 4xx status code +func (o *ListCredentialsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this list credentials not found response has a 5xx status code +func (o *ListCredentialsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this list credentials not found response a status code equal to that given +func (o *ListCredentialsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the list credentials not found response +func (o *ListCredentialsNotFound) Code() int { + return 404 +} + func (o *ListCredentialsNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsNotFound %s", 404, payload) +} + +func (o *ListCredentialsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentialsNotFound %s", 404, payload) } func (o *ListCredentialsNotFound) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *ListCredentialsNotFound) GetPayload() *models.ErrorPayload { func (o *ListCredentialsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewListCredentialsDefault(code int) *ListCredentialsDefault { } } -/*ListCredentialsDefault handles this case with default header values. +/* +ListCredentialsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ListCredentialsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this list credentials default response has a 2xx status code +func (o *ListCredentialsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list credentials default response has a 3xx status code +func (o *ListCredentialsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list credentials default response has a 4xx status code +func (o *ListCredentialsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list credentials default response has a 5xx status code +func (o *ListCredentialsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list credentials default response a status code equal to that given +func (o *ListCredentialsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the list credentials default response func (o *ListCredentialsDefault) Code() int { return o._statusCode } func (o *ListCredentialsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentials default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentials default %s", o._statusCode, payload) +} + +func (o *ListCredentialsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/credentials][%d] listCredentials default %s", o._statusCode, payload) } func (o *ListCredentialsDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *ListCredentialsDefault) GetPayload() *models.ErrorPayload { func (o *ListCredentialsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *ListCredentialsDefault) readResponse(response runtime.ClientResponse, c return nil } -/*ListCredentialsOKBody list credentials o k body +/* +ListCredentialsOKBody list credentials o k body swagger:model ListCredentialsOKBody */ type ListCredentialsOKBody struct { @@ -279,6 +444,8 @@ func (o *ListCredentialsOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("listCredentialsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listCredentialsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -299,6 +466,68 @@ func (o *ListCredentialsOKBody) validatePagination(formats strfmt.Registry) erro if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("listCredentialsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listCredentialsOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this list credentials o k body based on the context it is used +func (o *ListCredentialsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListCredentialsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listCredentialsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listCredentialsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *ListCredentialsOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listCredentialsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listCredentialsOK" + "." + "pagination") } return err } diff --git a/client/client/organization_credentials/organization_credentials_client.go b/client/client/organization_credentials/organization_credentials_client.go index ca17f9ca..ba6ebe05 100644 --- a/client/client/organization_credentials/organization_credentials_client.go +++ b/client/client/organization_credentials/organization_credentials_client.go @@ -7,15 +7,40 @@ package organization_credentials import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization credentials API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization credentials API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization credentials API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization credentials API */ @@ -24,8 +49,78 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateCredential(params *CreateCredentialParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateCredentialOK, error) + + DeleteCredential(params *DeleteCredentialParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteCredentialNoContent, error) + + GetCredential(params *GetCredentialParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCredentialOK, error) + + GetCredentialOptions(params *GetCredentialOptionsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCredentialOptionsOK, error) + + ListCredentials(params *ListCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListCredentialsOK, error) + + UpdateCredential(params *UpdateCredentialParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateCredentialOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* -CreateCredential Create a new Credential, based on the type you will have to pass different parameters within the body: + CreateCredential Create a new Credential, based on the type you will have to pass different parameters within the body: + * ssh: ssh_key * aws: access_key, secret_key * gcp: json_key @@ -36,13 +131,12 @@ CreateCredential Create a new Credential, based on the type you will have to pas * swift: auth_url, username, password, domain_id, tenant_id * vmware: username, password */ -func (a *Client) CreateCredential(params *CreateCredentialParams, authInfo runtime.ClientAuthInfoWriter) (*CreateCredentialOK, error) { +func (a *Client) CreateCredential(params *CreateCredentialParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateCredentialOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateCredentialParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createCredential", Method: "POST", PathPattern: "/organizations/{organization_canonical}/credentials", @@ -54,7 +148,12 @@ func (a *Client) CreateCredential(params *CreateCredentialParams, authInfo runti AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -70,13 +169,12 @@ func (a *Client) CreateCredential(params *CreateCredentialParams, authInfo runti /* DeleteCredential Delete the Credential. */ -func (a *Client) DeleteCredential(params *DeleteCredentialParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteCredentialNoContent, error) { +func (a *Client) DeleteCredential(params *DeleteCredentialParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteCredentialNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteCredentialParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteCredential", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/credentials/{credential_canonical}", @@ -88,7 +186,12 @@ func (a *Client) DeleteCredential(params *DeleteCredentialParams, authInfo runti AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -104,13 +207,12 @@ func (a *Client) DeleteCredential(params *DeleteCredentialParams, authInfo runti /* GetCredential Get the information of the Credential. */ -func (a *Client) GetCredential(params *GetCredentialParams, authInfo runtime.ClientAuthInfoWriter) (*GetCredentialOK, error) { +func (a *Client) GetCredential(params *GetCredentialParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCredentialOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetCredentialParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getCredential", Method: "GET", PathPattern: "/organizations/{organization_canonical}/credentials/{credential_canonical}", @@ -122,7 +224,12 @@ func (a *Client) GetCredential(params *GetCredentialParams, authInfo runtime.Cli AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -138,13 +245,12 @@ func (a *Client) GetCredential(params *GetCredentialParams, authInfo runtime.Cli /* GetCredentialOptions Get options of the Credential. */ -func (a *Client) GetCredentialOptions(params *GetCredentialOptionsParams, authInfo runtime.ClientAuthInfoWriter) (*GetCredentialOptionsOK, error) { +func (a *Client) GetCredentialOptions(params *GetCredentialOptionsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCredentialOptionsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetCredentialOptionsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getCredentialOptions", Method: "GET", PathPattern: "/organizations/{organization_canonical}/credentials/{credential_canonical}/options", @@ -156,7 +262,12 @@ func (a *Client) GetCredentialOptions(params *GetCredentialOptionsParams, authIn AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -172,13 +283,12 @@ func (a *Client) GetCredentialOptions(params *GetCredentialOptionsParams, authIn /* ListCredentials Return all the Credentials, depending on the caller permissions it'll return the Raw data or not. If the caller has List and not Get it'll not return the Raw, if it has List and Read it'll return the Raw. */ -func (a *Client) ListCredentials(params *ListCredentialsParams, authInfo runtime.ClientAuthInfoWriter) (*ListCredentialsOK, error) { +func (a *Client) ListCredentials(params *ListCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListCredentialsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewListCredentialsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "listCredentials", Method: "GET", PathPattern: "/organizations/{organization_canonical}/credentials", @@ -190,7 +300,12 @@ func (a *Client) ListCredentials(params *ListCredentialsParams, authInfo runtime AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -204,7 +319,8 @@ func (a *Client) ListCredentials(params *ListCredentialsParams, authInfo runtime } /* -UpdateCredential Update an existing Credential, based on the type you will have to pass different parameters within the body: + UpdateCredential Update an existing Credential, based on the type you will have to pass different parameters within the body: + * ssh: ssh_key * aws: access_key, secret_key * gcp: json_key @@ -215,13 +331,12 @@ UpdateCredential Update an existing Credential, based on the type you will have * swift: auth_url, username, password, domain_id, tenant_id * vmware: username, password */ -func (a *Client) UpdateCredential(params *UpdateCredentialParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateCredentialOK, error) { +func (a *Client) UpdateCredential(params *UpdateCredentialParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateCredentialOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateCredentialParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateCredential", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/credentials/{credential_canonical}", @@ -233,7 +348,12 @@ func (a *Client) UpdateCredential(params *UpdateCredentialParams, authInfo runti AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_credentials/update_credential_parameters.go b/client/client/organization_credentials/update_credential_parameters.go index 2bd584fa..18c2b462 100644 --- a/client/client/organization_credentials/update_credential_parameters.go +++ b/client/client/organization_credentials/update_credential_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateCredentialParams creates a new UpdateCredentialParams object -// with the default values initialized. +// NewUpdateCredentialParams creates a new UpdateCredentialParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateCredentialParams() *UpdateCredentialParams { - var () return &UpdateCredentialParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateCredentialParamsWithTimeout creates a new UpdateCredentialParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateCredentialParamsWithTimeout(timeout time.Duration) *UpdateCredentialParams { - var () return &UpdateCredentialParams{ - timeout: timeout, } } // NewUpdateCredentialParamsWithContext creates a new UpdateCredentialParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateCredentialParamsWithContext(ctx context.Context) *UpdateCredentialParams { - var () return &UpdateCredentialParams{ - Context: ctx, } } // NewUpdateCredentialParamsWithHTTPClient creates a new UpdateCredentialParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateCredentialParamsWithHTTPClient(client *http.Client) *UpdateCredentialParams { - var () return &UpdateCredentialParams{ HTTPClient: client, } } -/*UpdateCredentialParams contains all the parameters to send to the API endpoint -for the update credential operation typically these are written to a http.Request +/* +UpdateCredentialParams contains all the parameters to send to the API endpoint + + for the update credential operation. + + Typically these are written to a http.Request. */ type UpdateCredentialParams struct { - /*Body - The information of the organization to update. + /* Body. + The information of the organization to update. */ Body *models.UpdateCredential - /*CredentialCanonical - A Credential canonical + /* CredentialCanonical. + + A Credential canonical */ CredentialCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -84,6 +86,21 @@ type UpdateCredentialParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update credential params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateCredentialParams) WithDefaults() *UpdateCredentialParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update credential params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateCredentialParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update credential params func (o *UpdateCredentialParams) WithTimeout(timeout time.Duration) *UpdateCredentialParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateCredentialParams) WriteToRequest(r runtime.ClientRequest, reg str return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_credentials/update_credential_responses.go b/client/client/organization_credentials/update_credential_responses.go index f5635e9c..47547716 100644 --- a/client/client/organization_credentials/update_credential_responses.go +++ b/client/client/organization_credentials/update_credential_responses.go @@ -6,17 +6,18 @@ package organization_credentials // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateCredentialReader is a Reader for the UpdateCredential structure. @@ -74,7 +75,8 @@ func NewUpdateCredentialOK() *UpdateCredentialOK { return &UpdateCredentialOK{} } -/*UpdateCredentialOK handles this case with default header values. +/* +UpdateCredentialOK describes a response with status code 200, with default header values. Credential updated. */ @@ -82,8 +84,44 @@ type UpdateCredentialOK struct { Payload *UpdateCredentialOKBody } +// IsSuccess returns true when this update credential o k response has a 2xx status code +func (o *UpdateCredentialOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update credential o k response has a 3xx status code +func (o *UpdateCredentialOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update credential o k response has a 4xx status code +func (o *UpdateCredentialOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update credential o k response has a 5xx status code +func (o *UpdateCredentialOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update credential o k response a status code equal to that given +func (o *UpdateCredentialOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update credential o k response +func (o *UpdateCredentialOK) Code() int { + return 200 +} + func (o *UpdateCredentialOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialOK %s", 200, payload) +} + +func (o *UpdateCredentialOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialOK %s", 200, payload) } func (o *UpdateCredentialOK) GetPayload() *UpdateCredentialOKBody { @@ -107,20 +145,60 @@ func NewUpdateCredentialForbidden() *UpdateCredentialForbidden { return &UpdateCredentialForbidden{} } -/*UpdateCredentialForbidden handles this case with default header values. +/* +UpdateCredentialForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateCredentialForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update credential forbidden response has a 2xx status code +func (o *UpdateCredentialForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update credential forbidden response has a 3xx status code +func (o *UpdateCredentialForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update credential forbidden response has a 4xx status code +func (o *UpdateCredentialForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update credential forbidden response has a 5xx status code +func (o *UpdateCredentialForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update credential forbidden response a status code equal to that given +func (o *UpdateCredentialForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update credential forbidden response +func (o *UpdateCredentialForbidden) Code() int { + return 403 +} + func (o *UpdateCredentialForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialForbidden %s", 403, payload) +} + +func (o *UpdateCredentialForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialForbidden %s", 403, payload) } func (o *UpdateCredentialForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *UpdateCredentialForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateCredentialForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewUpdateCredentialNotFound() *UpdateCredentialNotFound { return &UpdateCredentialNotFound{} } -/*UpdateCredentialNotFound handles this case with default header values. +/* +UpdateCredentialNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateCredentialNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update credential not found response has a 2xx status code +func (o *UpdateCredentialNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update credential not found response has a 3xx status code +func (o *UpdateCredentialNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update credential not found response has a 4xx status code +func (o *UpdateCredentialNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update credential not found response has a 5xx status code +func (o *UpdateCredentialNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update credential not found response a status code equal to that given +func (o *UpdateCredentialNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update credential not found response +func (o *UpdateCredentialNotFound) Code() int { + return 404 +} + func (o *UpdateCredentialNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialNotFound %s", 404, payload) +} + +func (o *UpdateCredentialNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialNotFound %s", 404, payload) } func (o *UpdateCredentialNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *UpdateCredentialNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateCredentialNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewUpdateCredentialLengthRequired() *UpdateCredentialLengthRequired { return &UpdateCredentialLengthRequired{} } -/*UpdateCredentialLengthRequired handles this case with default header values. +/* +UpdateCredentialLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateCredentialLengthRequired struct { } +// IsSuccess returns true when this update credential length required response has a 2xx status code +func (o *UpdateCredentialLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update credential length required response has a 3xx status code +func (o *UpdateCredentialLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update credential length required response has a 4xx status code +func (o *UpdateCredentialLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update credential length required response has a 5xx status code +func (o *UpdateCredentialLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update credential length required response a status code equal to that given +func (o *UpdateCredentialLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update credential length required response +func (o *UpdateCredentialLengthRequired) Code() int { + return 411 +} + func (o *UpdateCredentialLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialLengthRequired", 411) +} + +func (o *UpdateCredentialLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialLengthRequired", 411) } func (o *UpdateCredentialLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewUpdateCredentialUnprocessableEntity() *UpdateCredentialUnprocessableEnti return &UpdateCredentialUnprocessableEntity{} } -/*UpdateCredentialUnprocessableEntity handles this case with default header values. +/* +UpdateCredentialUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateCredentialUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update credential unprocessable entity response has a 2xx status code +func (o *UpdateCredentialUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update credential unprocessable entity response has a 3xx status code +func (o *UpdateCredentialUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update credential unprocessable entity response has a 4xx status code +func (o *UpdateCredentialUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update credential unprocessable entity response has a 5xx status code +func (o *UpdateCredentialUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update credential unprocessable entity response a status code equal to that given +func (o *UpdateCredentialUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update credential unprocessable entity response +func (o *UpdateCredentialUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateCredentialUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateCredentialUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredentialUnprocessableEntity %s", 422, payload) } func (o *UpdateCredentialUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *UpdateCredentialUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *UpdateCredentialUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewUpdateCredentialDefault(code int) *UpdateCredentialDefault { } } -/*UpdateCredentialDefault handles this case with default header values. +/* +UpdateCredentialDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateCredentialDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update credential default response has a 2xx status code +func (o *UpdateCredentialDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update credential default response has a 3xx status code +func (o *UpdateCredentialDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update credential default response has a 4xx status code +func (o *UpdateCredentialDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update credential default response has a 5xx status code +func (o *UpdateCredentialDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update credential default response a status code equal to that given +func (o *UpdateCredentialDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update credential default response func (o *UpdateCredentialDefault) Code() int { return o._statusCode } func (o *UpdateCredentialDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredential default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredential default %s", o._statusCode, payload) +} + +func (o *UpdateCredentialDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/credentials/{credential_canonical}][%d] updateCredential default %s", o._statusCode, payload) } func (o *UpdateCredentialDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *UpdateCredentialDefault) GetPayload() *models.ErrorPayload { func (o *UpdateCredentialDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *UpdateCredentialDefault) readResponse(response runtime.ClientResponse, return nil } -/*UpdateCredentialOKBody update credential o k body +/* +UpdateCredentialOKBody update credential o k body swagger:model UpdateCredentialOKBody */ type UpdateCredentialOKBody struct { @@ -342,6 +586,39 @@ func (o *UpdateCredentialOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateCredentialOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateCredentialOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update credential o k body based on the context it is used +func (o *UpdateCredentialOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateCredentialOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateCredentialOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateCredentialOK" + "." + "data") } return err } diff --git a/client/client/organization_external_backends/create_external_backend_parameters.go b/client/client/organization_external_backends/create_external_backend_parameters.go index 4e46ac11..b0cc5cb4 100644 --- a/client/client/organization_external_backends/create_external_backend_parameters.go +++ b/client/client/organization_external_backends/create_external_backend_parameters.go @@ -13,88 +13,107 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateExternalBackendParams creates a new CreateExternalBackendParams object -// with the default values initialized. +// NewCreateExternalBackendParams creates a new CreateExternalBackendParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateExternalBackendParams() *CreateExternalBackendParams { - var () return &CreateExternalBackendParams{ - timeout: cr.DefaultTimeout, } } // NewCreateExternalBackendParamsWithTimeout creates a new CreateExternalBackendParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateExternalBackendParamsWithTimeout(timeout time.Duration) *CreateExternalBackendParams { - var () return &CreateExternalBackendParams{ - timeout: timeout, } } // NewCreateExternalBackendParamsWithContext creates a new CreateExternalBackendParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateExternalBackendParamsWithContext(ctx context.Context) *CreateExternalBackendParams { - var () return &CreateExternalBackendParams{ - Context: ctx, } } // NewCreateExternalBackendParamsWithHTTPClient creates a new CreateExternalBackendParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateExternalBackendParamsWithHTTPClient(client *http.Client) *CreateExternalBackendParams { - var () return &CreateExternalBackendParams{ HTTPClient: client, } } -/*CreateExternalBackendParams contains all the parameters to send to the API endpoint -for the create external backend operation typically these are written to a http.Request +/* +CreateExternalBackendParams contains all the parameters to send to the API endpoint + + for the create external backend operation. + + Typically these are written to a http.Request. */ type CreateExternalBackendParams struct { - /*Body - The information of the external backend + /* Body. + The information of the external backend */ Body *models.NewExternalBackend - /*Environment - The environment canonical to use a query filter + /* EnvironmentCanonical. + + A list of environments' canonical to filter from */ - Environment *string - /*ExternalBackendDefault - Filter for default Terraform External Backend + EnvironmentCanonical *string + /* ExternalBackendDefault. + + Filter for default Terraform External Backend */ ExternalBackendDefault *bool - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*Project - A canonical of a project used for filtering. + /* ProjectCanonical. + + A list of projects' canonical to filter from */ - Project *string + ProjectCanonical *string timeout time.Duration Context context.Context HTTPClient *http.Client } +// WithDefaults hydrates default values in the create external backend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateExternalBackendParams) WithDefaults() *CreateExternalBackendParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create external backend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateExternalBackendParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create external backend params func (o *CreateExternalBackendParams) WithTimeout(timeout time.Duration) *CreateExternalBackendParams { o.SetTimeout(timeout) @@ -139,15 +158,15 @@ func (o *CreateExternalBackendParams) SetBody(body *models.NewExternalBackend) { o.Body = body } -// WithEnvironment adds the environment to the create external backend params -func (o *CreateExternalBackendParams) WithEnvironment(environment *string) *CreateExternalBackendParams { - o.SetEnvironment(environment) +// WithEnvironmentCanonical adds the environmentCanonical to the create external backend params +func (o *CreateExternalBackendParams) WithEnvironmentCanonical(environmentCanonical *string) *CreateExternalBackendParams { + o.SetEnvironmentCanonical(environmentCanonical) return o } -// SetEnvironment adds the environment to the create external backend params -func (o *CreateExternalBackendParams) SetEnvironment(environment *string) { - o.Environment = environment +// SetEnvironmentCanonical adds the environmentCanonical to the create external backend params +func (o *CreateExternalBackendParams) SetEnvironmentCanonical(environmentCanonical *string) { + o.EnvironmentCanonical = environmentCanonical } // WithExternalBackendDefault adds the externalBackendDefault to the create external backend params @@ -172,15 +191,15 @@ func (o *CreateExternalBackendParams) SetOrganizationCanonical(organizationCanon o.OrganizationCanonical = organizationCanonical } -// WithProject adds the project to the create external backend params -func (o *CreateExternalBackendParams) WithProject(project *string) *CreateExternalBackendParams { - o.SetProject(project) +// WithProjectCanonical adds the projectCanonical to the create external backend params +func (o *CreateExternalBackendParams) WithProjectCanonical(projectCanonical *string) *CreateExternalBackendParams { + o.SetProjectCanonical(projectCanonical) return o } -// SetProject adds the project to the create external backend params -func (o *CreateExternalBackendParams) SetProject(project *string) { - o.Project = project +// SetProjectCanonical adds the projectCanonical to the create external backend params +func (o *CreateExternalBackendParams) SetProjectCanonical(projectCanonical *string) { + o.ProjectCanonical = projectCanonical } // WriteToRequest writes these params to a swagger request @@ -190,43 +209,44 @@ func (o *CreateExternalBackendParams) WriteToRequest(r runtime.ClientRequest, re return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err } } - if o.Environment != nil { + if o.EnvironmentCanonical != nil { - // query param environment - var qrEnvironment string - if o.Environment != nil { - qrEnvironment = *o.Environment + // query param environment_canonical + var qrEnvironmentCanonical string + + if o.EnvironmentCanonical != nil { + qrEnvironmentCanonical = *o.EnvironmentCanonical } - qEnvironment := qrEnvironment - if qEnvironment != "" { - if err := r.SetQueryParam("environment", qEnvironment); err != nil { + qEnvironmentCanonical := qrEnvironmentCanonical + if qEnvironmentCanonical != "" { + + if err := r.SetQueryParam("environment_canonical", qEnvironmentCanonical); err != nil { return err } } - } if o.ExternalBackendDefault != nil { // query param external_backend_default var qrExternalBackendDefault bool + if o.ExternalBackendDefault != nil { qrExternalBackendDefault = *o.ExternalBackendDefault } qExternalBackendDefault := swag.FormatBool(qrExternalBackendDefault) if qExternalBackendDefault != "" { + if err := r.SetQueryParam("external_backend_default", qExternalBackendDefault); err != nil { return err } } - } // path param organization_canonical @@ -234,20 +254,21 @@ func (o *CreateExternalBackendParams) WriteToRequest(r runtime.ClientRequest, re return err } - if o.Project != nil { + if o.ProjectCanonical != nil { - // query param project - var qrProject string - if o.Project != nil { - qrProject = *o.Project + // query param project_canonical + var qrProjectCanonical string + + if o.ProjectCanonical != nil { + qrProjectCanonical = *o.ProjectCanonical } - qProject := qrProject - if qProject != "" { - if err := r.SetQueryParam("project", qProject); err != nil { + qProjectCanonical := qrProjectCanonical + if qProjectCanonical != "" { + + if err := r.SetQueryParam("project_canonical", qProjectCanonical); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_external_backends/create_external_backend_responses.go b/client/client/organization_external_backends/create_external_backend_responses.go index e733be22..f25197b5 100644 --- a/client/client/organization_external_backends/create_external_backend_responses.go +++ b/client/client/organization_external_backends/create_external_backend_responses.go @@ -6,17 +6,18 @@ package organization_external_backends // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateExternalBackendReader is a Reader for the CreateExternalBackend structure. @@ -33,9 +34,8 @@ func (o *CreateExternalBackendReader) ReadResponse(response runtime.ClientRespon return nil, err } return result, nil - default: - return nil, runtime.NewAPIError("unknown error", response, response.Code()) + return nil, runtime.NewAPIError("[POST /organizations/{organization_canonical}/external_backends] createExternalBackend", response, response.Code()) } } @@ -44,7 +44,8 @@ func NewCreateExternalBackendOK() *CreateExternalBackendOK { return &CreateExternalBackendOK{} } -/*CreateExternalBackendOK handles this case with default header values. +/* +CreateExternalBackendOK describes a response with status code 200, with default header values. external backend has been registered */ @@ -52,8 +53,44 @@ type CreateExternalBackendOK struct { Payload *CreateExternalBackendOKBody } +// IsSuccess returns true when this create external backend o k response has a 2xx status code +func (o *CreateExternalBackendOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create external backend o k response has a 3xx status code +func (o *CreateExternalBackendOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create external backend o k response has a 4xx status code +func (o *CreateExternalBackendOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create external backend o k response has a 5xx status code +func (o *CreateExternalBackendOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create external backend o k response a status code equal to that given +func (o *CreateExternalBackendOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create external backend o k response +func (o *CreateExternalBackendOK) Code() int { + return 200 +} + func (o *CreateExternalBackendOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/external_backends][%d] createExternalBackendOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/external_backends][%d] createExternalBackendOK %s", 200, payload) +} + +func (o *CreateExternalBackendOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/external_backends][%d] createExternalBackendOK %s", 200, payload) } func (o *CreateExternalBackendOK) GetPayload() *CreateExternalBackendOKBody { @@ -72,7 +109,8 @@ func (o *CreateExternalBackendOK) readResponse(response runtime.ClientResponse, return nil } -/*CreateExternalBackendOKBody create external backend o k body +/* +CreateExternalBackendOKBody create external backend o k body swagger:model CreateExternalBackendOKBody */ type CreateExternalBackendOKBody struct { @@ -106,6 +144,39 @@ func (o *CreateExternalBackendOKBody) validateData(formats strfmt.Registry) erro if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createExternalBackendOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createExternalBackendOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create external backend o k body based on the context it is used +func (o *CreateExternalBackendOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateExternalBackendOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createExternalBackendOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createExternalBackendOK" + "." + "data") } return err } diff --git a/client/client/organization_external_backends/delete_external_backend_parameters.go b/client/client/organization_external_backends/delete_external_backend_parameters.go index 30d1f748..3f97e898 100644 --- a/client/client/organization_external_backends/delete_external_backend_parameters.go +++ b/client/client/organization_external_backends/delete_external_backend_parameters.go @@ -13,63 +13,66 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewDeleteExternalBackendParams creates a new DeleteExternalBackendParams object -// with the default values initialized. +// NewDeleteExternalBackendParams creates a new DeleteExternalBackendParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteExternalBackendParams() *DeleteExternalBackendParams { - var () return &DeleteExternalBackendParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteExternalBackendParamsWithTimeout creates a new DeleteExternalBackendParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteExternalBackendParamsWithTimeout(timeout time.Duration) *DeleteExternalBackendParams { - var () return &DeleteExternalBackendParams{ - timeout: timeout, } } // NewDeleteExternalBackendParamsWithContext creates a new DeleteExternalBackendParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteExternalBackendParamsWithContext(ctx context.Context) *DeleteExternalBackendParams { - var () return &DeleteExternalBackendParams{ - Context: ctx, } } // NewDeleteExternalBackendParamsWithHTTPClient creates a new DeleteExternalBackendParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteExternalBackendParamsWithHTTPClient(client *http.Client) *DeleteExternalBackendParams { - var () return &DeleteExternalBackendParams{ HTTPClient: client, } } -/*DeleteExternalBackendParams contains all the parameters to send to the API endpoint -for the delete external backend operation typically these are written to a http.Request +/* +DeleteExternalBackendParams contains all the parameters to send to the API endpoint + + for the delete external backend operation. + + Typically these are written to a http.Request. */ type DeleteExternalBackendParams struct { - /*ExternalBackendID - External Backend ID + /* ExternalBackendID. + + External Backend ID + Format: uint32 */ ExternalBackendID uint32 - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -78,6 +81,21 @@ type DeleteExternalBackendParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete external backend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteExternalBackendParams) WithDefaults() *DeleteExternalBackendParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete external backend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteExternalBackendParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete external backend params func (o *DeleteExternalBackendParams) WithTimeout(timeout time.Duration) *DeleteExternalBackendParams { o.SetTimeout(timeout) diff --git a/client/client/organization_external_backends/delete_external_backend_responses.go b/client/client/organization_external_backends/delete_external_backend_responses.go index 859e29ca..a630dc96 100644 --- a/client/client/organization_external_backends/delete_external_backend_responses.go +++ b/client/client/organization_external_backends/delete_external_backend_responses.go @@ -6,16 +6,16 @@ package organization_external_backends // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteExternalBackendReader is a Reader for the DeleteExternalBackend structure. @@ -67,15 +67,50 @@ func NewDeleteExternalBackendNoContent() *DeleteExternalBackendNoContent { return &DeleteExternalBackendNoContent{} } -/*DeleteExternalBackendNoContent handles this case with default header values. +/* +DeleteExternalBackendNoContent describes a response with status code 204, with default header values. Organization Service Catalog Sources has been deleted */ type DeleteExternalBackendNoContent struct { } +// IsSuccess returns true when this delete external backend no content response has a 2xx status code +func (o *DeleteExternalBackendNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete external backend no content response has a 3xx status code +func (o *DeleteExternalBackendNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete external backend no content response has a 4xx status code +func (o *DeleteExternalBackendNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete external backend no content response has a 5xx status code +func (o *DeleteExternalBackendNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete external backend no content response a status code equal to that given +func (o *DeleteExternalBackendNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete external backend no content response +func (o *DeleteExternalBackendNoContent) Code() int { + return 204 +} + func (o *DeleteExternalBackendNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendNoContent", 204) +} + +func (o *DeleteExternalBackendNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendNoContent", 204) } func (o *DeleteExternalBackendNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -88,20 +123,60 @@ func NewDeleteExternalBackendForbidden() *DeleteExternalBackendForbidden { return &DeleteExternalBackendForbidden{} } -/*DeleteExternalBackendForbidden handles this case with default header values. +/* +DeleteExternalBackendForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteExternalBackendForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete external backend forbidden response has a 2xx status code +func (o *DeleteExternalBackendForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete external backend forbidden response has a 3xx status code +func (o *DeleteExternalBackendForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete external backend forbidden response has a 4xx status code +func (o *DeleteExternalBackendForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete external backend forbidden response has a 5xx status code +func (o *DeleteExternalBackendForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete external backend forbidden response a status code equal to that given +func (o *DeleteExternalBackendForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete external backend forbidden response +func (o *DeleteExternalBackendForbidden) Code() int { + return 403 +} + func (o *DeleteExternalBackendForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendForbidden %s", 403, payload) +} + +func (o *DeleteExternalBackendForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendForbidden %s", 403, payload) } func (o *DeleteExternalBackendForbidden) GetPayload() *models.ErrorPayload { @@ -110,12 +185,16 @@ func (o *DeleteExternalBackendForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteExternalBackendForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -132,20 +211,60 @@ func NewDeleteExternalBackendNotFound() *DeleteExternalBackendNotFound { return &DeleteExternalBackendNotFound{} } -/*DeleteExternalBackendNotFound handles this case with default header values. +/* +DeleteExternalBackendNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteExternalBackendNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete external backend not found response has a 2xx status code +func (o *DeleteExternalBackendNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete external backend not found response has a 3xx status code +func (o *DeleteExternalBackendNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete external backend not found response has a 4xx status code +func (o *DeleteExternalBackendNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete external backend not found response has a 5xx status code +func (o *DeleteExternalBackendNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete external backend not found response a status code equal to that given +func (o *DeleteExternalBackendNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete external backend not found response +func (o *DeleteExternalBackendNotFound) Code() int { + return 404 +} + func (o *DeleteExternalBackendNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendNotFound %s", 404, payload) +} + +func (o *DeleteExternalBackendNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendNotFound %s", 404, payload) } func (o *DeleteExternalBackendNotFound) GetPayload() *models.ErrorPayload { @@ -154,12 +273,16 @@ func (o *DeleteExternalBackendNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteExternalBackendNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -176,20 +299,60 @@ func NewDeleteExternalBackendUnprocessableEntity() *DeleteExternalBackendUnproce return &DeleteExternalBackendUnprocessableEntity{} } -/*DeleteExternalBackendUnprocessableEntity handles this case with default header values. +/* +DeleteExternalBackendUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type DeleteExternalBackendUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete external backend unprocessable entity response has a 2xx status code +func (o *DeleteExternalBackendUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete external backend unprocessable entity response has a 3xx status code +func (o *DeleteExternalBackendUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete external backend unprocessable entity response has a 4xx status code +func (o *DeleteExternalBackendUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete external backend unprocessable entity response has a 5xx status code +func (o *DeleteExternalBackendUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this delete external backend unprocessable entity response a status code equal to that given +func (o *DeleteExternalBackendUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the delete external backend unprocessable entity response +func (o *DeleteExternalBackendUnprocessableEntity) Code() int { + return 422 +} + func (o *DeleteExternalBackendUnprocessableEntity) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendUnprocessableEntity %s", 422, payload) +} + +func (o *DeleteExternalBackendUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackendUnprocessableEntity %s", 422, payload) } func (o *DeleteExternalBackendUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -198,12 +361,16 @@ func (o *DeleteExternalBackendUnprocessableEntity) GetPayload() *models.ErrorPay func (o *DeleteExternalBackendUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -222,27 +389,61 @@ func NewDeleteExternalBackendDefault(code int) *DeleteExternalBackendDefault { } } -/*DeleteExternalBackendDefault handles this case with default header values. +/* +DeleteExternalBackendDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteExternalBackendDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete external backend default response has a 2xx status code +func (o *DeleteExternalBackendDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete external backend default response has a 3xx status code +func (o *DeleteExternalBackendDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete external backend default response has a 4xx status code +func (o *DeleteExternalBackendDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete external backend default response has a 5xx status code +func (o *DeleteExternalBackendDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete external backend default response a status code equal to that given +func (o *DeleteExternalBackendDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete external backend default response func (o *DeleteExternalBackendDefault) Code() int { return o._statusCode } func (o *DeleteExternalBackendDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackend default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackend default %s", o._statusCode, payload) +} + +func (o *DeleteExternalBackendDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] deleteExternalBackend default %s", o._statusCode, payload) } func (o *DeleteExternalBackendDefault) GetPayload() *models.ErrorPayload { @@ -251,12 +452,16 @@ func (o *DeleteExternalBackendDefault) GetPayload() *models.ErrorPayload { func (o *DeleteExternalBackendDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_external_backends/get_external_backend_parameters.go b/client/client/organization_external_backends/get_external_backend_parameters.go index 2cc1591c..a1b586ed 100644 --- a/client/client/organization_external_backends/get_external_backend_parameters.go +++ b/client/client/organization_external_backends/get_external_backend_parameters.go @@ -13,63 +13,66 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetExternalBackendParams creates a new GetExternalBackendParams object -// with the default values initialized. +// NewGetExternalBackendParams creates a new GetExternalBackendParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetExternalBackendParams() *GetExternalBackendParams { - var () return &GetExternalBackendParams{ - timeout: cr.DefaultTimeout, } } // NewGetExternalBackendParamsWithTimeout creates a new GetExternalBackendParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetExternalBackendParamsWithTimeout(timeout time.Duration) *GetExternalBackendParams { - var () return &GetExternalBackendParams{ - timeout: timeout, } } // NewGetExternalBackendParamsWithContext creates a new GetExternalBackendParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetExternalBackendParamsWithContext(ctx context.Context) *GetExternalBackendParams { - var () return &GetExternalBackendParams{ - Context: ctx, } } // NewGetExternalBackendParamsWithHTTPClient creates a new GetExternalBackendParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetExternalBackendParamsWithHTTPClient(client *http.Client) *GetExternalBackendParams { - var () return &GetExternalBackendParams{ HTTPClient: client, } } -/*GetExternalBackendParams contains all the parameters to send to the API endpoint -for the get external backend operation typically these are written to a http.Request +/* +GetExternalBackendParams contains all the parameters to send to the API endpoint + + for the get external backend operation. + + Typically these are written to a http.Request. */ type GetExternalBackendParams struct { - /*ExternalBackendID - External Backend ID + /* ExternalBackendID. + + External Backend ID + Format: uint32 */ ExternalBackendID uint32 - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -78,6 +81,21 @@ type GetExternalBackendParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get external backend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetExternalBackendParams) WithDefaults() *GetExternalBackendParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get external backend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetExternalBackendParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get external backend params func (o *GetExternalBackendParams) WithTimeout(timeout time.Duration) *GetExternalBackendParams { o.SetTimeout(timeout) diff --git a/client/client/organization_external_backends/get_external_backend_responses.go b/client/client/organization_external_backends/get_external_backend_responses.go index 426db563..45b17eb6 100644 --- a/client/client/organization_external_backends/get_external_backend_responses.go +++ b/client/client/organization_external_backends/get_external_backend_responses.go @@ -6,17 +6,18 @@ package organization_external_backends // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetExternalBackendReader is a Reader for the GetExternalBackend structure. @@ -62,7 +63,8 @@ func NewGetExternalBackendOK() *GetExternalBackendOK { return &GetExternalBackendOK{} } -/*GetExternalBackendOK handles this case with default header values. +/* +GetExternalBackendOK describes a response with status code 200, with default header values. The external backend */ @@ -70,8 +72,44 @@ type GetExternalBackendOK struct { Payload *GetExternalBackendOKBody } +// IsSuccess returns true when this get external backend o k response has a 2xx status code +func (o *GetExternalBackendOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get external backend o k response has a 3xx status code +func (o *GetExternalBackendOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get external backend o k response has a 4xx status code +func (o *GetExternalBackendOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get external backend o k response has a 5xx status code +func (o *GetExternalBackendOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get external backend o k response a status code equal to that given +func (o *GetExternalBackendOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get external backend o k response +func (o *GetExternalBackendOK) Code() int { + return 200 +} + func (o *GetExternalBackendOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendOK %s", 200, payload) +} + +func (o *GetExternalBackendOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendOK %s", 200, payload) } func (o *GetExternalBackendOK) GetPayload() *GetExternalBackendOKBody { @@ -95,20 +133,60 @@ func NewGetExternalBackendForbidden() *GetExternalBackendForbidden { return &GetExternalBackendForbidden{} } -/*GetExternalBackendForbidden handles this case with default header values. +/* +GetExternalBackendForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetExternalBackendForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get external backend forbidden response has a 2xx status code +func (o *GetExternalBackendForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get external backend forbidden response has a 3xx status code +func (o *GetExternalBackendForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get external backend forbidden response has a 4xx status code +func (o *GetExternalBackendForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get external backend forbidden response has a 5xx status code +func (o *GetExternalBackendForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get external backend forbidden response a status code equal to that given +func (o *GetExternalBackendForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get external backend forbidden response +func (o *GetExternalBackendForbidden) Code() int { + return 403 +} + func (o *GetExternalBackendForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendForbidden %s", 403, payload) +} + +func (o *GetExternalBackendForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendForbidden %s", 403, payload) } func (o *GetExternalBackendForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetExternalBackendForbidden) GetPayload() *models.ErrorPayload { func (o *GetExternalBackendForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetExternalBackendUnprocessableEntity() *GetExternalBackendUnprocessable return &GetExternalBackendUnprocessableEntity{} } -/*GetExternalBackendUnprocessableEntity handles this case with default header values. +/* +GetExternalBackendUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetExternalBackendUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get external backend unprocessable entity response has a 2xx status code +func (o *GetExternalBackendUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get external backend unprocessable entity response has a 3xx status code +func (o *GetExternalBackendUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get external backend unprocessable entity response has a 4xx status code +func (o *GetExternalBackendUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get external backend unprocessable entity response has a 5xx status code +func (o *GetExternalBackendUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get external backend unprocessable entity response a status code equal to that given +func (o *GetExternalBackendUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get external backend unprocessable entity response +func (o *GetExternalBackendUnprocessableEntity) Code() int { + return 422 +} + func (o *GetExternalBackendUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendUnprocessableEntity %s", 422, payload) +} + +func (o *GetExternalBackendUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackendUnprocessableEntity %s", 422, payload) } func (o *GetExternalBackendUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetExternalBackendUnprocessableEntity) GetPayload() *models.ErrorPayloa func (o *GetExternalBackendUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetExternalBackendDefault(code int) *GetExternalBackendDefault { } } -/*GetExternalBackendDefault handles this case with default header values. +/* +GetExternalBackendDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetExternalBackendDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get external backend default response has a 2xx status code +func (o *GetExternalBackendDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get external backend default response has a 3xx status code +func (o *GetExternalBackendDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get external backend default response has a 4xx status code +func (o *GetExternalBackendDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get external backend default response has a 5xx status code +func (o *GetExternalBackendDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get external backend default response a status code equal to that given +func (o *GetExternalBackendDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get external backend default response func (o *GetExternalBackendDefault) Code() int { return o._statusCode } func (o *GetExternalBackendDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackend default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackend default %s", o._statusCode, payload) +} + +func (o *GetExternalBackendDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] getExternalBackend default %s", o._statusCode, payload) } func (o *GetExternalBackendDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetExternalBackendDefault) GetPayload() *models.ErrorPayload { func (o *GetExternalBackendDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetExternalBackendDefault) readResponse(response runtime.ClientResponse return nil } -/*GetExternalBackendOKBody get external backend o k body +/* +GetExternalBackendOKBody get external backend o k body swagger:model GetExternalBackendOKBody */ type GetExternalBackendOKBody struct { @@ -265,6 +430,39 @@ func (o *GetExternalBackendOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getExternalBackendOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getExternalBackendOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get external backend o k body based on the context it is used +func (o *GetExternalBackendOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetExternalBackendOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getExternalBackendOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getExternalBackendOK" + "." + "data") } return err } diff --git a/client/client/organization_external_backends/get_external_backends_parameters.go b/client/client/organization_external_backends/get_external_backends_parameters.go index 2b0becfc..d88443c2 100644 --- a/client/client/organization_external_backends/get_external_backends_parameters.go +++ b/client/client/organization_external_backends/get_external_backends_parameters.go @@ -13,81 +13,99 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetExternalBackendsParams creates a new GetExternalBackendsParams object -// with the default values initialized. +// NewGetExternalBackendsParams creates a new GetExternalBackendsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetExternalBackendsParams() *GetExternalBackendsParams { - var () return &GetExternalBackendsParams{ - timeout: cr.DefaultTimeout, } } // NewGetExternalBackendsParamsWithTimeout creates a new GetExternalBackendsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetExternalBackendsParamsWithTimeout(timeout time.Duration) *GetExternalBackendsParams { - var () return &GetExternalBackendsParams{ - timeout: timeout, } } // NewGetExternalBackendsParamsWithContext creates a new GetExternalBackendsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetExternalBackendsParamsWithContext(ctx context.Context) *GetExternalBackendsParams { - var () return &GetExternalBackendsParams{ - Context: ctx, } } // NewGetExternalBackendsParamsWithHTTPClient creates a new GetExternalBackendsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetExternalBackendsParamsWithHTTPClient(client *http.Client) *GetExternalBackendsParams { - var () return &GetExternalBackendsParams{ HTTPClient: client, } } -/*GetExternalBackendsParams contains all the parameters to send to the API endpoint -for the get external backends operation typically these are written to a http.Request +/* +GetExternalBackendsParams contains all the parameters to send to the API endpoint + + for the get external backends operation. + + Typically these are written to a http.Request. */ type GetExternalBackendsParams struct { - /*Environment - The environment canonical to use a query filter + /* EnvironmentCanonical. + A list of environments' canonical to filter from */ - Environment *string - /*ExternalBackendDefault - Filter for default Terraform External Backend + EnvironmentCanonical *string + /* ExternalBackendDefault. + + Filter for default Terraform External Backend */ ExternalBackendDefault *bool - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*Project - A canonical of a project used for filtering. + /* ProjectCanonical. + + A list of projects' canonical to filter from */ - Project *string + ProjectCanonical *string timeout time.Duration Context context.Context HTTPClient *http.Client } +// WithDefaults hydrates default values in the get external backends params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetExternalBackendsParams) WithDefaults() *GetExternalBackendsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get external backends params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetExternalBackendsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get external backends params func (o *GetExternalBackendsParams) WithTimeout(timeout time.Duration) *GetExternalBackendsParams { o.SetTimeout(timeout) @@ -121,15 +139,15 @@ func (o *GetExternalBackendsParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } -// WithEnvironment adds the environment to the get external backends params -func (o *GetExternalBackendsParams) WithEnvironment(environment *string) *GetExternalBackendsParams { - o.SetEnvironment(environment) +// WithEnvironmentCanonical adds the environmentCanonical to the get external backends params +func (o *GetExternalBackendsParams) WithEnvironmentCanonical(environmentCanonical *string) *GetExternalBackendsParams { + o.SetEnvironmentCanonical(environmentCanonical) return o } -// SetEnvironment adds the environment to the get external backends params -func (o *GetExternalBackendsParams) SetEnvironment(environment *string) { - o.Environment = environment +// SetEnvironmentCanonical adds the environmentCanonical to the get external backends params +func (o *GetExternalBackendsParams) SetEnvironmentCanonical(environmentCanonical *string) { + o.EnvironmentCanonical = environmentCanonical } // WithExternalBackendDefault adds the externalBackendDefault to the get external backends params @@ -154,15 +172,15 @@ func (o *GetExternalBackendsParams) SetOrganizationCanonical(organizationCanonic o.OrganizationCanonical = organizationCanonical } -// WithProject adds the project to the get external backends params -func (o *GetExternalBackendsParams) WithProject(project *string) *GetExternalBackendsParams { - o.SetProject(project) +// WithProjectCanonical adds the projectCanonical to the get external backends params +func (o *GetExternalBackendsParams) WithProjectCanonical(projectCanonical *string) *GetExternalBackendsParams { + o.SetProjectCanonical(projectCanonical) return o } -// SetProject adds the project to the get external backends params -func (o *GetExternalBackendsParams) SetProject(project *string) { - o.Project = project +// SetProjectCanonical adds the projectCanonical to the get external backends params +func (o *GetExternalBackendsParams) SetProjectCanonical(projectCanonical *string) { + o.ProjectCanonical = projectCanonical } // WriteToRequest writes these params to a swagger request @@ -173,36 +191,38 @@ func (o *GetExternalBackendsParams) WriteToRequest(r runtime.ClientRequest, reg } var res []error - if o.Environment != nil { + if o.EnvironmentCanonical != nil { + + // query param environment_canonical + var qrEnvironmentCanonical string - // query param environment - var qrEnvironment string - if o.Environment != nil { - qrEnvironment = *o.Environment + if o.EnvironmentCanonical != nil { + qrEnvironmentCanonical = *o.EnvironmentCanonical } - qEnvironment := qrEnvironment - if qEnvironment != "" { - if err := r.SetQueryParam("environment", qEnvironment); err != nil { + qEnvironmentCanonical := qrEnvironmentCanonical + if qEnvironmentCanonical != "" { + + if err := r.SetQueryParam("environment_canonical", qEnvironmentCanonical); err != nil { return err } } - } if o.ExternalBackendDefault != nil { // query param external_backend_default var qrExternalBackendDefault bool + if o.ExternalBackendDefault != nil { qrExternalBackendDefault = *o.ExternalBackendDefault } qExternalBackendDefault := swag.FormatBool(qrExternalBackendDefault) if qExternalBackendDefault != "" { + if err := r.SetQueryParam("external_backend_default", qExternalBackendDefault); err != nil { return err } } - } // path param organization_canonical @@ -210,20 +230,21 @@ func (o *GetExternalBackendsParams) WriteToRequest(r runtime.ClientRequest, reg return err } - if o.Project != nil { + if o.ProjectCanonical != nil { + + // query param project_canonical + var qrProjectCanonical string - // query param project - var qrProject string - if o.Project != nil { - qrProject = *o.Project + if o.ProjectCanonical != nil { + qrProjectCanonical = *o.ProjectCanonical } - qProject := qrProject - if qProject != "" { - if err := r.SetQueryParam("project", qProject); err != nil { + qProjectCanonical := qrProjectCanonical + if qProjectCanonical != "" { + + if err := r.SetQueryParam("project_canonical", qProjectCanonical); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_external_backends/get_external_backends_responses.go b/client/client/organization_external_backends/get_external_backends_responses.go index 4c19190c..bfb50d96 100644 --- a/client/client/organization_external_backends/get_external_backends_responses.go +++ b/client/client/organization_external_backends/get_external_backends_responses.go @@ -6,18 +6,19 @@ package organization_external_backends // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetExternalBackendsReader is a Reader for the GetExternalBackends structure. @@ -63,7 +64,8 @@ func NewGetExternalBackendsOK() *GetExternalBackendsOK { return &GetExternalBackendsOK{} } -/*GetExternalBackendsOK handles this case with default header values. +/* +GetExternalBackendsOK describes a response with status code 200, with default header values. The list of the external backends */ @@ -71,8 +73,44 @@ type GetExternalBackendsOK struct { Payload *GetExternalBackendsOKBody } +// IsSuccess returns true when this get external backends o k response has a 2xx status code +func (o *GetExternalBackendsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get external backends o k response has a 3xx status code +func (o *GetExternalBackendsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get external backends o k response has a 4xx status code +func (o *GetExternalBackendsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get external backends o k response has a 5xx status code +func (o *GetExternalBackendsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get external backends o k response a status code equal to that given +func (o *GetExternalBackendsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get external backends o k response +func (o *GetExternalBackendsOK) Code() int { + return 200 +} + func (o *GetExternalBackendsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsOK %s", 200, payload) +} + +func (o *GetExternalBackendsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsOK %s", 200, payload) } func (o *GetExternalBackendsOK) GetPayload() *GetExternalBackendsOKBody { @@ -96,20 +134,60 @@ func NewGetExternalBackendsForbidden() *GetExternalBackendsForbidden { return &GetExternalBackendsForbidden{} } -/*GetExternalBackendsForbidden handles this case with default header values. +/* +GetExternalBackendsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetExternalBackendsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get external backends forbidden response has a 2xx status code +func (o *GetExternalBackendsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get external backends forbidden response has a 3xx status code +func (o *GetExternalBackendsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get external backends forbidden response has a 4xx status code +func (o *GetExternalBackendsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get external backends forbidden response has a 5xx status code +func (o *GetExternalBackendsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get external backends forbidden response a status code equal to that given +func (o *GetExternalBackendsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get external backends forbidden response +func (o *GetExternalBackendsForbidden) Code() int { + return 403 +} + func (o *GetExternalBackendsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsForbidden %s", 403, payload) +} + +func (o *GetExternalBackendsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsForbidden %s", 403, payload) } func (o *GetExternalBackendsForbidden) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *GetExternalBackendsForbidden) GetPayload() *models.ErrorPayload { func (o *GetExternalBackendsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewGetExternalBackendsUnprocessableEntity() *GetExternalBackendsUnprocessab return &GetExternalBackendsUnprocessableEntity{} } -/*GetExternalBackendsUnprocessableEntity handles this case with default header values. +/* +GetExternalBackendsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetExternalBackendsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get external backends unprocessable entity response has a 2xx status code +func (o *GetExternalBackendsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get external backends unprocessable entity response has a 3xx status code +func (o *GetExternalBackendsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get external backends unprocessable entity response has a 4xx status code +func (o *GetExternalBackendsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get external backends unprocessable entity response has a 5xx status code +func (o *GetExternalBackendsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get external backends unprocessable entity response a status code equal to that given +func (o *GetExternalBackendsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get external backends unprocessable entity response +func (o *GetExternalBackendsUnprocessableEntity) Code() int { + return 422 +} + func (o *GetExternalBackendsUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsUnprocessableEntity %s", 422, payload) +} + +func (o *GetExternalBackendsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackendsUnprocessableEntity %s", 422, payload) } func (o *GetExternalBackendsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *GetExternalBackendsUnprocessableEntity) GetPayload() *models.ErrorPaylo func (o *GetExternalBackendsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewGetExternalBackendsDefault(code int) *GetExternalBackendsDefault { } } -/*GetExternalBackendsDefault handles this case with default header values. +/* +GetExternalBackendsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetExternalBackendsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get external backends default response has a 2xx status code +func (o *GetExternalBackendsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get external backends default response has a 3xx status code +func (o *GetExternalBackendsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get external backends default response has a 4xx status code +func (o *GetExternalBackendsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get external backends default response has a 5xx status code +func (o *GetExternalBackendsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get external backends default response a status code equal to that given +func (o *GetExternalBackendsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get external backends default response func (o *GetExternalBackendsDefault) Code() int { return o._statusCode } func (o *GetExternalBackendsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackends default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackends default %s", o._statusCode, payload) +} + +func (o *GetExternalBackendsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/external_backends][%d] getExternalBackends default %s", o._statusCode, payload) } func (o *GetExternalBackendsDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *GetExternalBackendsDefault) GetPayload() *models.ErrorPayload { func (o *GetExternalBackendsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *GetExternalBackendsDefault) readResponse(response runtime.ClientRespons return nil } -/*GetExternalBackendsOKBody get external backends o k body +/* +GetExternalBackendsOKBody get external backends o k body swagger:model GetExternalBackendsOKBody */ type GetExternalBackendsOKBody struct { @@ -278,6 +443,8 @@ func (o *GetExternalBackendsOKBody) validateData(formats strfmt.Registry) error if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getExternalBackendsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getExternalBackendsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -289,7 +456,6 @@ func (o *GetExternalBackendsOKBody) validateData(formats strfmt.Registry) error } func (o *GetExternalBackendsOKBody) validatePagination(formats strfmt.Registry) error { - if swag.IsZero(o.Pagination) { // not required return nil } @@ -298,6 +464,72 @@ func (o *GetExternalBackendsOKBody) validatePagination(formats strfmt.Registry) if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getExternalBackendsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getExternalBackendsOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get external backends o k body based on the context it is used +func (o *GetExternalBackendsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetExternalBackendsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getExternalBackendsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getExternalBackendsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetExternalBackendsOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if swag.IsZero(o.Pagination) { // not required + return nil + } + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getExternalBackendsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getExternalBackendsOK" + "." + "pagination") } return err } diff --git a/client/client/organization_external_backends/organization_external_backends_client.go b/client/client/organization_external_backends/organization_external_backends_client.go index 7ba4db4e..d2febf78 100644 --- a/client/client/organization_external_backends/organization_external_backends_client.go +++ b/client/client/organization_external_backends/organization_external_backends_client.go @@ -9,15 +9,40 @@ import ( "fmt" "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization external backends API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization external backends API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization external backends API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization external backends API */ @@ -26,16 +51,82 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateExternalBackend(params *CreateExternalBackendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateExternalBackendOK, error) + + DeleteExternalBackend(params *DeleteExternalBackendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteExternalBackendNoContent, error) + + GetExternalBackend(params *GetExternalBackendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetExternalBackendOK, error) + + GetExternalBackends(params *GetExternalBackendsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetExternalBackendsOK, error) + + UpdateExternalBackend(params *UpdateExternalBackendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateExternalBackendOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateExternalBackend Save information about the external backend */ -func (a *Client) CreateExternalBackend(params *CreateExternalBackendParams, authInfo runtime.ClientAuthInfoWriter) (*CreateExternalBackendOK, error) { +func (a *Client) CreateExternalBackend(params *CreateExternalBackendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateExternalBackendOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateExternalBackendParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createExternalBackend", Method: "POST", PathPattern: "/organizations/{organization_canonical}/external_backends", @@ -47,7 +138,12 @@ func (a *Client) CreateExternalBackend(params *CreateExternalBackendParams, auth AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -64,13 +160,12 @@ func (a *Client) CreateExternalBackend(params *CreateExternalBackendParams, auth /* DeleteExternalBackend delete an External Backend */ -func (a *Client) DeleteExternalBackend(params *DeleteExternalBackendParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteExternalBackendNoContent, error) { +func (a *Client) DeleteExternalBackend(params *DeleteExternalBackendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteExternalBackendNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteExternalBackendParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteExternalBackend", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/external_backends/{external_backend_id}", @@ -82,7 +177,12 @@ func (a *Client) DeleteExternalBackend(params *DeleteExternalBackendParams, auth AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -98,13 +198,12 @@ func (a *Client) DeleteExternalBackend(params *DeleteExternalBackendParams, auth /* GetExternalBackend Get the external backend */ -func (a *Client) GetExternalBackend(params *GetExternalBackendParams, authInfo runtime.ClientAuthInfoWriter) (*GetExternalBackendOK, error) { +func (a *Client) GetExternalBackend(params *GetExternalBackendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetExternalBackendOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetExternalBackendParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getExternalBackend", Method: "GET", PathPattern: "/organizations/{organization_canonical}/external_backends/{external_backend_id}", @@ -116,7 +215,12 @@ func (a *Client) GetExternalBackend(params *GetExternalBackendParams, authInfo r AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -132,13 +236,12 @@ func (a *Client) GetExternalBackend(params *GetExternalBackendParams, authInfo r /* GetExternalBackends Get the list of organization external backends */ -func (a *Client) GetExternalBackends(params *GetExternalBackendsParams, authInfo runtime.ClientAuthInfoWriter) (*GetExternalBackendsOK, error) { +func (a *Client) GetExternalBackends(params *GetExternalBackendsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetExternalBackendsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetExternalBackendsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getExternalBackends", Method: "GET", PathPattern: "/organizations/{organization_canonical}/external_backends", @@ -150,7 +253,12 @@ func (a *Client) GetExternalBackends(params *GetExternalBackendsParams, authInfo AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -166,13 +274,12 @@ func (a *Client) GetExternalBackends(params *GetExternalBackendsParams, authInfo /* UpdateExternalBackend Update an External Backend */ -func (a *Client) UpdateExternalBackend(params *UpdateExternalBackendParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateExternalBackendOK, error) { +func (a *Client) UpdateExternalBackend(params *UpdateExternalBackendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateExternalBackendOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateExternalBackendParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateExternalBackend", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/external_backends/{external_backend_id}", @@ -184,7 +291,12 @@ func (a *Client) UpdateExternalBackend(params *UpdateExternalBackendParams, auth AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_external_backends/update_external_backend_parameters.go b/client/client/organization_external_backends/update_external_backend_parameters.go index 2cfff73e..1c1b4c26 100644 --- a/client/client/organization_external_backends/update_external_backend_parameters.go +++ b/client/client/organization_external_backends/update_external_backend_parameters.go @@ -13,70 +13,74 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateExternalBackendParams creates a new UpdateExternalBackendParams object -// with the default values initialized. +// NewUpdateExternalBackendParams creates a new UpdateExternalBackendParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateExternalBackendParams() *UpdateExternalBackendParams { - var () return &UpdateExternalBackendParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateExternalBackendParamsWithTimeout creates a new UpdateExternalBackendParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateExternalBackendParamsWithTimeout(timeout time.Duration) *UpdateExternalBackendParams { - var () return &UpdateExternalBackendParams{ - timeout: timeout, } } // NewUpdateExternalBackendParamsWithContext creates a new UpdateExternalBackendParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateExternalBackendParamsWithContext(ctx context.Context) *UpdateExternalBackendParams { - var () return &UpdateExternalBackendParams{ - Context: ctx, } } // NewUpdateExternalBackendParamsWithHTTPClient creates a new UpdateExternalBackendParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateExternalBackendParamsWithHTTPClient(client *http.Client) *UpdateExternalBackendParams { - var () return &UpdateExternalBackendParams{ HTTPClient: client, } } -/*UpdateExternalBackendParams contains all the parameters to send to the API endpoint -for the update external backend operation typically these are written to a http.Request +/* +UpdateExternalBackendParams contains all the parameters to send to the API endpoint + + for the update external backend operation. + + Typically these are written to a http.Request. */ type UpdateExternalBackendParams struct { - /*Body - The information of the external backend new data + /* Body. + The information of the external backend new data */ Body *models.UpdateExternalBackend - /*ExternalBackendID - External Backend ID + /* ExternalBackendID. + + External Backend ID + + Format: uint32 */ ExternalBackendID uint32 - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -85,6 +89,21 @@ type UpdateExternalBackendParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update external backend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateExternalBackendParams) WithDefaults() *UpdateExternalBackendParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update external backend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateExternalBackendParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update external backend params func (o *UpdateExternalBackendParams) WithTimeout(timeout time.Duration) *UpdateExternalBackendParams { o.SetTimeout(timeout) @@ -158,7 +177,6 @@ func (o *UpdateExternalBackendParams) WriteToRequest(r runtime.ClientRequest, re return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_external_backends/update_external_backend_responses.go b/client/client/organization_external_backends/update_external_backend_responses.go index 8c382814..ae482acb 100644 --- a/client/client/organization_external_backends/update_external_backend_responses.go +++ b/client/client/organization_external_backends/update_external_backend_responses.go @@ -6,17 +6,18 @@ package organization_external_backends // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateExternalBackendReader is a Reader for the UpdateExternalBackend structure. @@ -68,7 +69,8 @@ func NewUpdateExternalBackendOK() *UpdateExternalBackendOK { return &UpdateExternalBackendOK{} } -/*UpdateExternalBackendOK handles this case with default header values. +/* +UpdateExternalBackendOK describes a response with status code 200, with default header values. Success update */ @@ -76,8 +78,44 @@ type UpdateExternalBackendOK struct { Payload *UpdateExternalBackendOKBody } +// IsSuccess returns true when this update external backend o k response has a 2xx status code +func (o *UpdateExternalBackendOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update external backend o k response has a 3xx status code +func (o *UpdateExternalBackendOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update external backend o k response has a 4xx status code +func (o *UpdateExternalBackendOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update external backend o k response has a 5xx status code +func (o *UpdateExternalBackendOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update external backend o k response a status code equal to that given +func (o *UpdateExternalBackendOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update external backend o k response +func (o *UpdateExternalBackendOK) Code() int { + return 200 +} + func (o *UpdateExternalBackendOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendOK %s", 200, payload) +} + +func (o *UpdateExternalBackendOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendOK %s", 200, payload) } func (o *UpdateExternalBackendOK) GetPayload() *UpdateExternalBackendOKBody { @@ -101,20 +139,60 @@ func NewUpdateExternalBackendForbidden() *UpdateExternalBackendForbidden { return &UpdateExternalBackendForbidden{} } -/*UpdateExternalBackendForbidden handles this case with default header values. +/* +UpdateExternalBackendForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateExternalBackendForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update external backend forbidden response has a 2xx status code +func (o *UpdateExternalBackendForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update external backend forbidden response has a 3xx status code +func (o *UpdateExternalBackendForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update external backend forbidden response has a 4xx status code +func (o *UpdateExternalBackendForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update external backend forbidden response has a 5xx status code +func (o *UpdateExternalBackendForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update external backend forbidden response a status code equal to that given +func (o *UpdateExternalBackendForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update external backend forbidden response +func (o *UpdateExternalBackendForbidden) Code() int { + return 403 +} + func (o *UpdateExternalBackendForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendForbidden %s", 403, payload) +} + +func (o *UpdateExternalBackendForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendForbidden %s", 403, payload) } func (o *UpdateExternalBackendForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *UpdateExternalBackendForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateExternalBackendForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,15 +227,50 @@ func NewUpdateExternalBackendLengthRequired() *UpdateExternalBackendLengthRequir return &UpdateExternalBackendLengthRequired{} } -/*UpdateExternalBackendLengthRequired handles this case with default header values. +/* +UpdateExternalBackendLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateExternalBackendLengthRequired struct { } +// IsSuccess returns true when this update external backend length required response has a 2xx status code +func (o *UpdateExternalBackendLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update external backend length required response has a 3xx status code +func (o *UpdateExternalBackendLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update external backend length required response has a 4xx status code +func (o *UpdateExternalBackendLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update external backend length required response has a 5xx status code +func (o *UpdateExternalBackendLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update external backend length required response a status code equal to that given +func (o *UpdateExternalBackendLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update external backend length required response +func (o *UpdateExternalBackendLengthRequired) Code() int { + return 411 +} + func (o *UpdateExternalBackendLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendLengthRequired", 411) +} + +func (o *UpdateExternalBackendLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendLengthRequired", 411) } func (o *UpdateExternalBackendLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -166,20 +283,60 @@ func NewUpdateExternalBackendUnprocessableEntity() *UpdateExternalBackendUnproce return &UpdateExternalBackendUnprocessableEntity{} } -/*UpdateExternalBackendUnprocessableEntity handles this case with default header values. +/* +UpdateExternalBackendUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateExternalBackendUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update external backend unprocessable entity response has a 2xx status code +func (o *UpdateExternalBackendUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update external backend unprocessable entity response has a 3xx status code +func (o *UpdateExternalBackendUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update external backend unprocessable entity response has a 4xx status code +func (o *UpdateExternalBackendUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update external backend unprocessable entity response has a 5xx status code +func (o *UpdateExternalBackendUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update external backend unprocessable entity response a status code equal to that given +func (o *UpdateExternalBackendUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update external backend unprocessable entity response +func (o *UpdateExternalBackendUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateExternalBackendUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateExternalBackendUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackendUnprocessableEntity %s", 422, payload) } func (o *UpdateExternalBackendUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -188,12 +345,16 @@ func (o *UpdateExternalBackendUnprocessableEntity) GetPayload() *models.ErrorPay func (o *UpdateExternalBackendUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -212,27 +373,61 @@ func NewUpdateExternalBackendDefault(code int) *UpdateExternalBackendDefault { } } -/*UpdateExternalBackendDefault handles this case with default header values. +/* +UpdateExternalBackendDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateExternalBackendDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update external backend default response has a 2xx status code +func (o *UpdateExternalBackendDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update external backend default response has a 3xx status code +func (o *UpdateExternalBackendDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update external backend default response has a 4xx status code +func (o *UpdateExternalBackendDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update external backend default response has a 5xx status code +func (o *UpdateExternalBackendDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update external backend default response a status code equal to that given +func (o *UpdateExternalBackendDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update external backend default response func (o *UpdateExternalBackendDefault) Code() int { return o._statusCode } func (o *UpdateExternalBackendDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackend default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackend default %s", o._statusCode, payload) +} + +func (o *UpdateExternalBackendDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/external_backends/{external_backend_id}][%d] updateExternalBackend default %s", o._statusCode, payload) } func (o *UpdateExternalBackendDefault) GetPayload() *models.ErrorPayload { @@ -241,12 +436,16 @@ func (o *UpdateExternalBackendDefault) GetPayload() *models.ErrorPayload { func (o *UpdateExternalBackendDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -258,7 +457,8 @@ func (o *UpdateExternalBackendDefault) readResponse(response runtime.ClientRespo return nil } -/*UpdateExternalBackendOKBody update external backend o k body +/* +UpdateExternalBackendOKBody update external backend o k body swagger:model UpdateExternalBackendOKBody */ type UpdateExternalBackendOKBody struct { @@ -292,6 +492,39 @@ func (o *UpdateExternalBackendOKBody) validateData(formats strfmt.Registry) erro if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateExternalBackendOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateExternalBackendOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update external backend o k body based on the context it is used +func (o *UpdateExternalBackendOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateExternalBackendOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateExternalBackendOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateExternalBackendOK" + "." + "data") } return err } diff --git a/client/client/organization_forms/create_forms_config_parameters.go b/client/client/organization_forms/create_forms_config_parameters.go index 2bd0841a..186fbfef 100644 --- a/client/client/organization_forms/create_forms_config_parameters.go +++ b/client/client/organization_forms/create_forms_config_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateFormsConfigParams creates a new CreateFormsConfigParams object -// with the default values initialized. +// NewCreateFormsConfigParams creates a new CreateFormsConfigParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateFormsConfigParams() *CreateFormsConfigParams { - var () return &CreateFormsConfigParams{ - timeout: cr.DefaultTimeout, } } // NewCreateFormsConfigParamsWithTimeout creates a new CreateFormsConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateFormsConfigParamsWithTimeout(timeout time.Duration) *CreateFormsConfigParams { - var () return &CreateFormsConfigParams{ - timeout: timeout, } } // NewCreateFormsConfigParamsWithContext creates a new CreateFormsConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateFormsConfigParamsWithContext(ctx context.Context) *CreateFormsConfigParams { - var () return &CreateFormsConfigParams{ - Context: ctx, } } // NewCreateFormsConfigParamsWithHTTPClient creates a new CreateFormsConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateFormsConfigParamsWithHTTPClient(client *http.Client) *CreateFormsConfigParams { - var () return &CreateFormsConfigParams{ HTTPClient: client, } } -/*CreateFormsConfigParams contains all the parameters to send to the API endpoint -for the create forms config operation typically these are written to a http.Request +/* +CreateFormsConfigParams contains all the parameters to send to the API endpoint + + for the create forms config operation. + + Typically these are written to a http.Request. */ type CreateFormsConfigParams struct { - /*Body - The information of the filled forms for a new project. + /* Body. + The information of the filled forms for a new project. */ Body *models.FormInputs - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -84,6 +86,21 @@ type CreateFormsConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create forms config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateFormsConfigParams) WithDefaults() *CreateFormsConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create forms config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateFormsConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create forms config params func (o *CreateFormsConfigParams) WithTimeout(timeout time.Duration) *CreateFormsConfigParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *CreateFormsConfigParams) WriteToRequest(r runtime.ClientRequest, reg st return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_forms/create_forms_config_responses.go b/client/client/organization_forms/create_forms_config_responses.go index 284ced99..b53965d5 100644 --- a/client/client/organization_forms/create_forms_config_responses.go +++ b/client/client/organization_forms/create_forms_config_responses.go @@ -6,17 +6,17 @@ package organization_forms // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateFormsConfigReader is a Reader for the CreateFormsConfig structure. @@ -68,7 +68,8 @@ func NewCreateFormsConfigOK() *CreateFormsConfigOK { return &CreateFormsConfigOK{} } -/*CreateFormsConfigOK handles this case with default header values. +/* +CreateFormsConfigOK describes a response with status code 200, with default header values. Set of config to create the project / push onto repositories */ @@ -76,8 +77,44 @@ type CreateFormsConfigOK struct { Payload *CreateFormsConfigOKBody } +// IsSuccess returns true when this create forms config o k response has a 2xx status code +func (o *CreateFormsConfigOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create forms config o k response has a 3xx status code +func (o *CreateFormsConfigOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create forms config o k response has a 4xx status code +func (o *CreateFormsConfigOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create forms config o k response has a 5xx status code +func (o *CreateFormsConfigOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create forms config o k response a status code equal to that given +func (o *CreateFormsConfigOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create forms config o k response +func (o *CreateFormsConfigOK) Code() int { + return 200 +} + func (o *CreateFormsConfigOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigOK %s", 200, payload) +} + +func (o *CreateFormsConfigOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigOK %s", 200, payload) } func (o *CreateFormsConfigOK) GetPayload() *CreateFormsConfigOKBody { @@ -101,20 +138,60 @@ func NewCreateFormsConfigForbidden() *CreateFormsConfigForbidden { return &CreateFormsConfigForbidden{} } -/*CreateFormsConfigForbidden handles this case with default header values. +/* +CreateFormsConfigForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateFormsConfigForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create forms config forbidden response has a 2xx status code +func (o *CreateFormsConfigForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create forms config forbidden response has a 3xx status code +func (o *CreateFormsConfigForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create forms config forbidden response has a 4xx status code +func (o *CreateFormsConfigForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create forms config forbidden response has a 5xx status code +func (o *CreateFormsConfigForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create forms config forbidden response a status code equal to that given +func (o *CreateFormsConfigForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create forms config forbidden response +func (o *CreateFormsConfigForbidden) Code() int { + return 403 +} + func (o *CreateFormsConfigForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigForbidden %s", 403, payload) +} + +func (o *CreateFormsConfigForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigForbidden %s", 403, payload) } func (o *CreateFormsConfigForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +200,16 @@ func (o *CreateFormsConfigForbidden) GetPayload() *models.ErrorPayload { func (o *CreateFormsConfigForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +226,60 @@ func NewCreateFormsConfigNotFound() *CreateFormsConfigNotFound { return &CreateFormsConfigNotFound{} } -/*CreateFormsConfigNotFound handles this case with default header values. +/* +CreateFormsConfigNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateFormsConfigNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create forms config not found response has a 2xx status code +func (o *CreateFormsConfigNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create forms config not found response has a 3xx status code +func (o *CreateFormsConfigNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create forms config not found response has a 4xx status code +func (o *CreateFormsConfigNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create forms config not found response has a 5xx status code +func (o *CreateFormsConfigNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create forms config not found response a status code equal to that given +func (o *CreateFormsConfigNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create forms config not found response +func (o *CreateFormsConfigNotFound) Code() int { + return 404 +} + func (o *CreateFormsConfigNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigNotFound %s", 404, payload) +} + +func (o *CreateFormsConfigNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigNotFound %s", 404, payload) } func (o *CreateFormsConfigNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +288,16 @@ func (o *CreateFormsConfigNotFound) GetPayload() *models.ErrorPayload { func (o *CreateFormsConfigNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +314,60 @@ func NewCreateFormsConfigUnprocessableEntity() *CreateFormsConfigUnprocessableEn return &CreateFormsConfigUnprocessableEntity{} } -/*CreateFormsConfigUnprocessableEntity handles this case with default header values. +/* +CreateFormsConfigUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateFormsConfigUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create forms config unprocessable entity response has a 2xx status code +func (o *CreateFormsConfigUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create forms config unprocessable entity response has a 3xx status code +func (o *CreateFormsConfigUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create forms config unprocessable entity response has a 4xx status code +func (o *CreateFormsConfigUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create forms config unprocessable entity response has a 5xx status code +func (o *CreateFormsConfigUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create forms config unprocessable entity response a status code equal to that given +func (o *CreateFormsConfigUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create forms config unprocessable entity response +func (o *CreateFormsConfigUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateFormsConfigUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigUnprocessableEntity %s", 422, payload) +} + +func (o *CreateFormsConfigUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfigUnprocessableEntity %s", 422, payload) } func (o *CreateFormsConfigUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +376,16 @@ func (o *CreateFormsConfigUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *CreateFormsConfigUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +404,61 @@ func NewCreateFormsConfigDefault(code int) *CreateFormsConfigDefault { } } -/*CreateFormsConfigDefault handles this case with default header values. +/* +CreateFormsConfigDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateFormsConfigDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create forms config default response has a 2xx status code +func (o *CreateFormsConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create forms config default response has a 3xx status code +func (o *CreateFormsConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create forms config default response has a 4xx status code +func (o *CreateFormsConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create forms config default response has a 5xx status code +func (o *CreateFormsConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create forms config default response a status code equal to that given +func (o *CreateFormsConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create forms config default response func (o *CreateFormsConfigDefault) Code() int { return o._statusCode } func (o *CreateFormsConfigDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfig default %s", o._statusCode, payload) +} + +func (o *CreateFormsConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/forms/config][%d] createFormsConfig default %s", o._statusCode, payload) } func (o *CreateFormsConfigDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +467,16 @@ func (o *CreateFormsConfigDefault) GetPayload() *models.ErrorPayload { func (o *CreateFormsConfigDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +488,8 @@ func (o *CreateFormsConfigDefault) readResponse(response runtime.ClientResponse, return nil } -/*CreateFormsConfigOKBody create forms config o k body +/* +CreateFormsConfigOKBody create forms config o k body swagger:model CreateFormsConfigOKBody */ type CreateFormsConfigOKBody struct { @@ -307,13 +515,18 @@ func (o *CreateFormsConfigOKBody) Validate(formats strfmt.Registry) error { func (o *CreateFormsConfigOKBody) validateData(formats strfmt.Registry) error { - if err := validate.Required("createFormsConfigOK"+"."+"data", "body", o.Data); err != nil { - return err + if o.Data == nil { + return errors.Required("createFormsConfigOK"+"."+"data", "body", nil) } return nil } +// ContextValidate validates this create forms config o k body based on context it is used +func (o *CreateFormsConfigOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *CreateFormsConfigOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/organization_forms/organization_forms_client.go b/client/client/organization_forms/organization_forms_client.go index 5d6ab9c3..e5f9a40c 100644 --- a/client/client/organization_forms/organization_forms_client.go +++ b/client/client/organization_forms/organization_forms_client.go @@ -7,15 +7,40 @@ package organization_forms import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization forms API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization forms API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization forms API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization forms API */ @@ -24,16 +49,78 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateFormsConfig(params *CreateFormsConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateFormsConfigOK, error) + + ValidateFormsFile(params *ValidateFormsFileParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValidateFormsFileOK, error) + + ValuesRefForms(params *ValuesRefFormsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValuesRefFormsOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateFormsConfig Generate a set of configs based on the forms inputs */ -func (a *Client) CreateFormsConfig(params *CreateFormsConfigParams, authInfo runtime.ClientAuthInfoWriter) (*CreateFormsConfigOK, error) { +func (a *Client) CreateFormsConfig(params *CreateFormsConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateFormsConfigOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateFormsConfigParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createFormsConfig", Method: "POST", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/forms/config", @@ -45,7 +132,12 @@ func (a *Client) CreateFormsConfig(params *CreateFormsConfigParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +153,12 @@ func (a *Client) CreateFormsConfig(params *CreateFormsConfigParams, authInfo run /* ValidateFormsFile Validate a forms file definition */ -func (a *Client) ValidateFormsFile(params *ValidateFormsFileParams, authInfo runtime.ClientAuthInfoWriter) (*ValidateFormsFileOK, error) { +func (a *Client) ValidateFormsFile(params *ValidateFormsFileParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValidateFormsFileOK, error) { // TODO: Validate the params before sending if params == nil { params = NewValidateFormsFileParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "validateFormsFile", Method: "POST", PathPattern: "/organizations/{organization_canonical}/forms/validate", @@ -79,7 +170,12 @@ func (a *Client) ValidateFormsFile(params *ValidateFormsFileParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +191,12 @@ func (a *Client) ValidateFormsFile(params *ValidateFormsFileParams, authInfo run /* ValuesRefForms Returns the values from the ref */ -func (a *Client) ValuesRefForms(params *ValuesRefFormsParams, authInfo runtime.ClientAuthInfoWriter) (*ValuesRefFormsOK, error) { +func (a *Client) ValuesRefForms(params *ValuesRefFormsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValuesRefFormsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewValuesRefFormsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "valuesRefForms", Method: "POST", PathPattern: "/organizations/{organization_canonical}/forms/values_ref", @@ -113,7 +208,12 @@ func (a *Client) ValuesRefForms(params *ValuesRefFormsParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_forms/validate_forms_file_parameters.go b/client/client/organization_forms/validate_forms_file_parameters.go index 3724b592..308b8c47 100644 --- a/client/client/organization_forms/validate_forms_file_parameters.go +++ b/client/client/organization_forms/validate_forms_file_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewValidateFormsFileParams creates a new ValidateFormsFileParams object -// with the default values initialized. +// NewValidateFormsFileParams creates a new ValidateFormsFileParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewValidateFormsFileParams() *ValidateFormsFileParams { - var () return &ValidateFormsFileParams{ - timeout: cr.DefaultTimeout, } } // NewValidateFormsFileParamsWithTimeout creates a new ValidateFormsFileParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewValidateFormsFileParamsWithTimeout(timeout time.Duration) *ValidateFormsFileParams { - var () return &ValidateFormsFileParams{ - timeout: timeout, } } // NewValidateFormsFileParamsWithContext creates a new ValidateFormsFileParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewValidateFormsFileParamsWithContext(ctx context.Context) *ValidateFormsFileParams { - var () return &ValidateFormsFileParams{ - Context: ctx, } } // NewValidateFormsFileParamsWithHTTPClient creates a new ValidateFormsFileParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewValidateFormsFileParamsWithHTTPClient(client *http.Client) *ValidateFormsFileParams { - var () return &ValidateFormsFileParams{ HTTPClient: client, } } -/*ValidateFormsFileParams contains all the parameters to send to the API endpoint -for the validate forms file operation typically these are written to a http.Request +/* +ValidateFormsFileParams contains all the parameters to send to the API endpoint + + for the validate forms file operation. + + Typically these are written to a http.Request. */ type ValidateFormsFileParams struct { - /*Body - The content of the forms file to be validated. + /* Body. + The content of the forms file to be validated. */ Body *models.FormsValidation - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type ValidateFormsFileParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the validate forms file params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValidateFormsFileParams) WithDefaults() *ValidateFormsFileParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the validate forms file params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValidateFormsFileParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the validate forms file params func (o *ValidateFormsFileParams) WithTimeout(timeout time.Duration) *ValidateFormsFileParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *ValidateFormsFileParams) WriteToRequest(r runtime.ClientRequest, reg st return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_forms/validate_forms_file_responses.go b/client/client/organization_forms/validate_forms_file_responses.go index 2110a7f4..d37e6fee 100644 --- a/client/client/organization_forms/validate_forms_file_responses.go +++ b/client/client/organization_forms/validate_forms_file_responses.go @@ -6,17 +6,18 @@ package organization_forms // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ValidateFormsFileReader is a Reader for the ValidateFormsFile structure. @@ -68,7 +69,8 @@ func NewValidateFormsFileOK() *ValidateFormsFileOK { return &ValidateFormsFileOK{} } -/*ValidateFormsFileOK handles this case with default header values. +/* +ValidateFormsFileOK describes a response with status code 200, with default header values. The result of validating the provided configuration */ @@ -76,8 +78,44 @@ type ValidateFormsFileOK struct { Payload *ValidateFormsFileOKBody } +// IsSuccess returns true when this validate forms file o k response has a 2xx status code +func (o *ValidateFormsFileOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this validate forms file o k response has a 3xx status code +func (o *ValidateFormsFileOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate forms file o k response has a 4xx status code +func (o *ValidateFormsFileOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this validate forms file o k response has a 5xx status code +func (o *ValidateFormsFileOK) IsServerError() bool { + return false +} + +// IsCode returns true when this validate forms file o k response a status code equal to that given +func (o *ValidateFormsFileOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the validate forms file o k response +func (o *ValidateFormsFileOK) Code() int { + return 200 +} + func (o *ValidateFormsFileOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileOK %s", 200, payload) +} + +func (o *ValidateFormsFileOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileOK %s", 200, payload) } func (o *ValidateFormsFileOK) GetPayload() *ValidateFormsFileOKBody { @@ -101,20 +139,60 @@ func NewValidateFormsFileForbidden() *ValidateFormsFileForbidden { return &ValidateFormsFileForbidden{} } -/*ValidateFormsFileForbidden handles this case with default header values. +/* +ValidateFormsFileForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ValidateFormsFileForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate forms file forbidden response has a 2xx status code +func (o *ValidateFormsFileForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate forms file forbidden response has a 3xx status code +func (o *ValidateFormsFileForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate forms file forbidden response has a 4xx status code +func (o *ValidateFormsFileForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate forms file forbidden response has a 5xx status code +func (o *ValidateFormsFileForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this validate forms file forbidden response a status code equal to that given +func (o *ValidateFormsFileForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the validate forms file forbidden response +func (o *ValidateFormsFileForbidden) Code() int { + return 403 +} + func (o *ValidateFormsFileForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileForbidden %s", 403, payload) +} + +func (o *ValidateFormsFileForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileForbidden %s", 403, payload) } func (o *ValidateFormsFileForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *ValidateFormsFileForbidden) GetPayload() *models.ErrorPayload { func (o *ValidateFormsFileForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewValidateFormsFileNotFound() *ValidateFormsFileNotFound { return &ValidateFormsFileNotFound{} } -/*ValidateFormsFileNotFound handles this case with default header values. +/* +ValidateFormsFileNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type ValidateFormsFileNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate forms file not found response has a 2xx status code +func (o *ValidateFormsFileNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate forms file not found response has a 3xx status code +func (o *ValidateFormsFileNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate forms file not found response has a 4xx status code +func (o *ValidateFormsFileNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate forms file not found response has a 5xx status code +func (o *ValidateFormsFileNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this validate forms file not found response a status code equal to that given +func (o *ValidateFormsFileNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the validate forms file not found response +func (o *ValidateFormsFileNotFound) Code() int { + return 404 +} + func (o *ValidateFormsFileNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileNotFound %s", 404, payload) +} + +func (o *ValidateFormsFileNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileNotFound %s", 404, payload) } func (o *ValidateFormsFileNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *ValidateFormsFileNotFound) GetPayload() *models.ErrorPayload { func (o *ValidateFormsFileNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewValidateFormsFileUnprocessableEntity() *ValidateFormsFileUnprocessableEn return &ValidateFormsFileUnprocessableEntity{} } -/*ValidateFormsFileUnprocessableEntity handles this case with default header values. +/* +ValidateFormsFileUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type ValidateFormsFileUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate forms file unprocessable entity response has a 2xx status code +func (o *ValidateFormsFileUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate forms file unprocessable entity response has a 3xx status code +func (o *ValidateFormsFileUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate forms file unprocessable entity response has a 4xx status code +func (o *ValidateFormsFileUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate forms file unprocessable entity response has a 5xx status code +func (o *ValidateFormsFileUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this validate forms file unprocessable entity response a status code equal to that given +func (o *ValidateFormsFileUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the validate forms file unprocessable entity response +func (o *ValidateFormsFileUnprocessableEntity) Code() int { + return 422 +} + func (o *ValidateFormsFileUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileUnprocessableEntity %s", 422, payload) +} + +func (o *ValidateFormsFileUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFileUnprocessableEntity %s", 422, payload) } func (o *ValidateFormsFileUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *ValidateFormsFileUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *ValidateFormsFileUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewValidateFormsFileDefault(code int) *ValidateFormsFileDefault { } } -/*ValidateFormsFileDefault handles this case with default header values. +/* +ValidateFormsFileDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ValidateFormsFileDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate forms file default response has a 2xx status code +func (o *ValidateFormsFileDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this validate forms file default response has a 3xx status code +func (o *ValidateFormsFileDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this validate forms file default response has a 4xx status code +func (o *ValidateFormsFileDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this validate forms file default response has a 5xx status code +func (o *ValidateFormsFileDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this validate forms file default response a status code equal to that given +func (o *ValidateFormsFileDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the validate forms file default response func (o *ValidateFormsFileDefault) Code() int { return o._statusCode } func (o *ValidateFormsFileDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFile default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFile default %s", o._statusCode, payload) +} + +func (o *ValidateFormsFileDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/validate][%d] validateFormsFile default %s", o._statusCode, payload) } func (o *ValidateFormsFileDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *ValidateFormsFileDefault) GetPayload() *models.ErrorPayload { func (o *ValidateFormsFileDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *ValidateFormsFileDefault) readResponse(response runtime.ClientResponse, return nil } -/*ValidateFormsFileOKBody validate forms file o k body +/* +ValidateFormsFileOKBody validate forms file o k body swagger:model ValidateFormsFileOKBody */ type ValidateFormsFileOKBody struct { @@ -315,6 +524,39 @@ func (o *ValidateFormsFileOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("validateFormsFileOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("validateFormsFileOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this validate forms file o k body based on the context it is used +func (o *ValidateFormsFileOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ValidateFormsFileOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("validateFormsFileOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("validateFormsFileOK" + "." + "data") } return err } diff --git a/client/client/organization_forms/values_ref_forms_parameters.go b/client/client/organization_forms/values_ref_forms_parameters.go index fd2ba1b6..9697e64e 100644 --- a/client/client/organization_forms/values_ref_forms_parameters.go +++ b/client/client/organization_forms/values_ref_forms_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewValuesRefFormsParams creates a new ValuesRefFormsParams object -// with the default values initialized. +// NewValuesRefFormsParams creates a new ValuesRefFormsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewValuesRefFormsParams() *ValuesRefFormsParams { - var () return &ValuesRefFormsParams{ - timeout: cr.DefaultTimeout, } } // NewValuesRefFormsParamsWithTimeout creates a new ValuesRefFormsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewValuesRefFormsParamsWithTimeout(timeout time.Duration) *ValuesRefFormsParams { - var () return &ValuesRefFormsParams{ - timeout: timeout, } } // NewValuesRefFormsParamsWithContext creates a new ValuesRefFormsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewValuesRefFormsParamsWithContext(ctx context.Context) *ValuesRefFormsParams { - var () return &ValuesRefFormsParams{ - Context: ctx, } } // NewValuesRefFormsParamsWithHTTPClient creates a new ValuesRefFormsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewValuesRefFormsParamsWithHTTPClient(client *http.Client) *ValuesRefFormsParams { - var () return &ValuesRefFormsParams{ HTTPClient: client, } } -/*ValuesRefFormsParams contains all the parameters to send to the API endpoint -for the values ref forms operation typically these are written to a http.Request +/* +ValuesRefFormsParams contains all the parameters to send to the API endpoint + + for the values ref forms operation. + + Typically these are written to a http.Request. */ type ValuesRefFormsParams struct { - /*Body - The content of the forms file to be validated. + /* Body. + The content of the forms file to be validated. */ Body *models.FormsValuesRef - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type ValuesRefFormsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the values ref forms params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValuesRefFormsParams) WithDefaults() *ValuesRefFormsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the values ref forms params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValuesRefFormsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the values ref forms params func (o *ValuesRefFormsParams) WithTimeout(timeout time.Duration) *ValuesRefFormsParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *ValuesRefFormsParams) WriteToRequest(r runtime.ClientRequest, reg strfm return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_forms/values_ref_forms_responses.go b/client/client/organization_forms/values_ref_forms_responses.go index e3ce0bc5..3e72690f 100644 --- a/client/client/organization_forms/values_ref_forms_responses.go +++ b/client/client/organization_forms/values_ref_forms_responses.go @@ -6,17 +6,17 @@ package organization_forms // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ValuesRefFormsReader is a Reader for the ValuesRefForms structure. @@ -68,7 +68,8 @@ func NewValuesRefFormsOK() *ValuesRefFormsOK { return &ValuesRefFormsOK{} } -/*ValuesRefFormsOK handles this case with default header values. +/* +ValuesRefFormsOK describes a response with status code 200, with default header values. The result of validating the provided configuration */ @@ -76,8 +77,44 @@ type ValuesRefFormsOK struct { Payload *ValuesRefFormsOKBody } +// IsSuccess returns true when this values ref forms o k response has a 2xx status code +func (o *ValuesRefFormsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this values ref forms o k response has a 3xx status code +func (o *ValuesRefFormsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this values ref forms o k response has a 4xx status code +func (o *ValuesRefFormsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this values ref forms o k response has a 5xx status code +func (o *ValuesRefFormsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this values ref forms o k response a status code equal to that given +func (o *ValuesRefFormsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the values ref forms o k response +func (o *ValuesRefFormsOK) Code() int { + return 200 +} + func (o *ValuesRefFormsOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsOK %s", 200, payload) +} + +func (o *ValuesRefFormsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsOK %s", 200, payload) } func (o *ValuesRefFormsOK) GetPayload() *ValuesRefFormsOKBody { @@ -101,20 +138,60 @@ func NewValuesRefFormsForbidden() *ValuesRefFormsForbidden { return &ValuesRefFormsForbidden{} } -/*ValuesRefFormsForbidden handles this case with default header values. +/* +ValuesRefFormsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ValuesRefFormsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this values ref forms forbidden response has a 2xx status code +func (o *ValuesRefFormsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this values ref forms forbidden response has a 3xx status code +func (o *ValuesRefFormsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this values ref forms forbidden response has a 4xx status code +func (o *ValuesRefFormsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this values ref forms forbidden response has a 5xx status code +func (o *ValuesRefFormsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this values ref forms forbidden response a status code equal to that given +func (o *ValuesRefFormsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the values ref forms forbidden response +func (o *ValuesRefFormsForbidden) Code() int { + return 403 +} + func (o *ValuesRefFormsForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsForbidden %s", 403, payload) +} + +func (o *ValuesRefFormsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsForbidden %s", 403, payload) } func (o *ValuesRefFormsForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +200,16 @@ func (o *ValuesRefFormsForbidden) GetPayload() *models.ErrorPayload { func (o *ValuesRefFormsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +226,60 @@ func NewValuesRefFormsNotFound() *ValuesRefFormsNotFound { return &ValuesRefFormsNotFound{} } -/*ValuesRefFormsNotFound handles this case with default header values. +/* +ValuesRefFormsNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type ValuesRefFormsNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this values ref forms not found response has a 2xx status code +func (o *ValuesRefFormsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this values ref forms not found response has a 3xx status code +func (o *ValuesRefFormsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this values ref forms not found response has a 4xx status code +func (o *ValuesRefFormsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this values ref forms not found response has a 5xx status code +func (o *ValuesRefFormsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this values ref forms not found response a status code equal to that given +func (o *ValuesRefFormsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the values ref forms not found response +func (o *ValuesRefFormsNotFound) Code() int { + return 404 +} + func (o *ValuesRefFormsNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsNotFound %s", 404, payload) +} + +func (o *ValuesRefFormsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsNotFound %s", 404, payload) } func (o *ValuesRefFormsNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +288,16 @@ func (o *ValuesRefFormsNotFound) GetPayload() *models.ErrorPayload { func (o *ValuesRefFormsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +314,60 @@ func NewValuesRefFormsUnprocessableEntity() *ValuesRefFormsUnprocessableEntity { return &ValuesRefFormsUnprocessableEntity{} } -/*ValuesRefFormsUnprocessableEntity handles this case with default header values. +/* +ValuesRefFormsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type ValuesRefFormsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this values ref forms unprocessable entity response has a 2xx status code +func (o *ValuesRefFormsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this values ref forms unprocessable entity response has a 3xx status code +func (o *ValuesRefFormsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this values ref forms unprocessable entity response has a 4xx status code +func (o *ValuesRefFormsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this values ref forms unprocessable entity response has a 5xx status code +func (o *ValuesRefFormsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this values ref forms unprocessable entity response a status code equal to that given +func (o *ValuesRefFormsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the values ref forms unprocessable entity response +func (o *ValuesRefFormsUnprocessableEntity) Code() int { + return 422 +} + func (o *ValuesRefFormsUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsUnprocessableEntity %s", 422, payload) +} + +func (o *ValuesRefFormsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefFormsUnprocessableEntity %s", 422, payload) } func (o *ValuesRefFormsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +376,16 @@ func (o *ValuesRefFormsUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *ValuesRefFormsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +404,61 @@ func NewValuesRefFormsDefault(code int) *ValuesRefFormsDefault { } } -/*ValuesRefFormsDefault handles this case with default header values. +/* +ValuesRefFormsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ValuesRefFormsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this values ref forms default response has a 2xx status code +func (o *ValuesRefFormsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this values ref forms default response has a 3xx status code +func (o *ValuesRefFormsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this values ref forms default response has a 4xx status code +func (o *ValuesRefFormsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this values ref forms default response has a 5xx status code +func (o *ValuesRefFormsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this values ref forms default response a status code equal to that given +func (o *ValuesRefFormsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the values ref forms default response func (o *ValuesRefFormsDefault) Code() int { return o._statusCode } func (o *ValuesRefFormsDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefForms default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefForms default %s", o._statusCode, payload) +} + +func (o *ValuesRefFormsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/forms/values_ref][%d] valuesRefForms default %s", o._statusCode, payload) } func (o *ValuesRefFormsDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +467,16 @@ func (o *ValuesRefFormsDefault) GetPayload() *models.ErrorPayload { func (o *ValuesRefFormsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +488,8 @@ func (o *ValuesRefFormsDefault) readResponse(response runtime.ClientResponse, co return nil } -/*ValuesRefFormsOKBody values ref forms o k body +/* +ValuesRefFormsOKBody values ref forms o k body swagger:model ValuesRefFormsOKBody */ type ValuesRefFormsOKBody struct { @@ -307,13 +515,18 @@ func (o *ValuesRefFormsOKBody) Validate(formats strfmt.Registry) error { func (o *ValuesRefFormsOKBody) validateData(formats strfmt.Registry) error { - if err := validate.Required("valuesRefFormsOK"+"."+"data", "body", o.Data); err != nil { - return err + if o.Data == nil { + return errors.Required("valuesRefFormsOK"+"."+"data", "body", nil) } return nil } +// ContextValidate validates this values ref forms o k body based on context it is used +func (o *ValuesRefFormsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *ValuesRefFormsOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/organization_infrastructure_policies/create_infra_policy_parameters.go b/client/client/organization_infrastructure_policies/create_infra_policy_parameters.go index cb49a161..4d6994af 100644 --- a/client/client/organization_infrastructure_policies/create_infra_policy_parameters.go +++ b/client/client/organization_infrastructure_policies/create_infra_policy_parameters.go @@ -13,61 +13,62 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateInfraPolicyParams creates a new CreateInfraPolicyParams object -// with the default values initialized. +// NewCreateInfraPolicyParams creates a new CreateInfraPolicyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateInfraPolicyParams() *CreateInfraPolicyParams { - var () return &CreateInfraPolicyParams{ - timeout: cr.DefaultTimeout, } } // NewCreateInfraPolicyParamsWithTimeout creates a new CreateInfraPolicyParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateInfraPolicyParamsWithTimeout(timeout time.Duration) *CreateInfraPolicyParams { - var () return &CreateInfraPolicyParams{ - timeout: timeout, } } // NewCreateInfraPolicyParamsWithContext creates a new CreateInfraPolicyParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateInfraPolicyParamsWithContext(ctx context.Context) *CreateInfraPolicyParams { - var () return &CreateInfraPolicyParams{ - Context: ctx, } } // NewCreateInfraPolicyParamsWithHTTPClient creates a new CreateInfraPolicyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateInfraPolicyParamsWithHTTPClient(client *http.Client) *CreateInfraPolicyParams { - var () return &CreateInfraPolicyParams{ HTTPClient: client, } } -/*CreateInfraPolicyParams contains all the parameters to send to the API endpoint -for the create infra policy operation typically these are written to a http.Request +/* +CreateInfraPolicyParams contains all the parameters to send to the API endpoint + + for the create infra policy operation. + + Typically these are written to a http.Request. */ type CreateInfraPolicyParams struct { - /*Body*/ + // Body. Body *models.NewInfraPolicy - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -76,6 +77,21 @@ type CreateInfraPolicyParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create infra policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateInfraPolicyParams) WithDefaults() *CreateInfraPolicyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create infra policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateInfraPolicyParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create infra policy params func (o *CreateInfraPolicyParams) WithTimeout(timeout time.Duration) *CreateInfraPolicyParams { o.SetTimeout(timeout) @@ -138,7 +154,6 @@ func (o *CreateInfraPolicyParams) WriteToRequest(r runtime.ClientRequest, reg st return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_infrastructure_policies/create_infra_policy_responses.go b/client/client/organization_infrastructure_policies/create_infra_policy_responses.go index 4ae5f69b..90d2de5f 100644 --- a/client/client/organization_infrastructure_policies/create_infra_policy_responses.go +++ b/client/client/organization_infrastructure_policies/create_infra_policy_responses.go @@ -6,17 +6,18 @@ package organization_infrastructure_policies // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateInfraPolicyReader is a Reader for the CreateInfraPolicy structure. @@ -62,7 +63,8 @@ func NewCreateInfraPolicyOK() *CreateInfraPolicyOK { return &CreateInfraPolicyOK{} } -/*CreateInfraPolicyOK handles this case with default header values. +/* +CreateInfraPolicyOK describes a response with status code 200, with default header values. The new InfraPolicy created. */ @@ -70,8 +72,44 @@ type CreateInfraPolicyOK struct { Payload *CreateInfraPolicyOKBody } +// IsSuccess returns true when this create infra policy o k response has a 2xx status code +func (o *CreateInfraPolicyOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create infra policy o k response has a 3xx status code +func (o *CreateInfraPolicyOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create infra policy o k response has a 4xx status code +func (o *CreateInfraPolicyOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create infra policy o k response has a 5xx status code +func (o *CreateInfraPolicyOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create infra policy o k response a status code equal to that given +func (o *CreateInfraPolicyOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create infra policy o k response +func (o *CreateInfraPolicyOK) Code() int { + return 200 +} + func (o *CreateInfraPolicyOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyOK %s", 200, payload) +} + +func (o *CreateInfraPolicyOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyOK %s", 200, payload) } func (o *CreateInfraPolicyOK) GetPayload() *CreateInfraPolicyOKBody { @@ -95,15 +133,50 @@ func NewCreateInfraPolicyLengthRequired() *CreateInfraPolicyLengthRequired { return &CreateInfraPolicyLengthRequired{} } -/*CreateInfraPolicyLengthRequired handles this case with default header values. +/* +CreateInfraPolicyLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreateInfraPolicyLengthRequired struct { } +// IsSuccess returns true when this create infra policy length required response has a 2xx status code +func (o *CreateInfraPolicyLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create infra policy length required response has a 3xx status code +func (o *CreateInfraPolicyLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create infra policy length required response has a 4xx status code +func (o *CreateInfraPolicyLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create infra policy length required response has a 5xx status code +func (o *CreateInfraPolicyLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create infra policy length required response a status code equal to that given +func (o *CreateInfraPolicyLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create infra policy length required response +func (o *CreateInfraPolicyLengthRequired) Code() int { + return 411 +} + func (o *CreateInfraPolicyLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyLengthRequired", 411) +} + +func (o *CreateInfraPolicyLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyLengthRequired", 411) } func (o *CreateInfraPolicyLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -116,20 +189,60 @@ func NewCreateInfraPolicyUnprocessableEntity() *CreateInfraPolicyUnprocessableEn return &CreateInfraPolicyUnprocessableEntity{} } -/*CreateInfraPolicyUnprocessableEntity handles this case with default header values. +/* +CreateInfraPolicyUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateInfraPolicyUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create infra policy unprocessable entity response has a 2xx status code +func (o *CreateInfraPolicyUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create infra policy unprocessable entity response has a 3xx status code +func (o *CreateInfraPolicyUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create infra policy unprocessable entity response has a 4xx status code +func (o *CreateInfraPolicyUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create infra policy unprocessable entity response has a 5xx status code +func (o *CreateInfraPolicyUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create infra policy unprocessable entity response a status code equal to that given +func (o *CreateInfraPolicyUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create infra policy unprocessable entity response +func (o *CreateInfraPolicyUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateInfraPolicyUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyUnprocessableEntity %s", 422, payload) +} + +func (o *CreateInfraPolicyUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicyUnprocessableEntity %s", 422, payload) } func (o *CreateInfraPolicyUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -138,12 +251,16 @@ func (o *CreateInfraPolicyUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *CreateInfraPolicyUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -162,27 +279,61 @@ func NewCreateInfraPolicyDefault(code int) *CreateInfraPolicyDefault { } } -/*CreateInfraPolicyDefault handles this case with default header values. +/* +CreateInfraPolicyDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateInfraPolicyDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create infra policy default response has a 2xx status code +func (o *CreateInfraPolicyDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create infra policy default response has a 3xx status code +func (o *CreateInfraPolicyDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create infra policy default response has a 4xx status code +func (o *CreateInfraPolicyDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create infra policy default response has a 5xx status code +func (o *CreateInfraPolicyDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create infra policy default response a status code equal to that given +func (o *CreateInfraPolicyDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create infra policy default response func (o *CreateInfraPolicyDefault) Code() int { return o._statusCode } func (o *CreateInfraPolicyDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicy default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicy default %s", o._statusCode, payload) +} + +func (o *CreateInfraPolicyDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/infra_policies][%d] createInfraPolicy default %s", o._statusCode, payload) } func (o *CreateInfraPolicyDefault) GetPayload() *models.ErrorPayload { @@ -191,12 +342,16 @@ func (o *CreateInfraPolicyDefault) GetPayload() *models.ErrorPayload { func (o *CreateInfraPolicyDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -208,7 +363,8 @@ func (o *CreateInfraPolicyDefault) readResponse(response runtime.ClientResponse, return nil } -/*CreateInfraPolicyOKBody create infra policy o k body +/* +CreateInfraPolicyOKBody create infra policy o k body swagger:model CreateInfraPolicyOKBody */ type CreateInfraPolicyOKBody struct { @@ -242,6 +398,39 @@ func (o *CreateInfraPolicyOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createInfraPolicyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createInfraPolicyOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create infra policy o k body based on the context it is used +func (o *CreateInfraPolicyOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateInfraPolicyOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createInfraPolicyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createInfraPolicyOK" + "." + "data") } return err } diff --git a/client/client/organization_infrastructure_policies/delete_infra_policy_parameters.go b/client/client/organization_infrastructure_policies/delete_infra_policy_parameters.go index 89be867c..10114359 100644 --- a/client/client/organization_infrastructure_policies/delete_infra_policy_parameters.go +++ b/client/client/organization_infrastructure_policies/delete_infra_policy_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteInfraPolicyParams creates a new DeleteInfraPolicyParams object -// with the default values initialized. +// NewDeleteInfraPolicyParams creates a new DeleteInfraPolicyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteInfraPolicyParams() *DeleteInfraPolicyParams { - var () return &DeleteInfraPolicyParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteInfraPolicyParamsWithTimeout creates a new DeleteInfraPolicyParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteInfraPolicyParamsWithTimeout(timeout time.Duration) *DeleteInfraPolicyParams { - var () return &DeleteInfraPolicyParams{ - timeout: timeout, } } // NewDeleteInfraPolicyParamsWithContext creates a new DeleteInfraPolicyParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteInfraPolicyParamsWithContext(ctx context.Context) *DeleteInfraPolicyParams { - var () return &DeleteInfraPolicyParams{ - Context: ctx, } } // NewDeleteInfraPolicyParamsWithHTTPClient creates a new DeleteInfraPolicyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteInfraPolicyParamsWithHTTPClient(client *http.Client) *DeleteInfraPolicyParams { - var () return &DeleteInfraPolicyParams{ HTTPClient: client, } } -/*DeleteInfraPolicyParams contains all the parameters to send to the API endpoint -for the delete infra policy operation typically these are written to a http.Request +/* +DeleteInfraPolicyParams contains all the parameters to send to the API endpoint + + for the delete infra policy operation. + + Typically these are written to a http.Request. */ type DeleteInfraPolicyParams struct { - /*InfraPolicyCanonical - The canonical of an InfraPolicy. + /* InfraPolicyCanonical. + The canonical of an InfraPolicy. */ InfraPolicyCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type DeleteInfraPolicyParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete infra policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteInfraPolicyParams) WithDefaults() *DeleteInfraPolicyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete infra policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteInfraPolicyParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete infra policy params func (o *DeleteInfraPolicyParams) WithTimeout(timeout time.Duration) *DeleteInfraPolicyParams { o.SetTimeout(timeout) diff --git a/client/client/organization_infrastructure_policies/delete_infra_policy_responses.go b/client/client/organization_infrastructure_policies/delete_infra_policy_responses.go index e8049ff7..7ccba446 100644 --- a/client/client/organization_infrastructure_policies/delete_infra_policy_responses.go +++ b/client/client/organization_infrastructure_policies/delete_infra_policy_responses.go @@ -6,16 +6,16 @@ package organization_infrastructure_policies // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteInfraPolicyReader is a Reader for the DeleteInfraPolicy structure. @@ -61,15 +61,50 @@ func NewDeleteInfraPolicyNoContent() *DeleteInfraPolicyNoContent { return &DeleteInfraPolicyNoContent{} } -/*DeleteInfraPolicyNoContent handles this case with default header values. +/* +DeleteInfraPolicyNoContent describes a response with status code 204, with default header values. InfraPolicy has been deleted. */ type DeleteInfraPolicyNoContent struct { } +// IsSuccess returns true when this delete infra policy no content response has a 2xx status code +func (o *DeleteInfraPolicyNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete infra policy no content response has a 3xx status code +func (o *DeleteInfraPolicyNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete infra policy no content response has a 4xx status code +func (o *DeleteInfraPolicyNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete infra policy no content response has a 5xx status code +func (o *DeleteInfraPolicyNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete infra policy no content response a status code equal to that given +func (o *DeleteInfraPolicyNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete infra policy no content response +func (o *DeleteInfraPolicyNoContent) Code() int { + return 204 +} + func (o *DeleteInfraPolicyNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyNoContent", 204) +} + +func (o *DeleteInfraPolicyNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyNoContent", 204) } func (o *DeleteInfraPolicyNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteInfraPolicyForbidden() *DeleteInfraPolicyForbidden { return &DeleteInfraPolicyForbidden{} } -/*DeleteInfraPolicyForbidden handles this case with default header values. +/* +DeleteInfraPolicyForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteInfraPolicyForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete infra policy forbidden response has a 2xx status code +func (o *DeleteInfraPolicyForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete infra policy forbidden response has a 3xx status code +func (o *DeleteInfraPolicyForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete infra policy forbidden response has a 4xx status code +func (o *DeleteInfraPolicyForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete infra policy forbidden response has a 5xx status code +func (o *DeleteInfraPolicyForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete infra policy forbidden response a status code equal to that given +func (o *DeleteInfraPolicyForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete infra policy forbidden response +func (o *DeleteInfraPolicyForbidden) Code() int { + return 403 +} + func (o *DeleteInfraPolicyForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyForbidden %s", 403, payload) +} + +func (o *DeleteInfraPolicyForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyForbidden %s", 403, payload) } func (o *DeleteInfraPolicyForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteInfraPolicyForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteInfraPolicyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteInfraPolicyNotFound() *DeleteInfraPolicyNotFound { return &DeleteInfraPolicyNotFound{} } -/*DeleteInfraPolicyNotFound handles this case with default header values. +/* +DeleteInfraPolicyNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteInfraPolicyNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete infra policy not found response has a 2xx status code +func (o *DeleteInfraPolicyNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete infra policy not found response has a 3xx status code +func (o *DeleteInfraPolicyNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete infra policy not found response has a 4xx status code +func (o *DeleteInfraPolicyNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete infra policy not found response has a 5xx status code +func (o *DeleteInfraPolicyNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete infra policy not found response a status code equal to that given +func (o *DeleteInfraPolicyNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete infra policy not found response +func (o *DeleteInfraPolicyNotFound) Code() int { + return 404 +} + func (o *DeleteInfraPolicyNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyNotFound %s", 404, payload) +} + +func (o *DeleteInfraPolicyNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicyNotFound %s", 404, payload) } func (o *DeleteInfraPolicyNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteInfraPolicyNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteInfraPolicyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteInfraPolicyDefault(code int) *DeleteInfraPolicyDefault { } } -/*DeleteInfraPolicyDefault handles this case with default header values. +/* +DeleteInfraPolicyDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteInfraPolicyDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete infra policy default response has a 2xx status code +func (o *DeleteInfraPolicyDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete infra policy default response has a 3xx status code +func (o *DeleteInfraPolicyDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete infra policy default response has a 4xx status code +func (o *DeleteInfraPolicyDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete infra policy default response has a 5xx status code +func (o *DeleteInfraPolicyDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete infra policy default response a status code equal to that given +func (o *DeleteInfraPolicyDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete infra policy default response func (o *DeleteInfraPolicyDefault) Code() int { return o._statusCode } func (o *DeleteInfraPolicyDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicy default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicy default %s", o._statusCode, payload) +} + +func (o *DeleteInfraPolicyDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] deleteInfraPolicy default %s", o._statusCode, payload) } func (o *DeleteInfraPolicyDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteInfraPolicyDefault) GetPayload() *models.ErrorPayload { func (o *DeleteInfraPolicyDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_infrastructure_policies/get_infra_policies_parameters.go b/client/client/organization_infrastructure_policies/get_infra_policies_parameters.go index a05439cc..6e230e5a 100644 --- a/client/client/organization_infrastructure_policies/get_infra_policies_parameters.go +++ b/client/client/organization_infrastructure_policies/get_infra_policies_parameters.go @@ -13,119 +13,115 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetInfraPoliciesParams creates a new GetInfraPoliciesParams object -// with the default values initialized. +// NewGetInfraPoliciesParams creates a new GetInfraPoliciesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetInfraPoliciesParams() *GetInfraPoliciesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetInfraPoliciesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetInfraPoliciesParamsWithTimeout creates a new GetInfraPoliciesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetInfraPoliciesParamsWithTimeout(timeout time.Duration) *GetInfraPoliciesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetInfraPoliciesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetInfraPoliciesParamsWithContext creates a new GetInfraPoliciesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetInfraPoliciesParamsWithContext(ctx context.Context) *GetInfraPoliciesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetInfraPoliciesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetInfraPoliciesParamsWithHTTPClient creates a new GetInfraPoliciesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetInfraPoliciesParamsWithHTTPClient(client *http.Client) *GetInfraPoliciesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetInfraPoliciesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetInfraPoliciesParams contains all the parameters to send to the API endpoint -for the get infra policies operation typically these are written to a http.Request +/* +GetInfraPoliciesParams contains all the parameters to send to the API endpoint + + for the get infra policies operation. + + Typically these are written to a http.Request. */ type GetInfraPoliciesParams struct { - /*InfraPolicyCanonical - Search by infra policy canonical + /* InfraPolicyCanonical. + Search by infra policy canonical */ InfraPolicyCanonical *string - /*InfraPolicyCreatedAt - Search by InfraPolicy's creation date + /* InfraPolicyCreatedAt. + + Search by InfraPolicy's creation date + + Format: uint64 */ InfraPolicyCreatedAt *uint64 - /*InfraPolicyEnabled - Search by InfraPolicy's enabled + /* InfraPolicyEnabled. + + Search by InfraPolicy's enabled */ InfraPolicyEnabled *bool - /*InfraPolicyName - Search by InfraPolicy's name + /* InfraPolicyName. + + Search by InfraPolicy's name */ InfraPolicyName *string - /*InfraPolicySeverity - Search by InfraPolicy's severity + /* InfraPolicySeverity. + + Search by InfraPolicy's severity */ InfraPolicySeverity *string - /*OrderBy - Allows to order the list of items. Example usage: field_name:asc + /* OrderBy. + + Allows to order the list of items. Example usage: field_name:asc */ OrderBy *string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -134,6 +130,35 @@ type GetInfraPoliciesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get infra policies params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetInfraPoliciesParams) WithDefaults() *GetInfraPoliciesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get infra policies params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetInfraPoliciesParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetInfraPoliciesParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get infra policies params func (o *GetInfraPoliciesParams) WithTimeout(timeout time.Duration) *GetInfraPoliciesParams { o.SetTimeout(timeout) @@ -278,96 +303,102 @@ func (o *GetInfraPoliciesParams) WriteToRequest(r runtime.ClientRequest, reg str // query param infra_policy_canonical var qrInfraPolicyCanonical string + if o.InfraPolicyCanonical != nil { qrInfraPolicyCanonical = *o.InfraPolicyCanonical } qInfraPolicyCanonical := qrInfraPolicyCanonical if qInfraPolicyCanonical != "" { + if err := r.SetQueryParam("infra_policy_canonical", qInfraPolicyCanonical); err != nil { return err } } - } if o.InfraPolicyCreatedAt != nil { // query param infra_policy_created_at var qrInfraPolicyCreatedAt uint64 + if o.InfraPolicyCreatedAt != nil { qrInfraPolicyCreatedAt = *o.InfraPolicyCreatedAt } qInfraPolicyCreatedAt := swag.FormatUint64(qrInfraPolicyCreatedAt) if qInfraPolicyCreatedAt != "" { + if err := r.SetQueryParam("infra_policy_created_at", qInfraPolicyCreatedAt); err != nil { return err } } - } if o.InfraPolicyEnabled != nil { // query param infra_policy_enabled var qrInfraPolicyEnabled bool + if o.InfraPolicyEnabled != nil { qrInfraPolicyEnabled = *o.InfraPolicyEnabled } qInfraPolicyEnabled := swag.FormatBool(qrInfraPolicyEnabled) if qInfraPolicyEnabled != "" { + if err := r.SetQueryParam("infra_policy_enabled", qInfraPolicyEnabled); err != nil { return err } } - } if o.InfraPolicyName != nil { // query param infra_policy_name var qrInfraPolicyName string + if o.InfraPolicyName != nil { qrInfraPolicyName = *o.InfraPolicyName } qInfraPolicyName := qrInfraPolicyName if qInfraPolicyName != "" { + if err := r.SetQueryParam("infra_policy_name", qInfraPolicyName); err != nil { return err } } - } if o.InfraPolicySeverity != nil { // query param infra_policy_severity var qrInfraPolicySeverity string + if o.InfraPolicySeverity != nil { qrInfraPolicySeverity = *o.InfraPolicySeverity } qInfraPolicySeverity := qrInfraPolicySeverity if qInfraPolicySeverity != "" { + if err := r.SetQueryParam("infra_policy_severity", qInfraPolicySeverity); err != nil { return err } } - } if o.OrderBy != nil { // query param order_by var qrOrderBy string + if o.OrderBy != nil { qrOrderBy = *o.OrderBy } qOrderBy := qrOrderBy if qOrderBy != "" { + if err := r.SetQueryParam("order_by", qOrderBy); err != nil { return err } } - } // path param organization_canonical @@ -379,32 +410,34 @@ func (o *GetInfraPoliciesParams) WriteToRequest(r runtime.ClientRequest, reg str // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_infrastructure_policies/get_infra_policies_responses.go b/client/client/organization_infrastructure_policies/get_infra_policies_responses.go index d2242828..489fab0f 100644 --- a/client/client/organization_infrastructure_policies/get_infra_policies_responses.go +++ b/client/client/organization_infrastructure_policies/get_infra_policies_responses.go @@ -6,18 +6,19 @@ package organization_infrastructure_policies // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetInfraPoliciesReader is a Reader for the GetInfraPolicies structure. @@ -69,7 +70,8 @@ func NewGetInfraPoliciesOK() *GetInfraPoliciesOK { return &GetInfraPoliciesOK{} } -/*GetInfraPoliciesOK handles this case with default header values. +/* +GetInfraPoliciesOK describes a response with status code 200, with default header values. List of infrastructure policies. */ @@ -77,8 +79,44 @@ type GetInfraPoliciesOK struct { Payload *GetInfraPoliciesOKBody } +// IsSuccess returns true when this get infra policies o k response has a 2xx status code +func (o *GetInfraPoliciesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get infra policies o k response has a 3xx status code +func (o *GetInfraPoliciesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get infra policies o k response has a 4xx status code +func (o *GetInfraPoliciesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get infra policies o k response has a 5xx status code +func (o *GetInfraPoliciesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get infra policies o k response a status code equal to that given +func (o *GetInfraPoliciesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get infra policies o k response +func (o *GetInfraPoliciesOK) Code() int { + return 200 +} + func (o *GetInfraPoliciesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesOK %s", 200, payload) +} + +func (o *GetInfraPoliciesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesOK %s", 200, payload) } func (o *GetInfraPoliciesOK) GetPayload() *GetInfraPoliciesOKBody { @@ -102,20 +140,60 @@ func NewGetInfraPoliciesForbidden() *GetInfraPoliciesForbidden { return &GetInfraPoliciesForbidden{} } -/*GetInfraPoliciesForbidden handles this case with default header values. +/* +GetInfraPoliciesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetInfraPoliciesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get infra policies forbidden response has a 2xx status code +func (o *GetInfraPoliciesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get infra policies forbidden response has a 3xx status code +func (o *GetInfraPoliciesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get infra policies forbidden response has a 4xx status code +func (o *GetInfraPoliciesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get infra policies forbidden response has a 5xx status code +func (o *GetInfraPoliciesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get infra policies forbidden response a status code equal to that given +func (o *GetInfraPoliciesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get infra policies forbidden response +func (o *GetInfraPoliciesForbidden) Code() int { + return 403 +} + func (o *GetInfraPoliciesForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesForbidden %s", 403, payload) +} + +func (o *GetInfraPoliciesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesForbidden %s", 403, payload) } func (o *GetInfraPoliciesForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetInfraPoliciesForbidden) GetPayload() *models.ErrorPayload { func (o *GetInfraPoliciesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetInfraPoliciesNotFound() *GetInfraPoliciesNotFound { return &GetInfraPoliciesNotFound{} } -/*GetInfraPoliciesNotFound handles this case with default header values. +/* +GetInfraPoliciesNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetInfraPoliciesNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get infra policies not found response has a 2xx status code +func (o *GetInfraPoliciesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get infra policies not found response has a 3xx status code +func (o *GetInfraPoliciesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get infra policies not found response has a 4xx status code +func (o *GetInfraPoliciesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get infra policies not found response has a 5xx status code +func (o *GetInfraPoliciesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get infra policies not found response a status code equal to that given +func (o *GetInfraPoliciesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get infra policies not found response +func (o *GetInfraPoliciesNotFound) Code() int { + return 404 +} + func (o *GetInfraPoliciesNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesNotFound %s", 404, payload) +} + +func (o *GetInfraPoliciesNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesNotFound %s", 404, payload) } func (o *GetInfraPoliciesNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetInfraPoliciesNotFound) GetPayload() *models.ErrorPayload { func (o *GetInfraPoliciesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetInfraPoliciesUnprocessableEntity() *GetInfraPoliciesUnprocessableEnti return &GetInfraPoliciesUnprocessableEntity{} } -/*GetInfraPoliciesUnprocessableEntity handles this case with default header values. +/* +GetInfraPoliciesUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetInfraPoliciesUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get infra policies unprocessable entity response has a 2xx status code +func (o *GetInfraPoliciesUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get infra policies unprocessable entity response has a 3xx status code +func (o *GetInfraPoliciesUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get infra policies unprocessable entity response has a 4xx status code +func (o *GetInfraPoliciesUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get infra policies unprocessable entity response has a 5xx status code +func (o *GetInfraPoliciesUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get infra policies unprocessable entity response a status code equal to that given +func (o *GetInfraPoliciesUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get infra policies unprocessable entity response +func (o *GetInfraPoliciesUnprocessableEntity) Code() int { + return 422 +} + func (o *GetInfraPoliciesUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesUnprocessableEntity %s", 422, payload) +} + +func (o *GetInfraPoliciesUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPoliciesUnprocessableEntity %s", 422, payload) } func (o *GetInfraPoliciesUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetInfraPoliciesUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *GetInfraPoliciesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetInfraPoliciesDefault(code int) *GetInfraPoliciesDefault { } } -/*GetInfraPoliciesDefault handles this case with default header values. +/* +GetInfraPoliciesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetInfraPoliciesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get infra policies default response has a 2xx status code +func (o *GetInfraPoliciesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get infra policies default response has a 3xx status code +func (o *GetInfraPoliciesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get infra policies default response has a 4xx status code +func (o *GetInfraPoliciesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get infra policies default response has a 5xx status code +func (o *GetInfraPoliciesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get infra policies default response a status code equal to that given +func (o *GetInfraPoliciesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get infra policies default response func (o *GetInfraPoliciesDefault) Code() int { return o._statusCode } func (o *GetInfraPoliciesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPolicies default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPolicies default %s", o._statusCode, payload) +} + +func (o *GetInfraPoliciesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies][%d] getInfraPolicies default %s", o._statusCode, payload) } func (o *GetInfraPoliciesDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetInfraPoliciesDefault) GetPayload() *models.ErrorPayload { func (o *GetInfraPoliciesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetInfraPoliciesDefault) readResponse(response runtime.ClientResponse, return nil } -/*GetInfraPoliciesOKBody get infra policies o k body +/* +GetInfraPoliciesOKBody get infra policies o k body swagger:model GetInfraPoliciesOKBody */ type GetInfraPoliciesOKBody struct { @@ -328,6 +537,8 @@ func (o *GetInfraPoliciesOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getInfraPoliciesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInfraPoliciesOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -339,7 +550,6 @@ func (o *GetInfraPoliciesOKBody) validateData(formats strfmt.Registry) error { } func (o *GetInfraPoliciesOKBody) validatePagination(formats strfmt.Registry) error { - if swag.IsZero(o.Pagination) { // not required return nil } @@ -348,6 +558,72 @@ func (o *GetInfraPoliciesOKBody) validatePagination(formats strfmt.Registry) err if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getInfraPoliciesOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInfraPoliciesOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get infra policies o k body based on the context it is used +func (o *GetInfraPoliciesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetInfraPoliciesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getInfraPoliciesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInfraPoliciesOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetInfraPoliciesOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if swag.IsZero(o.Pagination) { // not required + return nil + } + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getInfraPoliciesOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInfraPoliciesOK" + "." + "pagination") } return err } diff --git a/client/client/organization_infrastructure_policies/get_infra_policy_parameters.go b/client/client/organization_infrastructure_policies/get_infra_policy_parameters.go index 92c7bb48..57b9327a 100644 --- a/client/client/organization_infrastructure_policies/get_infra_policy_parameters.go +++ b/client/client/organization_infrastructure_policies/get_infra_policy_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetInfraPolicyParams creates a new GetInfraPolicyParams object -// with the default values initialized. +// NewGetInfraPolicyParams creates a new GetInfraPolicyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetInfraPolicyParams() *GetInfraPolicyParams { - var () return &GetInfraPolicyParams{ - timeout: cr.DefaultTimeout, } } // NewGetInfraPolicyParamsWithTimeout creates a new GetInfraPolicyParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetInfraPolicyParamsWithTimeout(timeout time.Duration) *GetInfraPolicyParams { - var () return &GetInfraPolicyParams{ - timeout: timeout, } } // NewGetInfraPolicyParamsWithContext creates a new GetInfraPolicyParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetInfraPolicyParamsWithContext(ctx context.Context) *GetInfraPolicyParams { - var () return &GetInfraPolicyParams{ - Context: ctx, } } // NewGetInfraPolicyParamsWithHTTPClient creates a new GetInfraPolicyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetInfraPolicyParamsWithHTTPClient(client *http.Client) *GetInfraPolicyParams { - var () return &GetInfraPolicyParams{ HTTPClient: client, } } -/*GetInfraPolicyParams contains all the parameters to send to the API endpoint -for the get infra policy operation typically these are written to a http.Request +/* +GetInfraPolicyParams contains all the parameters to send to the API endpoint + + for the get infra policy operation. + + Typically these are written to a http.Request. */ type GetInfraPolicyParams struct { - /*InfraPolicyCanonical - The canonical of an InfraPolicy. + /* InfraPolicyCanonical. + The canonical of an InfraPolicy. */ InfraPolicyCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type GetInfraPolicyParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get infra policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetInfraPolicyParams) WithDefaults() *GetInfraPolicyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get infra policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetInfraPolicyParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get infra policy params func (o *GetInfraPolicyParams) WithTimeout(timeout time.Duration) *GetInfraPolicyParams { o.SetTimeout(timeout) diff --git a/client/client/organization_infrastructure_policies/get_infra_policy_responses.go b/client/client/organization_infrastructure_policies/get_infra_policy_responses.go index ed54c79a..dcc3eba6 100644 --- a/client/client/organization_infrastructure_policies/get_infra_policy_responses.go +++ b/client/client/organization_infrastructure_policies/get_infra_policy_responses.go @@ -6,17 +6,18 @@ package organization_infrastructure_policies // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetInfraPolicyReader is a Reader for the GetInfraPolicy structure. @@ -62,7 +63,8 @@ func NewGetInfraPolicyOK() *GetInfraPolicyOK { return &GetInfraPolicyOK{} } -/*GetInfraPolicyOK handles this case with default header values. +/* +GetInfraPolicyOK describes a response with status code 200, with default header values. The information of the InfraPolicy which has the specified canonical. */ @@ -70,8 +72,44 @@ type GetInfraPolicyOK struct { Payload *GetInfraPolicyOKBody } +// IsSuccess returns true when this get infra policy o k response has a 2xx status code +func (o *GetInfraPolicyOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get infra policy o k response has a 3xx status code +func (o *GetInfraPolicyOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get infra policy o k response has a 4xx status code +func (o *GetInfraPolicyOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get infra policy o k response has a 5xx status code +func (o *GetInfraPolicyOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get infra policy o k response a status code equal to that given +func (o *GetInfraPolicyOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get infra policy o k response +func (o *GetInfraPolicyOK) Code() int { + return 200 +} + func (o *GetInfraPolicyOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyOK %s", 200, payload) +} + +func (o *GetInfraPolicyOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyOK %s", 200, payload) } func (o *GetInfraPolicyOK) GetPayload() *GetInfraPolicyOKBody { @@ -95,20 +133,60 @@ func NewGetInfraPolicyForbidden() *GetInfraPolicyForbidden { return &GetInfraPolicyForbidden{} } -/*GetInfraPolicyForbidden handles this case with default header values. +/* +GetInfraPolicyForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetInfraPolicyForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get infra policy forbidden response has a 2xx status code +func (o *GetInfraPolicyForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get infra policy forbidden response has a 3xx status code +func (o *GetInfraPolicyForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get infra policy forbidden response has a 4xx status code +func (o *GetInfraPolicyForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get infra policy forbidden response has a 5xx status code +func (o *GetInfraPolicyForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get infra policy forbidden response a status code equal to that given +func (o *GetInfraPolicyForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get infra policy forbidden response +func (o *GetInfraPolicyForbidden) Code() int { + return 403 +} + func (o *GetInfraPolicyForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyForbidden %s", 403, payload) +} + +func (o *GetInfraPolicyForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyForbidden %s", 403, payload) } func (o *GetInfraPolicyForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetInfraPolicyForbidden) GetPayload() *models.ErrorPayload { func (o *GetInfraPolicyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetInfraPolicyNotFound() *GetInfraPolicyNotFound { return &GetInfraPolicyNotFound{} } -/*GetInfraPolicyNotFound handles this case with default header values. +/* +GetInfraPolicyNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetInfraPolicyNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get infra policy not found response has a 2xx status code +func (o *GetInfraPolicyNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get infra policy not found response has a 3xx status code +func (o *GetInfraPolicyNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get infra policy not found response has a 4xx status code +func (o *GetInfraPolicyNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get infra policy not found response has a 5xx status code +func (o *GetInfraPolicyNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get infra policy not found response a status code equal to that given +func (o *GetInfraPolicyNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get infra policy not found response +func (o *GetInfraPolicyNotFound) Code() int { + return 404 +} + func (o *GetInfraPolicyNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyNotFound %s", 404, payload) +} + +func (o *GetInfraPolicyNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicyNotFound %s", 404, payload) } func (o *GetInfraPolicyNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetInfraPolicyNotFound) GetPayload() *models.ErrorPayload { func (o *GetInfraPolicyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetInfraPolicyDefault(code int) *GetInfraPolicyDefault { } } -/*GetInfraPolicyDefault handles this case with default header values. +/* +GetInfraPolicyDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetInfraPolicyDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get infra policy default response has a 2xx status code +func (o *GetInfraPolicyDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get infra policy default response has a 3xx status code +func (o *GetInfraPolicyDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get infra policy default response has a 4xx status code +func (o *GetInfraPolicyDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get infra policy default response has a 5xx status code +func (o *GetInfraPolicyDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get infra policy default response a status code equal to that given +func (o *GetInfraPolicyDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get infra policy default response func (o *GetInfraPolicyDefault) Code() int { return o._statusCode } func (o *GetInfraPolicyDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicy default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicy default %s", o._statusCode, payload) +} + +func (o *GetInfraPolicyDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] getInfraPolicy default %s", o._statusCode, payload) } func (o *GetInfraPolicyDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetInfraPolicyDefault) GetPayload() *models.ErrorPayload { func (o *GetInfraPolicyDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetInfraPolicyDefault) readResponse(response runtime.ClientResponse, co return nil } -/*GetInfraPolicyOKBody get infra policy o k body +/* +GetInfraPolicyOKBody get infra policy o k body swagger:model GetInfraPolicyOKBody */ type GetInfraPolicyOKBody struct { @@ -265,6 +430,39 @@ func (o *GetInfraPolicyOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getInfraPolicyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInfraPolicyOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get infra policy o k body based on the context it is used +func (o *GetInfraPolicyOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetInfraPolicyOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getInfraPolicyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInfraPolicyOK" + "." + "data") } return err } diff --git a/client/client/organization_infrastructure_policies/organization_infrastructure_policies_client.go b/client/client/organization_infrastructure_policies/organization_infrastructure_policies_client.go index 7d76b347..0614b444 100644 --- a/client/client/organization_infrastructure_policies/organization_infrastructure_policies_client.go +++ b/client/client/organization_infrastructure_policies/organization_infrastructure_policies_client.go @@ -7,15 +7,40 @@ package organization_infrastructure_policies import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization infrastructure policies API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization infrastructure policies API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization infrastructure policies API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization infrastructure policies API */ @@ -24,16 +49,84 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateInfraPolicy(params *CreateInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateInfraPolicyOK, error) + + DeleteInfraPolicy(params *DeleteInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteInfraPolicyNoContent, error) + + GetInfraPolicies(params *GetInfraPoliciesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInfraPoliciesOK, error) + + GetInfraPolicy(params *GetInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInfraPolicyOK, error) + + UpdateInfraPolicy(params *UpdateInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateInfraPolicyOK, error) + + ValidateProjectInfraPolicies(params *ValidateProjectInfraPoliciesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValidateProjectInfraPoliciesOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateInfraPolicy Create a new policy. */ -func (a *Client) CreateInfraPolicy(params *CreateInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter) (*CreateInfraPolicyOK, error) { +func (a *Client) CreateInfraPolicy(params *CreateInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateInfraPolicyOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateInfraPolicyParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createInfraPolicy", Method: "POST", PathPattern: "/organizations/{organization_canonical}/infra_policies", @@ -45,7 +138,12 @@ func (a *Client) CreateInfraPolicy(params *CreateInfraPolicyParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +159,12 @@ func (a *Client) CreateInfraPolicy(params *CreateInfraPolicyParams, authInfo run /* DeleteInfraPolicy Delete the InfraPolicy. */ -func (a *Client) DeleteInfraPolicy(params *DeleteInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteInfraPolicyNoContent, error) { +func (a *Client) DeleteInfraPolicy(params *DeleteInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteInfraPolicyNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteInfraPolicyParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteInfraPolicy", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}", @@ -79,7 +176,12 @@ func (a *Client) DeleteInfraPolicy(params *DeleteInfraPolicyParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +197,12 @@ func (a *Client) DeleteInfraPolicy(params *DeleteInfraPolicyParams, authInfo run /* GetInfraPolicies Return a list of infrastructure policies which matches the scope specified by the filter. */ -func (a *Client) GetInfraPolicies(params *GetInfraPoliciesParams, authInfo runtime.ClientAuthInfoWriter) (*GetInfraPoliciesOK, error) { +func (a *Client) GetInfraPolicies(params *GetInfraPoliciesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInfraPoliciesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetInfraPoliciesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getInfraPolicies", Method: "GET", PathPattern: "/organizations/{organization_canonical}/infra_policies", @@ -113,7 +214,12 @@ func (a *Client) GetInfraPolicies(params *GetInfraPoliciesParams, authInfo runti AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +235,12 @@ func (a *Client) GetInfraPolicies(params *GetInfraPoliciesParams, authInfo runti /* GetInfraPolicy Get the information of the InfraPolicy. */ -func (a *Client) GetInfraPolicy(params *GetInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter) (*GetInfraPolicyOK, error) { +func (a *Client) GetInfraPolicy(params *GetInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInfraPolicyOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetInfraPolicyParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getInfraPolicy", Method: "GET", PathPattern: "/organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}", @@ -147,7 +252,12 @@ func (a *Client) GetInfraPolicy(params *GetInfraPolicyParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +273,12 @@ func (a *Client) GetInfraPolicy(params *GetInfraPolicyParams, authInfo runtime.C /* UpdateInfraPolicy Update an existing InfraPolicy */ -func (a *Client) UpdateInfraPolicy(params *UpdateInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateInfraPolicyOK, error) { +func (a *Client) UpdateInfraPolicy(params *UpdateInfraPolicyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateInfraPolicyOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateInfraPolicyParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateInfraPolicy", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}", @@ -181,7 +290,12 @@ func (a *Client) UpdateInfraPolicy(params *UpdateInfraPolicyParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -197,13 +311,12 @@ func (a *Client) UpdateInfraPolicy(params *UpdateInfraPolicyParams, authInfo run /* ValidateProjectInfraPolicies Check the InfraPolicies assigned to the Project and the Environment to identify if some are not respected. */ -func (a *Client) ValidateProjectInfraPolicies(params *ValidateProjectInfraPoliciesParams, authInfo runtime.ClientAuthInfoWriter) (*ValidateProjectInfraPoliciesOK, error) { +func (a *Client) ValidateProjectInfraPolicies(params *ValidateProjectInfraPoliciesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValidateProjectInfraPoliciesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewValidateProjectInfraPoliciesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "validateProjectInfraPolicies", Method: "POST", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies", @@ -215,7 +328,12 @@ func (a *Client) ValidateProjectInfraPolicies(params *ValidateProjectInfraPolici AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_infrastructure_policies/update_infra_policy_parameters.go b/client/client/organization_infrastructure_policies/update_infra_policy_parameters.go index e48eb1e8..e79d3275 100644 --- a/client/client/organization_infrastructure_policies/update_infra_policy_parameters.go +++ b/client/client/organization_infrastructure_policies/update_infra_policy_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateInfraPolicyParams creates a new UpdateInfraPolicyParams object -// with the default values initialized. +// NewUpdateInfraPolicyParams creates a new UpdateInfraPolicyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateInfraPolicyParams() *UpdateInfraPolicyParams { - var () return &UpdateInfraPolicyParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateInfraPolicyParamsWithTimeout creates a new UpdateInfraPolicyParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateInfraPolicyParamsWithTimeout(timeout time.Duration) *UpdateInfraPolicyParams { - var () return &UpdateInfraPolicyParams{ - timeout: timeout, } } // NewUpdateInfraPolicyParamsWithContext creates a new UpdateInfraPolicyParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateInfraPolicyParamsWithContext(ctx context.Context) *UpdateInfraPolicyParams { - var () return &UpdateInfraPolicyParams{ - Context: ctx, } } // NewUpdateInfraPolicyParamsWithHTTPClient creates a new UpdateInfraPolicyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateInfraPolicyParamsWithHTTPClient(client *http.Client) *UpdateInfraPolicyParams { - var () return &UpdateInfraPolicyParams{ HTTPClient: client, } } -/*UpdateInfraPolicyParams contains all the parameters to send to the API endpoint -for the update infra policy operation typically these are written to a http.Request +/* +UpdateInfraPolicyParams contains all the parameters to send to the API endpoint + + for the update infra policy operation. + + Typically these are written to a http.Request. */ type UpdateInfraPolicyParams struct { - /*Body - The information of the organization to update. + /* Body. + The information of the organization to update. */ Body *models.UpdateInfraPolicy - /*InfraPolicyCanonical - The canonical of an InfraPolicy. + /* InfraPolicyCanonical. + + The canonical of an InfraPolicy. */ InfraPolicyCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -84,6 +86,21 @@ type UpdateInfraPolicyParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update infra policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateInfraPolicyParams) WithDefaults() *UpdateInfraPolicyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update infra policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateInfraPolicyParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update infra policy params func (o *UpdateInfraPolicyParams) WithTimeout(timeout time.Duration) *UpdateInfraPolicyParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateInfraPolicyParams) WriteToRequest(r runtime.ClientRequest, reg st return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_infrastructure_policies/update_infra_policy_responses.go b/client/client/organization_infrastructure_policies/update_infra_policy_responses.go index f079b9c4..2d6ee74a 100644 --- a/client/client/organization_infrastructure_policies/update_infra_policy_responses.go +++ b/client/client/organization_infrastructure_policies/update_infra_policy_responses.go @@ -6,17 +6,18 @@ package organization_infrastructure_policies // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateInfraPolicyReader is a Reader for the UpdateInfraPolicy structure. @@ -68,7 +69,8 @@ func NewUpdateInfraPolicyOK() *UpdateInfraPolicyOK { return &UpdateInfraPolicyOK{} } -/*UpdateInfraPolicyOK handles this case with default header values. +/* +UpdateInfraPolicyOK describes a response with status code 200, with default header values. InfraPolicy updated. */ @@ -76,8 +78,44 @@ type UpdateInfraPolicyOK struct { Payload *UpdateInfraPolicyOKBody } +// IsSuccess returns true when this update infra policy o k response has a 2xx status code +func (o *UpdateInfraPolicyOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update infra policy o k response has a 3xx status code +func (o *UpdateInfraPolicyOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update infra policy o k response has a 4xx status code +func (o *UpdateInfraPolicyOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update infra policy o k response has a 5xx status code +func (o *UpdateInfraPolicyOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update infra policy o k response a status code equal to that given +func (o *UpdateInfraPolicyOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update infra policy o k response +func (o *UpdateInfraPolicyOK) Code() int { + return 200 +} + func (o *UpdateInfraPolicyOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyOK %s", 200, payload) +} + +func (o *UpdateInfraPolicyOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyOK %s", 200, payload) } func (o *UpdateInfraPolicyOK) GetPayload() *UpdateInfraPolicyOKBody { @@ -101,20 +139,60 @@ func NewUpdateInfraPolicyForbidden() *UpdateInfraPolicyForbidden { return &UpdateInfraPolicyForbidden{} } -/*UpdateInfraPolicyForbidden handles this case with default header values. +/* +UpdateInfraPolicyForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateInfraPolicyForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update infra policy forbidden response has a 2xx status code +func (o *UpdateInfraPolicyForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update infra policy forbidden response has a 3xx status code +func (o *UpdateInfraPolicyForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update infra policy forbidden response has a 4xx status code +func (o *UpdateInfraPolicyForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update infra policy forbidden response has a 5xx status code +func (o *UpdateInfraPolicyForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update infra policy forbidden response a status code equal to that given +func (o *UpdateInfraPolicyForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update infra policy forbidden response +func (o *UpdateInfraPolicyForbidden) Code() int { + return 403 +} + func (o *UpdateInfraPolicyForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyForbidden %s", 403, payload) +} + +func (o *UpdateInfraPolicyForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyForbidden %s", 403, payload) } func (o *UpdateInfraPolicyForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *UpdateInfraPolicyForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateInfraPolicyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewUpdateInfraPolicyNotFound() *UpdateInfraPolicyNotFound { return &UpdateInfraPolicyNotFound{} } -/*UpdateInfraPolicyNotFound handles this case with default header values. +/* +UpdateInfraPolicyNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateInfraPolicyNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update infra policy not found response has a 2xx status code +func (o *UpdateInfraPolicyNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update infra policy not found response has a 3xx status code +func (o *UpdateInfraPolicyNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update infra policy not found response has a 4xx status code +func (o *UpdateInfraPolicyNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update infra policy not found response has a 5xx status code +func (o *UpdateInfraPolicyNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update infra policy not found response a status code equal to that given +func (o *UpdateInfraPolicyNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update infra policy not found response +func (o *UpdateInfraPolicyNotFound) Code() int { + return 404 +} + func (o *UpdateInfraPolicyNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyNotFound %s", 404, payload) +} + +func (o *UpdateInfraPolicyNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyNotFound %s", 404, payload) } func (o *UpdateInfraPolicyNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *UpdateInfraPolicyNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateInfraPolicyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewUpdateInfraPolicyUnprocessableEntity() *UpdateInfraPolicyUnprocessableEn return &UpdateInfraPolicyUnprocessableEntity{} } -/*UpdateInfraPolicyUnprocessableEntity handles this case with default header values. +/* +UpdateInfraPolicyUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateInfraPolicyUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update infra policy unprocessable entity response has a 2xx status code +func (o *UpdateInfraPolicyUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update infra policy unprocessable entity response has a 3xx status code +func (o *UpdateInfraPolicyUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update infra policy unprocessable entity response has a 4xx status code +func (o *UpdateInfraPolicyUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update infra policy unprocessable entity response has a 5xx status code +func (o *UpdateInfraPolicyUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update infra policy unprocessable entity response a status code equal to that given +func (o *UpdateInfraPolicyUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update infra policy unprocessable entity response +func (o *UpdateInfraPolicyUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateInfraPolicyUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateInfraPolicyUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicyUnprocessableEntity %s", 422, payload) } func (o *UpdateInfraPolicyUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *UpdateInfraPolicyUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *UpdateInfraPolicyUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewUpdateInfraPolicyDefault(code int) *UpdateInfraPolicyDefault { } } -/*UpdateInfraPolicyDefault handles this case with default header values. +/* +UpdateInfraPolicyDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateInfraPolicyDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update infra policy default response has a 2xx status code +func (o *UpdateInfraPolicyDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update infra policy default response has a 3xx status code +func (o *UpdateInfraPolicyDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update infra policy default response has a 4xx status code +func (o *UpdateInfraPolicyDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update infra policy default response has a 5xx status code +func (o *UpdateInfraPolicyDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update infra policy default response a status code equal to that given +func (o *UpdateInfraPolicyDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update infra policy default response func (o *UpdateInfraPolicyDefault) Code() int { return o._statusCode } func (o *UpdateInfraPolicyDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicy default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicy default %s", o._statusCode, payload) +} + +func (o *UpdateInfraPolicyDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/infra_policies/{infra_policy_canonical}][%d] updateInfraPolicy default %s", o._statusCode, payload) } func (o *UpdateInfraPolicyDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *UpdateInfraPolicyDefault) GetPayload() *models.ErrorPayload { func (o *UpdateInfraPolicyDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *UpdateInfraPolicyDefault) readResponse(response runtime.ClientResponse, return nil } -/*UpdateInfraPolicyOKBody update infra policy o k body +/* +UpdateInfraPolicyOKBody update infra policy o k body swagger:model UpdateInfraPolicyOKBody */ type UpdateInfraPolicyOKBody struct { @@ -315,6 +524,39 @@ func (o *UpdateInfraPolicyOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateInfraPolicyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateInfraPolicyOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update infra policy o k body based on the context it is used +func (o *UpdateInfraPolicyOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateInfraPolicyOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateInfraPolicyOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateInfraPolicyOK" + "." + "data") } return err } diff --git a/client/client/organization_infrastructure_policies/validate_project_infra_policies_parameters.go b/client/client/organization_infrastructure_policies/validate_project_infra_policies_parameters.go index 352bb03b..e7d020e7 100644 --- a/client/client/organization_infrastructure_policies/validate_project_infra_policies_parameters.go +++ b/client/client/organization_infrastructure_policies/validate_project_infra_policies_parameters.go @@ -13,74 +13,77 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewValidateProjectInfraPoliciesParams creates a new ValidateProjectInfraPoliciesParams object -// with the default values initialized. +// NewValidateProjectInfraPoliciesParams creates a new ValidateProjectInfraPoliciesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewValidateProjectInfraPoliciesParams() *ValidateProjectInfraPoliciesParams { - var () return &ValidateProjectInfraPoliciesParams{ - timeout: cr.DefaultTimeout, } } // NewValidateProjectInfraPoliciesParamsWithTimeout creates a new ValidateProjectInfraPoliciesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewValidateProjectInfraPoliciesParamsWithTimeout(timeout time.Duration) *ValidateProjectInfraPoliciesParams { - var () return &ValidateProjectInfraPoliciesParams{ - timeout: timeout, } } // NewValidateProjectInfraPoliciesParamsWithContext creates a new ValidateProjectInfraPoliciesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewValidateProjectInfraPoliciesParamsWithContext(ctx context.Context) *ValidateProjectInfraPoliciesParams { - var () return &ValidateProjectInfraPoliciesParams{ - Context: ctx, } } // NewValidateProjectInfraPoliciesParamsWithHTTPClient creates a new ValidateProjectInfraPoliciesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewValidateProjectInfraPoliciesParamsWithHTTPClient(client *http.Client) *ValidateProjectInfraPoliciesParams { - var () return &ValidateProjectInfraPoliciesParams{ HTTPClient: client, } } -/*ValidateProjectInfraPoliciesParams contains all the parameters to send to the API endpoint -for the validate project infra policies operation typically these are written to a http.Request +/* +ValidateProjectInfraPoliciesParams contains all the parameters to send to the API endpoint + + for the validate project infra policies operation. + + Typically these are written to a http.Request. */ type ValidateProjectInfraPoliciesParams struct { - /*Body - The project's attributes to check before to apply an infrastructure change. + /* Body. + The project's attributes to check before to apply an infrastructure change. */ Body *models.TerraformPlanInput - /*EnvironmentCanonical - The environment canonical to use as part of a path + /* EnvironmentCanonical. + + The environment canonical to use as part of a path */ EnvironmentCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -89,6 +92,21 @@ type ValidateProjectInfraPoliciesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the validate project infra policies params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValidateProjectInfraPoliciesParams) WithDefaults() *ValidateProjectInfraPoliciesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the validate project infra policies params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValidateProjectInfraPoliciesParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the validate project infra policies params func (o *ValidateProjectInfraPoliciesParams) WithTimeout(timeout time.Duration) *ValidateProjectInfraPoliciesParams { o.SetTimeout(timeout) @@ -173,7 +191,6 @@ func (o *ValidateProjectInfraPoliciesParams) WriteToRequest(r runtime.ClientRequ return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_infrastructure_policies/validate_project_infra_policies_responses.go b/client/client/organization_infrastructure_policies/validate_project_infra_policies_responses.go index 79e389dd..9794dd9d 100644 --- a/client/client/organization_infrastructure_policies/validate_project_infra_policies_responses.go +++ b/client/client/organization_infrastructure_policies/validate_project_infra_policies_responses.go @@ -6,16 +6,17 @@ package organization_infrastructure_policies // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ValidateProjectInfraPoliciesReader is a Reader for the ValidateProjectInfraPolicies structure. @@ -67,7 +68,8 @@ func NewValidateProjectInfraPoliciesOK() *ValidateProjectInfraPoliciesOK { return &ValidateProjectInfraPoliciesOK{} } -/*ValidateProjectInfraPoliciesOK handles this case with default header values. +/* +ValidateProjectInfraPoliciesOK describes a response with status code 200, with default header values. The list of the policies not respected. */ @@ -75,8 +77,44 @@ type ValidateProjectInfraPoliciesOK struct { Payload *ValidateProjectInfraPoliciesOKBody } +// IsSuccess returns true when this validate project infra policies o k response has a 2xx status code +func (o *ValidateProjectInfraPoliciesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this validate project infra policies o k response has a 3xx status code +func (o *ValidateProjectInfraPoliciesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate project infra policies o k response has a 4xx status code +func (o *ValidateProjectInfraPoliciesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this validate project infra policies o k response has a 5xx status code +func (o *ValidateProjectInfraPoliciesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this validate project infra policies o k response a status code equal to that given +func (o *ValidateProjectInfraPoliciesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the validate project infra policies o k response +func (o *ValidateProjectInfraPoliciesOK) Code() int { + return 200 +} + func (o *ValidateProjectInfraPoliciesOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesOK %s", 200, payload) +} + +func (o *ValidateProjectInfraPoliciesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesOK %s", 200, payload) } func (o *ValidateProjectInfraPoliciesOK) GetPayload() *ValidateProjectInfraPoliciesOKBody { @@ -100,20 +138,60 @@ func NewValidateProjectInfraPoliciesForbidden() *ValidateProjectInfraPoliciesFor return &ValidateProjectInfraPoliciesForbidden{} } -/*ValidateProjectInfraPoliciesForbidden handles this case with default header values. +/* +ValidateProjectInfraPoliciesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ValidateProjectInfraPoliciesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate project infra policies forbidden response has a 2xx status code +func (o *ValidateProjectInfraPoliciesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate project infra policies forbidden response has a 3xx status code +func (o *ValidateProjectInfraPoliciesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate project infra policies forbidden response has a 4xx status code +func (o *ValidateProjectInfraPoliciesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate project infra policies forbidden response has a 5xx status code +func (o *ValidateProjectInfraPoliciesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this validate project infra policies forbidden response a status code equal to that given +func (o *ValidateProjectInfraPoliciesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the validate project infra policies forbidden response +func (o *ValidateProjectInfraPoliciesForbidden) Code() int { + return 403 +} + func (o *ValidateProjectInfraPoliciesForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesForbidden %s", 403, payload) +} + +func (o *ValidateProjectInfraPoliciesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesForbidden %s", 403, payload) } func (o *ValidateProjectInfraPoliciesForbidden) GetPayload() *models.ErrorPayload { @@ -122,12 +200,16 @@ func (o *ValidateProjectInfraPoliciesForbidden) GetPayload() *models.ErrorPayloa func (o *ValidateProjectInfraPoliciesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -144,20 +226,60 @@ func NewValidateProjectInfraPoliciesNotFound() *ValidateProjectInfraPoliciesNotF return &ValidateProjectInfraPoliciesNotFound{} } -/*ValidateProjectInfraPoliciesNotFound handles this case with default header values. +/* +ValidateProjectInfraPoliciesNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type ValidateProjectInfraPoliciesNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate project infra policies not found response has a 2xx status code +func (o *ValidateProjectInfraPoliciesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate project infra policies not found response has a 3xx status code +func (o *ValidateProjectInfraPoliciesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate project infra policies not found response has a 4xx status code +func (o *ValidateProjectInfraPoliciesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate project infra policies not found response has a 5xx status code +func (o *ValidateProjectInfraPoliciesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this validate project infra policies not found response a status code equal to that given +func (o *ValidateProjectInfraPoliciesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the validate project infra policies not found response +func (o *ValidateProjectInfraPoliciesNotFound) Code() int { + return 404 +} + func (o *ValidateProjectInfraPoliciesNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesNotFound %s", 404, payload) +} + +func (o *ValidateProjectInfraPoliciesNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesNotFound %s", 404, payload) } func (o *ValidateProjectInfraPoliciesNotFound) GetPayload() *models.ErrorPayload { @@ -166,12 +288,16 @@ func (o *ValidateProjectInfraPoliciesNotFound) GetPayload() *models.ErrorPayload func (o *ValidateProjectInfraPoliciesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -188,20 +314,60 @@ func NewValidateProjectInfraPoliciesUnprocessableEntity() *ValidateProjectInfraP return &ValidateProjectInfraPoliciesUnprocessableEntity{} } -/*ValidateProjectInfraPoliciesUnprocessableEntity handles this case with default header values. +/* +ValidateProjectInfraPoliciesUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type ValidateProjectInfraPoliciesUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate project infra policies unprocessable entity response has a 2xx status code +func (o *ValidateProjectInfraPoliciesUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate project infra policies unprocessable entity response has a 3xx status code +func (o *ValidateProjectInfraPoliciesUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate project infra policies unprocessable entity response has a 4xx status code +func (o *ValidateProjectInfraPoliciesUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate project infra policies unprocessable entity response has a 5xx status code +func (o *ValidateProjectInfraPoliciesUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this validate project infra policies unprocessable entity response a status code equal to that given +func (o *ValidateProjectInfraPoliciesUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the validate project infra policies unprocessable entity response +func (o *ValidateProjectInfraPoliciesUnprocessableEntity) Code() int { + return 422 +} + func (o *ValidateProjectInfraPoliciesUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesUnprocessableEntity %s", 422, payload) +} + +func (o *ValidateProjectInfraPoliciesUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPoliciesUnprocessableEntity %s", 422, payload) } func (o *ValidateProjectInfraPoliciesUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -210,12 +376,16 @@ func (o *ValidateProjectInfraPoliciesUnprocessableEntity) GetPayload() *models.E func (o *ValidateProjectInfraPoliciesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -234,27 +404,61 @@ func NewValidateProjectInfraPoliciesDefault(code int) *ValidateProjectInfraPolic } } -/*ValidateProjectInfraPoliciesDefault handles this case with default header values. +/* +ValidateProjectInfraPoliciesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ValidateProjectInfraPoliciesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate project infra policies default response has a 2xx status code +func (o *ValidateProjectInfraPoliciesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this validate project infra policies default response has a 3xx status code +func (o *ValidateProjectInfraPoliciesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this validate project infra policies default response has a 4xx status code +func (o *ValidateProjectInfraPoliciesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this validate project infra policies default response has a 5xx status code +func (o *ValidateProjectInfraPoliciesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this validate project infra policies default response a status code equal to that given +func (o *ValidateProjectInfraPoliciesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the validate project infra policies default response func (o *ValidateProjectInfraPoliciesDefault) Code() int { return o._statusCode } func (o *ValidateProjectInfraPoliciesDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPolicies default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPolicies default %s", o._statusCode, payload) +} + +func (o *ValidateProjectInfraPoliciesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}/validate_infra_policies][%d] validateProjectInfraPolicies default %s", o._statusCode, payload) } func (o *ValidateProjectInfraPoliciesDefault) GetPayload() *models.ErrorPayload { @@ -263,12 +467,16 @@ func (o *ValidateProjectInfraPoliciesDefault) GetPayload() *models.ErrorPayload func (o *ValidateProjectInfraPoliciesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -280,7 +488,8 @@ func (o *ValidateProjectInfraPoliciesDefault) readResponse(response runtime.Clie return nil } -/*ValidateProjectInfraPoliciesOKBody validate project infra policies o k body +/* +ValidateProjectInfraPoliciesOKBody validate project infra policies o k body swagger:model ValidateProjectInfraPoliciesOKBody */ type ValidateProjectInfraPoliciesOKBody struct { @@ -304,7 +513,6 @@ func (o *ValidateProjectInfraPoliciesOKBody) Validate(formats strfmt.Registry) e } func (o *ValidateProjectInfraPoliciesOKBody) validateData(formats strfmt.Registry) error { - if swag.IsZero(o.Data) { // not required return nil } @@ -313,6 +521,43 @@ func (o *ValidateProjectInfraPoliciesOKBody) validateData(formats strfmt.Registr if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("validateProjectInfraPoliciesOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("validateProjectInfraPoliciesOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this validate project infra policies o k body based on the context it is used +func (o *ValidateProjectInfraPoliciesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ValidateProjectInfraPoliciesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if swag.IsZero(o.Data) { // not required + return nil + } + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("validateProjectInfraPoliciesOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("validateProjectInfraPoliciesOK" + "." + "data") } return err } diff --git a/client/client/organization_invitations/delete_invitation_parameters.go b/client/client/organization_invitations/delete_invitation_parameters.go index 7303d4d4..a22f850d 100644 --- a/client/client/organization_invitations/delete_invitation_parameters.go +++ b/client/client/organization_invitations/delete_invitation_parameters.go @@ -13,63 +13,66 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewDeleteInvitationParams creates a new DeleteInvitationParams object -// with the default values initialized. +// NewDeleteInvitationParams creates a new DeleteInvitationParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteInvitationParams() *DeleteInvitationParams { - var () return &DeleteInvitationParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteInvitationParamsWithTimeout creates a new DeleteInvitationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteInvitationParamsWithTimeout(timeout time.Duration) *DeleteInvitationParams { - var () return &DeleteInvitationParams{ - timeout: timeout, } } // NewDeleteInvitationParamsWithContext creates a new DeleteInvitationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteInvitationParamsWithContext(ctx context.Context) *DeleteInvitationParams { - var () return &DeleteInvitationParams{ - Context: ctx, } } // NewDeleteInvitationParamsWithHTTPClient creates a new DeleteInvitationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteInvitationParamsWithHTTPClient(client *http.Client) *DeleteInvitationParams { - var () return &DeleteInvitationParams{ HTTPClient: client, } } -/*DeleteInvitationParams contains all the parameters to send to the API endpoint -for the delete invitation operation typically these are written to a http.Request +/* +DeleteInvitationParams contains all the parameters to send to the API endpoint + + for the delete invitation operation. + + Typically these are written to a http.Request. */ type DeleteInvitationParams struct { - /*InvitationID - Organization Invitation id. + /* InvitationID. + + Organization Invitation id. + Format: uint32 */ InvitationID uint32 - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -78,6 +81,21 @@ type DeleteInvitationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete invitation params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteInvitationParams) WithDefaults() *DeleteInvitationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete invitation params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteInvitationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete invitation params func (o *DeleteInvitationParams) WithTimeout(timeout time.Duration) *DeleteInvitationParams { o.SetTimeout(timeout) diff --git a/client/client/organization_invitations/delete_invitation_responses.go b/client/client/organization_invitations/delete_invitation_responses.go index 9783f504..945d0576 100644 --- a/client/client/organization_invitations/delete_invitation_responses.go +++ b/client/client/organization_invitations/delete_invitation_responses.go @@ -6,16 +6,16 @@ package organization_invitations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteInvitationReader is a Reader for the DeleteInvitation structure. @@ -61,15 +61,50 @@ func NewDeleteInvitationNoContent() *DeleteInvitationNoContent { return &DeleteInvitationNoContent{} } -/*DeleteInvitationNoContent handles this case with default header values. +/* +DeleteInvitationNoContent describes a response with status code 204, with default header values. Invitation has been deleted. */ type DeleteInvitationNoContent struct { } +// IsSuccess returns true when this delete invitation no content response has a 2xx status code +func (o *DeleteInvitationNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete invitation no content response has a 3xx status code +func (o *DeleteInvitationNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete invitation no content response has a 4xx status code +func (o *DeleteInvitationNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete invitation no content response has a 5xx status code +func (o *DeleteInvitationNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete invitation no content response a status code equal to that given +func (o *DeleteInvitationNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete invitation no content response +func (o *DeleteInvitationNoContent) Code() int { + return 204 +} + func (o *DeleteInvitationNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationNoContent", 204) +} + +func (o *DeleteInvitationNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationNoContent", 204) } func (o *DeleteInvitationNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteInvitationForbidden() *DeleteInvitationForbidden { return &DeleteInvitationForbidden{} } -/*DeleteInvitationForbidden handles this case with default header values. +/* +DeleteInvitationForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteInvitationForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete invitation forbidden response has a 2xx status code +func (o *DeleteInvitationForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete invitation forbidden response has a 3xx status code +func (o *DeleteInvitationForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete invitation forbidden response has a 4xx status code +func (o *DeleteInvitationForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete invitation forbidden response has a 5xx status code +func (o *DeleteInvitationForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete invitation forbidden response a status code equal to that given +func (o *DeleteInvitationForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete invitation forbidden response +func (o *DeleteInvitationForbidden) Code() int { + return 403 +} + func (o *DeleteInvitationForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationForbidden %s", 403, payload) +} + +func (o *DeleteInvitationForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationForbidden %s", 403, payload) } func (o *DeleteInvitationForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteInvitationForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteInvitationForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteInvitationNotFound() *DeleteInvitationNotFound { return &DeleteInvitationNotFound{} } -/*DeleteInvitationNotFound handles this case with default header values. +/* +DeleteInvitationNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteInvitationNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete invitation not found response has a 2xx status code +func (o *DeleteInvitationNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete invitation not found response has a 3xx status code +func (o *DeleteInvitationNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete invitation not found response has a 4xx status code +func (o *DeleteInvitationNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete invitation not found response has a 5xx status code +func (o *DeleteInvitationNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete invitation not found response a status code equal to that given +func (o *DeleteInvitationNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete invitation not found response +func (o *DeleteInvitationNotFound) Code() int { + return 404 +} + func (o *DeleteInvitationNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationNotFound %s", 404, payload) +} + +func (o *DeleteInvitationNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitationNotFound %s", 404, payload) } func (o *DeleteInvitationNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteInvitationNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteInvitationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteInvitationDefault(code int) *DeleteInvitationDefault { } } -/*DeleteInvitationDefault handles this case with default header values. +/* +DeleteInvitationDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteInvitationDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete invitation default response has a 2xx status code +func (o *DeleteInvitationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete invitation default response has a 3xx status code +func (o *DeleteInvitationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete invitation default response has a 4xx status code +func (o *DeleteInvitationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete invitation default response has a 5xx status code +func (o *DeleteInvitationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete invitation default response a status code equal to that given +func (o *DeleteInvitationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete invitation default response func (o *DeleteInvitationDefault) Code() int { return o._statusCode } func (o *DeleteInvitationDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitation default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitation default %s", o._statusCode, payload) +} + +func (o *DeleteInvitationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/invitations/{invitation_id}][%d] deleteInvitation default %s", o._statusCode, payload) } func (o *DeleteInvitationDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteInvitationDefault) GetPayload() *models.ErrorPayload { func (o *DeleteInvitationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_invitations/get_invitations_parameters.go b/client/client/organization_invitations/get_invitations_parameters.go index 2a057297..e2098e33 100644 --- a/client/client/organization_invitations/get_invitations_parameters.go +++ b/client/client/organization_invitations/get_invitations_parameters.go @@ -13,104 +13,97 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetInvitationsParams creates a new GetInvitationsParams object -// with the default values initialized. +// NewGetInvitationsParams creates a new GetInvitationsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetInvitationsParams() *GetInvitationsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetInvitationsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetInvitationsParamsWithTimeout creates a new GetInvitationsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetInvitationsParamsWithTimeout(timeout time.Duration) *GetInvitationsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetInvitationsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetInvitationsParamsWithContext creates a new GetInvitationsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetInvitationsParamsWithContext(ctx context.Context) *GetInvitationsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetInvitationsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetInvitationsParamsWithHTTPClient creates a new GetInvitationsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetInvitationsParamsWithHTTPClient(client *http.Client) *GetInvitationsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetInvitationsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetInvitationsParams contains all the parameters to send to the API endpoint -for the get invitations operation typically these are written to a http.Request +/* +GetInvitationsParams contains all the parameters to send to the API endpoint + + for the get invitations operation. + + Typically these are written to a http.Request. */ type GetInvitationsParams struct { - /*InvitationCreatedAt - Search by Invitation's creation date + /* InvitationCreatedAt. + Search by Invitation's creation date + + Format: uint64 */ InvitationCreatedAt *uint64 - /*InvitationState - Search by Invitation's state + /* InvitationState. + + Search by Invitation's state */ InvitationState *string - /*OrderBy - Allows to order the list of items. Example usage: field_name:asc + /* OrderBy. + + Allows to order the list of items. Example usage: field_name:asc */ OrderBy *string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -119,6 +112,35 @@ type GetInvitationsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get invitations params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetInvitationsParams) WithDefaults() *GetInvitationsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get invitations params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetInvitationsParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetInvitationsParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get invitations params func (o *GetInvitationsParams) WithTimeout(timeout time.Duration) *GetInvitationsParams { o.SetTimeout(timeout) @@ -230,48 +252,51 @@ func (o *GetInvitationsParams) WriteToRequest(r runtime.ClientRequest, reg strfm // query param invitation_created_at var qrInvitationCreatedAt uint64 + if o.InvitationCreatedAt != nil { qrInvitationCreatedAt = *o.InvitationCreatedAt } qInvitationCreatedAt := swag.FormatUint64(qrInvitationCreatedAt) if qInvitationCreatedAt != "" { + if err := r.SetQueryParam("invitation_created_at", qInvitationCreatedAt); err != nil { return err } } - } if o.InvitationState != nil { // query param invitation_state var qrInvitationState string + if o.InvitationState != nil { qrInvitationState = *o.InvitationState } qInvitationState := qrInvitationState if qInvitationState != "" { + if err := r.SetQueryParam("invitation_state", qInvitationState); err != nil { return err } } - } if o.OrderBy != nil { // query param order_by var qrOrderBy string + if o.OrderBy != nil { qrOrderBy = *o.OrderBy } qOrderBy := qrOrderBy if qOrderBy != "" { + if err := r.SetQueryParam("order_by", qOrderBy); err != nil { return err } } - } // path param organization_canonical @@ -283,32 +308,34 @@ func (o *GetInvitationsParams) WriteToRequest(r runtime.ClientRequest, reg strfm // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_invitations/get_invitations_responses.go b/client/client/organization_invitations/get_invitations_responses.go index 7792fa57..120a863b 100644 --- a/client/client/organization_invitations/get_invitations_responses.go +++ b/client/client/organization_invitations/get_invitations_responses.go @@ -6,18 +6,19 @@ package organization_invitations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetInvitationsReader is a Reader for the GetInvitations structure. @@ -69,7 +70,8 @@ func NewGetInvitationsOK() *GetInvitationsOK { return &GetInvitationsOK{} } -/*GetInvitationsOK handles this case with default header values. +/* +GetInvitationsOK describes a response with status code 200, with default header values. List of the Organization's Invitations. */ @@ -77,8 +79,44 @@ type GetInvitationsOK struct { Payload *GetInvitationsOKBody } +// IsSuccess returns true when this get invitations o k response has a 2xx status code +func (o *GetInvitationsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get invitations o k response has a 3xx status code +func (o *GetInvitationsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get invitations o k response has a 4xx status code +func (o *GetInvitationsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get invitations o k response has a 5xx status code +func (o *GetInvitationsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get invitations o k response a status code equal to that given +func (o *GetInvitationsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get invitations o k response +func (o *GetInvitationsOK) Code() int { + return 200 +} + func (o *GetInvitationsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsOK %s", 200, payload) +} + +func (o *GetInvitationsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsOK %s", 200, payload) } func (o *GetInvitationsOK) GetPayload() *GetInvitationsOKBody { @@ -102,20 +140,60 @@ func NewGetInvitationsForbidden() *GetInvitationsForbidden { return &GetInvitationsForbidden{} } -/*GetInvitationsForbidden handles this case with default header values. +/* +GetInvitationsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetInvitationsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get invitations forbidden response has a 2xx status code +func (o *GetInvitationsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get invitations forbidden response has a 3xx status code +func (o *GetInvitationsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get invitations forbidden response has a 4xx status code +func (o *GetInvitationsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get invitations forbidden response has a 5xx status code +func (o *GetInvitationsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get invitations forbidden response a status code equal to that given +func (o *GetInvitationsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get invitations forbidden response +func (o *GetInvitationsForbidden) Code() int { + return 403 +} + func (o *GetInvitationsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsForbidden %s", 403, payload) +} + +func (o *GetInvitationsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsForbidden %s", 403, payload) } func (o *GetInvitationsForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetInvitationsForbidden) GetPayload() *models.ErrorPayload { func (o *GetInvitationsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetInvitationsNotFound() *GetInvitationsNotFound { return &GetInvitationsNotFound{} } -/*GetInvitationsNotFound handles this case with default header values. +/* +GetInvitationsNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetInvitationsNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get invitations not found response has a 2xx status code +func (o *GetInvitationsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get invitations not found response has a 3xx status code +func (o *GetInvitationsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get invitations not found response has a 4xx status code +func (o *GetInvitationsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get invitations not found response has a 5xx status code +func (o *GetInvitationsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get invitations not found response a status code equal to that given +func (o *GetInvitationsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get invitations not found response +func (o *GetInvitationsNotFound) Code() int { + return 404 +} + func (o *GetInvitationsNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsNotFound %s", 404, payload) +} + +func (o *GetInvitationsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsNotFound %s", 404, payload) } func (o *GetInvitationsNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetInvitationsNotFound) GetPayload() *models.ErrorPayload { func (o *GetInvitationsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetInvitationsUnprocessableEntity() *GetInvitationsUnprocessableEntity { return &GetInvitationsUnprocessableEntity{} } -/*GetInvitationsUnprocessableEntity handles this case with default header values. +/* +GetInvitationsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetInvitationsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get invitations unprocessable entity response has a 2xx status code +func (o *GetInvitationsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get invitations unprocessable entity response has a 3xx status code +func (o *GetInvitationsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get invitations unprocessable entity response has a 4xx status code +func (o *GetInvitationsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get invitations unprocessable entity response has a 5xx status code +func (o *GetInvitationsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get invitations unprocessable entity response a status code equal to that given +func (o *GetInvitationsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get invitations unprocessable entity response +func (o *GetInvitationsUnprocessableEntity) Code() int { + return 422 +} + func (o *GetInvitationsUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsUnprocessableEntity %s", 422, payload) +} + +func (o *GetInvitationsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitationsUnprocessableEntity %s", 422, payload) } func (o *GetInvitationsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetInvitationsUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetInvitationsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetInvitationsDefault(code int) *GetInvitationsDefault { } } -/*GetInvitationsDefault handles this case with default header values. +/* +GetInvitationsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetInvitationsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get invitations default response has a 2xx status code +func (o *GetInvitationsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get invitations default response has a 3xx status code +func (o *GetInvitationsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get invitations default response has a 4xx status code +func (o *GetInvitationsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get invitations default response has a 5xx status code +func (o *GetInvitationsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get invitations default response a status code equal to that given +func (o *GetInvitationsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get invitations default response func (o *GetInvitationsDefault) Code() int { return o._statusCode } func (o *GetInvitationsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitations default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitations default %s", o._statusCode, payload) +} + +func (o *GetInvitationsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/invitations][%d] getInvitations default %s", o._statusCode, payload) } func (o *GetInvitationsDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetInvitationsDefault) GetPayload() *models.ErrorPayload { func (o *GetInvitationsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetInvitationsDefault) readResponse(response runtime.ClientResponse, co return nil } -/*GetInvitationsOKBody get invitations o k body +/* +GetInvitationsOKBody get invitations o k body swagger:model GetInvitationsOKBody */ type GetInvitationsOKBody struct { @@ -329,6 +538,8 @@ func (o *GetInvitationsOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getInvitationsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInvitationsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -349,6 +560,68 @@ func (o *GetInvitationsOKBody) validatePagination(formats strfmt.Registry) error if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getInvitationsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInvitationsOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get invitations o k body based on the context it is used +func (o *GetInvitationsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetInvitationsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getInvitationsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInvitationsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetInvitationsOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getInvitationsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getInvitationsOK" + "." + "pagination") } return err } diff --git a/client/client/organization_invitations/get_pending_invitation_parameters.go b/client/client/organization_invitations/get_pending_invitation_parameters.go index 2845bab7..ee6373cd 100644 --- a/client/client/organization_invitations/get_pending_invitation_parameters.go +++ b/client/client/organization_invitations/get_pending_invitation_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetPendingInvitationParams creates a new GetPendingInvitationParams object -// with the default values initialized. +// NewGetPendingInvitationParams creates a new GetPendingInvitationParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetPendingInvitationParams() *GetPendingInvitationParams { - var () return &GetPendingInvitationParams{ - timeout: cr.DefaultTimeout, } } // NewGetPendingInvitationParamsWithTimeout creates a new GetPendingInvitationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetPendingInvitationParamsWithTimeout(timeout time.Duration) *GetPendingInvitationParams { - var () return &GetPendingInvitationParams{ - timeout: timeout, } } // NewGetPendingInvitationParamsWithContext creates a new GetPendingInvitationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetPendingInvitationParamsWithContext(ctx context.Context) *GetPendingInvitationParams { - var () return &GetPendingInvitationParams{ - Context: ctx, } } // NewGetPendingInvitationParamsWithHTTPClient creates a new GetPendingInvitationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetPendingInvitationParamsWithHTTPClient(client *http.Client) *GetPendingInvitationParams { - var () return &GetPendingInvitationParams{ HTTPClient: client, } } -/*GetPendingInvitationParams contains all the parameters to send to the API endpoint -for the get pending invitation operation typically these are written to a http.Request +/* +GetPendingInvitationParams contains all the parameters to send to the API endpoint + + for the get pending invitation operation. + + Typically these are written to a http.Request. */ type GetPendingInvitationParams struct { - /*VerificationToken - A token for verifying emails, invitations, etc. + /* VerificationToken. + A token for verifying emails, invitations, etc. */ VerificationToken string @@ -72,6 +72,21 @@ type GetPendingInvitationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get pending invitation params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPendingInvitationParams) WithDefaults() *GetPendingInvitationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get pending invitation params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPendingInvitationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get pending invitation params func (o *GetPendingInvitationParams) WithTimeout(timeout time.Duration) *GetPendingInvitationParams { o.SetTimeout(timeout) diff --git a/client/client/organization_invitations/get_pending_invitation_responses.go b/client/client/organization_invitations/get_pending_invitation_responses.go index eabd7468..ee0c959c 100644 --- a/client/client/organization_invitations/get_pending_invitation_responses.go +++ b/client/client/organization_invitations/get_pending_invitation_responses.go @@ -6,17 +6,18 @@ package organization_invitations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetPendingInvitationReader is a Reader for the GetPendingInvitation structure. @@ -56,7 +57,8 @@ func NewGetPendingInvitationOK() *GetPendingInvitationOK { return &GetPendingInvitationOK{} } -/*GetPendingInvitationOK handles this case with default header values. +/* +GetPendingInvitationOK describes a response with status code 200, with default header values. The email address used for the pending invitation */ @@ -64,8 +66,44 @@ type GetPendingInvitationOK struct { Payload *GetPendingInvitationOKBody } +// IsSuccess returns true when this get pending invitation o k response has a 2xx status code +func (o *GetPendingInvitationOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get pending invitation o k response has a 3xx status code +func (o *GetPendingInvitationOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pending invitation o k response has a 4xx status code +func (o *GetPendingInvitationOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get pending invitation o k response has a 5xx status code +func (o *GetPendingInvitationOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get pending invitation o k response a status code equal to that given +func (o *GetPendingInvitationOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get pending invitation o k response +func (o *GetPendingInvitationOK) Code() int { + return 200 +} + func (o *GetPendingInvitationOK) Error() string { - return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitationOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitationOK %s", 200, payload) +} + +func (o *GetPendingInvitationOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitationOK %s", 200, payload) } func (o *GetPendingInvitationOK) GetPayload() *GetPendingInvitationOKBody { @@ -89,20 +127,60 @@ func NewGetPendingInvitationNotFound() *GetPendingInvitationNotFound { return &GetPendingInvitationNotFound{} } -/*GetPendingInvitationNotFound handles this case with default header values. +/* +GetPendingInvitationNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetPendingInvitationNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pending invitation not found response has a 2xx status code +func (o *GetPendingInvitationNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pending invitation not found response has a 3xx status code +func (o *GetPendingInvitationNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pending invitation not found response has a 4xx status code +func (o *GetPendingInvitationNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pending invitation not found response has a 5xx status code +func (o *GetPendingInvitationNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get pending invitation not found response a status code equal to that given +func (o *GetPendingInvitationNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get pending invitation not found response +func (o *GetPendingInvitationNotFound) Code() int { + return 404 +} + func (o *GetPendingInvitationNotFound) Error() string { - return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitationNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitationNotFound %s", 404, payload) +} + +func (o *GetPendingInvitationNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitationNotFound %s", 404, payload) } func (o *GetPendingInvitationNotFound) GetPayload() *models.ErrorPayload { @@ -111,12 +189,16 @@ func (o *GetPendingInvitationNotFound) GetPayload() *models.ErrorPayload { func (o *GetPendingInvitationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -135,27 +217,61 @@ func NewGetPendingInvitationDefault(code int) *GetPendingInvitationDefault { } } -/*GetPendingInvitationDefault handles this case with default header values. +/* +GetPendingInvitationDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetPendingInvitationDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pending invitation default response has a 2xx status code +func (o *GetPendingInvitationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get pending invitation default response has a 3xx status code +func (o *GetPendingInvitationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get pending invitation default response has a 4xx status code +func (o *GetPendingInvitationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get pending invitation default response has a 5xx status code +func (o *GetPendingInvitationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get pending invitation default response a status code equal to that given +func (o *GetPendingInvitationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get pending invitation default response func (o *GetPendingInvitationDefault) Code() int { return o._statusCode } func (o *GetPendingInvitationDefault) Error() string { - return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitation default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitation default %s", o._statusCode, payload) +} + +func (o *GetPendingInvitationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /invitations/{verification_token}][%d] getPendingInvitation default %s", o._statusCode, payload) } func (o *GetPendingInvitationDefault) GetPayload() *models.ErrorPayload { @@ -164,12 +280,16 @@ func (o *GetPendingInvitationDefault) GetPayload() *models.ErrorPayload { func (o *GetPendingInvitationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -181,7 +301,8 @@ func (o *GetPendingInvitationDefault) readResponse(response runtime.ClientRespon return nil } -/*GetPendingInvitationOKBody get pending invitation o k body +/* +GetPendingInvitationOKBody get pending invitation o k body swagger:model GetPendingInvitationOKBody */ type GetPendingInvitationOKBody struct { @@ -215,6 +336,39 @@ func (o *GetPendingInvitationOKBody) validateData(formats strfmt.Registry) error if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getPendingInvitationOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPendingInvitationOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get pending invitation o k body based on the context it is used +func (o *GetPendingInvitationOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetPendingInvitationOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getPendingInvitationOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPendingInvitationOK" + "." + "data") } return err } diff --git a/client/client/organization_invitations/organization_invitations_client.go b/client/client/organization_invitations/organization_invitations_client.go index 293d708a..fe2e2f94 100644 --- a/client/client/organization_invitations/organization_invitations_client.go +++ b/client/client/organization_invitations/organization_invitations_client.go @@ -7,15 +7,40 @@ package organization_invitations import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization invitations API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization invitations API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization invitations API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization invitations API */ @@ -24,16 +49,80 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + DeleteInvitation(params *DeleteInvitationParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteInvitationNoContent, error) + + GetInvitations(params *GetInvitationsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInvitationsOK, error) + + GetPendingInvitation(params *GetPendingInvitationParams, opts ...ClientOption) (*GetPendingInvitationOK, error) + + ResendInvitation(params *ResendInvitationParams, opts ...ClientOption) (*ResendInvitationNoContent, error) + + SetTransport(transport runtime.ClientTransport) +} + /* DeleteInvitation Delete an Organization's Invitation. */ -func (a *Client) DeleteInvitation(params *DeleteInvitationParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteInvitationNoContent, error) { +func (a *Client) DeleteInvitation(params *DeleteInvitationParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteInvitationNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteInvitationParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteInvitation", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/invitations/{invitation_id}", @@ -45,7 +134,12 @@ func (a *Client) DeleteInvitation(params *DeleteInvitationParams, authInfo runti AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +155,12 @@ func (a *Client) DeleteInvitation(params *DeleteInvitationParams, authInfo runti /* GetInvitations Get list of the Organization's Invitations. */ -func (a *Client) GetInvitations(params *GetInvitationsParams, authInfo runtime.ClientAuthInfoWriter) (*GetInvitationsOK, error) { +func (a *Client) GetInvitations(params *GetInvitationsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInvitationsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetInvitationsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getInvitations", Method: "GET", PathPattern: "/organizations/{organization_canonical}/invitations", @@ -79,7 +172,12 @@ func (a *Client) GetInvitations(params *GetInvitationsParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +193,12 @@ func (a *Client) GetInvitations(params *GetInvitationsParams, authInfo runtime.C /* GetPendingInvitation Get the email address used for the pending invitation */ -func (a *Client) GetPendingInvitation(params *GetPendingInvitationParams) (*GetPendingInvitationOK, error) { +func (a *Client) GetPendingInvitation(params *GetPendingInvitationParams, opts ...ClientOption) (*GetPendingInvitationOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetPendingInvitationParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getPendingInvitation", Method: "GET", PathPattern: "/invitations/{verification_token}", @@ -112,7 +209,12 @@ func (a *Client) GetPendingInvitation(params *GetPendingInvitationParams) (*GetP Reader: &GetPendingInvitationReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -128,13 +230,12 @@ func (a *Client) GetPendingInvitation(params *GetPendingInvitationParams) (*GetP /* ResendInvitation Resend the email containing the verification token to accept the Invitation. */ -func (a *Client) ResendInvitation(params *ResendInvitationParams) (*ResendInvitationNoContent, error) { +func (a *Client) ResendInvitation(params *ResendInvitationParams, opts ...ClientOption) (*ResendInvitationNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewResendInvitationParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "resendInvitation", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/invitations/{invitation_id}/resend", @@ -145,7 +246,12 @@ func (a *Client) ResendInvitation(params *ResendInvitationParams) (*ResendInvita Reader: &ResendInvitationReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_invitations/resend_invitation_parameters.go b/client/client/organization_invitations/resend_invitation_parameters.go index 6b9b5875..5424049b 100644 --- a/client/client/organization_invitations/resend_invitation_parameters.go +++ b/client/client/organization_invitations/resend_invitation_parameters.go @@ -13,63 +13,66 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewResendInvitationParams creates a new ResendInvitationParams object -// with the default values initialized. +// NewResendInvitationParams creates a new ResendInvitationParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewResendInvitationParams() *ResendInvitationParams { - var () return &ResendInvitationParams{ - timeout: cr.DefaultTimeout, } } // NewResendInvitationParamsWithTimeout creates a new ResendInvitationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewResendInvitationParamsWithTimeout(timeout time.Duration) *ResendInvitationParams { - var () return &ResendInvitationParams{ - timeout: timeout, } } // NewResendInvitationParamsWithContext creates a new ResendInvitationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewResendInvitationParamsWithContext(ctx context.Context) *ResendInvitationParams { - var () return &ResendInvitationParams{ - Context: ctx, } } // NewResendInvitationParamsWithHTTPClient creates a new ResendInvitationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewResendInvitationParamsWithHTTPClient(client *http.Client) *ResendInvitationParams { - var () return &ResendInvitationParams{ HTTPClient: client, } } -/*ResendInvitationParams contains all the parameters to send to the API endpoint -for the resend invitation operation typically these are written to a http.Request +/* +ResendInvitationParams contains all the parameters to send to the API endpoint + + for the resend invitation operation. + + Typically these are written to a http.Request. */ type ResendInvitationParams struct { - /*InvitationID - Organization Invitation id. + /* InvitationID. + + Organization Invitation id. + Format: uint32 */ InvitationID uint32 - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -78,6 +81,21 @@ type ResendInvitationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the resend invitation params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ResendInvitationParams) WithDefaults() *ResendInvitationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the resend invitation params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ResendInvitationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the resend invitation params func (o *ResendInvitationParams) WithTimeout(timeout time.Duration) *ResendInvitationParams { o.SetTimeout(timeout) diff --git a/client/client/organization_invitations/resend_invitation_responses.go b/client/client/organization_invitations/resend_invitation_responses.go index a890c0a6..8fa0a3de 100644 --- a/client/client/organization_invitations/resend_invitation_responses.go +++ b/client/client/organization_invitations/resend_invitation_responses.go @@ -6,16 +6,16 @@ package organization_invitations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ResendInvitationReader is a Reader for the ResendInvitation structure. @@ -61,15 +61,50 @@ func NewResendInvitationNoContent() *ResendInvitationNoContent { return &ResendInvitationNoContent{} } -/*ResendInvitationNoContent handles this case with default header values. +/* +ResendInvitationNoContent describes a response with status code 204, with default header values. The Invitation has been resent. */ type ResendInvitationNoContent struct { } +// IsSuccess returns true when this resend invitation no content response has a 2xx status code +func (o *ResendInvitationNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this resend invitation no content response has a 3xx status code +func (o *ResendInvitationNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this resend invitation no content response has a 4xx status code +func (o *ResendInvitationNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this resend invitation no content response has a 5xx status code +func (o *ResendInvitationNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this resend invitation no content response a status code equal to that given +func (o *ResendInvitationNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the resend invitation no content response +func (o *ResendInvitationNoContent) Code() int { + return 204 +} + func (o *ResendInvitationNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationNoContent", 204) +} + +func (o *ResendInvitationNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationNoContent", 204) } func (o *ResendInvitationNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewResendInvitationForbidden() *ResendInvitationForbidden { return &ResendInvitationForbidden{} } -/*ResendInvitationForbidden handles this case with default header values. +/* +ResendInvitationForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ResendInvitationForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this resend invitation forbidden response has a 2xx status code +func (o *ResendInvitationForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this resend invitation forbidden response has a 3xx status code +func (o *ResendInvitationForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this resend invitation forbidden response has a 4xx status code +func (o *ResendInvitationForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this resend invitation forbidden response has a 5xx status code +func (o *ResendInvitationForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this resend invitation forbidden response a status code equal to that given +func (o *ResendInvitationForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the resend invitation forbidden response +func (o *ResendInvitationForbidden) Code() int { + return 403 +} + func (o *ResendInvitationForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationForbidden %s", 403, payload) +} + +func (o *ResendInvitationForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationForbidden %s", 403, payload) } func (o *ResendInvitationForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *ResendInvitationForbidden) GetPayload() *models.ErrorPayload { func (o *ResendInvitationForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewResendInvitationNotFound() *ResendInvitationNotFound { return &ResendInvitationNotFound{} } -/*ResendInvitationNotFound handles this case with default header values. +/* +ResendInvitationNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type ResendInvitationNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this resend invitation not found response has a 2xx status code +func (o *ResendInvitationNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this resend invitation not found response has a 3xx status code +func (o *ResendInvitationNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this resend invitation not found response has a 4xx status code +func (o *ResendInvitationNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this resend invitation not found response has a 5xx status code +func (o *ResendInvitationNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this resend invitation not found response a status code equal to that given +func (o *ResendInvitationNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the resend invitation not found response +func (o *ResendInvitationNotFound) Code() int { + return 404 +} + func (o *ResendInvitationNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationNotFound %s", 404, payload) +} + +func (o *ResendInvitationNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitationNotFound %s", 404, payload) } func (o *ResendInvitationNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *ResendInvitationNotFound) GetPayload() *models.ErrorPayload { func (o *ResendInvitationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewResendInvitationDefault(code int) *ResendInvitationDefault { } } -/*ResendInvitationDefault handles this case with default header values. +/* +ResendInvitationDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ResendInvitationDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this resend invitation default response has a 2xx status code +func (o *ResendInvitationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this resend invitation default response has a 3xx status code +func (o *ResendInvitationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this resend invitation default response has a 4xx status code +func (o *ResendInvitationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this resend invitation default response has a 5xx status code +func (o *ResendInvitationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this resend invitation default response a status code equal to that given +func (o *ResendInvitationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the resend invitation default response func (o *ResendInvitationDefault) Code() int { return o._statusCode } func (o *ResendInvitationDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitation default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitation default %s", o._statusCode, payload) +} + +func (o *ResendInvitationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/invitations/{invitation_id}/resend][%d] resendInvitation default %s", o._statusCode, payload) } func (o *ResendInvitationDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *ResendInvitationDefault) GetPayload() *models.ErrorPayload { func (o *ResendInvitationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_kpis/create_k_p_i_favorite_parameters.go b/client/client/organization_kpis/create_k_p_i_favorite_parameters.go index 295d9722..ba81dd1d 100644 --- a/client/client/organization_kpis/create_k_p_i_favorite_parameters.go +++ b/client/client/organization_kpis/create_k_p_i_favorite_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewCreateKPIFavoriteParams creates a new CreateKPIFavoriteParams object -// with the default values initialized. +// NewCreateKPIFavoriteParams creates a new CreateKPIFavoriteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateKPIFavoriteParams() *CreateKPIFavoriteParams { - var () return &CreateKPIFavoriteParams{ - timeout: cr.DefaultTimeout, } } // NewCreateKPIFavoriteParamsWithTimeout creates a new CreateKPIFavoriteParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateKPIFavoriteParamsWithTimeout(timeout time.Duration) *CreateKPIFavoriteParams { - var () return &CreateKPIFavoriteParams{ - timeout: timeout, } } // NewCreateKPIFavoriteParamsWithContext creates a new CreateKPIFavoriteParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateKPIFavoriteParamsWithContext(ctx context.Context) *CreateKPIFavoriteParams { - var () return &CreateKPIFavoriteParams{ - Context: ctx, } } // NewCreateKPIFavoriteParamsWithHTTPClient creates a new CreateKPIFavoriteParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateKPIFavoriteParamsWithHTTPClient(client *http.Client) *CreateKPIFavoriteParams { - var () return &CreateKPIFavoriteParams{ HTTPClient: client, } } -/*CreateKPIFavoriteParams contains all the parameters to send to the API endpoint -for the create k p i favorite operation typically these are written to a http.Request +/* +CreateKPIFavoriteParams contains all the parameters to send to the API endpoint + + for the create k p i favorite operation. + + Typically these are written to a http.Request. */ type CreateKPIFavoriteParams struct { - /*KpiCanonical - A canonical of a kpi. + /* KpiCanonical. + A canonical of a kpi. */ KpiCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type CreateKPIFavoriteParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create k p i favorite params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateKPIFavoriteParams) WithDefaults() *CreateKPIFavoriteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create k p i favorite params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateKPIFavoriteParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create k p i favorite params func (o *CreateKPIFavoriteParams) WithTimeout(timeout time.Duration) *CreateKPIFavoriteParams { o.SetTimeout(timeout) diff --git a/client/client/organization_kpis/create_k_p_i_favorite_responses.go b/client/client/organization_kpis/create_k_p_i_favorite_responses.go index 9f75606c..ca7580bb 100644 --- a/client/client/organization_kpis/create_k_p_i_favorite_responses.go +++ b/client/client/organization_kpis/create_k_p_i_favorite_responses.go @@ -6,16 +6,16 @@ package organization_kpis // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateKPIFavoriteReader is a Reader for the CreateKPIFavorite structure. @@ -67,15 +67,50 @@ func NewCreateKPIFavoriteNoContent() *CreateKPIFavoriteNoContent { return &CreateKPIFavoriteNoContent{} } -/*CreateKPIFavoriteNoContent handles this case with default header values. +/* +CreateKPIFavoriteNoContent describes a response with status code 204, with default header values. The kpi has been added to user favorites list. */ type CreateKPIFavoriteNoContent struct { } +// IsSuccess returns true when this create k p i favorite no content response has a 2xx status code +func (o *CreateKPIFavoriteNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create k p i favorite no content response has a 3xx status code +func (o *CreateKPIFavoriteNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create k p i favorite no content response has a 4xx status code +func (o *CreateKPIFavoriteNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this create k p i favorite no content response has a 5xx status code +func (o *CreateKPIFavoriteNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this create k p i favorite no content response a status code equal to that given +func (o *CreateKPIFavoriteNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the create k p i favorite no content response +func (o *CreateKPIFavoriteNoContent) Code() int { + return 204 +} + func (o *CreateKPIFavoriteNoContent) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteNoContent ", 204) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteNoContent", 204) +} + +func (o *CreateKPIFavoriteNoContent) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteNoContent", 204) } func (o *CreateKPIFavoriteNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -88,20 +123,60 @@ func NewCreateKPIFavoriteForbidden() *CreateKPIFavoriteForbidden { return &CreateKPIFavoriteForbidden{} } -/*CreateKPIFavoriteForbidden handles this case with default header values. +/* +CreateKPIFavoriteForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateKPIFavoriteForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create k p i favorite forbidden response has a 2xx status code +func (o *CreateKPIFavoriteForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create k p i favorite forbidden response has a 3xx status code +func (o *CreateKPIFavoriteForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create k p i favorite forbidden response has a 4xx status code +func (o *CreateKPIFavoriteForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create k p i favorite forbidden response has a 5xx status code +func (o *CreateKPIFavoriteForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create k p i favorite forbidden response a status code equal to that given +func (o *CreateKPIFavoriteForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create k p i favorite forbidden response +func (o *CreateKPIFavoriteForbidden) Code() int { + return 403 +} + func (o *CreateKPIFavoriteForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteForbidden %s", 403, payload) +} + +func (o *CreateKPIFavoriteForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteForbidden %s", 403, payload) } func (o *CreateKPIFavoriteForbidden) GetPayload() *models.ErrorPayload { @@ -110,12 +185,16 @@ func (o *CreateKPIFavoriteForbidden) GetPayload() *models.ErrorPayload { func (o *CreateKPIFavoriteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -132,20 +211,60 @@ func NewCreateKPIFavoriteNotFound() *CreateKPIFavoriteNotFound { return &CreateKPIFavoriteNotFound{} } -/*CreateKPIFavoriteNotFound handles this case with default header values. +/* +CreateKPIFavoriteNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateKPIFavoriteNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create k p i favorite not found response has a 2xx status code +func (o *CreateKPIFavoriteNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create k p i favorite not found response has a 3xx status code +func (o *CreateKPIFavoriteNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create k p i favorite not found response has a 4xx status code +func (o *CreateKPIFavoriteNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create k p i favorite not found response has a 5xx status code +func (o *CreateKPIFavoriteNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create k p i favorite not found response a status code equal to that given +func (o *CreateKPIFavoriteNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create k p i favorite not found response +func (o *CreateKPIFavoriteNotFound) Code() int { + return 404 +} + func (o *CreateKPIFavoriteNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteNotFound %s", 404, payload) +} + +func (o *CreateKPIFavoriteNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteNotFound %s", 404, payload) } func (o *CreateKPIFavoriteNotFound) GetPayload() *models.ErrorPayload { @@ -154,12 +273,16 @@ func (o *CreateKPIFavoriteNotFound) GetPayload() *models.ErrorPayload { func (o *CreateKPIFavoriteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -176,20 +299,60 @@ func NewCreateKPIFavoriteUnprocessableEntity() *CreateKPIFavoriteUnprocessableEn return &CreateKPIFavoriteUnprocessableEntity{} } -/*CreateKPIFavoriteUnprocessableEntity handles this case with default header values. +/* +CreateKPIFavoriteUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateKPIFavoriteUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create k p i favorite unprocessable entity response has a 2xx status code +func (o *CreateKPIFavoriteUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create k p i favorite unprocessable entity response has a 3xx status code +func (o *CreateKPIFavoriteUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create k p i favorite unprocessable entity response has a 4xx status code +func (o *CreateKPIFavoriteUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create k p i favorite unprocessable entity response has a 5xx status code +func (o *CreateKPIFavoriteUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create k p i favorite unprocessable entity response a status code equal to that given +func (o *CreateKPIFavoriteUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create k p i favorite unprocessable entity response +func (o *CreateKPIFavoriteUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateKPIFavoriteUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteUnprocessableEntity %s", 422, payload) +} + +func (o *CreateKPIFavoriteUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavoriteUnprocessableEntity %s", 422, payload) } func (o *CreateKPIFavoriteUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -198,12 +361,16 @@ func (o *CreateKPIFavoriteUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *CreateKPIFavoriteUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -222,27 +389,61 @@ func NewCreateKPIFavoriteDefault(code int) *CreateKPIFavoriteDefault { } } -/*CreateKPIFavoriteDefault handles this case with default header values. +/* +CreateKPIFavoriteDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateKPIFavoriteDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create k p i favorite default response has a 2xx status code +func (o *CreateKPIFavoriteDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create k p i favorite default response has a 3xx status code +func (o *CreateKPIFavoriteDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create k p i favorite default response has a 4xx status code +func (o *CreateKPIFavoriteDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create k p i favorite default response has a 5xx status code +func (o *CreateKPIFavoriteDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create k p i favorite default response a status code equal to that given +func (o *CreateKPIFavoriteDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create k p i favorite default response func (o *CreateKPIFavoriteDefault) Code() int { return o._statusCode } func (o *CreateKPIFavoriteDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavorite default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavorite default %s", o._statusCode, payload) +} + +func (o *CreateKPIFavoriteDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] createKPIFavorite default %s", o._statusCode, payload) } func (o *CreateKPIFavoriteDefault) GetPayload() *models.ErrorPayload { @@ -251,12 +452,16 @@ func (o *CreateKPIFavoriteDefault) GetPayload() *models.ErrorPayload { func (o *CreateKPIFavoriteDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_kpis/create_kpi_parameters.go b/client/client/organization_kpis/create_kpi_parameters.go index b6a0329a..2994a3a7 100644 --- a/client/client/organization_kpis/create_kpi_parameters.go +++ b/client/client/organization_kpis/create_kpi_parameters.go @@ -13,135 +13,163 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateKpiParams creates a new CreateKpiParams object -// with the default values initialized. +// NewCreateKpiParams creates a new CreateKpiParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateKpiParams() *CreateKpiParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &CreateKpiParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewCreateKpiParamsWithTimeout creates a new CreateKpiParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateKpiParamsWithTimeout(timeout time.Duration) *CreateKpiParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &CreateKpiParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewCreateKpiParamsWithContext creates a new CreateKpiParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateKpiParamsWithContext(ctx context.Context) *CreateKpiParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &CreateKpiParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewCreateKpiParamsWithHTTPClient creates a new CreateKpiParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateKpiParamsWithHTTPClient(client *http.Client) *CreateKpiParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &CreateKpiParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*CreateKpiParams contains all the parameters to send to the API endpoint -for the create kpi operation typically these are written to a http.Request +/* +CreateKpiParams contains all the parameters to send to the API endpoint + + for the create kpi operation. + + Typically these are written to a http.Request. */ type CreateKpiParams struct { - /*Begin - The unix timestamp in seconds, which indicate the start of the time range. + /* Begin. + The unix timestamp in seconds, which indicate the start of the time range. + + Format: uint64 */ Begin *uint64 - /*Body - The information of the KPI + /* Body. + + The information of the KPI */ Body *models.NewKPI - /*End - The unix timestamp in seconds, which indicate the end of the time range. + /* End. + + The unix timestamp in seconds, which indicate the end of the time range. + + Format: uint64 */ End *uint64 - /*Environment - The environment canonical to use a query filter + /* EnvironmentCanonical. + + A list of environments' canonical to filter from */ - Environment *string - /*Favorite - Flag to retrieve favorite data from the members favorite list. + EnvironmentCanonical *string + /* Favorite. + + Flag to retrieve favorite data from the members favorite list. */ Favorite *bool - /*FetchData - Flag to retrieve KPIs' data upon retrieving KPIs themselves + /* FetchData. + + Flag to retrieve KPIs' data upon retrieving KPIs themselves */ FetchData *bool - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*Project - A canonical of a project used for filtering. + /* ProjectCanonical. + + A list of projects' canonical to filter from */ - Project *string + ProjectCanonical *string timeout time.Duration Context context.Context HTTPClient *http.Client } +// WithDefaults hydrates default values in the create kpi params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateKpiParams) WithDefaults() *CreateKpiParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create kpi params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateKpiParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := CreateKpiParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the create kpi params func (o *CreateKpiParams) WithTimeout(timeout time.Duration) *CreateKpiParams { o.SetTimeout(timeout) @@ -208,15 +236,15 @@ func (o *CreateKpiParams) SetEnd(end *uint64) { o.End = end } -// WithEnvironment adds the environment to the create kpi params -func (o *CreateKpiParams) WithEnvironment(environment *string) *CreateKpiParams { - o.SetEnvironment(environment) +// WithEnvironmentCanonical adds the environmentCanonical to the create kpi params +func (o *CreateKpiParams) WithEnvironmentCanonical(environmentCanonical *string) *CreateKpiParams { + o.SetEnvironmentCanonical(environmentCanonical) return o } -// SetEnvironment adds the environment to the create kpi params -func (o *CreateKpiParams) SetEnvironment(environment *string) { - o.Environment = environment +// SetEnvironmentCanonical adds the environmentCanonical to the create kpi params +func (o *CreateKpiParams) SetEnvironmentCanonical(environmentCanonical *string) { + o.EnvironmentCanonical = environmentCanonical } // WithFavorite adds the favorite to the create kpi params @@ -274,15 +302,15 @@ func (o *CreateKpiParams) SetPageSize(pageSize *uint32) { o.PageSize = pageSize } -// WithProject adds the project to the create kpi params -func (o *CreateKpiParams) WithProject(project *string) *CreateKpiParams { - o.SetProject(project) +// WithProjectCanonical adds the projectCanonical to the create kpi params +func (o *CreateKpiParams) WithProjectCanonical(projectCanonical *string) *CreateKpiParams { + o.SetProjectCanonical(projectCanonical) return o } -// SetProject adds the project to the create kpi params -func (o *CreateKpiParams) SetProject(project *string) { - o.Project = project +// SetProjectCanonical adds the projectCanonical to the create kpi params +func (o *CreateKpiParams) SetProjectCanonical(projectCanonical *string) { + o.ProjectCanonical = projectCanonical } // WriteToRequest writes these params to a swagger request @@ -297,18 +325,18 @@ func (o *CreateKpiParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg // query param begin var qrBegin uint64 + if o.Begin != nil { qrBegin = *o.Begin } qBegin := swag.FormatUint64(qrBegin) if qBegin != "" { + if err := r.SetQueryParam("begin", qBegin); err != nil { return err } } - } - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err @@ -319,64 +347,68 @@ func (o *CreateKpiParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg // query param end var qrEnd uint64 + if o.End != nil { qrEnd = *o.End } qEnd := swag.FormatUint64(qrEnd) if qEnd != "" { + if err := r.SetQueryParam("end", qEnd); err != nil { return err } } - } - if o.Environment != nil { + if o.EnvironmentCanonical != nil { + + // query param environment_canonical + var qrEnvironmentCanonical string - // query param environment - var qrEnvironment string - if o.Environment != nil { - qrEnvironment = *o.Environment + if o.EnvironmentCanonical != nil { + qrEnvironmentCanonical = *o.EnvironmentCanonical } - qEnvironment := qrEnvironment - if qEnvironment != "" { - if err := r.SetQueryParam("environment", qEnvironment); err != nil { + qEnvironmentCanonical := qrEnvironmentCanonical + if qEnvironmentCanonical != "" { + + if err := r.SetQueryParam("environment_canonical", qEnvironmentCanonical); err != nil { return err } } - } if o.Favorite != nil { // query param favorite var qrFavorite bool + if o.Favorite != nil { qrFavorite = *o.Favorite } qFavorite := swag.FormatBool(qrFavorite) if qFavorite != "" { + if err := r.SetQueryParam("favorite", qFavorite); err != nil { return err } } - } if o.FetchData != nil { // query param fetch_data var qrFetchData bool + if o.FetchData != nil { qrFetchData = *o.FetchData } qFetchData := swag.FormatBool(qrFetchData) if qFetchData != "" { + if err := r.SetQueryParam("fetch_data", qFetchData); err != nil { return err } } - } // path param organization_canonical @@ -388,48 +420,51 @@ func (o *CreateKpiParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } - if o.Project != nil { + if o.ProjectCanonical != nil { + + // query param project_canonical + var qrProjectCanonical string - // query param project - var qrProject string - if o.Project != nil { - qrProject = *o.Project + if o.ProjectCanonical != nil { + qrProjectCanonical = *o.ProjectCanonical } - qProject := qrProject - if qProject != "" { - if err := r.SetQueryParam("project", qProject); err != nil { + qProjectCanonical := qrProjectCanonical + if qProjectCanonical != "" { + + if err := r.SetQueryParam("project_canonical", qProjectCanonical); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_kpis/create_kpi_responses.go b/client/client/organization_kpis/create_kpi_responses.go index 1dfcf8c3..7eebd15a 100644 --- a/client/client/organization_kpis/create_kpi_responses.go +++ b/client/client/organization_kpis/create_kpi_responses.go @@ -6,17 +6,18 @@ package organization_kpis // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateKpiReader is a Reader for the CreateKpi structure. @@ -62,7 +63,8 @@ func NewCreateKpiOK() *CreateKpiOK { return &CreateKpiOK{} } -/*CreateKpiOK handles this case with default header values. +/* +CreateKpiOK describes a response with status code 200, with default header values. KPI has been configured */ @@ -70,8 +72,44 @@ type CreateKpiOK struct { Payload *CreateKpiOKBody } +// IsSuccess returns true when this create kpi o k response has a 2xx status code +func (o *CreateKpiOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create kpi o k response has a 3xx status code +func (o *CreateKpiOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create kpi o k response has a 4xx status code +func (o *CreateKpiOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create kpi o k response has a 5xx status code +func (o *CreateKpiOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create kpi o k response a status code equal to that given +func (o *CreateKpiOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create kpi o k response +func (o *CreateKpiOK) Code() int { + return 200 +} + func (o *CreateKpiOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiOK %s", 200, payload) +} + +func (o *CreateKpiOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiOK %s", 200, payload) } func (o *CreateKpiOK) GetPayload() *CreateKpiOKBody { @@ -95,20 +133,60 @@ func NewCreateKpiForbidden() *CreateKpiForbidden { return &CreateKpiForbidden{} } -/*CreateKpiForbidden handles this case with default header values. +/* +CreateKpiForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateKpiForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create kpi forbidden response has a 2xx status code +func (o *CreateKpiForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create kpi forbidden response has a 3xx status code +func (o *CreateKpiForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create kpi forbidden response has a 4xx status code +func (o *CreateKpiForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create kpi forbidden response has a 5xx status code +func (o *CreateKpiForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create kpi forbidden response a status code equal to that given +func (o *CreateKpiForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create kpi forbidden response +func (o *CreateKpiForbidden) Code() int { + return 403 +} + func (o *CreateKpiForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiForbidden %s", 403, payload) +} + +func (o *CreateKpiForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiForbidden %s", 403, payload) } func (o *CreateKpiForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *CreateKpiForbidden) GetPayload() *models.ErrorPayload { func (o *CreateKpiForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewCreateKpiUnprocessableEntity() *CreateKpiUnprocessableEntity { return &CreateKpiUnprocessableEntity{} } -/*CreateKpiUnprocessableEntity handles this case with default header values. +/* +CreateKpiUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateKpiUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create kpi unprocessable entity response has a 2xx status code +func (o *CreateKpiUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create kpi unprocessable entity response has a 3xx status code +func (o *CreateKpiUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create kpi unprocessable entity response has a 4xx status code +func (o *CreateKpiUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create kpi unprocessable entity response has a 5xx status code +func (o *CreateKpiUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create kpi unprocessable entity response a status code equal to that given +func (o *CreateKpiUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create kpi unprocessable entity response +func (o *CreateKpiUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateKpiUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiUnprocessableEntity %s", 422, payload) +} + +func (o *CreateKpiUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpiUnprocessableEntity %s", 422, payload) } func (o *CreateKpiUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *CreateKpiUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *CreateKpiUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewCreateKpiDefault(code int) *CreateKpiDefault { } } -/*CreateKpiDefault handles this case with default header values. +/* +CreateKpiDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateKpiDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create kpi default response has a 2xx status code +func (o *CreateKpiDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create kpi default response has a 3xx status code +func (o *CreateKpiDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create kpi default response has a 4xx status code +func (o *CreateKpiDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create kpi default response has a 5xx status code +func (o *CreateKpiDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create kpi default response a status code equal to that given +func (o *CreateKpiDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create kpi default response func (o *CreateKpiDefault) Code() int { return o._statusCode } func (o *CreateKpiDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpi default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpi default %s", o._statusCode, payload) +} + +func (o *CreateKpiDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/kpis][%d] createKpi default %s", o._statusCode, payload) } func (o *CreateKpiDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *CreateKpiDefault) GetPayload() *models.ErrorPayload { func (o *CreateKpiDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *CreateKpiDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*CreateKpiOKBody create kpi o k body +/* +CreateKpiOKBody create kpi o k body swagger:model CreateKpiOKBody */ type CreateKpiOKBody struct { @@ -265,6 +430,39 @@ func (o *CreateKpiOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createKpiOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createKpiOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create kpi o k body based on the context it is used +func (o *CreateKpiOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateKpiOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createKpiOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createKpiOK" + "." + "data") } return err } diff --git a/client/client/organization_kpis/delete_k_p_i_favorite_parameters.go b/client/client/organization_kpis/delete_k_p_i_favorite_parameters.go index a7701524..729c40d1 100644 --- a/client/client/organization_kpis/delete_k_p_i_favorite_parameters.go +++ b/client/client/organization_kpis/delete_k_p_i_favorite_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteKPIFavoriteParams creates a new DeleteKPIFavoriteParams object -// with the default values initialized. +// NewDeleteKPIFavoriteParams creates a new DeleteKPIFavoriteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteKPIFavoriteParams() *DeleteKPIFavoriteParams { - var () return &DeleteKPIFavoriteParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteKPIFavoriteParamsWithTimeout creates a new DeleteKPIFavoriteParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteKPIFavoriteParamsWithTimeout(timeout time.Duration) *DeleteKPIFavoriteParams { - var () return &DeleteKPIFavoriteParams{ - timeout: timeout, } } // NewDeleteKPIFavoriteParamsWithContext creates a new DeleteKPIFavoriteParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteKPIFavoriteParamsWithContext(ctx context.Context) *DeleteKPIFavoriteParams { - var () return &DeleteKPIFavoriteParams{ - Context: ctx, } } // NewDeleteKPIFavoriteParamsWithHTTPClient creates a new DeleteKPIFavoriteParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteKPIFavoriteParamsWithHTTPClient(client *http.Client) *DeleteKPIFavoriteParams { - var () return &DeleteKPIFavoriteParams{ HTTPClient: client, } } -/*DeleteKPIFavoriteParams contains all the parameters to send to the API endpoint -for the delete k p i favorite operation typically these are written to a http.Request +/* +DeleteKPIFavoriteParams contains all the parameters to send to the API endpoint + + for the delete k p i favorite operation. + + Typically these are written to a http.Request. */ type DeleteKPIFavoriteParams struct { - /*KpiCanonical - A canonical of a kpi. + /* KpiCanonical. + A canonical of a kpi. */ KpiCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type DeleteKPIFavoriteParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete k p i favorite params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteKPIFavoriteParams) WithDefaults() *DeleteKPIFavoriteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete k p i favorite params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteKPIFavoriteParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete k p i favorite params func (o *DeleteKPIFavoriteParams) WithTimeout(timeout time.Duration) *DeleteKPIFavoriteParams { o.SetTimeout(timeout) diff --git a/client/client/organization_kpis/delete_k_p_i_favorite_responses.go b/client/client/organization_kpis/delete_k_p_i_favorite_responses.go index f29b2347..4d3beff2 100644 --- a/client/client/organization_kpis/delete_k_p_i_favorite_responses.go +++ b/client/client/organization_kpis/delete_k_p_i_favorite_responses.go @@ -6,16 +6,16 @@ package organization_kpis // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteKPIFavoriteReader is a Reader for the DeleteKPIFavorite structure. @@ -61,15 +61,50 @@ func NewDeleteKPIFavoriteNoContent() *DeleteKPIFavoriteNoContent { return &DeleteKPIFavoriteNoContent{} } -/*DeleteKPIFavoriteNoContent handles this case with default header values. +/* +DeleteKPIFavoriteNoContent describes a response with status code 204, with default header values. The kpi has been removed from user favorites list. */ type DeleteKPIFavoriteNoContent struct { } +// IsSuccess returns true when this delete k p i favorite no content response has a 2xx status code +func (o *DeleteKPIFavoriteNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete k p i favorite no content response has a 3xx status code +func (o *DeleteKPIFavoriteNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete k p i favorite no content response has a 4xx status code +func (o *DeleteKPIFavoriteNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete k p i favorite no content response has a 5xx status code +func (o *DeleteKPIFavoriteNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete k p i favorite no content response a status code equal to that given +func (o *DeleteKPIFavoriteNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete k p i favorite no content response +func (o *DeleteKPIFavoriteNoContent) Code() int { + return 204 +} + func (o *DeleteKPIFavoriteNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteNoContent", 204) +} + +func (o *DeleteKPIFavoriteNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteNoContent", 204) } func (o *DeleteKPIFavoriteNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteKPIFavoriteForbidden() *DeleteKPIFavoriteForbidden { return &DeleteKPIFavoriteForbidden{} } -/*DeleteKPIFavoriteForbidden handles this case with default header values. +/* +DeleteKPIFavoriteForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteKPIFavoriteForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete k p i favorite forbidden response has a 2xx status code +func (o *DeleteKPIFavoriteForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete k p i favorite forbidden response has a 3xx status code +func (o *DeleteKPIFavoriteForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete k p i favorite forbidden response has a 4xx status code +func (o *DeleteKPIFavoriteForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete k p i favorite forbidden response has a 5xx status code +func (o *DeleteKPIFavoriteForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete k p i favorite forbidden response a status code equal to that given +func (o *DeleteKPIFavoriteForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete k p i favorite forbidden response +func (o *DeleteKPIFavoriteForbidden) Code() int { + return 403 +} + func (o *DeleteKPIFavoriteForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteForbidden %s", 403, payload) +} + +func (o *DeleteKPIFavoriteForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteForbidden %s", 403, payload) } func (o *DeleteKPIFavoriteForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteKPIFavoriteForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteKPIFavoriteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteKPIFavoriteNotFound() *DeleteKPIFavoriteNotFound { return &DeleteKPIFavoriteNotFound{} } -/*DeleteKPIFavoriteNotFound handles this case with default header values. +/* +DeleteKPIFavoriteNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteKPIFavoriteNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete k p i favorite not found response has a 2xx status code +func (o *DeleteKPIFavoriteNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete k p i favorite not found response has a 3xx status code +func (o *DeleteKPIFavoriteNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete k p i favorite not found response has a 4xx status code +func (o *DeleteKPIFavoriteNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete k p i favorite not found response has a 5xx status code +func (o *DeleteKPIFavoriteNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete k p i favorite not found response a status code equal to that given +func (o *DeleteKPIFavoriteNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete k p i favorite not found response +func (o *DeleteKPIFavoriteNotFound) Code() int { + return 404 +} + func (o *DeleteKPIFavoriteNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteNotFound %s", 404, payload) +} + +func (o *DeleteKPIFavoriteNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavoriteNotFound %s", 404, payload) } func (o *DeleteKPIFavoriteNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteKPIFavoriteNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteKPIFavoriteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteKPIFavoriteDefault(code int) *DeleteKPIFavoriteDefault { } } -/*DeleteKPIFavoriteDefault handles this case with default header values. +/* +DeleteKPIFavoriteDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteKPIFavoriteDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete k p i favorite default response has a 2xx status code +func (o *DeleteKPIFavoriteDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete k p i favorite default response has a 3xx status code +func (o *DeleteKPIFavoriteDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete k p i favorite default response has a 4xx status code +func (o *DeleteKPIFavoriteDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete k p i favorite default response has a 5xx status code +func (o *DeleteKPIFavoriteDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete k p i favorite default response a status code equal to that given +func (o *DeleteKPIFavoriteDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete k p i favorite default response func (o *DeleteKPIFavoriteDefault) Code() int { return o._statusCode } func (o *DeleteKPIFavoriteDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavorite default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavorite default %s", o._statusCode, payload) +} + +func (o *DeleteKPIFavoriteDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites][%d] deleteKPIFavorite default %s", o._statusCode, payload) } func (o *DeleteKPIFavoriteDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteKPIFavoriteDefault) GetPayload() *models.ErrorPayload { func (o *DeleteKPIFavoriteDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_kpis/delete_kpi_parameters.go b/client/client/organization_kpis/delete_kpi_parameters.go index b0a81518..bb0aac81 100644 --- a/client/client/organization_kpis/delete_kpi_parameters.go +++ b/client/client/organization_kpis/delete_kpi_parameters.go @@ -13,79 +13,87 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewDeleteKpiParams creates a new DeleteKpiParams object -// with the default values initialized. +// NewDeleteKpiParams creates a new DeleteKpiParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteKpiParams() *DeleteKpiParams { - var () return &DeleteKpiParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteKpiParamsWithTimeout creates a new DeleteKpiParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteKpiParamsWithTimeout(timeout time.Duration) *DeleteKpiParams { - var () return &DeleteKpiParams{ - timeout: timeout, } } // NewDeleteKpiParamsWithContext creates a new DeleteKpiParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteKpiParamsWithContext(ctx context.Context) *DeleteKpiParams { - var () return &DeleteKpiParams{ - Context: ctx, } } // NewDeleteKpiParamsWithHTTPClient creates a new DeleteKpiParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteKpiParamsWithHTTPClient(client *http.Client) *DeleteKpiParams { - var () return &DeleteKpiParams{ HTTPClient: client, } } -/*DeleteKpiParams contains all the parameters to send to the API endpoint -for the delete kpi operation typically these are written to a http.Request +/* +DeleteKpiParams contains all the parameters to send to the API endpoint + + for the delete kpi operation. + + Typically these are written to a http.Request. */ type DeleteKpiParams struct { - /*Begin - The unix timestamp in seconds, which indicate the start of the time range. + /* Begin. + + The unix timestamp in seconds, which indicate the start of the time range. + Format: uint64 */ Begin *uint64 - /*End - The unix timestamp in seconds, which indicate the end of the time range. + /* End. + + The unix timestamp in seconds, which indicate the end of the time range. + + Format: uint64 */ End *uint64 - /*FetchData - Flag to retrieve KPIs' data upon retrieving KPIs themselves + /* FetchData. + + Flag to retrieve KPIs' data upon retrieving KPIs themselves */ FetchData *bool - /*KpiCanonical - A canonical of a kpi. + /* KpiCanonical. + + A canonical of a kpi. */ KpiCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -94,6 +102,21 @@ type DeleteKpiParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete kpi params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteKpiParams) WithDefaults() *DeleteKpiParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete kpi params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteKpiParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete kpi params func (o *DeleteKpiParams) WithTimeout(timeout time.Duration) *DeleteKpiParams { o.SetTimeout(timeout) @@ -194,48 +217,51 @@ func (o *DeleteKpiParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg // query param begin var qrBegin uint64 + if o.Begin != nil { qrBegin = *o.Begin } qBegin := swag.FormatUint64(qrBegin) if qBegin != "" { + if err := r.SetQueryParam("begin", qBegin); err != nil { return err } } - } if o.End != nil { // query param end var qrEnd uint64 + if o.End != nil { qrEnd = *o.End } qEnd := swag.FormatUint64(qrEnd) if qEnd != "" { + if err := r.SetQueryParam("end", qEnd); err != nil { return err } } - } if o.FetchData != nil { // query param fetch_data var qrFetchData bool + if o.FetchData != nil { qrFetchData = *o.FetchData } qFetchData := swag.FormatBool(qrFetchData) if qFetchData != "" { + if err := r.SetQueryParam("fetch_data", qFetchData); err != nil { return err } } - } // path param kpi_canonical diff --git a/client/client/organization_kpis/delete_kpi_responses.go b/client/client/organization_kpis/delete_kpi_responses.go index 2d539b6f..82cfccb9 100644 --- a/client/client/organization_kpis/delete_kpi_responses.go +++ b/client/client/organization_kpis/delete_kpi_responses.go @@ -6,16 +6,16 @@ package organization_kpis // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteKpiReader is a Reader for the DeleteKpi structure. @@ -61,15 +61,50 @@ func NewDeleteKpiNoContent() *DeleteKpiNoContent { return &DeleteKpiNoContent{} } -/*DeleteKpiNoContent handles this case with default header values. +/* +DeleteKpiNoContent describes a response with status code 204, with default header values. Organization's KPI has been deleted */ type DeleteKpiNoContent struct { } +// IsSuccess returns true when this delete kpi no content response has a 2xx status code +func (o *DeleteKpiNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete kpi no content response has a 3xx status code +func (o *DeleteKpiNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete kpi no content response has a 4xx status code +func (o *DeleteKpiNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete kpi no content response has a 5xx status code +func (o *DeleteKpiNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete kpi no content response a status code equal to that given +func (o *DeleteKpiNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete kpi no content response +func (o *DeleteKpiNoContent) Code() int { + return 204 +} + func (o *DeleteKpiNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiNoContent", 204) +} + +func (o *DeleteKpiNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiNoContent", 204) } func (o *DeleteKpiNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteKpiForbidden() *DeleteKpiForbidden { return &DeleteKpiForbidden{} } -/*DeleteKpiForbidden handles this case with default header values. +/* +DeleteKpiForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteKpiForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete kpi forbidden response has a 2xx status code +func (o *DeleteKpiForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete kpi forbidden response has a 3xx status code +func (o *DeleteKpiForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete kpi forbidden response has a 4xx status code +func (o *DeleteKpiForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete kpi forbidden response has a 5xx status code +func (o *DeleteKpiForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete kpi forbidden response a status code equal to that given +func (o *DeleteKpiForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete kpi forbidden response +func (o *DeleteKpiForbidden) Code() int { + return 403 +} + func (o *DeleteKpiForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiForbidden %s", 403, payload) +} + +func (o *DeleteKpiForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiForbidden %s", 403, payload) } func (o *DeleteKpiForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteKpiForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteKpiForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteKpiNotFound() *DeleteKpiNotFound { return &DeleteKpiNotFound{} } -/*DeleteKpiNotFound handles this case with default header values. +/* +DeleteKpiNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteKpiNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete kpi not found response has a 2xx status code +func (o *DeleteKpiNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete kpi not found response has a 3xx status code +func (o *DeleteKpiNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete kpi not found response has a 4xx status code +func (o *DeleteKpiNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete kpi not found response has a 5xx status code +func (o *DeleteKpiNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete kpi not found response a status code equal to that given +func (o *DeleteKpiNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete kpi not found response +func (o *DeleteKpiNotFound) Code() int { + return 404 +} + func (o *DeleteKpiNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiNotFound %s", 404, payload) +} + +func (o *DeleteKpiNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpiNotFound %s", 404, payload) } func (o *DeleteKpiNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteKpiNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteKpiNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteKpiDefault(code int) *DeleteKpiDefault { } } -/*DeleteKpiDefault handles this case with default header values. +/* +DeleteKpiDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteKpiDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete kpi default response has a 2xx status code +func (o *DeleteKpiDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete kpi default response has a 3xx status code +func (o *DeleteKpiDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete kpi default response has a 4xx status code +func (o *DeleteKpiDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete kpi default response has a 5xx status code +func (o *DeleteKpiDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete kpi default response a status code equal to that given +func (o *DeleteKpiDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete kpi default response func (o *DeleteKpiDefault) Code() int { return o._statusCode } func (o *DeleteKpiDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpi default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpi default %s", o._statusCode, payload) +} + +func (o *DeleteKpiDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] deleteKpi default %s", o._statusCode, payload) } func (o *DeleteKpiDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteKpiDefault) GetPayload() *models.ErrorPayload { func (o *DeleteKpiDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_kpis/get_kpi_parameters.go b/client/client/organization_kpis/get_kpi_parameters.go index dce58439..41a025f8 100644 --- a/client/client/organization_kpis/get_kpi_parameters.go +++ b/client/client/organization_kpis/get_kpi_parameters.go @@ -13,79 +13,87 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetKpiParams creates a new GetKpiParams object -// with the default values initialized. +// NewGetKpiParams creates a new GetKpiParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetKpiParams() *GetKpiParams { - var () return &GetKpiParams{ - timeout: cr.DefaultTimeout, } } // NewGetKpiParamsWithTimeout creates a new GetKpiParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetKpiParamsWithTimeout(timeout time.Duration) *GetKpiParams { - var () return &GetKpiParams{ - timeout: timeout, } } // NewGetKpiParamsWithContext creates a new GetKpiParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetKpiParamsWithContext(ctx context.Context) *GetKpiParams { - var () return &GetKpiParams{ - Context: ctx, } } // NewGetKpiParamsWithHTTPClient creates a new GetKpiParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetKpiParamsWithHTTPClient(client *http.Client) *GetKpiParams { - var () return &GetKpiParams{ HTTPClient: client, } } -/*GetKpiParams contains all the parameters to send to the API endpoint -for the get kpi operation typically these are written to a http.Request +/* +GetKpiParams contains all the parameters to send to the API endpoint + + for the get kpi operation. + + Typically these are written to a http.Request. */ type GetKpiParams struct { - /*Begin - The unix timestamp in seconds, which indicate the start of the time range. + /* Begin. + + The unix timestamp in seconds, which indicate the start of the time range. + Format: uint64 */ Begin *uint64 - /*End - The unix timestamp in seconds, which indicate the end of the time range. + /* End. + + The unix timestamp in seconds, which indicate the end of the time range. + + Format: uint64 */ End *uint64 - /*FetchData - Flag to retrieve KPIs' data upon retrieving KPIs themselves + /* FetchData. + + Flag to retrieve KPIs' data upon retrieving KPIs themselves */ FetchData *bool - /*KpiCanonical - A canonical of a kpi. + /* KpiCanonical. + + A canonical of a kpi. */ KpiCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -94,6 +102,21 @@ type GetKpiParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get kpi params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetKpiParams) WithDefaults() *GetKpiParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get kpi params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetKpiParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get kpi params func (o *GetKpiParams) WithTimeout(timeout time.Duration) *GetKpiParams { o.SetTimeout(timeout) @@ -194,48 +217,51 @@ func (o *GetKpiParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regist // query param begin var qrBegin uint64 + if o.Begin != nil { qrBegin = *o.Begin } qBegin := swag.FormatUint64(qrBegin) if qBegin != "" { + if err := r.SetQueryParam("begin", qBegin); err != nil { return err } } - } if o.End != nil { // query param end var qrEnd uint64 + if o.End != nil { qrEnd = *o.End } qEnd := swag.FormatUint64(qrEnd) if qEnd != "" { + if err := r.SetQueryParam("end", qEnd); err != nil { return err } } - } if o.FetchData != nil { // query param fetch_data var qrFetchData bool + if o.FetchData != nil { qrFetchData = *o.FetchData } qFetchData := swag.FormatBool(qrFetchData) if qFetchData != "" { + if err := r.SetQueryParam("fetch_data", qFetchData); err != nil { return err } } - } // path param kpi_canonical diff --git a/client/client/organization_kpis/get_kpi_responses.go b/client/client/organization_kpis/get_kpi_responses.go index 596e1ced..23f26ae3 100644 --- a/client/client/organization_kpis/get_kpi_responses.go +++ b/client/client/organization_kpis/get_kpi_responses.go @@ -6,17 +6,18 @@ package organization_kpis // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetKpiReader is a Reader for the GetKpi structure. @@ -62,7 +63,8 @@ func NewGetKpiOK() *GetKpiOK { return &GetKpiOK{} } -/*GetKpiOK handles this case with default header values. +/* +GetKpiOK describes a response with status code 200, with default header values. The KPI */ @@ -70,8 +72,44 @@ type GetKpiOK struct { Payload *GetKpiOKBody } +// IsSuccess returns true when this get kpi o k response has a 2xx status code +func (o *GetKpiOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get kpi o k response has a 3xx status code +func (o *GetKpiOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get kpi o k response has a 4xx status code +func (o *GetKpiOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get kpi o k response has a 5xx status code +func (o *GetKpiOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get kpi o k response a status code equal to that given +func (o *GetKpiOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get kpi o k response +func (o *GetKpiOK) Code() int { + return 200 +} + func (o *GetKpiOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiOK %s", 200, payload) +} + +func (o *GetKpiOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiOK %s", 200, payload) } func (o *GetKpiOK) GetPayload() *GetKpiOKBody { @@ -95,20 +133,60 @@ func NewGetKpiForbidden() *GetKpiForbidden { return &GetKpiForbidden{} } -/*GetKpiForbidden handles this case with default header values. +/* +GetKpiForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetKpiForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get kpi forbidden response has a 2xx status code +func (o *GetKpiForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get kpi forbidden response has a 3xx status code +func (o *GetKpiForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get kpi forbidden response has a 4xx status code +func (o *GetKpiForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get kpi forbidden response has a 5xx status code +func (o *GetKpiForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get kpi forbidden response a status code equal to that given +func (o *GetKpiForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get kpi forbidden response +func (o *GetKpiForbidden) Code() int { + return 403 +} + func (o *GetKpiForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiForbidden %s", 403, payload) +} + +func (o *GetKpiForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiForbidden %s", 403, payload) } func (o *GetKpiForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetKpiForbidden) GetPayload() *models.ErrorPayload { func (o *GetKpiForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetKpiUnprocessableEntity() *GetKpiUnprocessableEntity { return &GetKpiUnprocessableEntity{} } -/*GetKpiUnprocessableEntity handles this case with default header values. +/* +GetKpiUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetKpiUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get kpi unprocessable entity response has a 2xx status code +func (o *GetKpiUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get kpi unprocessable entity response has a 3xx status code +func (o *GetKpiUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get kpi unprocessable entity response has a 4xx status code +func (o *GetKpiUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get kpi unprocessable entity response has a 5xx status code +func (o *GetKpiUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get kpi unprocessable entity response a status code equal to that given +func (o *GetKpiUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get kpi unprocessable entity response +func (o *GetKpiUnprocessableEntity) Code() int { + return 422 +} + func (o *GetKpiUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiUnprocessableEntity %s", 422, payload) +} + +func (o *GetKpiUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpiUnprocessableEntity %s", 422, payload) } func (o *GetKpiUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetKpiUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetKpiUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetKpiDefault(code int) *GetKpiDefault { } } -/*GetKpiDefault handles this case with default header values. +/* +GetKpiDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetKpiDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get kpi default response has a 2xx status code +func (o *GetKpiDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get kpi default response has a 3xx status code +func (o *GetKpiDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get kpi default response has a 4xx status code +func (o *GetKpiDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get kpi default response has a 5xx status code +func (o *GetKpiDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get kpi default response a status code equal to that given +func (o *GetKpiDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get kpi default response func (o *GetKpiDefault) Code() int { return o._statusCode } func (o *GetKpiDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpi default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpi default %s", o._statusCode, payload) +} + +func (o *GetKpiDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] getKpi default %s", o._statusCode, payload) } func (o *GetKpiDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetKpiDefault) GetPayload() *models.ErrorPayload { func (o *GetKpiDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetKpiDefault) readResponse(response runtime.ClientResponse, consumer r return nil } -/*GetKpiOKBody get kpi o k body +/* +GetKpiOKBody get kpi o k body swagger:model GetKpiOKBody */ type GetKpiOKBody struct { @@ -265,6 +430,39 @@ func (o *GetKpiOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getKpiOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getKpiOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get kpi o k body based on the context it is used +func (o *GetKpiOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetKpiOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getKpiOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getKpiOK" + "." + "data") } return err } diff --git a/client/client/organization_kpis/get_kpis_parameters.go b/client/client/organization_kpis/get_kpis_parameters.go index 2f80ee47..08b8be18 100644 --- a/client/client/organization_kpis/get_kpis_parameters.go +++ b/client/client/organization_kpis/get_kpis_parameters.go @@ -13,128 +13,155 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetKpisParams creates a new GetKpisParams object -// with the default values initialized. +// NewGetKpisParams creates a new GetKpisParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetKpisParams() *GetKpisParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetKpisParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetKpisParamsWithTimeout creates a new GetKpisParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetKpisParamsWithTimeout(timeout time.Duration) *GetKpisParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetKpisParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetKpisParamsWithContext creates a new GetKpisParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetKpisParamsWithContext(ctx context.Context) *GetKpisParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetKpisParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetKpisParamsWithHTTPClient creates a new GetKpisParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetKpisParamsWithHTTPClient(client *http.Client) *GetKpisParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetKpisParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetKpisParams contains all the parameters to send to the API endpoint -for the get kpis operation typically these are written to a http.Request +/* +GetKpisParams contains all the parameters to send to the API endpoint + + for the get kpis operation. + + Typically these are written to a http.Request. */ type GetKpisParams struct { - /*Begin - The unix timestamp in seconds, which indicate the start of the time range. + /* Begin. + The unix timestamp in seconds, which indicate the start of the time range. + + Format: uint64 */ Begin *uint64 - /*End - The unix timestamp in seconds, which indicate the end of the time range. + /* End. + + The unix timestamp in seconds, which indicate the end of the time range. + + Format: uint64 */ End *uint64 - /*Environment - The environment canonical to use a query filter + /* EnvironmentCanonical. + + A list of environments' canonical to filter from */ - Environment *string - /*Favorite - Flag to retrieve favorite data from the members favorite list. + EnvironmentCanonical *string + /* Favorite. + + Flag to retrieve favorite data from the members favorite list. */ Favorite *bool - /*FetchData - Flag to retrieve KPIs' data upon retrieving KPIs themselves + /* FetchData. + + Flag to retrieve KPIs' data upon retrieving KPIs themselves */ FetchData *bool - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*Project - A canonical of a project used for filtering. + /* ProjectCanonical. + + A list of projects' canonical to filter from */ - Project *string + ProjectCanonical *string timeout time.Duration Context context.Context HTTPClient *http.Client } +// WithDefaults hydrates default values in the get kpis params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetKpisParams) WithDefaults() *GetKpisParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get kpis params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetKpisParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetKpisParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get kpis params func (o *GetKpisParams) WithTimeout(timeout time.Duration) *GetKpisParams { o.SetTimeout(timeout) @@ -190,15 +217,15 @@ func (o *GetKpisParams) SetEnd(end *uint64) { o.End = end } -// WithEnvironment adds the environment to the get kpis params -func (o *GetKpisParams) WithEnvironment(environment *string) *GetKpisParams { - o.SetEnvironment(environment) +// WithEnvironmentCanonical adds the environmentCanonical to the get kpis params +func (o *GetKpisParams) WithEnvironmentCanonical(environmentCanonical *string) *GetKpisParams { + o.SetEnvironmentCanonical(environmentCanonical) return o } -// SetEnvironment adds the environment to the get kpis params -func (o *GetKpisParams) SetEnvironment(environment *string) { - o.Environment = environment +// SetEnvironmentCanonical adds the environmentCanonical to the get kpis params +func (o *GetKpisParams) SetEnvironmentCanonical(environmentCanonical *string) { + o.EnvironmentCanonical = environmentCanonical } // WithFavorite adds the favorite to the get kpis params @@ -256,15 +283,15 @@ func (o *GetKpisParams) SetPageSize(pageSize *uint32) { o.PageSize = pageSize } -// WithProject adds the project to the get kpis params -func (o *GetKpisParams) WithProject(project *string) *GetKpisParams { - o.SetProject(project) +// WithProjectCanonical adds the projectCanonical to the get kpis params +func (o *GetKpisParams) WithProjectCanonical(projectCanonical *string) *GetKpisParams { + o.SetProjectCanonical(projectCanonical) return o } -// SetProject adds the project to the get kpis params -func (o *GetKpisParams) SetProject(project *string) { - o.Project = project +// SetProjectCanonical adds the projectCanonical to the get kpis params +func (o *GetKpisParams) SetProjectCanonical(projectCanonical *string) { + o.ProjectCanonical = projectCanonical } // WriteToRequest writes these params to a swagger request @@ -279,80 +306,85 @@ func (o *GetKpisParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regis // query param begin var qrBegin uint64 + if o.Begin != nil { qrBegin = *o.Begin } qBegin := swag.FormatUint64(qrBegin) if qBegin != "" { + if err := r.SetQueryParam("begin", qBegin); err != nil { return err } } - } if o.End != nil { // query param end var qrEnd uint64 + if o.End != nil { qrEnd = *o.End } qEnd := swag.FormatUint64(qrEnd) if qEnd != "" { + if err := r.SetQueryParam("end", qEnd); err != nil { return err } } - } - if o.Environment != nil { + if o.EnvironmentCanonical != nil { - // query param environment - var qrEnvironment string - if o.Environment != nil { - qrEnvironment = *o.Environment + // query param environment_canonical + var qrEnvironmentCanonical string + + if o.EnvironmentCanonical != nil { + qrEnvironmentCanonical = *o.EnvironmentCanonical } - qEnvironment := qrEnvironment - if qEnvironment != "" { - if err := r.SetQueryParam("environment", qEnvironment); err != nil { + qEnvironmentCanonical := qrEnvironmentCanonical + if qEnvironmentCanonical != "" { + + if err := r.SetQueryParam("environment_canonical", qEnvironmentCanonical); err != nil { return err } } - } if o.Favorite != nil { // query param favorite var qrFavorite bool + if o.Favorite != nil { qrFavorite = *o.Favorite } qFavorite := swag.FormatBool(qrFavorite) if qFavorite != "" { + if err := r.SetQueryParam("favorite", qFavorite); err != nil { return err } } - } if o.FetchData != nil { // query param fetch_data var qrFetchData bool + if o.FetchData != nil { qrFetchData = *o.FetchData } qFetchData := swag.FormatBool(qrFetchData) if qFetchData != "" { + if err := r.SetQueryParam("fetch_data", qFetchData); err != nil { return err } } - } // path param organization_canonical @@ -364,48 +396,51 @@ func (o *GetKpisParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regis // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } - if o.Project != nil { + if o.ProjectCanonical != nil { + + // query param project_canonical + var qrProjectCanonical string - // query param project - var qrProject string - if o.Project != nil { - qrProject = *o.Project + if o.ProjectCanonical != nil { + qrProjectCanonical = *o.ProjectCanonical } - qProject := qrProject - if qProject != "" { - if err := r.SetQueryParam("project", qProject); err != nil { + qProjectCanonical := qrProjectCanonical + if qProjectCanonical != "" { + + if err := r.SetQueryParam("project_canonical", qProjectCanonical); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_kpis/get_kpis_responses.go b/client/client/organization_kpis/get_kpis_responses.go index 98b53caa..78be8032 100644 --- a/client/client/organization_kpis/get_kpis_responses.go +++ b/client/client/organization_kpis/get_kpis_responses.go @@ -6,18 +6,19 @@ package organization_kpis // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetKpisReader is a Reader for the GetKpis structure. @@ -63,7 +64,8 @@ func NewGetKpisOK() *GetKpisOK { return &GetKpisOK{} } -/*GetKpisOK handles this case with default header values. +/* +GetKpisOK describes a response with status code 200, with default header values. The list of the KPIs */ @@ -71,8 +73,44 @@ type GetKpisOK struct { Payload *GetKpisOKBody } +// IsSuccess returns true when this get kpis o k response has a 2xx status code +func (o *GetKpisOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get kpis o k response has a 3xx status code +func (o *GetKpisOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get kpis o k response has a 4xx status code +func (o *GetKpisOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get kpis o k response has a 5xx status code +func (o *GetKpisOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get kpis o k response a status code equal to that given +func (o *GetKpisOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get kpis o k response +func (o *GetKpisOK) Code() int { + return 200 +} + func (o *GetKpisOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisOK %s", 200, payload) +} + +func (o *GetKpisOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisOK %s", 200, payload) } func (o *GetKpisOK) GetPayload() *GetKpisOKBody { @@ -96,20 +134,60 @@ func NewGetKpisForbidden() *GetKpisForbidden { return &GetKpisForbidden{} } -/*GetKpisForbidden handles this case with default header values. +/* +GetKpisForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetKpisForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get kpis forbidden response has a 2xx status code +func (o *GetKpisForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get kpis forbidden response has a 3xx status code +func (o *GetKpisForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get kpis forbidden response has a 4xx status code +func (o *GetKpisForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get kpis forbidden response has a 5xx status code +func (o *GetKpisForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get kpis forbidden response a status code equal to that given +func (o *GetKpisForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get kpis forbidden response +func (o *GetKpisForbidden) Code() int { + return 403 +} + func (o *GetKpisForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisForbidden %s", 403, payload) +} + +func (o *GetKpisForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisForbidden %s", 403, payload) } func (o *GetKpisForbidden) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *GetKpisForbidden) GetPayload() *models.ErrorPayload { func (o *GetKpisForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewGetKpisUnprocessableEntity() *GetKpisUnprocessableEntity { return &GetKpisUnprocessableEntity{} } -/*GetKpisUnprocessableEntity handles this case with default header values. +/* +GetKpisUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetKpisUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get kpis unprocessable entity response has a 2xx status code +func (o *GetKpisUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get kpis unprocessable entity response has a 3xx status code +func (o *GetKpisUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get kpis unprocessable entity response has a 4xx status code +func (o *GetKpisUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get kpis unprocessable entity response has a 5xx status code +func (o *GetKpisUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get kpis unprocessable entity response a status code equal to that given +func (o *GetKpisUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get kpis unprocessable entity response +func (o *GetKpisUnprocessableEntity) Code() int { + return 422 +} + func (o *GetKpisUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisUnprocessableEntity %s", 422, payload) +} + +func (o *GetKpisUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpisUnprocessableEntity %s", 422, payload) } func (o *GetKpisUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *GetKpisUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetKpisUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewGetKpisDefault(code int) *GetKpisDefault { } } -/*GetKpisDefault handles this case with default header values. +/* +GetKpisDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetKpisDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get kpis default response has a 2xx status code +func (o *GetKpisDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get kpis default response has a 3xx status code +func (o *GetKpisDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get kpis default response has a 4xx status code +func (o *GetKpisDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get kpis default response has a 5xx status code +func (o *GetKpisDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get kpis default response a status code equal to that given +func (o *GetKpisDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get kpis default response func (o *GetKpisDefault) Code() int { return o._statusCode } func (o *GetKpisDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpis default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpis default %s", o._statusCode, payload) +} + +func (o *GetKpisDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/kpis][%d] getKpis default %s", o._statusCode, payload) } func (o *GetKpisDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *GetKpisDefault) GetPayload() *models.ErrorPayload { func (o *GetKpisDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *GetKpisDefault) readResponse(response runtime.ClientResponse, consumer return nil } -/*GetKpisOKBody get kpis o k body +/* +GetKpisOKBody get kpis o k body swagger:model GetKpisOKBody */ type GetKpisOKBody struct { @@ -278,6 +443,8 @@ func (o *GetKpisOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getKpisOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getKpisOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -289,7 +456,6 @@ func (o *GetKpisOKBody) validateData(formats strfmt.Registry) error { } func (o *GetKpisOKBody) validatePagination(formats strfmt.Registry) error { - if swag.IsZero(o.Pagination) { // not required return nil } @@ -298,6 +464,72 @@ func (o *GetKpisOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getKpisOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getKpisOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get kpis o k body based on the context it is used +func (o *GetKpisOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetKpisOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getKpisOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getKpisOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetKpisOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if swag.IsZero(o.Pagination) { // not required + return nil + } + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getKpisOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getKpisOK" + "." + "pagination") } return err } diff --git a/client/client/organization_kpis/organization_kpis_client.go b/client/client/organization_kpis/organization_kpis_client.go index bfe1ad89..39f66586 100644 --- a/client/client/organization_kpis/organization_kpis_client.go +++ b/client/client/organization_kpis/organization_kpis_client.go @@ -7,15 +7,40 @@ package organization_kpis import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization kpis API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization kpis API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization kpis API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization kpis API */ @@ -24,16 +49,86 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateKPIFavorite(params *CreateKPIFavoriteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateKPIFavoriteNoContent, error) + + CreateKpi(params *CreateKpiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateKpiOK, error) + + DeleteKPIFavorite(params *DeleteKPIFavoriteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteKPIFavoriteNoContent, error) + + DeleteKpi(params *DeleteKpiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteKpiNoContent, error) + + GetKpi(params *GetKpiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetKpiOK, error) + + GetKpis(params *GetKpisParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetKpisOK, error) + + UpdateKpi(params *UpdateKpiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateKpiOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateKPIFavorite Add a kpi in the user favorites list. */ -func (a *Client) CreateKPIFavorite(params *CreateKPIFavoriteParams, authInfo runtime.ClientAuthInfoWriter) (*CreateKPIFavoriteNoContent, error) { +func (a *Client) CreateKPIFavorite(params *CreateKPIFavoriteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateKPIFavoriteNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateKPIFavoriteParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createKPIFavorite", Method: "POST", PathPattern: "/organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites", @@ -45,7 +140,12 @@ func (a *Client) CreateKPIFavorite(params *CreateKPIFavoriteParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +161,12 @@ func (a *Client) CreateKPIFavorite(params *CreateKPIFavoriteParams, authInfo run /* CreateKpi Save information about the KPI */ -func (a *Client) CreateKpi(params *CreateKpiParams, authInfo runtime.ClientAuthInfoWriter) (*CreateKpiOK, error) { +func (a *Client) CreateKpi(params *CreateKpiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateKpiOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateKpiParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createKpi", Method: "POST", PathPattern: "/organizations/{organization_canonical}/kpis", @@ -79,7 +178,12 @@ func (a *Client) CreateKpi(params *CreateKpiParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +199,12 @@ func (a *Client) CreateKpi(params *CreateKpiParams, authInfo runtime.ClientAuthI /* DeleteKPIFavorite Remove a kpi from the user favorites list. */ -func (a *Client) DeleteKPIFavorite(params *DeleteKPIFavoriteParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteKPIFavoriteNoContent, error) { +func (a *Client) DeleteKPIFavorite(params *DeleteKPIFavoriteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteKPIFavoriteNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteKPIFavoriteParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteKPIFavorite", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/kpis/{kpi_canonical}/favorites", @@ -113,7 +216,12 @@ func (a *Client) DeleteKPIFavorite(params *DeleteKPIFavoriteParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +237,12 @@ func (a *Client) DeleteKPIFavorite(params *DeleteKPIFavoriteParams, authInfo run /* DeleteKpi delete a KPI */ -func (a *Client) DeleteKpi(params *DeleteKpiParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteKpiNoContent, error) { +func (a *Client) DeleteKpi(params *DeleteKpiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteKpiNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteKpiParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteKpi", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/kpis/{kpi_canonical}", @@ -147,7 +254,12 @@ func (a *Client) DeleteKpi(params *DeleteKpiParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +275,12 @@ func (a *Client) DeleteKpi(params *DeleteKpiParams, authInfo runtime.ClientAuthI /* GetKpi Get the KPI */ -func (a *Client) GetKpi(params *GetKpiParams, authInfo runtime.ClientAuthInfoWriter) (*GetKpiOK, error) { +func (a *Client) GetKpi(params *GetKpiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetKpiOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetKpiParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getKpi", Method: "GET", PathPattern: "/organizations/{organization_canonical}/kpis/{kpi_canonical}", @@ -181,7 +292,12 @@ func (a *Client) GetKpi(params *GetKpiParams, authInfo runtime.ClientAuthInfoWri AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -197,13 +313,12 @@ func (a *Client) GetKpi(params *GetKpiParams, authInfo runtime.ClientAuthInfoWri /* GetKpis Get the list of configured organization KPIs */ -func (a *Client) GetKpis(params *GetKpisParams, authInfo runtime.ClientAuthInfoWriter) (*GetKpisOK, error) { +func (a *Client) GetKpis(params *GetKpisParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetKpisOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetKpisParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getKpis", Method: "GET", PathPattern: "/organizations/{organization_canonical}/kpis", @@ -215,7 +330,12 @@ func (a *Client) GetKpis(params *GetKpisParams, authInfo runtime.ClientAuthInfoW AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -231,13 +351,12 @@ func (a *Client) GetKpis(params *GetKpisParams, authInfo runtime.ClientAuthInfoW /* UpdateKpi Update a KPI */ -func (a *Client) UpdateKpi(params *UpdateKpiParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateKpiOK, error) { +func (a *Client) UpdateKpi(params *UpdateKpiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateKpiOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateKpiParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateKpi", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/kpis/{kpi_canonical}", @@ -249,7 +368,12 @@ func (a *Client) UpdateKpi(params *UpdateKpiParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_kpis/update_kpi_parameters.go b/client/client/organization_kpis/update_kpi_parameters.go index 461c0a6e..2d2c4547 100644 --- a/client/client/organization_kpis/update_kpi_parameters.go +++ b/client/client/organization_kpis/update_kpi_parameters.go @@ -13,86 +13,95 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateKpiParams creates a new UpdateKpiParams object -// with the default values initialized. +// NewUpdateKpiParams creates a new UpdateKpiParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateKpiParams() *UpdateKpiParams { - var () return &UpdateKpiParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateKpiParamsWithTimeout creates a new UpdateKpiParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateKpiParamsWithTimeout(timeout time.Duration) *UpdateKpiParams { - var () return &UpdateKpiParams{ - timeout: timeout, } } // NewUpdateKpiParamsWithContext creates a new UpdateKpiParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateKpiParamsWithContext(ctx context.Context) *UpdateKpiParams { - var () return &UpdateKpiParams{ - Context: ctx, } } // NewUpdateKpiParamsWithHTTPClient creates a new UpdateKpiParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateKpiParamsWithHTTPClient(client *http.Client) *UpdateKpiParams { - var () return &UpdateKpiParams{ HTTPClient: client, } } -/*UpdateKpiParams contains all the parameters to send to the API endpoint -for the update kpi operation typically these are written to a http.Request +/* +UpdateKpiParams contains all the parameters to send to the API endpoint + + for the update kpi operation. + + Typically these are written to a http.Request. */ type UpdateKpiParams struct { - /*Begin - The unix timestamp in seconds, which indicate the start of the time range. + /* Begin. + + The unix timestamp in seconds, which indicate the start of the time range. + Format: uint64 */ Begin *uint64 - /*Body - The information of the KPI new data + /* Body. + + The information of the KPI new data */ Body *models.NewKPI - /*End - The unix timestamp in seconds, which indicate the end of the time range. + /* End. + + The unix timestamp in seconds, which indicate the end of the time range. + + Format: uint64 */ End *uint64 - /*FetchData - Flag to retrieve KPIs' data upon retrieving KPIs themselves + /* FetchData. + + Flag to retrieve KPIs' data upon retrieving KPIs themselves */ FetchData *bool - /*KpiCanonical - A canonical of a kpi. + /* KpiCanonical. + + A canonical of a kpi. */ KpiCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -101,6 +110,21 @@ type UpdateKpiParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update kpi params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateKpiParams) WithDefaults() *UpdateKpiParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update kpi params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateKpiParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update kpi params func (o *UpdateKpiParams) WithTimeout(timeout time.Duration) *UpdateKpiParams { o.SetTimeout(timeout) @@ -212,18 +236,18 @@ func (o *UpdateKpiParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg // query param begin var qrBegin uint64 + if o.Begin != nil { qrBegin = *o.Begin } qBegin := swag.FormatUint64(qrBegin) if qBegin != "" { + if err := r.SetQueryParam("begin", qBegin); err != nil { return err } } - } - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err @@ -234,32 +258,34 @@ func (o *UpdateKpiParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg // query param end var qrEnd uint64 + if o.End != nil { qrEnd = *o.End } qEnd := swag.FormatUint64(qrEnd) if qEnd != "" { + if err := r.SetQueryParam("end", qEnd); err != nil { return err } } - } if o.FetchData != nil { // query param fetch_data var qrFetchData bool + if o.FetchData != nil { qrFetchData = *o.FetchData } qFetchData := swag.FormatBool(qrFetchData) if qFetchData != "" { + if err := r.SetQueryParam("fetch_data", qFetchData); err != nil { return err } } - } // path param kpi_canonical diff --git a/client/client/organization_kpis/update_kpi_responses.go b/client/client/organization_kpis/update_kpi_responses.go index c43b7248..980c6a50 100644 --- a/client/client/organization_kpis/update_kpi_responses.go +++ b/client/client/organization_kpis/update_kpi_responses.go @@ -6,17 +6,18 @@ package organization_kpis // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateKpiReader is a Reader for the UpdateKpi structure. @@ -74,7 +75,8 @@ func NewUpdateKpiOK() *UpdateKpiOK { return &UpdateKpiOK{} } -/*UpdateKpiOK handles this case with default header values. +/* +UpdateKpiOK describes a response with status code 200, with default header values. Success update */ @@ -82,8 +84,44 @@ type UpdateKpiOK struct { Payload *UpdateKpiOKBody } +// IsSuccess returns true when this update kpi o k response has a 2xx status code +func (o *UpdateKpiOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update kpi o k response has a 3xx status code +func (o *UpdateKpiOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update kpi o k response has a 4xx status code +func (o *UpdateKpiOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update kpi o k response has a 5xx status code +func (o *UpdateKpiOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update kpi o k response a status code equal to that given +func (o *UpdateKpiOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update kpi o k response +func (o *UpdateKpiOK) Code() int { + return 200 +} + func (o *UpdateKpiOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiOK %s", 200, payload) +} + +func (o *UpdateKpiOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiOK %s", 200, payload) } func (o *UpdateKpiOK) GetPayload() *UpdateKpiOKBody { @@ -107,20 +145,60 @@ func NewUpdateKpiForbidden() *UpdateKpiForbidden { return &UpdateKpiForbidden{} } -/*UpdateKpiForbidden handles this case with default header values. +/* +UpdateKpiForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateKpiForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update kpi forbidden response has a 2xx status code +func (o *UpdateKpiForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update kpi forbidden response has a 3xx status code +func (o *UpdateKpiForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update kpi forbidden response has a 4xx status code +func (o *UpdateKpiForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update kpi forbidden response has a 5xx status code +func (o *UpdateKpiForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update kpi forbidden response a status code equal to that given +func (o *UpdateKpiForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update kpi forbidden response +func (o *UpdateKpiForbidden) Code() int { + return 403 +} + func (o *UpdateKpiForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiForbidden %s", 403, payload) +} + +func (o *UpdateKpiForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiForbidden %s", 403, payload) } func (o *UpdateKpiForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *UpdateKpiForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateKpiForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewUpdateKpiNotFound() *UpdateKpiNotFound { return &UpdateKpiNotFound{} } -/*UpdateKpiNotFound handles this case with default header values. +/* +UpdateKpiNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateKpiNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update kpi not found response has a 2xx status code +func (o *UpdateKpiNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update kpi not found response has a 3xx status code +func (o *UpdateKpiNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update kpi not found response has a 4xx status code +func (o *UpdateKpiNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update kpi not found response has a 5xx status code +func (o *UpdateKpiNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update kpi not found response a status code equal to that given +func (o *UpdateKpiNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update kpi not found response +func (o *UpdateKpiNotFound) Code() int { + return 404 +} + func (o *UpdateKpiNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiNotFound %s", 404, payload) +} + +func (o *UpdateKpiNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiNotFound %s", 404, payload) } func (o *UpdateKpiNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *UpdateKpiNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateKpiNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewUpdateKpiLengthRequired() *UpdateKpiLengthRequired { return &UpdateKpiLengthRequired{} } -/*UpdateKpiLengthRequired handles this case with default header values. +/* +UpdateKpiLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateKpiLengthRequired struct { } +// IsSuccess returns true when this update kpi length required response has a 2xx status code +func (o *UpdateKpiLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update kpi length required response has a 3xx status code +func (o *UpdateKpiLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update kpi length required response has a 4xx status code +func (o *UpdateKpiLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update kpi length required response has a 5xx status code +func (o *UpdateKpiLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update kpi length required response a status code equal to that given +func (o *UpdateKpiLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update kpi length required response +func (o *UpdateKpiLengthRequired) Code() int { + return 411 +} + func (o *UpdateKpiLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiLengthRequired", 411) +} + +func (o *UpdateKpiLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiLengthRequired", 411) } func (o *UpdateKpiLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewUpdateKpiUnprocessableEntity() *UpdateKpiUnprocessableEntity { return &UpdateKpiUnprocessableEntity{} } -/*UpdateKpiUnprocessableEntity handles this case with default header values. +/* +UpdateKpiUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateKpiUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update kpi unprocessable entity response has a 2xx status code +func (o *UpdateKpiUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update kpi unprocessable entity response has a 3xx status code +func (o *UpdateKpiUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update kpi unprocessable entity response has a 4xx status code +func (o *UpdateKpiUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update kpi unprocessable entity response has a 5xx status code +func (o *UpdateKpiUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update kpi unprocessable entity response a status code equal to that given +func (o *UpdateKpiUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update kpi unprocessable entity response +func (o *UpdateKpiUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateKpiUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateKpiUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpiUnprocessableEntity %s", 422, payload) } func (o *UpdateKpiUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *UpdateKpiUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *UpdateKpiUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewUpdateKpiDefault(code int) *UpdateKpiDefault { } } -/*UpdateKpiDefault handles this case with default header values. +/* +UpdateKpiDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateKpiDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update kpi default response has a 2xx status code +func (o *UpdateKpiDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update kpi default response has a 3xx status code +func (o *UpdateKpiDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update kpi default response has a 4xx status code +func (o *UpdateKpiDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update kpi default response has a 5xx status code +func (o *UpdateKpiDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update kpi default response a status code equal to that given +func (o *UpdateKpiDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update kpi default response func (o *UpdateKpiDefault) Code() int { return o._statusCode } func (o *UpdateKpiDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpi default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpi default %s", o._statusCode, payload) +} + +func (o *UpdateKpiDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/kpis/{kpi_canonical}][%d] updateKpi default %s", o._statusCode, payload) } func (o *UpdateKpiDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *UpdateKpiDefault) GetPayload() *models.ErrorPayload { func (o *UpdateKpiDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *UpdateKpiDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*UpdateKpiOKBody update kpi o k body +/* +UpdateKpiOKBody update kpi o k body swagger:model UpdateKpiOKBody */ type UpdateKpiOKBody struct { @@ -342,6 +586,39 @@ func (o *UpdateKpiOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateKpiOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateKpiOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update kpi o k body based on the context it is used +func (o *UpdateKpiOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateKpiOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateKpiOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateKpiOK" + "." + "data") } return err } diff --git a/client/client/organization_members/get_org_member_parameters.go b/client/client/organization_members/get_org_member_parameters.go index 37bdb003..b6fea4f1 100644 --- a/client/client/organization_members/get_org_member_parameters.go +++ b/client/client/organization_members/get_org_member_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetOrgMemberParams creates a new GetOrgMemberParams object -// with the default values initialized. +// NewGetOrgMemberParams creates a new GetOrgMemberParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetOrgMemberParams() *GetOrgMemberParams { - var () return &GetOrgMemberParams{ - timeout: cr.DefaultTimeout, } } // NewGetOrgMemberParamsWithTimeout creates a new GetOrgMemberParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetOrgMemberParamsWithTimeout(timeout time.Duration) *GetOrgMemberParams { - var () return &GetOrgMemberParams{ - timeout: timeout, } } // NewGetOrgMemberParamsWithContext creates a new GetOrgMemberParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetOrgMemberParamsWithContext(ctx context.Context) *GetOrgMemberParams { - var () return &GetOrgMemberParams{ - Context: ctx, } } // NewGetOrgMemberParamsWithHTTPClient creates a new GetOrgMemberParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetOrgMemberParamsWithHTTPClient(client *http.Client) *GetOrgMemberParams { - var () return &GetOrgMemberParams{ HTTPClient: client, } } -/*GetOrgMemberParams contains all the parameters to send to the API endpoint -for the get org member operation typically these are written to a http.Request +/* +GetOrgMemberParams contains all the parameters to send to the API endpoint + + for the get org member operation. + + Typically these are written to a http.Request. */ type GetOrgMemberParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*Username - A username + /* Username. + + A username */ Username string @@ -77,6 +78,21 @@ type GetOrgMemberParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get org member params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgMemberParams) WithDefaults() *GetOrgMemberParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get org member params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgMemberParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get org member params func (o *GetOrgMemberParams) WithTimeout(timeout time.Duration) *GetOrgMemberParams { o.SetTimeout(timeout) diff --git a/client/client/organization_members/get_org_member_responses.go b/client/client/organization_members/get_org_member_responses.go index cca190bf..e0f58505 100644 --- a/client/client/organization_members/get_org_member_responses.go +++ b/client/client/organization_members/get_org_member_responses.go @@ -6,17 +6,18 @@ package organization_members // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetOrgMemberReader is a Reader for the GetOrgMember structure. @@ -62,7 +63,8 @@ func NewGetOrgMemberOK() *GetOrgMemberOK { return &GetOrgMemberOK{} } -/*GetOrgMemberOK handles this case with default header values. +/* +GetOrgMemberOK describes a response with status code 200, with default header values. The information of the member of the organization. */ @@ -70,8 +72,44 @@ type GetOrgMemberOK struct { Payload *GetOrgMemberOKBody } +// IsSuccess returns true when this get org member o k response has a 2xx status code +func (o *GetOrgMemberOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get org member o k response has a 3xx status code +func (o *GetOrgMemberOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org member o k response has a 4xx status code +func (o *GetOrgMemberOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get org member o k response has a 5xx status code +func (o *GetOrgMemberOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get org member o k response a status code equal to that given +func (o *GetOrgMemberOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get org member o k response +func (o *GetOrgMemberOK) Code() int { + return 200 +} + func (o *GetOrgMemberOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberOK %s", 200, payload) +} + +func (o *GetOrgMemberOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberOK %s", 200, payload) } func (o *GetOrgMemberOK) GetPayload() *GetOrgMemberOKBody { @@ -95,20 +133,60 @@ func NewGetOrgMemberForbidden() *GetOrgMemberForbidden { return &GetOrgMemberForbidden{} } -/*GetOrgMemberForbidden handles this case with default header values. +/* +GetOrgMemberForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetOrgMemberForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org member forbidden response has a 2xx status code +func (o *GetOrgMemberForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get org member forbidden response has a 3xx status code +func (o *GetOrgMemberForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org member forbidden response has a 4xx status code +func (o *GetOrgMemberForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get org member forbidden response has a 5xx status code +func (o *GetOrgMemberForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get org member forbidden response a status code equal to that given +func (o *GetOrgMemberForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get org member forbidden response +func (o *GetOrgMemberForbidden) Code() int { + return 403 +} + func (o *GetOrgMemberForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberForbidden %s", 403, payload) +} + +func (o *GetOrgMemberForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberForbidden %s", 403, payload) } func (o *GetOrgMemberForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetOrgMemberForbidden) GetPayload() *models.ErrorPayload { func (o *GetOrgMemberForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetOrgMemberNotFound() *GetOrgMemberNotFound { return &GetOrgMemberNotFound{} } -/*GetOrgMemberNotFound handles this case with default header values. +/* +GetOrgMemberNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetOrgMemberNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org member not found response has a 2xx status code +func (o *GetOrgMemberNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get org member not found response has a 3xx status code +func (o *GetOrgMemberNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org member not found response has a 4xx status code +func (o *GetOrgMemberNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get org member not found response has a 5xx status code +func (o *GetOrgMemberNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get org member not found response a status code equal to that given +func (o *GetOrgMemberNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get org member not found response +func (o *GetOrgMemberNotFound) Code() int { + return 404 +} + func (o *GetOrgMemberNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberNotFound %s", 404, payload) +} + +func (o *GetOrgMemberNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMemberNotFound %s", 404, payload) } func (o *GetOrgMemberNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetOrgMemberNotFound) GetPayload() *models.ErrorPayload { func (o *GetOrgMemberNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetOrgMemberDefault(code int) *GetOrgMemberDefault { } } -/*GetOrgMemberDefault handles this case with default header values. +/* +GetOrgMemberDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetOrgMemberDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org member default response has a 2xx status code +func (o *GetOrgMemberDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get org member default response has a 3xx status code +func (o *GetOrgMemberDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get org member default response has a 4xx status code +func (o *GetOrgMemberDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get org member default response has a 5xx status code +func (o *GetOrgMemberDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get org member default response a status code equal to that given +func (o *GetOrgMemberDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get org member default response func (o *GetOrgMemberDefault) Code() int { return o._statusCode } func (o *GetOrgMemberDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMember default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMember default %s", o._statusCode, payload) +} + +func (o *GetOrgMemberDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members/{username}][%d] getOrgMember default %s", o._statusCode, payload) } func (o *GetOrgMemberDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetOrgMemberDefault) GetPayload() *models.ErrorPayload { func (o *GetOrgMemberDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetOrgMemberDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*GetOrgMemberOKBody get org member o k body +/* +GetOrgMemberOKBody get org member o k body swagger:model GetOrgMemberOKBody */ type GetOrgMemberOKBody struct { @@ -265,6 +430,39 @@ func (o *GetOrgMemberOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getOrgMemberOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgMemberOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get org member o k body based on the context it is used +func (o *GetOrgMemberOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetOrgMemberOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getOrgMemberOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgMemberOK" + "." + "data") } return err } diff --git a/client/client/organization_members/get_org_members_parameters.go b/client/client/organization_members/get_org_members_parameters.go index d29846bd..ac4609b5 100644 --- a/client/client/organization_members/get_org_members_parameters.go +++ b/client/client/organization_members/get_org_members_parameters.go @@ -13,124 +13,123 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetOrgMembersParams creates a new GetOrgMembersParams object -// with the default values initialized. +// NewGetOrgMembersParams creates a new GetOrgMembersParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetOrgMembersParams() *GetOrgMembersParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetOrgMembersParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetOrgMembersParamsWithTimeout creates a new GetOrgMembersParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetOrgMembersParamsWithTimeout(timeout time.Duration) *GetOrgMembersParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetOrgMembersParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetOrgMembersParamsWithContext creates a new GetOrgMembersParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetOrgMembersParamsWithContext(ctx context.Context) *GetOrgMembersParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetOrgMembersParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetOrgMembersParamsWithHTTPClient creates a new GetOrgMembersParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetOrgMembersParamsWithHTTPClient(client *http.Client) *GetOrgMembersParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetOrgMembersParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetOrgMembersParams contains all the parameters to send to the API endpoint -for the get org members operation typically these are written to a http.Request +/* +GetOrgMembersParams contains all the parameters to send to the API endpoint + + for the get org members operation. + + Typically these are written to a http.Request. */ type GetOrgMembersParams struct { - /*MemberCreatedAt - Search by member joining date + /* MemberCreatedAt. + + Search by member joining date + Format: uint64 */ MemberCreatedAt *uint64 - /*OrderBy - Allows to order the list of items. Example usage: field_name:asc + /* OrderBy. + + Allows to order the list of items. Example usage: field_name:asc */ OrderBy *string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*RoleName - Search by the role's name + /* RoleName. + + Search by the role's name */ RoleName *string - /*UserCanonical - Search by the user canonical + /* UserCanonical. + + Search by the user canonical */ UserCanonical *string - /*UserCreatedAt - Search by user creation date + /* UserCreatedAt. + + Search by user creation date + + Format: uint64 */ UserCreatedAt *uint64 - /*UserFamilyName - Search by the user's family name + /* UserFamilyName. + + Search by the user's family name */ UserFamilyName *string - /*UserGivenName - Search by the user's given name + /* UserGivenName. + + Search by the user's given name */ UserGivenName *string @@ -139,6 +138,35 @@ type GetOrgMembersParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get org members params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgMembersParams) WithDefaults() *GetOrgMembersParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get org members params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgMembersParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetOrgMembersParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get org members params func (o *GetOrgMembersParams) WithTimeout(timeout time.Duration) *GetOrgMembersParams { o.SetTimeout(timeout) @@ -294,32 +322,34 @@ func (o *GetOrgMembersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt // query param member_created_at var qrMemberCreatedAt uint64 + if o.MemberCreatedAt != nil { qrMemberCreatedAt = *o.MemberCreatedAt } qMemberCreatedAt := swag.FormatUint64(qrMemberCreatedAt) if qMemberCreatedAt != "" { + if err := r.SetQueryParam("member_created_at", qMemberCreatedAt); err != nil { return err } } - } if o.OrderBy != nil { // query param order_by var qrOrderBy string + if o.OrderBy != nil { qrOrderBy = *o.OrderBy } qOrderBy := qrOrderBy if qOrderBy != "" { + if err := r.SetQueryParam("order_by", qOrderBy); err != nil { return err } } - } // path param organization_canonical @@ -331,112 +361,119 @@ func (o *GetOrgMembersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if o.RoleName != nil { // query param role_name var qrRoleName string + if o.RoleName != nil { qrRoleName = *o.RoleName } qRoleName := qrRoleName if qRoleName != "" { + if err := r.SetQueryParam("role_name", qRoleName); err != nil { return err } } - } if o.UserCanonical != nil { // query param user_canonical var qrUserCanonical string + if o.UserCanonical != nil { qrUserCanonical = *o.UserCanonical } qUserCanonical := qrUserCanonical if qUserCanonical != "" { + if err := r.SetQueryParam("user_canonical", qUserCanonical); err != nil { return err } } - } if o.UserCreatedAt != nil { // query param user_created_at var qrUserCreatedAt uint64 + if o.UserCreatedAt != nil { qrUserCreatedAt = *o.UserCreatedAt } qUserCreatedAt := swag.FormatUint64(qrUserCreatedAt) if qUserCreatedAt != "" { + if err := r.SetQueryParam("user_created_at", qUserCreatedAt); err != nil { return err } } - } if o.UserFamilyName != nil { // query param user_family_name var qrUserFamilyName string + if o.UserFamilyName != nil { qrUserFamilyName = *o.UserFamilyName } qUserFamilyName := qrUserFamilyName if qUserFamilyName != "" { + if err := r.SetQueryParam("user_family_name", qUserFamilyName); err != nil { return err } } - } if o.UserGivenName != nil { // query param user_given_name var qrUserGivenName string + if o.UserGivenName != nil { qrUserGivenName = *o.UserGivenName } qUserGivenName := qrUserGivenName if qUserGivenName != "" { + if err := r.SetQueryParam("user_given_name", qUserGivenName); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_members/get_org_members_responses.go b/client/client/organization_members/get_org_members_responses.go index e244f9b2..6244a68e 100644 --- a/client/client/organization_members/get_org_members_responses.go +++ b/client/client/organization_members/get_org_members_responses.go @@ -6,18 +6,19 @@ package organization_members // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetOrgMembersReader is a Reader for the GetOrgMembers structure. @@ -69,7 +70,8 @@ func NewGetOrgMembersOK() *GetOrgMembersOK { return &GetOrgMembersOK{} } -/*GetOrgMembersOK handles this case with default header values. +/* +GetOrgMembersOK describes a response with status code 200, with default header values. List of the members of the organization. */ @@ -77,8 +79,44 @@ type GetOrgMembersOK struct { Payload *GetOrgMembersOKBody } +// IsSuccess returns true when this get org members o k response has a 2xx status code +func (o *GetOrgMembersOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get org members o k response has a 3xx status code +func (o *GetOrgMembersOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org members o k response has a 4xx status code +func (o *GetOrgMembersOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get org members o k response has a 5xx status code +func (o *GetOrgMembersOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get org members o k response a status code equal to that given +func (o *GetOrgMembersOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get org members o k response +func (o *GetOrgMembersOK) Code() int { + return 200 +} + func (o *GetOrgMembersOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersOK %s", 200, payload) +} + +func (o *GetOrgMembersOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersOK %s", 200, payload) } func (o *GetOrgMembersOK) GetPayload() *GetOrgMembersOKBody { @@ -102,20 +140,60 @@ func NewGetOrgMembersForbidden() *GetOrgMembersForbidden { return &GetOrgMembersForbidden{} } -/*GetOrgMembersForbidden handles this case with default header values. +/* +GetOrgMembersForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetOrgMembersForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org members forbidden response has a 2xx status code +func (o *GetOrgMembersForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get org members forbidden response has a 3xx status code +func (o *GetOrgMembersForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org members forbidden response has a 4xx status code +func (o *GetOrgMembersForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get org members forbidden response has a 5xx status code +func (o *GetOrgMembersForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get org members forbidden response a status code equal to that given +func (o *GetOrgMembersForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get org members forbidden response +func (o *GetOrgMembersForbidden) Code() int { + return 403 +} + func (o *GetOrgMembersForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersForbidden %s", 403, payload) +} + +func (o *GetOrgMembersForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersForbidden %s", 403, payload) } func (o *GetOrgMembersForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetOrgMembersForbidden) GetPayload() *models.ErrorPayload { func (o *GetOrgMembersForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetOrgMembersNotFound() *GetOrgMembersNotFound { return &GetOrgMembersNotFound{} } -/*GetOrgMembersNotFound handles this case with default header values. +/* +GetOrgMembersNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetOrgMembersNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org members not found response has a 2xx status code +func (o *GetOrgMembersNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get org members not found response has a 3xx status code +func (o *GetOrgMembersNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org members not found response has a 4xx status code +func (o *GetOrgMembersNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get org members not found response has a 5xx status code +func (o *GetOrgMembersNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get org members not found response a status code equal to that given +func (o *GetOrgMembersNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get org members not found response +func (o *GetOrgMembersNotFound) Code() int { + return 404 +} + func (o *GetOrgMembersNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersNotFound %s", 404, payload) +} + +func (o *GetOrgMembersNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersNotFound %s", 404, payload) } func (o *GetOrgMembersNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetOrgMembersNotFound) GetPayload() *models.ErrorPayload { func (o *GetOrgMembersNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetOrgMembersUnprocessableEntity() *GetOrgMembersUnprocessableEntity { return &GetOrgMembersUnprocessableEntity{} } -/*GetOrgMembersUnprocessableEntity handles this case with default header values. +/* +GetOrgMembersUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetOrgMembersUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org members unprocessable entity response has a 2xx status code +func (o *GetOrgMembersUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get org members unprocessable entity response has a 3xx status code +func (o *GetOrgMembersUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org members unprocessable entity response has a 4xx status code +func (o *GetOrgMembersUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get org members unprocessable entity response has a 5xx status code +func (o *GetOrgMembersUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get org members unprocessable entity response a status code equal to that given +func (o *GetOrgMembersUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get org members unprocessable entity response +func (o *GetOrgMembersUnprocessableEntity) Code() int { + return 422 +} + func (o *GetOrgMembersUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersUnprocessableEntity %s", 422, payload) +} + +func (o *GetOrgMembersUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembersUnprocessableEntity %s", 422, payload) } func (o *GetOrgMembersUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetOrgMembersUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetOrgMembersUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetOrgMembersDefault(code int) *GetOrgMembersDefault { } } -/*GetOrgMembersDefault handles this case with default header values. +/* +GetOrgMembersDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetOrgMembersDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org members default response has a 2xx status code +func (o *GetOrgMembersDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get org members default response has a 3xx status code +func (o *GetOrgMembersDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get org members default response has a 4xx status code +func (o *GetOrgMembersDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get org members default response has a 5xx status code +func (o *GetOrgMembersDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get org members default response a status code equal to that given +func (o *GetOrgMembersDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get org members default response func (o *GetOrgMembersDefault) Code() int { return o._statusCode } func (o *GetOrgMembersDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembers default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembers default %s", o._statusCode, payload) +} + +func (o *GetOrgMembersDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/members][%d] getOrgMembers default %s", o._statusCode, payload) } func (o *GetOrgMembersDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetOrgMembersDefault) GetPayload() *models.ErrorPayload { func (o *GetOrgMembersDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetOrgMembersDefault) readResponse(response runtime.ClientResponse, con return nil } -/*GetOrgMembersOKBody get org members o k body +/* +GetOrgMembersOKBody get org members o k body swagger:model GetOrgMembersOKBody */ type GetOrgMembersOKBody struct { @@ -329,6 +538,8 @@ func (o *GetOrgMembersOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getOrgMembersOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgMembersOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -349,6 +560,68 @@ func (o *GetOrgMembersOKBody) validatePagination(formats strfmt.Registry) error if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getOrgMembersOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgMembersOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get org members o k body based on the context it is used +func (o *GetOrgMembersOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetOrgMembersOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getOrgMembersOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgMembersOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetOrgMembersOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getOrgMembersOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgMembersOK" + "." + "pagination") } return err } diff --git a/client/client/organization_members/invite_user_to_org_member_parameters.go b/client/client/organization_members/invite_user_to_org_member_parameters.go index d5bf49b3..03735173 100644 --- a/client/client/organization_members/invite_user_to_org_member_parameters.go +++ b/client/client/organization_members/invite_user_to_org_member_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewInviteUserToOrgMemberParams creates a new InviteUserToOrgMemberParams object -// with the default values initialized. +// NewInviteUserToOrgMemberParams creates a new InviteUserToOrgMemberParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewInviteUserToOrgMemberParams() *InviteUserToOrgMemberParams { - var () return &InviteUserToOrgMemberParams{ - timeout: cr.DefaultTimeout, } } // NewInviteUserToOrgMemberParamsWithTimeout creates a new InviteUserToOrgMemberParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewInviteUserToOrgMemberParamsWithTimeout(timeout time.Duration) *InviteUserToOrgMemberParams { - var () return &InviteUserToOrgMemberParams{ - timeout: timeout, } } // NewInviteUserToOrgMemberParamsWithContext creates a new InviteUserToOrgMemberParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewInviteUserToOrgMemberParamsWithContext(ctx context.Context) *InviteUserToOrgMemberParams { - var () return &InviteUserToOrgMemberParams{ - Context: ctx, } } // NewInviteUserToOrgMemberParamsWithHTTPClient creates a new InviteUserToOrgMemberParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewInviteUserToOrgMemberParamsWithHTTPClient(client *http.Client) *InviteUserToOrgMemberParams { - var () return &InviteUserToOrgMemberParams{ HTTPClient: client, } } -/*InviteUserToOrgMemberParams contains all the parameters to send to the API endpoint -for the invite user to org member operation typically these are written to a http.Request +/* +InviteUserToOrgMemberParams contains all the parameters to send to the API endpoint + + for the invite user to org member operation. + + Typically these are written to a http.Request. */ type InviteUserToOrgMemberParams struct { - /*Body - The user's member invitation. + /* Body. + The user's member invitation. */ Body *models.NewMemberInvitation - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type InviteUserToOrgMemberParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the invite user to org member params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InviteUserToOrgMemberParams) WithDefaults() *InviteUserToOrgMemberParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the invite user to org member params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InviteUserToOrgMemberParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the invite user to org member params func (o *InviteUserToOrgMemberParams) WithTimeout(timeout time.Duration) *InviteUserToOrgMemberParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *InviteUserToOrgMemberParams) WriteToRequest(r runtime.ClientRequest, re return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_members/invite_user_to_org_member_responses.go b/client/client/organization_members/invite_user_to_org_member_responses.go index ac7e59d3..597dee1b 100644 --- a/client/client/organization_members/invite_user_to_org_member_responses.go +++ b/client/client/organization_members/invite_user_to_org_member_responses.go @@ -6,16 +6,16 @@ package organization_members // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // InviteUserToOrgMemberReader is a Reader for the InviteUserToOrgMember structure. @@ -67,15 +67,50 @@ func NewInviteUserToOrgMemberNoContent() *InviteUserToOrgMemberNoContent { return &InviteUserToOrgMemberNoContent{} } -/*InviteUserToOrgMemberNoContent handles this case with default header values. +/* +InviteUserToOrgMemberNoContent describes a response with status code 204, with default header values. The user has been invited to be a member of the organization. The verification is pending. */ type InviteUserToOrgMemberNoContent struct { } +// IsSuccess returns true when this invite user to org member no content response has a 2xx status code +func (o *InviteUserToOrgMemberNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this invite user to org member no content response has a 3xx status code +func (o *InviteUserToOrgMemberNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this invite user to org member no content response has a 4xx status code +func (o *InviteUserToOrgMemberNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this invite user to org member no content response has a 5xx status code +func (o *InviteUserToOrgMemberNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this invite user to org member no content response a status code equal to that given +func (o *InviteUserToOrgMemberNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the invite user to org member no content response +func (o *InviteUserToOrgMemberNoContent) Code() int { + return 204 +} + func (o *InviteUserToOrgMemberNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberNoContent", 204) +} + +func (o *InviteUserToOrgMemberNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberNoContent", 204) } func (o *InviteUserToOrgMemberNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -88,20 +123,60 @@ func NewInviteUserToOrgMemberNotFound() *InviteUserToOrgMemberNotFound { return &InviteUserToOrgMemberNotFound{} } -/*InviteUserToOrgMemberNotFound handles this case with default header values. +/* +InviteUserToOrgMemberNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type InviteUserToOrgMemberNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this invite user to org member not found response has a 2xx status code +func (o *InviteUserToOrgMemberNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this invite user to org member not found response has a 3xx status code +func (o *InviteUserToOrgMemberNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this invite user to org member not found response has a 4xx status code +func (o *InviteUserToOrgMemberNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this invite user to org member not found response has a 5xx status code +func (o *InviteUserToOrgMemberNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this invite user to org member not found response a status code equal to that given +func (o *InviteUserToOrgMemberNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the invite user to org member not found response +func (o *InviteUserToOrgMemberNotFound) Code() int { + return 404 +} + func (o *InviteUserToOrgMemberNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberNotFound %s", 404, payload) +} + +func (o *InviteUserToOrgMemberNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberNotFound %s", 404, payload) } func (o *InviteUserToOrgMemberNotFound) GetPayload() *models.ErrorPayload { @@ -110,12 +185,16 @@ func (o *InviteUserToOrgMemberNotFound) GetPayload() *models.ErrorPayload { func (o *InviteUserToOrgMemberNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -132,15 +211,50 @@ func NewInviteUserToOrgMemberLengthRequired() *InviteUserToOrgMemberLengthRequir return &InviteUserToOrgMemberLengthRequired{} } -/*InviteUserToOrgMemberLengthRequired handles this case with default header values. +/* +InviteUserToOrgMemberLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type InviteUserToOrgMemberLengthRequired struct { } +// IsSuccess returns true when this invite user to org member length required response has a 2xx status code +func (o *InviteUserToOrgMemberLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this invite user to org member length required response has a 3xx status code +func (o *InviteUserToOrgMemberLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this invite user to org member length required response has a 4xx status code +func (o *InviteUserToOrgMemberLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this invite user to org member length required response has a 5xx status code +func (o *InviteUserToOrgMemberLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this invite user to org member length required response a status code equal to that given +func (o *InviteUserToOrgMemberLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the invite user to org member length required response +func (o *InviteUserToOrgMemberLengthRequired) Code() int { + return 411 +} + func (o *InviteUserToOrgMemberLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberLengthRequired", 411) +} + +func (o *InviteUserToOrgMemberLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberLengthRequired", 411) } func (o *InviteUserToOrgMemberLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -153,20 +267,60 @@ func NewInviteUserToOrgMemberUnprocessableEntity() *InviteUserToOrgMemberUnproce return &InviteUserToOrgMemberUnprocessableEntity{} } -/*InviteUserToOrgMemberUnprocessableEntity handles this case with default header values. +/* +InviteUserToOrgMemberUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type InviteUserToOrgMemberUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this invite user to org member unprocessable entity response has a 2xx status code +func (o *InviteUserToOrgMemberUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this invite user to org member unprocessable entity response has a 3xx status code +func (o *InviteUserToOrgMemberUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this invite user to org member unprocessable entity response has a 4xx status code +func (o *InviteUserToOrgMemberUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this invite user to org member unprocessable entity response has a 5xx status code +func (o *InviteUserToOrgMemberUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this invite user to org member unprocessable entity response a status code equal to that given +func (o *InviteUserToOrgMemberUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the invite user to org member unprocessable entity response +func (o *InviteUserToOrgMemberUnprocessableEntity) Code() int { + return 422 +} + func (o *InviteUserToOrgMemberUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberUnprocessableEntity %s", 422, payload) +} + +func (o *InviteUserToOrgMemberUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMemberUnprocessableEntity %s", 422, payload) } func (o *InviteUserToOrgMemberUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -175,12 +329,16 @@ func (o *InviteUserToOrgMemberUnprocessableEntity) GetPayload() *models.ErrorPay func (o *InviteUserToOrgMemberUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -199,27 +357,61 @@ func NewInviteUserToOrgMemberDefault(code int) *InviteUserToOrgMemberDefault { } } -/*InviteUserToOrgMemberDefault handles this case with default header values. +/* +InviteUserToOrgMemberDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type InviteUserToOrgMemberDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this invite user to org member default response has a 2xx status code +func (o *InviteUserToOrgMemberDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this invite user to org member default response has a 3xx status code +func (o *InviteUserToOrgMemberDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this invite user to org member default response has a 4xx status code +func (o *InviteUserToOrgMemberDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this invite user to org member default response has a 5xx status code +func (o *InviteUserToOrgMemberDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this invite user to org member default response a status code equal to that given +func (o *InviteUserToOrgMemberDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the invite user to org member default response func (o *InviteUserToOrgMemberDefault) Code() int { return o._statusCode } func (o *InviteUserToOrgMemberDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMember default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMember default %s", o._statusCode, payload) +} + +func (o *InviteUserToOrgMemberDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members-invitations][%d] inviteUserToOrgMember default %s", o._statusCode, payload) } func (o *InviteUserToOrgMemberDefault) GetPayload() *models.ErrorPayload { @@ -228,12 +420,16 @@ func (o *InviteUserToOrgMemberDefault) GetPayload() *models.ErrorPayload { func (o *InviteUserToOrgMemberDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_members/organization_members_client.go b/client/client/organization_members/organization_members_client.go index a9b00cdd..32e024af 100644 --- a/client/client/organization_members/organization_members_client.go +++ b/client/client/organization_members/organization_members_client.go @@ -7,15 +7,40 @@ package organization_members import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization members API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization members API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization members API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization members API */ @@ -24,16 +49,82 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + GetOrgMember(params *GetOrgMemberParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgMemberOK, error) + + GetOrgMembers(params *GetOrgMembersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgMembersOK, error) + + InviteUserToOrgMember(params *InviteUserToOrgMemberParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InviteUserToOrgMemberNoContent, error) + + RemoveOrgMember(params *RemoveOrgMemberParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoveOrgMemberNoContent, error) + + UpdateOrgMember(params *UpdateOrgMemberParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOrgMemberOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* GetOrgMember Get the information of a member of the organization. */ -func (a *Client) GetOrgMember(params *GetOrgMemberParams, authInfo runtime.ClientAuthInfoWriter) (*GetOrgMemberOK, error) { +func (a *Client) GetOrgMember(params *GetOrgMemberParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgMemberOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetOrgMemberParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getOrgMember", Method: "GET", PathPattern: "/organizations/{organization_canonical}/members/{username}", @@ -45,7 +136,12 @@ func (a *Client) GetOrgMember(params *GetOrgMemberParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +157,12 @@ func (a *Client) GetOrgMember(params *GetOrgMemberParams, authInfo runtime.Clien /* GetOrgMembers Get the members of an organization. */ -func (a *Client) GetOrgMembers(params *GetOrgMembersParams, authInfo runtime.ClientAuthInfoWriter) (*GetOrgMembersOK, error) { +func (a *Client) GetOrgMembers(params *GetOrgMembersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgMembersOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetOrgMembersParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getOrgMembers", Method: "GET", PathPattern: "/organizations/{organization_canonical}/members", @@ -79,7 +174,12 @@ func (a *Client) GetOrgMembers(params *GetOrgMembersParams, authInfo runtime.Cli AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +195,12 @@ func (a *Client) GetOrgMembers(params *GetOrgMembersParams, authInfo runtime.Cli /* InviteUserToOrgMember Invite a user to be a member of the organization. */ -func (a *Client) InviteUserToOrgMember(params *InviteUserToOrgMemberParams, authInfo runtime.ClientAuthInfoWriter) (*InviteUserToOrgMemberNoContent, error) { +func (a *Client) InviteUserToOrgMember(params *InviteUserToOrgMemberParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InviteUserToOrgMemberNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewInviteUserToOrgMemberParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "inviteUserToOrgMember", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/members-invitations", @@ -113,7 +212,12 @@ func (a *Client) InviteUserToOrgMember(params *InviteUserToOrgMemberParams, auth AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +233,12 @@ func (a *Client) InviteUserToOrgMember(params *InviteUserToOrgMemberParams, auth /* RemoveOrgMember Remove a member of the organization. */ -func (a *Client) RemoveOrgMember(params *RemoveOrgMemberParams, authInfo runtime.ClientAuthInfoWriter) (*RemoveOrgMemberNoContent, error) { +func (a *Client) RemoveOrgMember(params *RemoveOrgMemberParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoveOrgMemberNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewRemoveOrgMemberParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "removeOrgMember", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/members/{username}", @@ -147,7 +250,12 @@ func (a *Client) RemoveOrgMember(params *RemoveOrgMemberParams, authInfo runtime AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +271,12 @@ func (a *Client) RemoveOrgMember(params *RemoveOrgMemberParams, authInfo runtime /* UpdateOrgMember Update member of the organization. */ -func (a *Client) UpdateOrgMember(params *UpdateOrgMemberParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateOrgMemberOK, error) { +func (a *Client) UpdateOrgMember(params *UpdateOrgMemberParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOrgMemberOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateOrgMemberParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateOrgMember", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/members/{username}", @@ -181,7 +288,12 @@ func (a *Client) UpdateOrgMember(params *UpdateOrgMemberParams, authInfo runtime AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_members/remove_org_member_parameters.go b/client/client/organization_members/remove_org_member_parameters.go index 8202418a..79ee71e1 100644 --- a/client/client/organization_members/remove_org_member_parameters.go +++ b/client/client/organization_members/remove_org_member_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewRemoveOrgMemberParams creates a new RemoveOrgMemberParams object -// with the default values initialized. +// NewRemoveOrgMemberParams creates a new RemoveOrgMemberParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewRemoveOrgMemberParams() *RemoveOrgMemberParams { - var () return &RemoveOrgMemberParams{ - timeout: cr.DefaultTimeout, } } // NewRemoveOrgMemberParamsWithTimeout creates a new RemoveOrgMemberParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewRemoveOrgMemberParamsWithTimeout(timeout time.Duration) *RemoveOrgMemberParams { - var () return &RemoveOrgMemberParams{ - timeout: timeout, } } // NewRemoveOrgMemberParamsWithContext creates a new RemoveOrgMemberParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewRemoveOrgMemberParamsWithContext(ctx context.Context) *RemoveOrgMemberParams { - var () return &RemoveOrgMemberParams{ - Context: ctx, } } // NewRemoveOrgMemberParamsWithHTTPClient creates a new RemoveOrgMemberParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewRemoveOrgMemberParamsWithHTTPClient(client *http.Client) *RemoveOrgMemberParams { - var () return &RemoveOrgMemberParams{ HTTPClient: client, } } -/*RemoveOrgMemberParams contains all the parameters to send to the API endpoint -for the remove org member operation typically these are written to a http.Request +/* +RemoveOrgMemberParams contains all the parameters to send to the API endpoint + + for the remove org member operation. + + Typically these are written to a http.Request. */ type RemoveOrgMemberParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*Username - A username + /* Username. + + A username */ Username string @@ -77,6 +78,21 @@ type RemoveOrgMemberParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the remove org member params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RemoveOrgMemberParams) WithDefaults() *RemoveOrgMemberParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the remove org member params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RemoveOrgMemberParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the remove org member params func (o *RemoveOrgMemberParams) WithTimeout(timeout time.Duration) *RemoveOrgMemberParams { o.SetTimeout(timeout) diff --git a/client/client/organization_members/remove_org_member_responses.go b/client/client/organization_members/remove_org_member_responses.go index e786b4f5..6b1a3399 100644 --- a/client/client/organization_members/remove_org_member_responses.go +++ b/client/client/organization_members/remove_org_member_responses.go @@ -6,16 +6,16 @@ package organization_members // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // RemoveOrgMemberReader is a Reader for the RemoveOrgMember structure. @@ -61,15 +61,50 @@ func NewRemoveOrgMemberNoContent() *RemoveOrgMemberNoContent { return &RemoveOrgMemberNoContent{} } -/*RemoveOrgMemberNoContent handles this case with default header values. +/* +RemoveOrgMemberNoContent describes a response with status code 204, with default header values. Member has been removed. */ type RemoveOrgMemberNoContent struct { } +// IsSuccess returns true when this remove org member no content response has a 2xx status code +func (o *RemoveOrgMemberNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this remove org member no content response has a 3xx status code +func (o *RemoveOrgMemberNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remove org member no content response has a 4xx status code +func (o *RemoveOrgMemberNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this remove org member no content response has a 5xx status code +func (o *RemoveOrgMemberNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this remove org member no content response a status code equal to that given +func (o *RemoveOrgMemberNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the remove org member no content response +func (o *RemoveOrgMemberNoContent) Code() int { + return 204 +} + func (o *RemoveOrgMemberNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberNoContent", 204) +} + +func (o *RemoveOrgMemberNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberNoContent", 204) } func (o *RemoveOrgMemberNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewRemoveOrgMemberForbidden() *RemoveOrgMemberForbidden { return &RemoveOrgMemberForbidden{} } -/*RemoveOrgMemberForbidden handles this case with default header values. +/* +RemoveOrgMemberForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type RemoveOrgMemberForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this remove org member forbidden response has a 2xx status code +func (o *RemoveOrgMemberForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this remove org member forbidden response has a 3xx status code +func (o *RemoveOrgMemberForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remove org member forbidden response has a 4xx status code +func (o *RemoveOrgMemberForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this remove org member forbidden response has a 5xx status code +func (o *RemoveOrgMemberForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this remove org member forbidden response a status code equal to that given +func (o *RemoveOrgMemberForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the remove org member forbidden response +func (o *RemoveOrgMemberForbidden) Code() int { + return 403 +} + func (o *RemoveOrgMemberForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberForbidden %s", 403, payload) +} + +func (o *RemoveOrgMemberForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberForbidden %s", 403, payload) } func (o *RemoveOrgMemberForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *RemoveOrgMemberForbidden) GetPayload() *models.ErrorPayload { func (o *RemoveOrgMemberForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewRemoveOrgMemberNotFound() *RemoveOrgMemberNotFound { return &RemoveOrgMemberNotFound{} } -/*RemoveOrgMemberNotFound handles this case with default header values. +/* +RemoveOrgMemberNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type RemoveOrgMemberNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this remove org member not found response has a 2xx status code +func (o *RemoveOrgMemberNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this remove org member not found response has a 3xx status code +func (o *RemoveOrgMemberNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remove org member not found response has a 4xx status code +func (o *RemoveOrgMemberNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this remove org member not found response has a 5xx status code +func (o *RemoveOrgMemberNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this remove org member not found response a status code equal to that given +func (o *RemoveOrgMemberNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the remove org member not found response +func (o *RemoveOrgMemberNotFound) Code() int { + return 404 +} + func (o *RemoveOrgMemberNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberNotFound %s", 404, payload) +} + +func (o *RemoveOrgMemberNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMemberNotFound %s", 404, payload) } func (o *RemoveOrgMemberNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *RemoveOrgMemberNotFound) GetPayload() *models.ErrorPayload { func (o *RemoveOrgMemberNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewRemoveOrgMemberDefault(code int) *RemoveOrgMemberDefault { } } -/*RemoveOrgMemberDefault handles this case with default header values. +/* +RemoveOrgMemberDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type RemoveOrgMemberDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this remove org member default response has a 2xx status code +func (o *RemoveOrgMemberDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this remove org member default response has a 3xx status code +func (o *RemoveOrgMemberDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this remove org member default response has a 4xx status code +func (o *RemoveOrgMemberDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this remove org member default response has a 5xx status code +func (o *RemoveOrgMemberDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this remove org member default response a status code equal to that given +func (o *RemoveOrgMemberDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the remove org member default response func (o *RemoveOrgMemberDefault) Code() int { return o._statusCode } func (o *RemoveOrgMemberDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMember default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMember default %s", o._statusCode, payload) +} + +func (o *RemoveOrgMemberDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/members/{username}][%d] removeOrgMember default %s", o._statusCode, payload) } func (o *RemoveOrgMemberDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *RemoveOrgMemberDefault) GetPayload() *models.ErrorPayload { func (o *RemoveOrgMemberDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_members/update_org_member_parameters.go b/client/client/organization_members/update_org_member_parameters.go index b3deb51c..0b2a8575 100644 --- a/client/client/organization_members/update_org_member_parameters.go +++ b/client/client/organization_members/update_org_member_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateOrgMemberParams creates a new UpdateOrgMemberParams object -// with the default values initialized. +// NewUpdateOrgMemberParams creates a new UpdateOrgMemberParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateOrgMemberParams() *UpdateOrgMemberParams { - var () return &UpdateOrgMemberParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateOrgMemberParamsWithTimeout creates a new UpdateOrgMemberParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateOrgMemberParamsWithTimeout(timeout time.Duration) *UpdateOrgMemberParams { - var () return &UpdateOrgMemberParams{ - timeout: timeout, } } // NewUpdateOrgMemberParamsWithContext creates a new UpdateOrgMemberParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateOrgMemberParamsWithContext(ctx context.Context) *UpdateOrgMemberParams { - var () return &UpdateOrgMemberParams{ - Context: ctx, } } // NewUpdateOrgMemberParamsWithHTTPClient creates a new UpdateOrgMemberParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateOrgMemberParamsWithHTTPClient(client *http.Client) *UpdateOrgMemberParams { - var () return &UpdateOrgMemberParams{ HTTPClient: client, } } -/*UpdateOrgMemberParams contains all the parameters to send to the API endpoint -for the update org member operation typically these are written to a http.Request +/* +UpdateOrgMemberParams contains all the parameters to send to the API endpoint + + for the update org member operation. + + Typically these are written to a http.Request. */ type UpdateOrgMemberParams struct { - /*Body - The member information to be updated. + /* Body. + The member information to be updated. */ Body *models.MemberAssignation - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*Username - A username + /* Username. + + A username */ Username string @@ -84,6 +86,21 @@ type UpdateOrgMemberParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update org member params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateOrgMemberParams) WithDefaults() *UpdateOrgMemberParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update org member params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateOrgMemberParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update org member params func (o *UpdateOrgMemberParams) WithTimeout(timeout time.Duration) *UpdateOrgMemberParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateOrgMemberParams) WriteToRequest(r runtime.ClientRequest, reg strf return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_members/update_org_member_responses.go b/client/client/organization_members/update_org_member_responses.go index c14a7de7..683d3750 100644 --- a/client/client/organization_members/update_org_member_responses.go +++ b/client/client/organization_members/update_org_member_responses.go @@ -6,17 +6,18 @@ package organization_members // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateOrgMemberReader is a Reader for the UpdateOrgMember structure. @@ -68,7 +69,8 @@ func NewUpdateOrgMemberOK() *UpdateOrgMemberOK { return &UpdateOrgMemberOK{} } -/*UpdateOrgMemberOK handles this case with default header values. +/* +UpdateOrgMemberOK describes a response with status code 200, with default header values. The information of the member of the organization. */ @@ -76,8 +78,44 @@ type UpdateOrgMemberOK struct { Payload *UpdateOrgMemberOKBody } +// IsSuccess returns true when this update org member o k response has a 2xx status code +func (o *UpdateOrgMemberOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update org member o k response has a 3xx status code +func (o *UpdateOrgMemberOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org member o k response has a 4xx status code +func (o *UpdateOrgMemberOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update org member o k response has a 5xx status code +func (o *UpdateOrgMemberOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update org member o k response a status code equal to that given +func (o *UpdateOrgMemberOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update org member o k response +func (o *UpdateOrgMemberOK) Code() int { + return 200 +} + func (o *UpdateOrgMemberOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberOK %s", 200, payload) +} + +func (o *UpdateOrgMemberOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberOK %s", 200, payload) } func (o *UpdateOrgMemberOK) GetPayload() *UpdateOrgMemberOKBody { @@ -101,20 +139,60 @@ func NewUpdateOrgMemberForbidden() *UpdateOrgMemberForbidden { return &UpdateOrgMemberForbidden{} } -/*UpdateOrgMemberForbidden handles this case with default header values. +/* +UpdateOrgMemberForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateOrgMemberForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update org member forbidden response has a 2xx status code +func (o *UpdateOrgMemberForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update org member forbidden response has a 3xx status code +func (o *UpdateOrgMemberForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org member forbidden response has a 4xx status code +func (o *UpdateOrgMemberForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update org member forbidden response has a 5xx status code +func (o *UpdateOrgMemberForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update org member forbidden response a status code equal to that given +func (o *UpdateOrgMemberForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update org member forbidden response +func (o *UpdateOrgMemberForbidden) Code() int { + return 403 +} + func (o *UpdateOrgMemberForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberForbidden %s", 403, payload) +} + +func (o *UpdateOrgMemberForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberForbidden %s", 403, payload) } func (o *UpdateOrgMemberForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *UpdateOrgMemberForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateOrgMemberForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewUpdateOrgMemberNotFound() *UpdateOrgMemberNotFound { return &UpdateOrgMemberNotFound{} } -/*UpdateOrgMemberNotFound handles this case with default header values. +/* +UpdateOrgMemberNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateOrgMemberNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update org member not found response has a 2xx status code +func (o *UpdateOrgMemberNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update org member not found response has a 3xx status code +func (o *UpdateOrgMemberNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org member not found response has a 4xx status code +func (o *UpdateOrgMemberNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update org member not found response has a 5xx status code +func (o *UpdateOrgMemberNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update org member not found response a status code equal to that given +func (o *UpdateOrgMemberNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update org member not found response +func (o *UpdateOrgMemberNotFound) Code() int { + return 404 +} + func (o *UpdateOrgMemberNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberNotFound %s", 404, payload) +} + +func (o *UpdateOrgMemberNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberNotFound %s", 404, payload) } func (o *UpdateOrgMemberNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *UpdateOrgMemberNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateOrgMemberNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewUpdateOrgMemberUnprocessableEntity() *UpdateOrgMemberUnprocessableEntity return &UpdateOrgMemberUnprocessableEntity{} } -/*UpdateOrgMemberUnprocessableEntity handles this case with default header values. +/* +UpdateOrgMemberUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateOrgMemberUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update org member unprocessable entity response has a 2xx status code +func (o *UpdateOrgMemberUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update org member unprocessable entity response has a 3xx status code +func (o *UpdateOrgMemberUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org member unprocessable entity response has a 4xx status code +func (o *UpdateOrgMemberUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update org member unprocessable entity response has a 5xx status code +func (o *UpdateOrgMemberUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update org member unprocessable entity response a status code equal to that given +func (o *UpdateOrgMemberUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update org member unprocessable entity response +func (o *UpdateOrgMemberUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateOrgMemberUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateOrgMemberUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMemberUnprocessableEntity %s", 422, payload) } func (o *UpdateOrgMemberUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *UpdateOrgMemberUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *UpdateOrgMemberUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewUpdateOrgMemberDefault(code int) *UpdateOrgMemberDefault { } } -/*UpdateOrgMemberDefault handles this case with default header values. +/* +UpdateOrgMemberDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateOrgMemberDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update org member default response has a 2xx status code +func (o *UpdateOrgMemberDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update org member default response has a 3xx status code +func (o *UpdateOrgMemberDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update org member default response has a 4xx status code +func (o *UpdateOrgMemberDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update org member default response has a 5xx status code +func (o *UpdateOrgMemberDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update org member default response a status code equal to that given +func (o *UpdateOrgMemberDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update org member default response func (o *UpdateOrgMemberDefault) Code() int { return o._statusCode } func (o *UpdateOrgMemberDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMember default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMember default %s", o._statusCode, payload) +} + +func (o *UpdateOrgMemberDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/members/{username}][%d] updateOrgMember default %s", o._statusCode, payload) } func (o *UpdateOrgMemberDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *UpdateOrgMemberDefault) GetPayload() *models.ErrorPayload { func (o *UpdateOrgMemberDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *UpdateOrgMemberDefault) readResponse(response runtime.ClientResponse, c return nil } -/*UpdateOrgMemberOKBody update org member o k body +/* +UpdateOrgMemberOKBody update org member o k body swagger:model UpdateOrgMemberOKBody */ type UpdateOrgMemberOKBody struct { @@ -315,6 +524,39 @@ func (o *UpdateOrgMemberOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateOrgMemberOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateOrgMemberOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update org member o k body based on the context it is used +func (o *UpdateOrgMemberOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateOrgMemberOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateOrgMemberOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateOrgMemberOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines/create_pipeline_parameters.go b/client/client/organization_pipelines/create_pipeline_parameters.go index de395a7a..cb2dc000 100644 --- a/client/client/organization_pipelines/create_pipeline_parameters.go +++ b/client/client/organization_pipelines/create_pipeline_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreatePipelineParams creates a new CreatePipelineParams object -// with the default values initialized. +// NewCreatePipelineParams creates a new CreatePipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreatePipelineParams() *CreatePipelineParams { - var () return &CreatePipelineParams{ - timeout: cr.DefaultTimeout, } } // NewCreatePipelineParamsWithTimeout creates a new CreatePipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreatePipelineParamsWithTimeout(timeout time.Duration) *CreatePipelineParams { - var () return &CreatePipelineParams{ - timeout: timeout, } } // NewCreatePipelineParamsWithContext creates a new CreatePipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreatePipelineParamsWithContext(ctx context.Context) *CreatePipelineParams { - var () return &CreatePipelineParams{ - Context: ctx, } } // NewCreatePipelineParamsWithHTTPClient creates a new CreatePipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreatePipelineParamsWithHTTPClient(client *http.Client) *CreatePipelineParams { - var () return &CreatePipelineParams{ HTTPClient: client, } } -/*CreatePipelineParams contains all the parameters to send to the API endpoint -for the create pipeline operation typically these are written to a http.Request +/* +CreatePipelineParams contains all the parameters to send to the API endpoint + + for the create pipeline operation. + + Typically these are written to a http.Request. */ type CreatePipelineParams struct { - /*Body - The configuration of the pipeline to create. + /* Body. + The configuration of the pipeline to create. */ Body *models.NewPipeline - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -84,6 +86,21 @@ type CreatePipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreatePipelineParams) WithDefaults() *CreatePipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreatePipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create pipeline params func (o *CreatePipelineParams) WithTimeout(timeout time.Duration) *CreatePipelineParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *CreatePipelineParams) WriteToRequest(r runtime.ClientRequest, reg strfm return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_pipelines/create_pipeline_responses.go b/client/client/organization_pipelines/create_pipeline_responses.go index 9973582a..2c12900b 100644 --- a/client/client/organization_pipelines/create_pipeline_responses.go +++ b/client/client/organization_pipelines/create_pipeline_responses.go @@ -6,17 +6,18 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreatePipelineReader is a Reader for the CreatePipeline structure. @@ -74,7 +75,8 @@ func NewCreatePipelineOK() *CreatePipelineOK { return &CreatePipelineOK{} } -/*CreatePipelineOK handles this case with default header values. +/* +CreatePipelineOK describes a response with status code 200, with default header values. The information of the pipeline which has been created. */ @@ -82,8 +84,44 @@ type CreatePipelineOK struct { Payload *CreatePipelineOKBody } +// IsSuccess returns true when this create pipeline o k response has a 2xx status code +func (o *CreatePipelineOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create pipeline o k response has a 3xx status code +func (o *CreatePipelineOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create pipeline o k response has a 4xx status code +func (o *CreatePipelineOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create pipeline o k response has a 5xx status code +func (o *CreatePipelineOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create pipeline o k response a status code equal to that given +func (o *CreatePipelineOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create pipeline o k response +func (o *CreatePipelineOK) Code() int { + return 200 +} + func (o *CreatePipelineOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineOK %s", 200, payload) +} + +func (o *CreatePipelineOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineOK %s", 200, payload) } func (o *CreatePipelineOK) GetPayload() *CreatePipelineOKBody { @@ -107,20 +145,60 @@ func NewCreatePipelineForbidden() *CreatePipelineForbidden { return &CreatePipelineForbidden{} } -/*CreatePipelineForbidden handles this case with default header values. +/* +CreatePipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreatePipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create pipeline forbidden response has a 2xx status code +func (o *CreatePipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create pipeline forbidden response has a 3xx status code +func (o *CreatePipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create pipeline forbidden response has a 4xx status code +func (o *CreatePipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create pipeline forbidden response has a 5xx status code +func (o *CreatePipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create pipeline forbidden response a status code equal to that given +func (o *CreatePipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create pipeline forbidden response +func (o *CreatePipelineForbidden) Code() int { + return 403 +} + func (o *CreatePipelineForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineForbidden %s", 403, payload) +} + +func (o *CreatePipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineForbidden %s", 403, payload) } func (o *CreatePipelineForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *CreatePipelineForbidden) GetPayload() *models.ErrorPayload { func (o *CreatePipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewCreatePipelineNotFound() *CreatePipelineNotFound { return &CreatePipelineNotFound{} } -/*CreatePipelineNotFound handles this case with default header values. +/* +CreatePipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreatePipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create pipeline not found response has a 2xx status code +func (o *CreatePipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create pipeline not found response has a 3xx status code +func (o *CreatePipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create pipeline not found response has a 4xx status code +func (o *CreatePipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create pipeline not found response has a 5xx status code +func (o *CreatePipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create pipeline not found response a status code equal to that given +func (o *CreatePipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create pipeline not found response +func (o *CreatePipelineNotFound) Code() int { + return 404 +} + func (o *CreatePipelineNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineNotFound %s", 404, payload) +} + +func (o *CreatePipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineNotFound %s", 404, payload) } func (o *CreatePipelineNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *CreatePipelineNotFound) GetPayload() *models.ErrorPayload { func (o *CreatePipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewCreatePipelineLengthRequired() *CreatePipelineLengthRequired { return &CreatePipelineLengthRequired{} } -/*CreatePipelineLengthRequired handles this case with default header values. +/* +CreatePipelineLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreatePipelineLengthRequired struct { } +// IsSuccess returns true when this create pipeline length required response has a 2xx status code +func (o *CreatePipelineLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create pipeline length required response has a 3xx status code +func (o *CreatePipelineLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create pipeline length required response has a 4xx status code +func (o *CreatePipelineLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create pipeline length required response has a 5xx status code +func (o *CreatePipelineLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create pipeline length required response a status code equal to that given +func (o *CreatePipelineLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create pipeline length required response +func (o *CreatePipelineLengthRequired) Code() int { + return 411 +} + func (o *CreatePipelineLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineLengthRequired", 411) +} + +func (o *CreatePipelineLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineLengthRequired", 411) } func (o *CreatePipelineLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewCreatePipelineUnprocessableEntity() *CreatePipelineUnprocessableEntity { return &CreatePipelineUnprocessableEntity{} } -/*CreatePipelineUnprocessableEntity handles this case with default header values. +/* +CreatePipelineUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreatePipelineUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create pipeline unprocessable entity response has a 2xx status code +func (o *CreatePipelineUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create pipeline unprocessable entity response has a 3xx status code +func (o *CreatePipelineUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create pipeline unprocessable entity response has a 4xx status code +func (o *CreatePipelineUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create pipeline unprocessable entity response has a 5xx status code +func (o *CreatePipelineUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create pipeline unprocessable entity response a status code equal to that given +func (o *CreatePipelineUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create pipeline unprocessable entity response +func (o *CreatePipelineUnprocessableEntity) Code() int { + return 422 +} + func (o *CreatePipelineUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineUnprocessableEntity %s", 422, payload) +} + +func (o *CreatePipelineUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipelineUnprocessableEntity %s", 422, payload) } func (o *CreatePipelineUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *CreatePipelineUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *CreatePipelineUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewCreatePipelineDefault(code int) *CreatePipelineDefault { } } -/*CreatePipelineDefault handles this case with default header values. +/* +CreatePipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreatePipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create pipeline default response has a 2xx status code +func (o *CreatePipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create pipeline default response has a 3xx status code +func (o *CreatePipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create pipeline default response has a 4xx status code +func (o *CreatePipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create pipeline default response has a 5xx status code +func (o *CreatePipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create pipeline default response a status code equal to that given +func (o *CreatePipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create pipeline default response func (o *CreatePipelineDefault) Code() int { return o._statusCode } func (o *CreatePipelineDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipeline default %s", o._statusCode, payload) +} + +func (o *CreatePipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] createPipeline default %s", o._statusCode, payload) } func (o *CreatePipelineDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *CreatePipelineDefault) GetPayload() *models.ErrorPayload { func (o *CreatePipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *CreatePipelineDefault) readResponse(response runtime.ClientResponse, co return nil } -/*CreatePipelineOKBody create pipeline o k body +/* +CreatePipelineOKBody create pipeline o k body swagger:model CreatePipelineOKBody */ type CreatePipelineOKBody struct { @@ -342,6 +586,39 @@ func (o *CreatePipelineOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createPipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createPipelineOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create pipeline o k body based on the context it is used +func (o *CreatePipelineOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreatePipelineOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createPipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createPipelineOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines/delete_pipeline_parameters.go b/client/client/organization_pipelines/delete_pipeline_parameters.go index a5bffe90..4431efd8 100644 --- a/client/client/organization_pipelines/delete_pipeline_parameters.go +++ b/client/client/organization_pipelines/delete_pipeline_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeletePipelineParams creates a new DeletePipelineParams object -// with the default values initialized. +// NewDeletePipelineParams creates a new DeletePipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeletePipelineParams() *DeletePipelineParams { - var () return &DeletePipelineParams{ - timeout: cr.DefaultTimeout, } } // NewDeletePipelineParamsWithTimeout creates a new DeletePipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeletePipelineParamsWithTimeout(timeout time.Duration) *DeletePipelineParams { - var () return &DeletePipelineParams{ - timeout: timeout, } } // NewDeletePipelineParamsWithContext creates a new DeletePipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeletePipelineParamsWithContext(ctx context.Context) *DeletePipelineParams { - var () return &DeletePipelineParams{ - Context: ctx, } } // NewDeletePipelineParamsWithHTTPClient creates a new DeletePipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeletePipelineParamsWithHTTPClient(client *http.Client) *DeletePipelineParams { - var () return &DeletePipelineParams{ HTTPClient: client, } } -/*DeletePipelineParams contains all the parameters to send to the API endpoint -for the delete pipeline operation typically these are written to a http.Request +/* +DeletePipelineParams contains all the parameters to send to the API endpoint + + for the delete pipeline operation. + + Typically these are written to a http.Request. */ type DeletePipelineParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -82,6 +84,21 @@ type DeletePipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeletePipelineParams) WithDefaults() *DeletePipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeletePipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete pipeline params func (o *DeletePipelineParams) WithTimeout(timeout time.Duration) *DeletePipelineParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines/delete_pipeline_responses.go b/client/client/organization_pipelines/delete_pipeline_responses.go index 3ab0fe56..66570d39 100644 --- a/client/client/organization_pipelines/delete_pipeline_responses.go +++ b/client/client/organization_pipelines/delete_pipeline_responses.go @@ -6,16 +6,16 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeletePipelineReader is a Reader for the DeletePipeline structure. @@ -61,15 +61,50 @@ func NewDeletePipelineNoContent() *DeletePipelineNoContent { return &DeletePipelineNoContent{} } -/*DeletePipelineNoContent handles this case with default header values. +/* +DeletePipelineNoContent describes a response with status code 204, with default header values. Pipeline has been deleted. */ type DeletePipelineNoContent struct { } +// IsSuccess returns true when this delete pipeline no content response has a 2xx status code +func (o *DeletePipelineNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete pipeline no content response has a 3xx status code +func (o *DeletePipelineNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete pipeline no content response has a 4xx status code +func (o *DeletePipelineNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete pipeline no content response has a 5xx status code +func (o *DeletePipelineNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete pipeline no content response a status code equal to that given +func (o *DeletePipelineNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete pipeline no content response +func (o *DeletePipelineNoContent) Code() int { + return 204 +} + func (o *DeletePipelineNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineNoContent", 204) +} + +func (o *DeletePipelineNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineNoContent", 204) } func (o *DeletePipelineNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeletePipelineForbidden() *DeletePipelineForbidden { return &DeletePipelineForbidden{} } -/*DeletePipelineForbidden handles this case with default header values. +/* +DeletePipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeletePipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete pipeline forbidden response has a 2xx status code +func (o *DeletePipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete pipeline forbidden response has a 3xx status code +func (o *DeletePipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete pipeline forbidden response has a 4xx status code +func (o *DeletePipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete pipeline forbidden response has a 5xx status code +func (o *DeletePipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete pipeline forbidden response a status code equal to that given +func (o *DeletePipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete pipeline forbidden response +func (o *DeletePipelineForbidden) Code() int { + return 403 +} + func (o *DeletePipelineForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineForbidden %s", 403, payload) +} + +func (o *DeletePipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineForbidden %s", 403, payload) } func (o *DeletePipelineForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeletePipelineForbidden) GetPayload() *models.ErrorPayload { func (o *DeletePipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeletePipelineNotFound() *DeletePipelineNotFound { return &DeletePipelineNotFound{} } -/*DeletePipelineNotFound handles this case with default header values. +/* +DeletePipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeletePipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete pipeline not found response has a 2xx status code +func (o *DeletePipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete pipeline not found response has a 3xx status code +func (o *DeletePipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete pipeline not found response has a 4xx status code +func (o *DeletePipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete pipeline not found response has a 5xx status code +func (o *DeletePipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete pipeline not found response a status code equal to that given +func (o *DeletePipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete pipeline not found response +func (o *DeletePipelineNotFound) Code() int { + return 404 +} + func (o *DeletePipelineNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineNotFound %s", 404, payload) +} + +func (o *DeletePipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipelineNotFound %s", 404, payload) } func (o *DeletePipelineNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeletePipelineNotFound) GetPayload() *models.ErrorPayload { func (o *DeletePipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeletePipelineDefault(code int) *DeletePipelineDefault { } } -/*DeletePipelineDefault handles this case with default header values. +/* +DeletePipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeletePipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete pipeline default response has a 2xx status code +func (o *DeletePipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete pipeline default response has a 3xx status code +func (o *DeletePipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete pipeline default response has a 4xx status code +func (o *DeletePipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete pipeline default response has a 5xx status code +func (o *DeletePipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete pipeline default response a status code equal to that given +func (o *DeletePipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete pipeline default response func (o *DeletePipelineDefault) Code() int { return o._statusCode } func (o *DeletePipelineDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipeline default %s", o._statusCode, payload) +} + +func (o *DeletePipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] deletePipeline default %s", o._statusCode, payload) } func (o *DeletePipelineDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeletePipelineDefault) GetPayload() *models.ErrorPayload { func (o *DeletePipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_pipelines/diff_pipeline_parameters.go b/client/client/organization_pipelines/diff_pipeline_parameters.go index 2e0999ec..bb3e48ce 100644 --- a/client/client/organization_pipelines/diff_pipeline_parameters.go +++ b/client/client/organization_pipelines/diff_pipeline_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewDiffPipelineParams creates a new DiffPipelineParams object -// with the default values initialized. +// NewDiffPipelineParams creates a new DiffPipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDiffPipelineParams() *DiffPipelineParams { - var () return &DiffPipelineParams{ - timeout: cr.DefaultTimeout, } } // NewDiffPipelineParamsWithTimeout creates a new DiffPipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDiffPipelineParamsWithTimeout(timeout time.Duration) *DiffPipelineParams { - var () return &DiffPipelineParams{ - timeout: timeout, } } // NewDiffPipelineParamsWithContext creates a new DiffPipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDiffPipelineParamsWithContext(ctx context.Context) *DiffPipelineParams { - var () return &DiffPipelineParams{ - Context: ctx, } } // NewDiffPipelineParamsWithHTTPClient creates a new DiffPipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDiffPipelineParamsWithHTTPClient(client *http.Client) *DiffPipelineParams { - var () return &DiffPipelineParams{ HTTPClient: client, } } -/*DiffPipelineParams contains all the parameters to send to the API endpoint -for the diff pipeline operation typically these are written to a http.Request +/* +DiffPipelineParams contains all the parameters to send to the API endpoint + + for the diff pipeline operation. + + Typically these are written to a http.Request. */ type DiffPipelineParams struct { - /*Body - The pipeline configuration + /* Body. + The pipeline configuration */ Body *models.UpdatePipeline - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -84,6 +86,21 @@ type DiffPipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the diff pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DiffPipelineParams) WithDefaults() *DiffPipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the diff pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DiffPipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the diff pipeline params func (o *DiffPipelineParams) WithTimeout(timeout time.Duration) *DiffPipelineParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *DiffPipelineParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_pipelines/diff_pipeline_responses.go b/client/client/organization_pipelines/diff_pipeline_responses.go index 0f3b3c6f..4873bfca 100644 --- a/client/client/organization_pipelines/diff_pipeline_responses.go +++ b/client/client/organization_pipelines/diff_pipeline_responses.go @@ -6,17 +6,18 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DiffPipelineReader is a Reader for the DiffPipeline structure. @@ -74,7 +75,8 @@ func NewDiffPipelineOK() *DiffPipelineOK { return &DiffPipelineOK{} } -/*DiffPipelineOK handles this case with default header values. +/* +DiffPipelineOK describes a response with status code 200, with default header values. The diff between the provided pipeline configuration and the existing pipeline has been done. */ @@ -82,8 +84,44 @@ type DiffPipelineOK struct { Payload *DiffPipelineOKBody } +// IsSuccess returns true when this diff pipeline o k response has a 2xx status code +func (o *DiffPipelineOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this diff pipeline o k response has a 3xx status code +func (o *DiffPipelineOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this diff pipeline o k response has a 4xx status code +func (o *DiffPipelineOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this diff pipeline o k response has a 5xx status code +func (o *DiffPipelineOK) IsServerError() bool { + return false +} + +// IsCode returns true when this diff pipeline o k response a status code equal to that given +func (o *DiffPipelineOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the diff pipeline o k response +func (o *DiffPipelineOK) Code() int { + return 200 +} + func (o *DiffPipelineOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineOK %s", 200, payload) +} + +func (o *DiffPipelineOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineOK %s", 200, payload) } func (o *DiffPipelineOK) GetPayload() *DiffPipelineOKBody { @@ -107,20 +145,60 @@ func NewDiffPipelineForbidden() *DiffPipelineForbidden { return &DiffPipelineForbidden{} } -/*DiffPipelineForbidden handles this case with default header values. +/* +DiffPipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DiffPipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this diff pipeline forbidden response has a 2xx status code +func (o *DiffPipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this diff pipeline forbidden response has a 3xx status code +func (o *DiffPipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this diff pipeline forbidden response has a 4xx status code +func (o *DiffPipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this diff pipeline forbidden response has a 5xx status code +func (o *DiffPipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this diff pipeline forbidden response a status code equal to that given +func (o *DiffPipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the diff pipeline forbidden response +func (o *DiffPipelineForbidden) Code() int { + return 403 +} + func (o *DiffPipelineForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineForbidden %s", 403, payload) +} + +func (o *DiffPipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineForbidden %s", 403, payload) } func (o *DiffPipelineForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *DiffPipelineForbidden) GetPayload() *models.ErrorPayload { func (o *DiffPipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewDiffPipelineNotFound() *DiffPipelineNotFound { return &DiffPipelineNotFound{} } -/*DiffPipelineNotFound handles this case with default header values. +/* +DiffPipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DiffPipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this diff pipeline not found response has a 2xx status code +func (o *DiffPipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this diff pipeline not found response has a 3xx status code +func (o *DiffPipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this diff pipeline not found response has a 4xx status code +func (o *DiffPipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this diff pipeline not found response has a 5xx status code +func (o *DiffPipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this diff pipeline not found response a status code equal to that given +func (o *DiffPipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the diff pipeline not found response +func (o *DiffPipelineNotFound) Code() int { + return 404 +} + func (o *DiffPipelineNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineNotFound %s", 404, payload) +} + +func (o *DiffPipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineNotFound %s", 404, payload) } func (o *DiffPipelineNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *DiffPipelineNotFound) GetPayload() *models.ErrorPayload { func (o *DiffPipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewDiffPipelineLengthRequired() *DiffPipelineLengthRequired { return &DiffPipelineLengthRequired{} } -/*DiffPipelineLengthRequired handles this case with default header values. +/* +DiffPipelineLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type DiffPipelineLengthRequired struct { } +// IsSuccess returns true when this diff pipeline length required response has a 2xx status code +func (o *DiffPipelineLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this diff pipeline length required response has a 3xx status code +func (o *DiffPipelineLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this diff pipeline length required response has a 4xx status code +func (o *DiffPipelineLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this diff pipeline length required response has a 5xx status code +func (o *DiffPipelineLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this diff pipeline length required response a status code equal to that given +func (o *DiffPipelineLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the diff pipeline length required response +func (o *DiffPipelineLengthRequired) Code() int { + return 411 +} + func (o *DiffPipelineLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineLengthRequired", 411) +} + +func (o *DiffPipelineLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineLengthRequired", 411) } func (o *DiffPipelineLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewDiffPipelineUnprocessableEntity() *DiffPipelineUnprocessableEntity { return &DiffPipelineUnprocessableEntity{} } -/*DiffPipelineUnprocessableEntity handles this case with default header values. +/* +DiffPipelineUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type DiffPipelineUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this diff pipeline unprocessable entity response has a 2xx status code +func (o *DiffPipelineUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this diff pipeline unprocessable entity response has a 3xx status code +func (o *DiffPipelineUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this diff pipeline unprocessable entity response has a 4xx status code +func (o *DiffPipelineUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this diff pipeline unprocessable entity response has a 5xx status code +func (o *DiffPipelineUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this diff pipeline unprocessable entity response a status code equal to that given +func (o *DiffPipelineUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the diff pipeline unprocessable entity response +func (o *DiffPipelineUnprocessableEntity) Code() int { + return 422 +} + func (o *DiffPipelineUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineUnprocessableEntity %s", 422, payload) +} + +func (o *DiffPipelineUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipelineUnprocessableEntity %s", 422, payload) } func (o *DiffPipelineUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *DiffPipelineUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *DiffPipelineUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewDiffPipelineDefault(code int) *DiffPipelineDefault { } } -/*DiffPipelineDefault handles this case with default header values. +/* +DiffPipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DiffPipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this diff pipeline default response has a 2xx status code +func (o *DiffPipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this diff pipeline default response has a 3xx status code +func (o *DiffPipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this diff pipeline default response has a 4xx status code +func (o *DiffPipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this diff pipeline default response has a 5xx status code +func (o *DiffPipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this diff pipeline default response a status code equal to that given +func (o *DiffPipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the diff pipeline default response func (o *DiffPipelineDefault) Code() int { return o._statusCode } func (o *DiffPipelineDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipeline default %s", o._statusCode, payload) +} + +func (o *DiffPipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff][%d] diffPipeline default %s", o._statusCode, payload) } func (o *DiffPipelineDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *DiffPipelineDefault) GetPayload() *models.ErrorPayload { func (o *DiffPipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *DiffPipelineDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*DiffPipelineOKBody diff pipeline o k body +/* +DiffPipelineOKBody diff pipeline o k body swagger:model DiffPipelineOKBody */ type DiffPipelineOKBody struct { @@ -342,6 +586,39 @@ func (o *DiffPipelineOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("diffPipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("diffPipelineOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this diff pipeline o k body based on the context it is used +func (o *DiffPipelineOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *DiffPipelineOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("diffPipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("diffPipelineOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines/get_pipeline_config_parameters.go b/client/client/organization_pipelines/get_pipeline_config_parameters.go index d040e024..a643d550 100644 --- a/client/client/organization_pipelines/get_pipeline_config_parameters.go +++ b/client/client/organization_pipelines/get_pipeline_config_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetPipelineConfigParams creates a new GetPipelineConfigParams object -// with the default values initialized. +// NewGetPipelineConfigParams creates a new GetPipelineConfigParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetPipelineConfigParams() *GetPipelineConfigParams { - var () return &GetPipelineConfigParams{ - timeout: cr.DefaultTimeout, } } // NewGetPipelineConfigParamsWithTimeout creates a new GetPipelineConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetPipelineConfigParamsWithTimeout(timeout time.Duration) *GetPipelineConfigParams { - var () return &GetPipelineConfigParams{ - timeout: timeout, } } // NewGetPipelineConfigParamsWithContext creates a new GetPipelineConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetPipelineConfigParamsWithContext(ctx context.Context) *GetPipelineConfigParams { - var () return &GetPipelineConfigParams{ - Context: ctx, } } // NewGetPipelineConfigParamsWithHTTPClient creates a new GetPipelineConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetPipelineConfigParamsWithHTTPClient(client *http.Client) *GetPipelineConfigParams { - var () return &GetPipelineConfigParams{ HTTPClient: client, } } -/*GetPipelineConfigParams contains all the parameters to send to the API endpoint -for the get pipeline config operation typically these are written to a http.Request +/* +GetPipelineConfigParams contains all the parameters to send to the API endpoint + + for the get pipeline config operation. + + Typically these are written to a http.Request. */ type GetPipelineConfigParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -82,6 +84,21 @@ type GetPipelineConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get pipeline config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPipelineConfigParams) WithDefaults() *GetPipelineConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get pipeline config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPipelineConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get pipeline config params func (o *GetPipelineConfigParams) WithTimeout(timeout time.Duration) *GetPipelineConfigParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines/get_pipeline_config_responses.go b/client/client/organization_pipelines/get_pipeline_config_responses.go index 3cffe981..8b82b15d 100644 --- a/client/client/organization_pipelines/get_pipeline_config_responses.go +++ b/client/client/organization_pipelines/get_pipeline_config_responses.go @@ -6,17 +6,18 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetPipelineConfigReader is a Reader for the GetPipelineConfig structure. @@ -62,7 +63,8 @@ func NewGetPipelineConfigOK() *GetPipelineConfigOK { return &GetPipelineConfigOK{} } -/*GetPipelineConfigOK handles this case with default header values. +/* +GetPipelineConfigOK describes a response with status code 200, with default header values. This endpoint returns the config of the pipeline. */ @@ -70,8 +72,44 @@ type GetPipelineConfigOK struct { Payload *GetPipelineConfigOKBody } +// IsSuccess returns true when this get pipeline config o k response has a 2xx status code +func (o *GetPipelineConfigOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get pipeline config o k response has a 3xx status code +func (o *GetPipelineConfigOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline config o k response has a 4xx status code +func (o *GetPipelineConfigOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get pipeline config o k response has a 5xx status code +func (o *GetPipelineConfigOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline config o k response a status code equal to that given +func (o *GetPipelineConfigOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get pipeline config o k response +func (o *GetPipelineConfigOK) Code() int { + return 200 +} + func (o *GetPipelineConfigOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigOK %s", 200, payload) +} + +func (o *GetPipelineConfigOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigOK %s", 200, payload) } func (o *GetPipelineConfigOK) GetPayload() *GetPipelineConfigOKBody { @@ -95,20 +133,60 @@ func NewGetPipelineConfigForbidden() *GetPipelineConfigForbidden { return &GetPipelineConfigForbidden{} } -/*GetPipelineConfigForbidden handles this case with default header values. +/* +GetPipelineConfigForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetPipelineConfigForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline config forbidden response has a 2xx status code +func (o *GetPipelineConfigForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipeline config forbidden response has a 3xx status code +func (o *GetPipelineConfigForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline config forbidden response has a 4xx status code +func (o *GetPipelineConfigForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipeline config forbidden response has a 5xx status code +func (o *GetPipelineConfigForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline config forbidden response a status code equal to that given +func (o *GetPipelineConfigForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get pipeline config forbidden response +func (o *GetPipelineConfigForbidden) Code() int { + return 403 +} + func (o *GetPipelineConfigForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigForbidden %s", 403, payload) +} + +func (o *GetPipelineConfigForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigForbidden %s", 403, payload) } func (o *GetPipelineConfigForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetPipelineConfigForbidden) GetPayload() *models.ErrorPayload { func (o *GetPipelineConfigForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetPipelineConfigNotFound() *GetPipelineConfigNotFound { return &GetPipelineConfigNotFound{} } -/*GetPipelineConfigNotFound handles this case with default header values. +/* +GetPipelineConfigNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetPipelineConfigNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline config not found response has a 2xx status code +func (o *GetPipelineConfigNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipeline config not found response has a 3xx status code +func (o *GetPipelineConfigNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline config not found response has a 4xx status code +func (o *GetPipelineConfigNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipeline config not found response has a 5xx status code +func (o *GetPipelineConfigNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline config not found response a status code equal to that given +func (o *GetPipelineConfigNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get pipeline config not found response +func (o *GetPipelineConfigNotFound) Code() int { + return 404 +} + func (o *GetPipelineConfigNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigNotFound %s", 404, payload) +} + +func (o *GetPipelineConfigNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfigNotFound %s", 404, payload) } func (o *GetPipelineConfigNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetPipelineConfigNotFound) GetPayload() *models.ErrorPayload { func (o *GetPipelineConfigNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetPipelineConfigDefault(code int) *GetPipelineConfigDefault { } } -/*GetPipelineConfigDefault handles this case with default header values. +/* +GetPipelineConfigDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetPipelineConfigDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline config default response has a 2xx status code +func (o *GetPipelineConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get pipeline config default response has a 3xx status code +func (o *GetPipelineConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get pipeline config default response has a 4xx status code +func (o *GetPipelineConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get pipeline config default response has a 5xx status code +func (o *GetPipelineConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get pipeline config default response a status code equal to that given +func (o *GetPipelineConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get pipeline config default response func (o *GetPipelineConfigDefault) Code() int { return o._statusCode } func (o *GetPipelineConfigDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfig default %s", o._statusCode, payload) +} + +func (o *GetPipelineConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config][%d] getPipelineConfig default %s", o._statusCode, payload) } func (o *GetPipelineConfigDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetPipelineConfigDefault) GetPayload() *models.ErrorPayload { func (o *GetPipelineConfigDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetPipelineConfigDefault) readResponse(response runtime.ClientResponse, return nil } -/*GetPipelineConfigOKBody get pipeline config o k body +/* +GetPipelineConfigOKBody get pipeline config o k body swagger:model GetPipelineConfigOKBody */ type GetPipelineConfigOKBody struct { @@ -264,6 +429,11 @@ func (o *GetPipelineConfigOKBody) validateData(formats strfmt.Registry) error { return nil } +// ContextValidate validates this get pipeline config o k body based on context it is used +func (o *GetPipelineConfigOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *GetPipelineConfigOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/organization_pipelines/get_pipeline_parameters.go b/client/client/organization_pipelines/get_pipeline_parameters.go index 0f8f3d2d..6ea68bab 100644 --- a/client/client/organization_pipelines/get_pipeline_parameters.go +++ b/client/client/organization_pipelines/get_pipeline_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetPipelineParams creates a new GetPipelineParams object -// with the default values initialized. +// NewGetPipelineParams creates a new GetPipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetPipelineParams() *GetPipelineParams { - var () return &GetPipelineParams{ - timeout: cr.DefaultTimeout, } } // NewGetPipelineParamsWithTimeout creates a new GetPipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetPipelineParamsWithTimeout(timeout time.Duration) *GetPipelineParams { - var () return &GetPipelineParams{ - timeout: timeout, } } // NewGetPipelineParamsWithContext creates a new GetPipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetPipelineParamsWithContext(ctx context.Context) *GetPipelineParams { - var () return &GetPipelineParams{ - Context: ctx, } } // NewGetPipelineParamsWithHTTPClient creates a new GetPipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetPipelineParamsWithHTTPClient(client *http.Client) *GetPipelineParams { - var () return &GetPipelineParams{ HTTPClient: client, } } -/*GetPipelineParams contains all the parameters to send to the API endpoint -for the get pipeline operation typically these are written to a http.Request +/* +GetPipelineParams contains all the parameters to send to the API endpoint + + for the get pipeline operation. + + Typically these are written to a http.Request. */ type GetPipelineParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -82,6 +84,21 @@ type GetPipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPipelineParams) WithDefaults() *GetPipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get pipeline params func (o *GetPipelineParams) WithTimeout(timeout time.Duration) *GetPipelineParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines/get_pipeline_responses.go b/client/client/organization_pipelines/get_pipeline_responses.go index 8860ba47..9d7118eb 100644 --- a/client/client/organization_pipelines/get_pipeline_responses.go +++ b/client/client/organization_pipelines/get_pipeline_responses.go @@ -6,17 +6,18 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetPipelineReader is a Reader for the GetPipeline structure. @@ -62,7 +63,8 @@ func NewGetPipelineOK() *GetPipelineOK { return &GetPipelineOK{} } -/*GetPipelineOK handles this case with default header values. +/* +GetPipelineOK describes a response with status code 200, with default header values. The information of the pipeline which has the specified name. */ @@ -70,8 +72,44 @@ type GetPipelineOK struct { Payload *GetPipelineOKBody } +// IsSuccess returns true when this get pipeline o k response has a 2xx status code +func (o *GetPipelineOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get pipeline o k response has a 3xx status code +func (o *GetPipelineOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline o k response has a 4xx status code +func (o *GetPipelineOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get pipeline o k response has a 5xx status code +func (o *GetPipelineOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline o k response a status code equal to that given +func (o *GetPipelineOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get pipeline o k response +func (o *GetPipelineOK) Code() int { + return 200 +} + func (o *GetPipelineOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineOK %s", 200, payload) +} + +func (o *GetPipelineOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineOK %s", 200, payload) } func (o *GetPipelineOK) GetPayload() *GetPipelineOKBody { @@ -95,20 +133,60 @@ func NewGetPipelineForbidden() *GetPipelineForbidden { return &GetPipelineForbidden{} } -/*GetPipelineForbidden handles this case with default header values. +/* +GetPipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetPipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline forbidden response has a 2xx status code +func (o *GetPipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipeline forbidden response has a 3xx status code +func (o *GetPipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline forbidden response has a 4xx status code +func (o *GetPipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipeline forbidden response has a 5xx status code +func (o *GetPipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline forbidden response a status code equal to that given +func (o *GetPipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get pipeline forbidden response +func (o *GetPipelineForbidden) Code() int { + return 403 +} + func (o *GetPipelineForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineForbidden %s", 403, payload) +} + +func (o *GetPipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineForbidden %s", 403, payload) } func (o *GetPipelineForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetPipelineForbidden) GetPayload() *models.ErrorPayload { func (o *GetPipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetPipelineNotFound() *GetPipelineNotFound { return &GetPipelineNotFound{} } -/*GetPipelineNotFound handles this case with default header values. +/* +GetPipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetPipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline not found response has a 2xx status code +func (o *GetPipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipeline not found response has a 3xx status code +func (o *GetPipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline not found response has a 4xx status code +func (o *GetPipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipeline not found response has a 5xx status code +func (o *GetPipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline not found response a status code equal to that given +func (o *GetPipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get pipeline not found response +func (o *GetPipelineNotFound) Code() int { + return 404 +} + func (o *GetPipelineNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineNotFound %s", 404, payload) +} + +func (o *GetPipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipelineNotFound %s", 404, payload) } func (o *GetPipelineNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetPipelineNotFound) GetPayload() *models.ErrorPayload { func (o *GetPipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetPipelineDefault(code int) *GetPipelineDefault { } } -/*GetPipelineDefault handles this case with default header values. +/* +GetPipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetPipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline default response has a 2xx status code +func (o *GetPipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get pipeline default response has a 3xx status code +func (o *GetPipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get pipeline default response has a 4xx status code +func (o *GetPipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get pipeline default response has a 5xx status code +func (o *GetPipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get pipeline default response a status code equal to that given +func (o *GetPipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get pipeline default response func (o *GetPipelineDefault) Code() int { return o._statusCode } func (o *GetPipelineDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipeline default %s", o._statusCode, payload) +} + +func (o *GetPipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] getPipeline default %s", o._statusCode, payload) } func (o *GetPipelineDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetPipelineDefault) GetPayload() *models.ErrorPayload { func (o *GetPipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetPipelineDefault) readResponse(response runtime.ClientResponse, consu return nil } -/*GetPipelineOKBody get pipeline o k body +/* +GetPipelineOKBody get pipeline o k body swagger:model GetPipelineOKBody */ type GetPipelineOKBody struct { @@ -265,6 +430,39 @@ func (o *GetPipelineOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getPipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPipelineOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get pipeline o k body based on the context it is used +func (o *GetPipelineOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetPipelineOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getPipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPipelineOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines/get_pipeline_variables_parameters.go b/client/client/organization_pipelines/get_pipeline_variables_parameters.go index 45478bb6..7bead116 100644 --- a/client/client/organization_pipelines/get_pipeline_variables_parameters.go +++ b/client/client/organization_pipelines/get_pipeline_variables_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetPipelineVariablesParams creates a new GetPipelineVariablesParams object -// with the default values initialized. +// NewGetPipelineVariablesParams creates a new GetPipelineVariablesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetPipelineVariablesParams() *GetPipelineVariablesParams { - var () return &GetPipelineVariablesParams{ - timeout: cr.DefaultTimeout, } } // NewGetPipelineVariablesParamsWithTimeout creates a new GetPipelineVariablesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetPipelineVariablesParamsWithTimeout(timeout time.Duration) *GetPipelineVariablesParams { - var () return &GetPipelineVariablesParams{ - timeout: timeout, } } // NewGetPipelineVariablesParamsWithContext creates a new GetPipelineVariablesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetPipelineVariablesParamsWithContext(ctx context.Context) *GetPipelineVariablesParams { - var () return &GetPipelineVariablesParams{ - Context: ctx, } } // NewGetPipelineVariablesParamsWithHTTPClient creates a new GetPipelineVariablesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetPipelineVariablesParamsWithHTTPClient(client *http.Client) *GetPipelineVariablesParams { - var () return &GetPipelineVariablesParams{ HTTPClient: client, } } -/*GetPipelineVariablesParams contains all the parameters to send to the API endpoint -for the get pipeline variables operation typically these are written to a http.Request +/* +GetPipelineVariablesParams contains all the parameters to send to the API endpoint + + for the get pipeline variables operation. + + Typically these are written to a http.Request. */ type GetPipelineVariablesParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -82,6 +84,21 @@ type GetPipelineVariablesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get pipeline variables params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPipelineVariablesParams) WithDefaults() *GetPipelineVariablesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get pipeline variables params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPipelineVariablesParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get pipeline variables params func (o *GetPipelineVariablesParams) WithTimeout(timeout time.Duration) *GetPipelineVariablesParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines/get_pipeline_variables_responses.go b/client/client/organization_pipelines/get_pipeline_variables_responses.go index 600234bb..12a29471 100644 --- a/client/client/organization_pipelines/get_pipeline_variables_responses.go +++ b/client/client/organization_pipelines/get_pipeline_variables_responses.go @@ -6,17 +6,18 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetPipelineVariablesReader is a Reader for the GetPipelineVariables structure. @@ -68,7 +69,8 @@ func NewGetPipelineVariablesOK() *GetPipelineVariablesOK { return &GetPipelineVariablesOK{} } -/*GetPipelineVariablesOK handles this case with default header values. +/* +GetPipelineVariablesOK describes a response with status code 200, with default header values. This endpoint returns the variables of the pipeline. */ @@ -76,8 +78,44 @@ type GetPipelineVariablesOK struct { Payload *GetPipelineVariablesOKBody } +// IsSuccess returns true when this get pipeline variables o k response has a 2xx status code +func (o *GetPipelineVariablesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get pipeline variables o k response has a 3xx status code +func (o *GetPipelineVariablesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline variables o k response has a 4xx status code +func (o *GetPipelineVariablesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get pipeline variables o k response has a 5xx status code +func (o *GetPipelineVariablesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline variables o k response a status code equal to that given +func (o *GetPipelineVariablesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get pipeline variables o k response +func (o *GetPipelineVariablesOK) Code() int { + return 200 +} + func (o *GetPipelineVariablesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesOK %s", 200, payload) +} + +func (o *GetPipelineVariablesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesOK %s", 200, payload) } func (o *GetPipelineVariablesOK) GetPayload() *GetPipelineVariablesOKBody { @@ -101,20 +139,60 @@ func NewGetPipelineVariablesForbidden() *GetPipelineVariablesForbidden { return &GetPipelineVariablesForbidden{} } -/*GetPipelineVariablesForbidden handles this case with default header values. +/* +GetPipelineVariablesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetPipelineVariablesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline variables forbidden response has a 2xx status code +func (o *GetPipelineVariablesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipeline variables forbidden response has a 3xx status code +func (o *GetPipelineVariablesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline variables forbidden response has a 4xx status code +func (o *GetPipelineVariablesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipeline variables forbidden response has a 5xx status code +func (o *GetPipelineVariablesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline variables forbidden response a status code equal to that given +func (o *GetPipelineVariablesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get pipeline variables forbidden response +func (o *GetPipelineVariablesForbidden) Code() int { + return 403 +} + func (o *GetPipelineVariablesForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesForbidden %s", 403, payload) +} + +func (o *GetPipelineVariablesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesForbidden %s", 403, payload) } func (o *GetPipelineVariablesForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *GetPipelineVariablesForbidden) GetPayload() *models.ErrorPayload { func (o *GetPipelineVariablesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewGetPipelineVariablesNotFound() *GetPipelineVariablesNotFound { return &GetPipelineVariablesNotFound{} } -/*GetPipelineVariablesNotFound handles this case with default header values. +/* +GetPipelineVariablesNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetPipelineVariablesNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline variables not found response has a 2xx status code +func (o *GetPipelineVariablesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipeline variables not found response has a 3xx status code +func (o *GetPipelineVariablesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline variables not found response has a 4xx status code +func (o *GetPipelineVariablesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipeline variables not found response has a 5xx status code +func (o *GetPipelineVariablesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline variables not found response a status code equal to that given +func (o *GetPipelineVariablesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get pipeline variables not found response +func (o *GetPipelineVariablesNotFound) Code() int { + return 404 +} + func (o *GetPipelineVariablesNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesNotFound %s", 404, payload) +} + +func (o *GetPipelineVariablesNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesNotFound %s", 404, payload) } func (o *GetPipelineVariablesNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *GetPipelineVariablesNotFound) GetPayload() *models.ErrorPayload { func (o *GetPipelineVariablesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,15 +315,50 @@ func NewGetPipelineVariablesConflict() *GetPipelineVariablesConflict { return &GetPipelineVariablesConflict{} } -/*GetPipelineVariablesConflict handles this case with default header values. +/* +GetPipelineVariablesConflict describes a response with status code 409, with default header values. Project has no config repository configured */ type GetPipelineVariablesConflict struct { } +// IsSuccess returns true when this get pipeline variables conflict response has a 2xx status code +func (o *GetPipelineVariablesConflict) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipeline variables conflict response has a 3xx status code +func (o *GetPipelineVariablesConflict) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipeline variables conflict response has a 4xx status code +func (o *GetPipelineVariablesConflict) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipeline variables conflict response has a 5xx status code +func (o *GetPipelineVariablesConflict) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipeline variables conflict response a status code equal to that given +func (o *GetPipelineVariablesConflict) IsCode(code int) bool { + return code == 409 +} + +// Code gets the status code for the get pipeline variables conflict response +func (o *GetPipelineVariablesConflict) Code() int { + return 409 +} + func (o *GetPipelineVariablesConflict) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesConflict ", 409) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesConflict", 409) +} + +func (o *GetPipelineVariablesConflict) String() string { + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariablesConflict", 409) } func (o *GetPipelineVariablesConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -212,27 +373,61 @@ func NewGetPipelineVariablesDefault(code int) *GetPipelineVariablesDefault { } } -/*GetPipelineVariablesDefault handles this case with default header values. +/* +GetPipelineVariablesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetPipelineVariablesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipeline variables default response has a 2xx status code +func (o *GetPipelineVariablesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get pipeline variables default response has a 3xx status code +func (o *GetPipelineVariablesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get pipeline variables default response has a 4xx status code +func (o *GetPipelineVariablesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get pipeline variables default response has a 5xx status code +func (o *GetPipelineVariablesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get pipeline variables default response a status code equal to that given +func (o *GetPipelineVariablesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get pipeline variables default response func (o *GetPipelineVariablesDefault) Code() int { return o._statusCode } func (o *GetPipelineVariablesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariables default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariables default %s", o._statusCode, payload) +} + +func (o *GetPipelineVariablesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables][%d] getPipelineVariables default %s", o._statusCode, payload) } func (o *GetPipelineVariablesDefault) GetPayload() *models.ErrorPayload { @@ -241,12 +436,16 @@ func (o *GetPipelineVariablesDefault) GetPayload() *models.ErrorPayload { func (o *GetPipelineVariablesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -258,7 +457,8 @@ func (o *GetPipelineVariablesDefault) readResponse(response runtime.ClientRespon return nil } -/*GetPipelineVariablesOKBody get pipeline variables o k body +/* +GetPipelineVariablesOKBody get pipeline variables o k body swagger:model GetPipelineVariablesOKBody */ type GetPipelineVariablesOKBody struct { @@ -292,6 +492,39 @@ func (o *GetPipelineVariablesOKBody) validateData(formats strfmt.Registry) error if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getPipelineVariablesOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPipelineVariablesOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get pipeline variables o k body based on the context it is used +func (o *GetPipelineVariablesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetPipelineVariablesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getPipelineVariablesOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPipelineVariablesOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines/get_pipelines_parameters.go b/client/client/organization_pipelines/get_pipelines_parameters.go index 671b1ce6..7aea32b9 100644 --- a/client/client/organization_pipelines/get_pipelines_parameters.go +++ b/client/client/organization_pipelines/get_pipelines_parameters.go @@ -13,108 +13,100 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetPipelinesParams creates a new GetPipelinesParams object -// with the default values initialized. +// NewGetPipelinesParams creates a new GetPipelinesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetPipelinesParams() *GetPipelinesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetPipelinesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetPipelinesParamsWithTimeout creates a new GetPipelinesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetPipelinesParamsWithTimeout(timeout time.Duration) *GetPipelinesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetPipelinesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetPipelinesParamsWithContext creates a new GetPipelinesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetPipelinesParamsWithContext(ctx context.Context) *GetPipelinesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetPipelinesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetPipelinesParamsWithHTTPClient creates a new GetPipelinesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetPipelinesParamsWithHTTPClient(client *http.Client) *GetPipelinesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetPipelinesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetPipelinesParams contains all the parameters to send to the API endpoint -for the get pipelines operation typically these are written to a http.Request +/* +GetPipelinesParams contains all the parameters to send to the API endpoint + + for the get pipelines operation. + + Typically these are written to a http.Request. */ type GetPipelinesParams struct { - /*ConcoursePipelineName - A pipeline name + /* ConcoursePipelineName. + A pipeline name */ ConcoursePipelineName *string - /*EnvironmentCanonical - A list of environments' canonical to filter from + /* EnvironmentCanonical. + + A list of environments' canonical to filter from */ - EnvironmentCanonical []string - /*OrganizationCanonical - A canonical of an organization. + EnvironmentCanonical *string + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*ProjectCanonical - A list of projects' canonical to filter from + /* ProjectCanonical. + + A list of projects' canonical to filter from */ - ProjectCanonical []string - /*Statuses - List of statuses that you want to filter a pipeline/job with. Pipeline can be either paused or unpaused, but jobs can be started, pending, succeeded, failed, errored, aborted. So if any of a pipeline's job has one of the given status, the associated pipeline will be included in the response. + ProjectCanonical *string + + /* Statuses. + List of statuses that you want to filter a pipeline/job with. Pipeline can be either paused or unpaused, but jobs can be started, pending, succeeded, failed, errored, aborted. So if any of a pipeline's job has one of the given status, the associated pipeline will be included in the response. */ Statuses []string @@ -123,6 +115,35 @@ type GetPipelinesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get pipelines params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPipelinesParams) WithDefaults() *GetPipelinesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get pipelines params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPipelinesParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetPipelinesParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get pipelines params func (o *GetPipelinesParams) WithTimeout(timeout time.Duration) *GetPipelinesParams { o.SetTimeout(timeout) @@ -168,13 +189,13 @@ func (o *GetPipelinesParams) SetConcoursePipelineName(concoursePipelineName *str } // WithEnvironmentCanonical adds the environmentCanonical to the get pipelines params -func (o *GetPipelinesParams) WithEnvironmentCanonical(environmentCanonical []string) *GetPipelinesParams { +func (o *GetPipelinesParams) WithEnvironmentCanonical(environmentCanonical *string) *GetPipelinesParams { o.SetEnvironmentCanonical(environmentCanonical) return o } // SetEnvironmentCanonical adds the environmentCanonical to the get pipelines params -func (o *GetPipelinesParams) SetEnvironmentCanonical(environmentCanonical []string) { +func (o *GetPipelinesParams) SetEnvironmentCanonical(environmentCanonical *string) { o.EnvironmentCanonical = environmentCanonical } @@ -212,13 +233,13 @@ func (o *GetPipelinesParams) SetPageSize(pageSize *uint32) { } // WithProjectCanonical adds the projectCanonical to the get pipelines params -func (o *GetPipelinesParams) WithProjectCanonical(projectCanonical []string) *GetPipelinesParams { +func (o *GetPipelinesParams) WithProjectCanonical(projectCanonical *string) *GetPipelinesParams { o.SetProjectCanonical(projectCanonical) return o } // SetProjectCanonical adds the projectCanonical to the get pipelines params -func (o *GetPipelinesParams) SetProjectCanonical(projectCanonical []string) { +func (o *GetPipelinesParams) SetProjectCanonical(projectCanonical *string) { o.ProjectCanonical = projectCanonical } @@ -245,24 +266,34 @@ func (o *GetPipelinesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. // query param concourse_pipeline_name var qrConcoursePipelineName string + if o.ConcoursePipelineName != nil { qrConcoursePipelineName = *o.ConcoursePipelineName } qConcoursePipelineName := qrConcoursePipelineName if qConcoursePipelineName != "" { + if err := r.SetQueryParam("concourse_pipeline_name", qConcoursePipelineName); err != nil { return err } } - } - valuesEnvironmentCanonical := o.EnvironmentCanonical + if o.EnvironmentCanonical != nil { - joinedEnvironmentCanonical := swag.JoinByFormat(valuesEnvironmentCanonical, "") - // query array param environment_canonical - if err := r.SetQueryParam("environment_canonical", joinedEnvironmentCanonical...); err != nil { - return err + // query param environment_canonical + var qrEnvironmentCanonical string + + if o.EnvironmentCanonical != nil { + qrEnvironmentCanonical = *o.EnvironmentCanonical + } + qEnvironmentCanonical := qrEnvironmentCanonical + if qEnvironmentCanonical != "" { + + if err := r.SetQueryParam("environment_canonical", qEnvironmentCanonical); err != nil { + return err + } + } } // path param organization_canonical @@ -274,48 +305,62 @@ func (o *GetPipelinesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } - valuesProjectCanonical := o.ProjectCanonical + if o.ProjectCanonical != nil { - joinedProjectCanonical := swag.JoinByFormat(valuesProjectCanonical, "") - // query array param project_canonical - if err := r.SetQueryParam("project_canonical", joinedProjectCanonical...); err != nil { - return err + // query param project_canonical + var qrProjectCanonical string + + if o.ProjectCanonical != nil { + qrProjectCanonical = *o.ProjectCanonical + } + qProjectCanonical := qrProjectCanonical + if qProjectCanonical != "" { + + if err := r.SetQueryParam("project_canonical", qProjectCanonical); err != nil { + return err + } + } } - valuesStatuses := o.Statuses + if o.Statuses != nil { - joinedStatuses := swag.JoinByFormat(valuesStatuses, "multi") - // query array param statuses - if err := r.SetQueryParam("statuses", joinedStatuses...); err != nil { - return err + // binding items for statuses + joinedStatuses := o.bindParamStatuses(reg) + + // query array param statuses + if err := r.SetQueryParam("statuses", joinedStatuses...); err != nil { + return err + } } if len(res) > 0 { @@ -323,3 +368,20 @@ func (o *GetPipelinesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. } return nil } + +// bindParamGetPipelines binds the parameter statuses +func (o *GetPipelinesParams) bindParamStatuses(formats strfmt.Registry) []string { + statusesIR := o.Statuses + + var statusesIC []string + for _, statusesIIR := range statusesIR { // explode []string + + statusesIIV := statusesIIR // string as string + statusesIC = append(statusesIC, statusesIIV) + } + + // items.CollectionFormat: "multi" + statusesIS := swag.JoinByFormat(statusesIC, "multi") + + return statusesIS +} diff --git a/client/client/organization_pipelines/get_pipelines_responses.go b/client/client/organization_pipelines/get_pipelines_responses.go index 5b645343..b02ce7fc 100644 --- a/client/client/organization_pipelines/get_pipelines_responses.go +++ b/client/client/organization_pipelines/get_pipelines_responses.go @@ -6,18 +6,19 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetPipelinesReader is a Reader for the GetPipelines structure. @@ -63,7 +64,8 @@ func NewGetPipelinesOK() *GetPipelinesOK { return &GetPipelinesOK{} } -/*GetPipelinesOK handles this case with default header values. +/* +GetPipelinesOK describes a response with status code 200, with default header values. List of all the pipelines which authenticated user has access to. */ @@ -71,8 +73,44 @@ type GetPipelinesOK struct { Payload *GetPipelinesOKBody } +// IsSuccess returns true when this get pipelines o k response has a 2xx status code +func (o *GetPipelinesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get pipelines o k response has a 3xx status code +func (o *GetPipelinesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipelines o k response has a 4xx status code +func (o *GetPipelinesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get pipelines o k response has a 5xx status code +func (o *GetPipelinesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipelines o k response a status code equal to that given +func (o *GetPipelinesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get pipelines o k response +func (o *GetPipelinesOK) Code() int { + return 200 +} + func (o *GetPipelinesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesOK %s", 200, payload) +} + +func (o *GetPipelinesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesOK %s", 200, payload) } func (o *GetPipelinesOK) GetPayload() *GetPipelinesOKBody { @@ -96,20 +134,60 @@ func NewGetPipelinesNotFound() *GetPipelinesNotFound { return &GetPipelinesNotFound{} } -/*GetPipelinesNotFound handles this case with default header values. +/* +GetPipelinesNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetPipelinesNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipelines not found response has a 2xx status code +func (o *GetPipelinesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipelines not found response has a 3xx status code +func (o *GetPipelinesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipelines not found response has a 4xx status code +func (o *GetPipelinesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipelines not found response has a 5xx status code +func (o *GetPipelinesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipelines not found response a status code equal to that given +func (o *GetPipelinesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get pipelines not found response +func (o *GetPipelinesNotFound) Code() int { + return 404 +} + func (o *GetPipelinesNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesNotFound %s", 404, payload) +} + +func (o *GetPipelinesNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesNotFound %s", 404, payload) } func (o *GetPipelinesNotFound) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *GetPipelinesNotFound) GetPayload() *models.ErrorPayload { func (o *GetPipelinesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewGetPipelinesUnprocessableEntity() *GetPipelinesUnprocessableEntity { return &GetPipelinesUnprocessableEntity{} } -/*GetPipelinesUnprocessableEntity handles this case with default header values. +/* +GetPipelinesUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetPipelinesUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipelines unprocessable entity response has a 2xx status code +func (o *GetPipelinesUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get pipelines unprocessable entity response has a 3xx status code +func (o *GetPipelinesUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get pipelines unprocessable entity response has a 4xx status code +func (o *GetPipelinesUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get pipelines unprocessable entity response has a 5xx status code +func (o *GetPipelinesUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get pipelines unprocessable entity response a status code equal to that given +func (o *GetPipelinesUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get pipelines unprocessable entity response +func (o *GetPipelinesUnprocessableEntity) Code() int { + return 422 +} + func (o *GetPipelinesUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesUnprocessableEntity %s", 422, payload) +} + +func (o *GetPipelinesUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelinesUnprocessableEntity %s", 422, payload) } func (o *GetPipelinesUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *GetPipelinesUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetPipelinesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewGetPipelinesDefault(code int) *GetPipelinesDefault { } } -/*GetPipelinesDefault handles this case with default header values. +/* +GetPipelinesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetPipelinesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get pipelines default response has a 2xx status code +func (o *GetPipelinesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get pipelines default response has a 3xx status code +func (o *GetPipelinesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get pipelines default response has a 4xx status code +func (o *GetPipelinesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get pipelines default response has a 5xx status code +func (o *GetPipelinesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get pipelines default response a status code equal to that given +func (o *GetPipelinesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get pipelines default response func (o *GetPipelinesDefault) Code() int { return o._statusCode } func (o *GetPipelinesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelines default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelines default %s", o._statusCode, payload) +} + +func (o *GetPipelinesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines][%d] getPipelines default %s", o._statusCode, payload) } func (o *GetPipelinesDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *GetPipelinesDefault) GetPayload() *models.ErrorPayload { func (o *GetPipelinesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *GetPipelinesDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*GetPipelinesOKBody get pipelines o k body +/* +GetPipelinesOKBody get pipelines o k body swagger:model GetPipelinesOKBody */ type GetPipelinesOKBody struct { @@ -279,6 +444,8 @@ func (o *GetPipelinesOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getPipelinesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPipelinesOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -299,6 +466,68 @@ func (o *GetPipelinesOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getPipelinesOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPipelinesOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get pipelines o k body based on the context it is used +func (o *GetPipelinesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetPipelinesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getPipelinesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPipelinesOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetPipelinesOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getPipelinesOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getPipelinesOK" + "." + "pagination") } return err } diff --git a/client/client/organization_pipelines/get_project_pipelines_parameters.go b/client/client/organization_pipelines/get_project_pipelines_parameters.go index e268a357..5d63152b 100644 --- a/client/client/organization_pipelines/get_project_pipelines_parameters.go +++ b/client/client/organization_pipelines/get_project_pipelines_parameters.go @@ -13,93 +13,82 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetProjectPipelinesParams creates a new GetProjectPipelinesParams object -// with the default values initialized. +// NewGetProjectPipelinesParams creates a new GetProjectPipelinesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetProjectPipelinesParams() *GetProjectPipelinesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetProjectPipelinesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetProjectPipelinesParamsWithTimeout creates a new GetProjectPipelinesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetProjectPipelinesParamsWithTimeout(timeout time.Duration) *GetProjectPipelinesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetProjectPipelinesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetProjectPipelinesParamsWithContext creates a new GetProjectPipelinesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetProjectPipelinesParamsWithContext(ctx context.Context) *GetProjectPipelinesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetProjectPipelinesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetProjectPipelinesParamsWithHTTPClient creates a new GetProjectPipelinesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetProjectPipelinesParamsWithHTTPClient(client *http.Client) *GetProjectPipelinesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetProjectPipelinesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetProjectPipelinesParams contains all the parameters to send to the API endpoint -for the get project pipelines operation typically these are written to a http.Request +/* +GetProjectPipelinesParams contains all the parameters to send to the API endpoint + + for the get project pipelines operation. + + Typically these are written to a http.Request. */ type GetProjectPipelinesParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -108,6 +97,35 @@ type GetProjectPipelinesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get project pipelines params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetProjectPipelinesParams) WithDefaults() *GetProjectPipelinesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get project pipelines params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetProjectPipelinesParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetProjectPipelinesParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get project pipelines params func (o *GetProjectPipelinesParams) WithTimeout(timeout time.Duration) *GetProjectPipelinesParams { o.SetTimeout(timeout) @@ -202,32 +220,34 @@ func (o *GetProjectPipelinesParams) WriteToRequest(r runtime.ClientRequest, reg // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } // path param project_canonical diff --git a/client/client/organization_pipelines/get_project_pipelines_responses.go b/client/client/organization_pipelines/get_project_pipelines_responses.go index 793e171d..80203b6e 100644 --- a/client/client/organization_pipelines/get_project_pipelines_responses.go +++ b/client/client/organization_pipelines/get_project_pipelines_responses.go @@ -6,18 +6,19 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetProjectPipelinesReader is a Reader for the GetProjectPipelines structure. @@ -63,7 +64,8 @@ func NewGetProjectPipelinesOK() *GetProjectPipelinesOK { return &GetProjectPipelinesOK{} } -/*GetProjectPipelinesOK handles this case with default header values. +/* +GetProjectPipelinesOK describes a response with status code 200, with default header values. List of the pipelines which authenticated user has access to. */ @@ -71,8 +73,44 @@ type GetProjectPipelinesOK struct { Payload *GetProjectPipelinesOKBody } +// IsSuccess returns true when this get project pipelines o k response has a 2xx status code +func (o *GetProjectPipelinesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get project pipelines o k response has a 3xx status code +func (o *GetProjectPipelinesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project pipelines o k response has a 4xx status code +func (o *GetProjectPipelinesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get project pipelines o k response has a 5xx status code +func (o *GetProjectPipelinesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get project pipelines o k response a status code equal to that given +func (o *GetProjectPipelinesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get project pipelines o k response +func (o *GetProjectPipelinesOK) Code() int { + return 200 +} + func (o *GetProjectPipelinesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesOK %s", 200, payload) +} + +func (o *GetProjectPipelinesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesOK %s", 200, payload) } func (o *GetProjectPipelinesOK) GetPayload() *GetProjectPipelinesOKBody { @@ -96,20 +134,60 @@ func NewGetProjectPipelinesNotFound() *GetProjectPipelinesNotFound { return &GetProjectPipelinesNotFound{} } -/*GetProjectPipelinesNotFound handles this case with default header values. +/* +GetProjectPipelinesNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetProjectPipelinesNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project pipelines not found response has a 2xx status code +func (o *GetProjectPipelinesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get project pipelines not found response has a 3xx status code +func (o *GetProjectPipelinesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project pipelines not found response has a 4xx status code +func (o *GetProjectPipelinesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get project pipelines not found response has a 5xx status code +func (o *GetProjectPipelinesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get project pipelines not found response a status code equal to that given +func (o *GetProjectPipelinesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get project pipelines not found response +func (o *GetProjectPipelinesNotFound) Code() int { + return 404 +} + func (o *GetProjectPipelinesNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesNotFound %s", 404, payload) +} + +func (o *GetProjectPipelinesNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesNotFound %s", 404, payload) } func (o *GetProjectPipelinesNotFound) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *GetProjectPipelinesNotFound) GetPayload() *models.ErrorPayload { func (o *GetProjectPipelinesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewGetProjectPipelinesUnprocessableEntity() *GetProjectPipelinesUnprocessab return &GetProjectPipelinesUnprocessableEntity{} } -/*GetProjectPipelinesUnprocessableEntity handles this case with default header values. +/* +GetProjectPipelinesUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetProjectPipelinesUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project pipelines unprocessable entity response has a 2xx status code +func (o *GetProjectPipelinesUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get project pipelines unprocessable entity response has a 3xx status code +func (o *GetProjectPipelinesUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project pipelines unprocessable entity response has a 4xx status code +func (o *GetProjectPipelinesUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get project pipelines unprocessable entity response has a 5xx status code +func (o *GetProjectPipelinesUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get project pipelines unprocessable entity response a status code equal to that given +func (o *GetProjectPipelinesUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get project pipelines unprocessable entity response +func (o *GetProjectPipelinesUnprocessableEntity) Code() int { + return 422 +} + func (o *GetProjectPipelinesUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesUnprocessableEntity %s", 422, payload) +} + +func (o *GetProjectPipelinesUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelinesUnprocessableEntity %s", 422, payload) } func (o *GetProjectPipelinesUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *GetProjectPipelinesUnprocessableEntity) GetPayload() *models.ErrorPaylo func (o *GetProjectPipelinesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewGetProjectPipelinesDefault(code int) *GetProjectPipelinesDefault { } } -/*GetProjectPipelinesDefault handles this case with default header values. +/* +GetProjectPipelinesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetProjectPipelinesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project pipelines default response has a 2xx status code +func (o *GetProjectPipelinesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get project pipelines default response has a 3xx status code +func (o *GetProjectPipelinesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get project pipelines default response has a 4xx status code +func (o *GetProjectPipelinesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get project pipelines default response has a 5xx status code +func (o *GetProjectPipelinesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get project pipelines default response a status code equal to that given +func (o *GetProjectPipelinesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get project pipelines default response func (o *GetProjectPipelinesDefault) Code() int { return o._statusCode } func (o *GetProjectPipelinesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelines default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelines default %s", o._statusCode, payload) +} + +func (o *GetProjectPipelinesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines][%d] getProjectPipelines default %s", o._statusCode, payload) } func (o *GetProjectPipelinesDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *GetProjectPipelinesDefault) GetPayload() *models.ErrorPayload { func (o *GetProjectPipelinesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *GetProjectPipelinesDefault) readResponse(response runtime.ClientRespons return nil } -/*GetProjectPipelinesOKBody get project pipelines o k body +/* +GetProjectPipelinesOKBody get project pipelines o k body swagger:model GetProjectPipelinesOKBody */ type GetProjectPipelinesOKBody struct { @@ -279,6 +444,8 @@ func (o *GetProjectPipelinesOKBody) validateData(formats strfmt.Registry) error if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getProjectPipelinesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectPipelinesOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -299,6 +466,68 @@ func (o *GetProjectPipelinesOKBody) validatePagination(formats strfmt.Registry) if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getProjectPipelinesOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectPipelinesOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get project pipelines o k body based on the context it is used +func (o *GetProjectPipelinesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetProjectPipelinesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getProjectPipelinesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectPipelinesOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetProjectPipelinesOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getProjectPipelinesOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectPipelinesOK" + "." + "pagination") } return err } diff --git a/client/client/organization_pipelines/organization_pipelines_client.go b/client/client/organization_pipelines/organization_pipelines_client.go index 6babc3fd..03e594d7 100644 --- a/client/client/organization_pipelines/organization_pipelines_client.go +++ b/client/client/organization_pipelines/organization_pipelines_client.go @@ -7,15 +7,40 @@ package organization_pipelines import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization pipelines API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization pipelines API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization pipelines API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization pipelines API */ @@ -24,16 +49,98 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreatePipeline(params *CreatePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreatePipelineOK, error) + + DeletePipeline(params *DeletePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeletePipelineNoContent, error) + + DiffPipeline(params *DiffPipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DiffPipelineOK, error) + + GetPipeline(params *GetPipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPipelineOK, error) + + GetPipelineConfig(params *GetPipelineConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPipelineConfigOK, error) + + GetPipelineVariables(params *GetPipelineVariablesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPipelineVariablesOK, error) + + GetPipelines(params *GetPipelinesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPipelinesOK, error) + + GetProjectPipelines(params *GetProjectPipelinesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectPipelinesOK, error) + + PausePipeline(params *PausePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PausePipelineNoContent, error) + + RenamePipeline(params *RenamePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RenamePipelineNoContent, error) + + SyncedPipeline(params *SyncedPipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SyncedPipelineOK, error) + + UnpausePipeline(params *UnpausePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnpausePipelineNoContent, error) + + UpdatePipeline(params *UpdatePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdatePipelineOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreatePipeline Create a new pipeline */ -func (a *Client) CreatePipeline(params *CreatePipelineParams, authInfo runtime.ClientAuthInfoWriter) (*CreatePipelineOK, error) { +func (a *Client) CreatePipeline(params *CreatePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreatePipelineOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreatePipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createPipeline", Method: "POST", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines", @@ -45,7 +152,12 @@ func (a *Client) CreatePipeline(params *CreatePipelineParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +173,12 @@ func (a *Client) CreatePipeline(params *CreatePipelineParams, authInfo runtime.C /* DeletePipeline Delete the pipeline. */ -func (a *Client) DeletePipeline(params *DeletePipelineParams, authInfo runtime.ClientAuthInfoWriter) (*DeletePipelineNoContent, error) { +func (a *Client) DeletePipeline(params *DeletePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeletePipelineNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeletePipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deletePipeline", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}", @@ -79,7 +190,12 @@ func (a *Client) DeletePipeline(params *DeletePipelineParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +211,12 @@ func (a *Client) DeletePipeline(params *DeletePipelineParams, authInfo runtime.C /* DiffPipeline The diff between the provided pipeline configuration and the pipeline from the given name. */ -func (a *Client) DiffPipeline(params *DiffPipelineParams, authInfo runtime.ClientAuthInfoWriter) (*DiffPipelineOK, error) { +func (a *Client) DiffPipeline(params *DiffPipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DiffPipelineOK, error) { // TODO: Validate the params before sending if params == nil { params = NewDiffPipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "diffPipeline", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/diff", @@ -113,7 +228,12 @@ func (a *Client) DiffPipeline(params *DiffPipelineParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +249,12 @@ func (a *Client) DiffPipeline(params *DiffPipelineParams, authInfo runtime.Clien /* GetPipeline Get the configuration of the pipeline. */ -func (a *Client) GetPipeline(params *GetPipelineParams, authInfo runtime.ClientAuthInfoWriter) (*GetPipelineOK, error) { +func (a *Client) GetPipeline(params *GetPipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPipelineOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetPipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getPipeline", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}", @@ -147,7 +266,12 @@ func (a *Client) GetPipeline(params *GetPipelineParams, authInfo runtime.ClientA AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +287,12 @@ func (a *Client) GetPipeline(params *GetPipelineParams, authInfo runtime.ClientA /* GetPipelineConfig Get the YAML configuration of the pipeline. */ -func (a *Client) GetPipelineConfig(params *GetPipelineConfigParams, authInfo runtime.ClientAuthInfoWriter) (*GetPipelineConfigOK, error) { +func (a *Client) GetPipelineConfig(params *GetPipelineConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPipelineConfigOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetPipelineConfigParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getPipelineConfig", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/config", @@ -181,7 +304,12 @@ func (a *Client) GetPipelineConfig(params *GetPipelineConfigParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -197,13 +325,12 @@ func (a *Client) GetPipelineConfig(params *GetPipelineConfigParams, authInfo run /* GetPipelineVariables Get the YAML variables of the pipeline. */ -func (a *Client) GetPipelineVariables(params *GetPipelineVariablesParams, authInfo runtime.ClientAuthInfoWriter) (*GetPipelineVariablesOK, error) { +func (a *Client) GetPipelineVariables(params *GetPipelineVariablesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPipelineVariablesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetPipelineVariablesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getPipelineVariables", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/variables", @@ -215,7 +342,12 @@ func (a *Client) GetPipelineVariables(params *GetPipelineVariablesParams, authIn AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -231,13 +363,12 @@ func (a *Client) GetPipelineVariables(params *GetPipelineVariablesParams, authIn /* GetPipelines Get all the pipelines that the authenticated user has access to. */ -func (a *Client) GetPipelines(params *GetPipelinesParams, authInfo runtime.ClientAuthInfoWriter) (*GetPipelinesOK, error) { +func (a *Client) GetPipelines(params *GetPipelinesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetPipelinesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetPipelinesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getPipelines", Method: "GET", PathPattern: "/organizations/{organization_canonical}/pipelines", @@ -249,7 +380,12 @@ func (a *Client) GetPipelines(params *GetPipelinesParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -265,13 +401,12 @@ func (a *Client) GetPipelines(params *GetPipelinesParams, authInfo runtime.Clien /* GetProjectPipelines Get the pipelines that the authenticated user has access to. */ -func (a *Client) GetProjectPipelines(params *GetProjectPipelinesParams, authInfo runtime.ClientAuthInfoWriter) (*GetProjectPipelinesOK, error) { +func (a *Client) GetProjectPipelines(params *GetProjectPipelinesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectPipelinesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetProjectPipelinesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getProjectPipelines", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines", @@ -283,7 +418,12 @@ func (a *Client) GetProjectPipelines(params *GetProjectPipelinesParams, authInfo AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -299,13 +439,12 @@ func (a *Client) GetProjectPipelines(params *GetProjectPipelinesParams, authInfo /* PausePipeline Pause a pipeline */ -func (a *Client) PausePipeline(params *PausePipelineParams, authInfo runtime.ClientAuthInfoWriter) (*PausePipelineNoContent, error) { +func (a *Client) PausePipeline(params *PausePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PausePipelineNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewPausePipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "pausePipeline", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause", @@ -317,7 +456,12 @@ func (a *Client) PausePipeline(params *PausePipelineParams, authInfo runtime.Cli AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -333,13 +477,12 @@ func (a *Client) PausePipeline(params *PausePipelineParams, authInfo runtime.Cli /* RenamePipeline Rename a pipeline */ -func (a *Client) RenamePipeline(params *RenamePipelineParams, authInfo runtime.ClientAuthInfoWriter) (*RenamePipelineNoContent, error) { +func (a *Client) RenamePipeline(params *RenamePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RenamePipelineNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewRenamePipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "renamePipeline", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename", @@ -351,7 +494,12 @@ func (a *Client) RenamePipeline(params *RenamePipelineParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -367,13 +515,12 @@ func (a *Client) RenamePipeline(params *RenamePipelineParams, authInfo runtime.C /* SyncedPipeline Will check if the pipeline from the database and the one specified in the stack are synced or not */ -func (a *Client) SyncedPipeline(params *SyncedPipelineParams, authInfo runtime.ClientAuthInfoWriter) (*SyncedPipelineOK, error) { +func (a *Client) SyncedPipeline(params *SyncedPipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SyncedPipelineOK, error) { // TODO: Validate the params before sending if params == nil { params = NewSyncedPipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "syncedPipeline", Method: "GET", PathPattern: "/organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced", @@ -385,7 +532,12 @@ func (a *Client) SyncedPipeline(params *SyncedPipelineParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -401,13 +553,12 @@ func (a *Client) SyncedPipeline(params *SyncedPipelineParams, authInfo runtime.C /* UnpausePipeline Unpause a pipeline */ -func (a *Client) UnpausePipeline(params *UnpausePipelineParams, authInfo runtime.ClientAuthInfoWriter) (*UnpausePipelineNoContent, error) { +func (a *Client) UnpausePipeline(params *UnpausePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnpausePipelineNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewUnpausePipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "unpausePipeline", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause", @@ -419,7 +570,12 @@ func (a *Client) UnpausePipeline(params *UnpausePipelineParams, authInfo runtime AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -435,13 +591,12 @@ func (a *Client) UnpausePipeline(params *UnpausePipelineParams, authInfo runtime /* UpdatePipeline Update the configuration of the given pipeline name. */ -func (a *Client) UpdatePipeline(params *UpdatePipelineParams, authInfo runtime.ClientAuthInfoWriter) (*UpdatePipelineOK, error) { +func (a *Client) UpdatePipeline(params *UpdatePipelineParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdatePipelineOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdatePipelineParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updatePipeline", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}", @@ -453,7 +608,12 @@ func (a *Client) UpdatePipeline(params *UpdatePipelineParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_pipelines/pause_pipeline_parameters.go b/client/client/organization_pipelines/pause_pipeline_parameters.go index a3e6cdde..fbedfa47 100644 --- a/client/client/organization_pipelines/pause_pipeline_parameters.go +++ b/client/client/organization_pipelines/pause_pipeline_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewPausePipelineParams creates a new PausePipelineParams object -// with the default values initialized. +// NewPausePipelineParams creates a new PausePipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewPausePipelineParams() *PausePipelineParams { - var () return &PausePipelineParams{ - timeout: cr.DefaultTimeout, } } // NewPausePipelineParamsWithTimeout creates a new PausePipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPausePipelineParamsWithTimeout(timeout time.Duration) *PausePipelineParams { - var () return &PausePipelineParams{ - timeout: timeout, } } // NewPausePipelineParamsWithContext creates a new PausePipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPausePipelineParamsWithContext(ctx context.Context) *PausePipelineParams { - var () return &PausePipelineParams{ - Context: ctx, } } // NewPausePipelineParamsWithHTTPClient creates a new PausePipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPausePipelineParamsWithHTTPClient(client *http.Client) *PausePipelineParams { - var () return &PausePipelineParams{ HTTPClient: client, } } -/*PausePipelineParams contains all the parameters to send to the API endpoint -for the pause pipeline operation typically these are written to a http.Request +/* +PausePipelineParams contains all the parameters to send to the API endpoint + + for the pause pipeline operation. + + Typically these are written to a http.Request. */ type PausePipelineParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -82,6 +84,21 @@ type PausePipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the pause pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PausePipelineParams) WithDefaults() *PausePipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pause pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PausePipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the pause pipeline params func (o *PausePipelineParams) WithTimeout(timeout time.Duration) *PausePipelineParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines/pause_pipeline_responses.go b/client/client/organization_pipelines/pause_pipeline_responses.go index 9b27cec1..5bf93273 100644 --- a/client/client/organization_pipelines/pause_pipeline_responses.go +++ b/client/client/organization_pipelines/pause_pipeline_responses.go @@ -6,16 +6,16 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // PausePipelineReader is a Reader for the PausePipeline structure. @@ -61,15 +61,50 @@ func NewPausePipelineNoContent() *PausePipelineNoContent { return &PausePipelineNoContent{} } -/*PausePipelineNoContent handles this case with default header values. +/* +PausePipelineNoContent describes a response with status code 204, with default header values. Pipeline has been paused. */ type PausePipelineNoContent struct { } +// IsSuccess returns true when this pause pipeline no content response has a 2xx status code +func (o *PausePipelineNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this pause pipeline no content response has a 3xx status code +func (o *PausePipelineNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this pause pipeline no content response has a 4xx status code +func (o *PausePipelineNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this pause pipeline no content response has a 5xx status code +func (o *PausePipelineNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this pause pipeline no content response a status code equal to that given +func (o *PausePipelineNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the pause pipeline no content response +func (o *PausePipelineNoContent) Code() int { + return 204 +} + func (o *PausePipelineNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineNoContent", 204) +} + +func (o *PausePipelineNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineNoContent", 204) } func (o *PausePipelineNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewPausePipelineForbidden() *PausePipelineForbidden { return &PausePipelineForbidden{} } -/*PausePipelineForbidden handles this case with default header values. +/* +PausePipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type PausePipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this pause pipeline forbidden response has a 2xx status code +func (o *PausePipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this pause pipeline forbidden response has a 3xx status code +func (o *PausePipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this pause pipeline forbidden response has a 4xx status code +func (o *PausePipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this pause pipeline forbidden response has a 5xx status code +func (o *PausePipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this pause pipeline forbidden response a status code equal to that given +func (o *PausePipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the pause pipeline forbidden response +func (o *PausePipelineForbidden) Code() int { + return 403 +} + func (o *PausePipelineForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineForbidden %s", 403, payload) +} + +func (o *PausePipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineForbidden %s", 403, payload) } func (o *PausePipelineForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *PausePipelineForbidden) GetPayload() *models.ErrorPayload { func (o *PausePipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewPausePipelineNotFound() *PausePipelineNotFound { return &PausePipelineNotFound{} } -/*PausePipelineNotFound handles this case with default header values. +/* +PausePipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type PausePipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this pause pipeline not found response has a 2xx status code +func (o *PausePipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this pause pipeline not found response has a 3xx status code +func (o *PausePipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this pause pipeline not found response has a 4xx status code +func (o *PausePipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this pause pipeline not found response has a 5xx status code +func (o *PausePipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this pause pipeline not found response a status code equal to that given +func (o *PausePipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the pause pipeline not found response +func (o *PausePipelineNotFound) Code() int { + return 404 +} + func (o *PausePipelineNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineNotFound %s", 404, payload) +} + +func (o *PausePipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipelineNotFound %s", 404, payload) } func (o *PausePipelineNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *PausePipelineNotFound) GetPayload() *models.ErrorPayload { func (o *PausePipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewPausePipelineDefault(code int) *PausePipelineDefault { } } -/*PausePipelineDefault handles this case with default header values. +/* +PausePipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type PausePipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this pause pipeline default response has a 2xx status code +func (o *PausePipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this pause pipeline default response has a 3xx status code +func (o *PausePipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this pause pipeline default response has a 4xx status code +func (o *PausePipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this pause pipeline default response has a 5xx status code +func (o *PausePipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this pause pipeline default response a status code equal to that given +func (o *PausePipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the pause pipeline default response func (o *PausePipelineDefault) Code() int { return o._statusCode } func (o *PausePipelineDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipeline default %s", o._statusCode, payload) +} + +func (o *PausePipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/pause][%d] pausePipeline default %s", o._statusCode, payload) } func (o *PausePipelineDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *PausePipelineDefault) GetPayload() *models.ErrorPayload { func (o *PausePipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_pipelines/rename_pipeline_parameters.go b/client/client/organization_pipelines/rename_pipeline_parameters.go index a2b60466..19024af0 100644 --- a/client/client/organization_pipelines/rename_pipeline_parameters.go +++ b/client/client/organization_pipelines/rename_pipeline_parameters.go @@ -13,72 +13,75 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewRenamePipelineParams creates a new RenamePipelineParams object -// with the default values initialized. +// NewRenamePipelineParams creates a new RenamePipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewRenamePipelineParams() *RenamePipelineParams { - var () return &RenamePipelineParams{ - timeout: cr.DefaultTimeout, } } // NewRenamePipelineParamsWithTimeout creates a new RenamePipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewRenamePipelineParamsWithTimeout(timeout time.Duration) *RenamePipelineParams { - var () return &RenamePipelineParams{ - timeout: timeout, } } // NewRenamePipelineParamsWithContext creates a new RenamePipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewRenamePipelineParamsWithContext(ctx context.Context) *RenamePipelineParams { - var () return &RenamePipelineParams{ - Context: ctx, } } // NewRenamePipelineParamsWithHTTPClient creates a new RenamePipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewRenamePipelineParamsWithHTTPClient(client *http.Client) *RenamePipelineParams { - var () return &RenamePipelineParams{ HTTPClient: client, } } -/*RenamePipelineParams contains all the parameters to send to the API endpoint -for the rename pipeline operation typically these are written to a http.Request +/* +RenamePipelineParams contains all the parameters to send to the API endpoint + + for the rename pipeline operation. + + Typically these are written to a http.Request. */ type RenamePipelineParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PipelineName - A pipeline name + /* PipelineName. + + A pipeline name */ PipelineName string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -87,6 +90,21 @@ type RenamePipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the rename pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RenamePipelineParams) WithDefaults() *RenamePipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the rename pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RenamePipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the rename pipeline params func (o *RenamePipelineParams) WithTimeout(timeout time.Duration) *RenamePipelineParams { o.SetTimeout(timeout) @@ -186,6 +204,7 @@ func (o *RenamePipelineParams) WriteToRequest(r runtime.ClientRequest, reg strfm qrPipelineName := o.PipelineName qPipelineName := qrPipelineName if qPipelineName != "" { + if err := r.SetQueryParam("pipeline_name", qPipelineName); err != nil { return err } diff --git a/client/client/organization_pipelines/rename_pipeline_responses.go b/client/client/organization_pipelines/rename_pipeline_responses.go index d57278c7..7b3d2c7e 100644 --- a/client/client/organization_pipelines/rename_pipeline_responses.go +++ b/client/client/organization_pipelines/rename_pipeline_responses.go @@ -6,16 +6,16 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // RenamePipelineReader is a Reader for the RenamePipeline structure. @@ -61,15 +61,50 @@ func NewRenamePipelineNoContent() *RenamePipelineNoContent { return &RenamePipelineNoContent{} } -/*RenamePipelineNoContent handles this case with default header values. +/* +RenamePipelineNoContent describes a response with status code 204, with default header values. Pipeline has been renamed. */ type RenamePipelineNoContent struct { } +// IsSuccess returns true when this rename pipeline no content response has a 2xx status code +func (o *RenamePipelineNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this rename pipeline no content response has a 3xx status code +func (o *RenamePipelineNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this rename pipeline no content response has a 4xx status code +func (o *RenamePipelineNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this rename pipeline no content response has a 5xx status code +func (o *RenamePipelineNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this rename pipeline no content response a status code equal to that given +func (o *RenamePipelineNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the rename pipeline no content response +func (o *RenamePipelineNoContent) Code() int { + return 204 +} + func (o *RenamePipelineNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineNoContent", 204) +} + +func (o *RenamePipelineNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineNoContent", 204) } func (o *RenamePipelineNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewRenamePipelineForbidden() *RenamePipelineForbidden { return &RenamePipelineForbidden{} } -/*RenamePipelineForbidden handles this case with default header values. +/* +RenamePipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type RenamePipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this rename pipeline forbidden response has a 2xx status code +func (o *RenamePipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this rename pipeline forbidden response has a 3xx status code +func (o *RenamePipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this rename pipeline forbidden response has a 4xx status code +func (o *RenamePipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this rename pipeline forbidden response has a 5xx status code +func (o *RenamePipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this rename pipeline forbidden response a status code equal to that given +func (o *RenamePipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the rename pipeline forbidden response +func (o *RenamePipelineForbidden) Code() int { + return 403 +} + func (o *RenamePipelineForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineForbidden %s", 403, payload) +} + +func (o *RenamePipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineForbidden %s", 403, payload) } func (o *RenamePipelineForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *RenamePipelineForbidden) GetPayload() *models.ErrorPayload { func (o *RenamePipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewRenamePipelineNotFound() *RenamePipelineNotFound { return &RenamePipelineNotFound{} } -/*RenamePipelineNotFound handles this case with default header values. +/* +RenamePipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type RenamePipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this rename pipeline not found response has a 2xx status code +func (o *RenamePipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this rename pipeline not found response has a 3xx status code +func (o *RenamePipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this rename pipeline not found response has a 4xx status code +func (o *RenamePipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this rename pipeline not found response has a 5xx status code +func (o *RenamePipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this rename pipeline not found response a status code equal to that given +func (o *RenamePipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the rename pipeline not found response +func (o *RenamePipelineNotFound) Code() int { + return 404 +} + func (o *RenamePipelineNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineNotFound %s", 404, payload) +} + +func (o *RenamePipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipelineNotFound %s", 404, payload) } func (o *RenamePipelineNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *RenamePipelineNotFound) GetPayload() *models.ErrorPayload { func (o *RenamePipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewRenamePipelineDefault(code int) *RenamePipelineDefault { } } -/*RenamePipelineDefault handles this case with default header values. +/* +RenamePipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type RenamePipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this rename pipeline default response has a 2xx status code +func (o *RenamePipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this rename pipeline default response has a 3xx status code +func (o *RenamePipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this rename pipeline default response has a 4xx status code +func (o *RenamePipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this rename pipeline default response has a 5xx status code +func (o *RenamePipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this rename pipeline default response a status code equal to that given +func (o *RenamePipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the rename pipeline default response func (o *RenamePipelineDefault) Code() int { return o._statusCode } func (o *RenamePipelineDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipeline default %s", o._statusCode, payload) +} + +func (o *RenamePipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/rename][%d] renamePipeline default %s", o._statusCode, payload) } func (o *RenamePipelineDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *RenamePipelineDefault) GetPayload() *models.ErrorPayload { func (o *RenamePipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_pipelines/synced_pipeline_parameters.go b/client/client/organization_pipelines/synced_pipeline_parameters.go index e7194c24..0a74eaa2 100644 --- a/client/client/organization_pipelines/synced_pipeline_parameters.go +++ b/client/client/organization_pipelines/synced_pipeline_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewSyncedPipelineParams creates a new SyncedPipelineParams object -// with the default values initialized. +// NewSyncedPipelineParams creates a new SyncedPipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewSyncedPipelineParams() *SyncedPipelineParams { - var () return &SyncedPipelineParams{ - timeout: cr.DefaultTimeout, } } // NewSyncedPipelineParamsWithTimeout creates a new SyncedPipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewSyncedPipelineParamsWithTimeout(timeout time.Duration) *SyncedPipelineParams { - var () return &SyncedPipelineParams{ - timeout: timeout, } } // NewSyncedPipelineParamsWithContext creates a new SyncedPipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewSyncedPipelineParamsWithContext(ctx context.Context) *SyncedPipelineParams { - var () return &SyncedPipelineParams{ - Context: ctx, } } // NewSyncedPipelineParamsWithHTTPClient creates a new SyncedPipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewSyncedPipelineParamsWithHTTPClient(client *http.Client) *SyncedPipelineParams { - var () return &SyncedPipelineParams{ HTTPClient: client, } } -/*SyncedPipelineParams contains all the parameters to send to the API endpoint -for the synced pipeline operation typically these are written to a http.Request +/* +SyncedPipelineParams contains all the parameters to send to the API endpoint + + for the synced pipeline operation. + + Typically these are written to a http.Request. */ type SyncedPipelineParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -77,6 +78,21 @@ type SyncedPipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the synced pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SyncedPipelineParams) WithDefaults() *SyncedPipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the synced pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SyncedPipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the synced pipeline params func (o *SyncedPipelineParams) WithTimeout(timeout time.Duration) *SyncedPipelineParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines/synced_pipeline_responses.go b/client/client/organization_pipelines/synced_pipeline_responses.go index 0df2e952..85f15908 100644 --- a/client/client/organization_pipelines/synced_pipeline_responses.go +++ b/client/client/organization_pipelines/synced_pipeline_responses.go @@ -6,17 +6,18 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // SyncedPipelineReader is a Reader for the SyncedPipeline structure. @@ -74,7 +75,8 @@ func NewSyncedPipelineOK() *SyncedPipelineOK { return &SyncedPipelineOK{} } -/*SyncedPipelineOK handles this case with default header values. +/* +SyncedPipelineOK describes a response with status code 200, with default header values. The diff between the stack's pipeline and the existing pipeline if any exists. */ @@ -82,8 +84,44 @@ type SyncedPipelineOK struct { Payload *SyncedPipelineOKBody } +// IsSuccess returns true when this synced pipeline o k response has a 2xx status code +func (o *SyncedPipelineOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this synced pipeline o k response has a 3xx status code +func (o *SyncedPipelineOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this synced pipeline o k response has a 4xx status code +func (o *SyncedPipelineOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this synced pipeline o k response has a 5xx status code +func (o *SyncedPipelineOK) IsServerError() bool { + return false +} + +// IsCode returns true when this synced pipeline o k response a status code equal to that given +func (o *SyncedPipelineOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the synced pipeline o k response +func (o *SyncedPipelineOK) Code() int { + return 200 +} + func (o *SyncedPipelineOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineOK %s", 200, payload) +} + +func (o *SyncedPipelineOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineOK %s", 200, payload) } func (o *SyncedPipelineOK) GetPayload() *SyncedPipelineOKBody { @@ -107,20 +145,60 @@ func NewSyncedPipelineForbidden() *SyncedPipelineForbidden { return &SyncedPipelineForbidden{} } -/*SyncedPipelineForbidden handles this case with default header values. +/* +SyncedPipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type SyncedPipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this synced pipeline forbidden response has a 2xx status code +func (o *SyncedPipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this synced pipeline forbidden response has a 3xx status code +func (o *SyncedPipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this synced pipeline forbidden response has a 4xx status code +func (o *SyncedPipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this synced pipeline forbidden response has a 5xx status code +func (o *SyncedPipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this synced pipeline forbidden response a status code equal to that given +func (o *SyncedPipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the synced pipeline forbidden response +func (o *SyncedPipelineForbidden) Code() int { + return 403 +} + func (o *SyncedPipelineForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineForbidden %s", 403, payload) +} + +func (o *SyncedPipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineForbidden %s", 403, payload) } func (o *SyncedPipelineForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *SyncedPipelineForbidden) GetPayload() *models.ErrorPayload { func (o *SyncedPipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewSyncedPipelineNotFound() *SyncedPipelineNotFound { return &SyncedPipelineNotFound{} } -/*SyncedPipelineNotFound handles this case with default header values. +/* +SyncedPipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type SyncedPipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this synced pipeline not found response has a 2xx status code +func (o *SyncedPipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this synced pipeline not found response has a 3xx status code +func (o *SyncedPipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this synced pipeline not found response has a 4xx status code +func (o *SyncedPipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this synced pipeline not found response has a 5xx status code +func (o *SyncedPipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this synced pipeline not found response a status code equal to that given +func (o *SyncedPipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the synced pipeline not found response +func (o *SyncedPipelineNotFound) Code() int { + return 404 +} + func (o *SyncedPipelineNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineNotFound %s", 404, payload) +} + +func (o *SyncedPipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineNotFound %s", 404, payload) } func (o *SyncedPipelineNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *SyncedPipelineNotFound) GetPayload() *models.ErrorPayload { func (o *SyncedPipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewSyncedPipelineLengthRequired() *SyncedPipelineLengthRequired { return &SyncedPipelineLengthRequired{} } -/*SyncedPipelineLengthRequired handles this case with default header values. +/* +SyncedPipelineLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type SyncedPipelineLengthRequired struct { } +// IsSuccess returns true when this synced pipeline length required response has a 2xx status code +func (o *SyncedPipelineLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this synced pipeline length required response has a 3xx status code +func (o *SyncedPipelineLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this synced pipeline length required response has a 4xx status code +func (o *SyncedPipelineLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this synced pipeline length required response has a 5xx status code +func (o *SyncedPipelineLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this synced pipeline length required response a status code equal to that given +func (o *SyncedPipelineLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the synced pipeline length required response +func (o *SyncedPipelineLengthRequired) Code() int { + return 411 +} + func (o *SyncedPipelineLengthRequired) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineLengthRequired ", 411) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineLengthRequired", 411) +} + +func (o *SyncedPipelineLengthRequired) String() string { + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineLengthRequired", 411) } func (o *SyncedPipelineLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewSyncedPipelineUnprocessableEntity() *SyncedPipelineUnprocessableEntity { return &SyncedPipelineUnprocessableEntity{} } -/*SyncedPipelineUnprocessableEntity handles this case with default header values. +/* +SyncedPipelineUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type SyncedPipelineUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this synced pipeline unprocessable entity response has a 2xx status code +func (o *SyncedPipelineUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this synced pipeline unprocessable entity response has a 3xx status code +func (o *SyncedPipelineUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this synced pipeline unprocessable entity response has a 4xx status code +func (o *SyncedPipelineUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this synced pipeline unprocessable entity response has a 5xx status code +func (o *SyncedPipelineUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this synced pipeline unprocessable entity response a status code equal to that given +func (o *SyncedPipelineUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the synced pipeline unprocessable entity response +func (o *SyncedPipelineUnprocessableEntity) Code() int { + return 422 +} + func (o *SyncedPipelineUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineUnprocessableEntity %s", 422, payload) +} + +func (o *SyncedPipelineUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipelineUnprocessableEntity %s", 422, payload) } func (o *SyncedPipelineUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *SyncedPipelineUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *SyncedPipelineUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewSyncedPipelineDefault(code int) *SyncedPipelineDefault { } } -/*SyncedPipelineDefault handles this case with default header values. +/* +SyncedPipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type SyncedPipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this synced pipeline default response has a 2xx status code +func (o *SyncedPipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this synced pipeline default response has a 3xx status code +func (o *SyncedPipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this synced pipeline default response has a 4xx status code +func (o *SyncedPipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this synced pipeline default response has a 5xx status code +func (o *SyncedPipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this synced pipeline default response a status code equal to that given +func (o *SyncedPipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the synced pipeline default response func (o *SyncedPipelineDefault) Code() int { return o._statusCode } func (o *SyncedPipelineDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipeline default %s", o._statusCode, payload) +} + +func (o *SyncedPipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/pipelines/{inpath_pipeline_name}/synced][%d] syncedPipeline default %s", o._statusCode, payload) } func (o *SyncedPipelineDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *SyncedPipelineDefault) GetPayload() *models.ErrorPayload { func (o *SyncedPipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *SyncedPipelineDefault) readResponse(response runtime.ClientResponse, co return nil } -/*SyncedPipelineOKBody synced pipeline o k body +/* +SyncedPipelineOKBody synced pipeline o k body swagger:model SyncedPipelineOKBody */ type SyncedPipelineOKBody struct { @@ -342,6 +586,39 @@ func (o *SyncedPipelineOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("syncedPipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("syncedPipelineOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this synced pipeline o k body based on the context it is used +func (o *SyncedPipelineOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *SyncedPipelineOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("syncedPipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("syncedPipelineOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines/unpause_pipeline_parameters.go b/client/client/organization_pipelines/unpause_pipeline_parameters.go index ea9d2d1a..b9587586 100644 --- a/client/client/organization_pipelines/unpause_pipeline_parameters.go +++ b/client/client/organization_pipelines/unpause_pipeline_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewUnpausePipelineParams creates a new UnpausePipelineParams object -// with the default values initialized. +// NewUnpausePipelineParams creates a new UnpausePipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUnpausePipelineParams() *UnpausePipelineParams { - var () return &UnpausePipelineParams{ - timeout: cr.DefaultTimeout, } } // NewUnpausePipelineParamsWithTimeout creates a new UnpausePipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUnpausePipelineParamsWithTimeout(timeout time.Duration) *UnpausePipelineParams { - var () return &UnpausePipelineParams{ - timeout: timeout, } } // NewUnpausePipelineParamsWithContext creates a new UnpausePipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUnpausePipelineParamsWithContext(ctx context.Context) *UnpausePipelineParams { - var () return &UnpausePipelineParams{ - Context: ctx, } } // NewUnpausePipelineParamsWithHTTPClient creates a new UnpausePipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUnpausePipelineParamsWithHTTPClient(client *http.Client) *UnpausePipelineParams { - var () return &UnpausePipelineParams{ HTTPClient: client, } } -/*UnpausePipelineParams contains all the parameters to send to the API endpoint -for the unpause pipeline operation typically these are written to a http.Request +/* +UnpausePipelineParams contains all the parameters to send to the API endpoint + + for the unpause pipeline operation. + + Typically these are written to a http.Request. */ type UnpausePipelineParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -82,6 +84,21 @@ type UnpausePipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the unpause pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UnpausePipelineParams) WithDefaults() *UnpausePipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the unpause pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UnpausePipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the unpause pipeline params func (o *UnpausePipelineParams) WithTimeout(timeout time.Duration) *UnpausePipelineParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines/unpause_pipeline_responses.go b/client/client/organization_pipelines/unpause_pipeline_responses.go index 4c67b76b..b87c990f 100644 --- a/client/client/organization_pipelines/unpause_pipeline_responses.go +++ b/client/client/organization_pipelines/unpause_pipeline_responses.go @@ -6,16 +6,16 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UnpausePipelineReader is a Reader for the UnpausePipeline structure. @@ -61,15 +61,50 @@ func NewUnpausePipelineNoContent() *UnpausePipelineNoContent { return &UnpausePipelineNoContent{} } -/*UnpausePipelineNoContent handles this case with default header values. +/* +UnpausePipelineNoContent describes a response with status code 204, with default header values. Pipeline has been unpaused. */ type UnpausePipelineNoContent struct { } +// IsSuccess returns true when this unpause pipeline no content response has a 2xx status code +func (o *UnpausePipelineNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this unpause pipeline no content response has a 3xx status code +func (o *UnpausePipelineNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unpause pipeline no content response has a 4xx status code +func (o *UnpausePipelineNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this unpause pipeline no content response has a 5xx status code +func (o *UnpausePipelineNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this unpause pipeline no content response a status code equal to that given +func (o *UnpausePipelineNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the unpause pipeline no content response +func (o *UnpausePipelineNoContent) Code() int { + return 204 +} + func (o *UnpausePipelineNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineNoContent", 204) +} + +func (o *UnpausePipelineNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineNoContent", 204) } func (o *UnpausePipelineNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewUnpausePipelineForbidden() *UnpausePipelineForbidden { return &UnpausePipelineForbidden{} } -/*UnpausePipelineForbidden handles this case with default header values. +/* +UnpausePipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UnpausePipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this unpause pipeline forbidden response has a 2xx status code +func (o *UnpausePipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this unpause pipeline forbidden response has a 3xx status code +func (o *UnpausePipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unpause pipeline forbidden response has a 4xx status code +func (o *UnpausePipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this unpause pipeline forbidden response has a 5xx status code +func (o *UnpausePipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this unpause pipeline forbidden response a status code equal to that given +func (o *UnpausePipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the unpause pipeline forbidden response +func (o *UnpausePipelineForbidden) Code() int { + return 403 +} + func (o *UnpausePipelineForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineForbidden %s", 403, payload) +} + +func (o *UnpausePipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineForbidden %s", 403, payload) } func (o *UnpausePipelineForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *UnpausePipelineForbidden) GetPayload() *models.ErrorPayload { func (o *UnpausePipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewUnpausePipelineNotFound() *UnpausePipelineNotFound { return &UnpausePipelineNotFound{} } -/*UnpausePipelineNotFound handles this case with default header values. +/* +UnpausePipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UnpausePipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this unpause pipeline not found response has a 2xx status code +func (o *UnpausePipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this unpause pipeline not found response has a 3xx status code +func (o *UnpausePipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unpause pipeline not found response has a 4xx status code +func (o *UnpausePipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this unpause pipeline not found response has a 5xx status code +func (o *UnpausePipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this unpause pipeline not found response a status code equal to that given +func (o *UnpausePipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the unpause pipeline not found response +func (o *UnpausePipelineNotFound) Code() int { + return 404 +} + func (o *UnpausePipelineNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineNotFound %s", 404, payload) +} + +func (o *UnpausePipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipelineNotFound %s", 404, payload) } func (o *UnpausePipelineNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *UnpausePipelineNotFound) GetPayload() *models.ErrorPayload { func (o *UnpausePipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewUnpausePipelineDefault(code int) *UnpausePipelineDefault { } } -/*UnpausePipelineDefault handles this case with default header values. +/* +UnpausePipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UnpausePipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this unpause pipeline default response has a 2xx status code +func (o *UnpausePipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this unpause pipeline default response has a 3xx status code +func (o *UnpausePipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this unpause pipeline default response has a 4xx status code +func (o *UnpausePipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this unpause pipeline default response has a 5xx status code +func (o *UnpausePipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this unpause pipeline default response a status code equal to that given +func (o *UnpausePipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the unpause pipeline default response func (o *UnpausePipelineDefault) Code() int { return o._statusCode } func (o *UnpausePipelineDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipeline default %s", o._statusCode, payload) +} + +func (o *UnpausePipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/unpause][%d] unpausePipeline default %s", o._statusCode, payload) } func (o *UnpausePipelineDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *UnpausePipelineDefault) GetPayload() *models.ErrorPayload { func (o *UnpausePipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_pipelines/update_pipeline_parameters.go b/client/client/organization_pipelines/update_pipeline_parameters.go index 576fe5cf..831b336c 100644 --- a/client/client/organization_pipelines/update_pipeline_parameters.go +++ b/client/client/organization_pipelines/update_pipeline_parameters.go @@ -13,74 +13,77 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdatePipelineParams creates a new UpdatePipelineParams object -// with the default values initialized. +// NewUpdatePipelineParams creates a new UpdatePipelineParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdatePipelineParams() *UpdatePipelineParams { - var () return &UpdatePipelineParams{ - timeout: cr.DefaultTimeout, } } // NewUpdatePipelineParamsWithTimeout creates a new UpdatePipelineParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdatePipelineParamsWithTimeout(timeout time.Duration) *UpdatePipelineParams { - var () return &UpdatePipelineParams{ - timeout: timeout, } } // NewUpdatePipelineParamsWithContext creates a new UpdatePipelineParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdatePipelineParamsWithContext(ctx context.Context) *UpdatePipelineParams { - var () return &UpdatePipelineParams{ - Context: ctx, } } // NewUpdatePipelineParamsWithHTTPClient creates a new UpdatePipelineParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdatePipelineParamsWithHTTPClient(client *http.Client) *UpdatePipelineParams { - var () return &UpdatePipelineParams{ HTTPClient: client, } } -/*UpdatePipelineParams contains all the parameters to send to the API endpoint -for the update pipeline operation typically these are written to a http.Request +/* +UpdatePipelineParams contains all the parameters to send to the API endpoint + + for the update pipeline operation. + + Typically these are written to a http.Request. */ type UpdatePipelineParams struct { - /*Body - The pipeline configuration + /* Body. + The pipeline configuration */ Body *models.UpdatePipeline - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -89,6 +92,21 @@ type UpdatePipelineParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdatePipelineParams) WithDefaults() *UpdatePipelineParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update pipeline params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdatePipelineParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update pipeline params func (o *UpdatePipelineParams) WithTimeout(timeout time.Duration) *UpdatePipelineParams { o.SetTimeout(timeout) @@ -173,7 +191,6 @@ func (o *UpdatePipelineParams) WriteToRequest(r runtime.ClientRequest, reg strfm return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_pipelines/update_pipeline_responses.go b/client/client/organization_pipelines/update_pipeline_responses.go index e069911d..74b93bde 100644 --- a/client/client/organization_pipelines/update_pipeline_responses.go +++ b/client/client/organization_pipelines/update_pipeline_responses.go @@ -6,17 +6,18 @@ package organization_pipelines // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdatePipelineReader is a Reader for the UpdatePipeline structure. @@ -74,7 +75,8 @@ func NewUpdatePipelineOK() *UpdatePipelineOK { return &UpdatePipelineOK{} } -/*UpdatePipelineOK handles this case with default header values. +/* +UpdatePipelineOK describes a response with status code 200, with default header values. The information of the pipeline which has been updated. */ @@ -82,8 +84,44 @@ type UpdatePipelineOK struct { Payload *UpdatePipelineOKBody } +// IsSuccess returns true when this update pipeline o k response has a 2xx status code +func (o *UpdatePipelineOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update pipeline o k response has a 3xx status code +func (o *UpdatePipelineOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update pipeline o k response has a 4xx status code +func (o *UpdatePipelineOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update pipeline o k response has a 5xx status code +func (o *UpdatePipelineOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update pipeline o k response a status code equal to that given +func (o *UpdatePipelineOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update pipeline o k response +func (o *UpdatePipelineOK) Code() int { + return 200 +} + func (o *UpdatePipelineOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineOK %s", 200, payload) +} + +func (o *UpdatePipelineOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineOK %s", 200, payload) } func (o *UpdatePipelineOK) GetPayload() *UpdatePipelineOKBody { @@ -107,20 +145,60 @@ func NewUpdatePipelineForbidden() *UpdatePipelineForbidden { return &UpdatePipelineForbidden{} } -/*UpdatePipelineForbidden handles this case with default header values. +/* +UpdatePipelineForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdatePipelineForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update pipeline forbidden response has a 2xx status code +func (o *UpdatePipelineForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update pipeline forbidden response has a 3xx status code +func (o *UpdatePipelineForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update pipeline forbidden response has a 4xx status code +func (o *UpdatePipelineForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update pipeline forbidden response has a 5xx status code +func (o *UpdatePipelineForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update pipeline forbidden response a status code equal to that given +func (o *UpdatePipelineForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update pipeline forbidden response +func (o *UpdatePipelineForbidden) Code() int { + return 403 +} + func (o *UpdatePipelineForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineForbidden %s", 403, payload) +} + +func (o *UpdatePipelineForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineForbidden %s", 403, payload) } func (o *UpdatePipelineForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *UpdatePipelineForbidden) GetPayload() *models.ErrorPayload { func (o *UpdatePipelineForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewUpdatePipelineNotFound() *UpdatePipelineNotFound { return &UpdatePipelineNotFound{} } -/*UpdatePipelineNotFound handles this case with default header values. +/* +UpdatePipelineNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdatePipelineNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update pipeline not found response has a 2xx status code +func (o *UpdatePipelineNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update pipeline not found response has a 3xx status code +func (o *UpdatePipelineNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update pipeline not found response has a 4xx status code +func (o *UpdatePipelineNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update pipeline not found response has a 5xx status code +func (o *UpdatePipelineNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update pipeline not found response a status code equal to that given +func (o *UpdatePipelineNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update pipeline not found response +func (o *UpdatePipelineNotFound) Code() int { + return 404 +} + func (o *UpdatePipelineNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineNotFound %s", 404, payload) +} + +func (o *UpdatePipelineNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineNotFound %s", 404, payload) } func (o *UpdatePipelineNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *UpdatePipelineNotFound) GetPayload() *models.ErrorPayload { func (o *UpdatePipelineNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewUpdatePipelineLengthRequired() *UpdatePipelineLengthRequired { return &UpdatePipelineLengthRequired{} } -/*UpdatePipelineLengthRequired handles this case with default header values. +/* +UpdatePipelineLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdatePipelineLengthRequired struct { } +// IsSuccess returns true when this update pipeline length required response has a 2xx status code +func (o *UpdatePipelineLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update pipeline length required response has a 3xx status code +func (o *UpdatePipelineLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update pipeline length required response has a 4xx status code +func (o *UpdatePipelineLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update pipeline length required response has a 5xx status code +func (o *UpdatePipelineLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update pipeline length required response a status code equal to that given +func (o *UpdatePipelineLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update pipeline length required response +func (o *UpdatePipelineLengthRequired) Code() int { + return 411 +} + func (o *UpdatePipelineLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineLengthRequired", 411) +} + +func (o *UpdatePipelineLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineLengthRequired", 411) } func (o *UpdatePipelineLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewUpdatePipelineUnprocessableEntity() *UpdatePipelineUnprocessableEntity { return &UpdatePipelineUnprocessableEntity{} } -/*UpdatePipelineUnprocessableEntity handles this case with default header values. +/* +UpdatePipelineUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdatePipelineUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update pipeline unprocessable entity response has a 2xx status code +func (o *UpdatePipelineUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update pipeline unprocessable entity response has a 3xx status code +func (o *UpdatePipelineUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update pipeline unprocessable entity response has a 4xx status code +func (o *UpdatePipelineUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update pipeline unprocessable entity response has a 5xx status code +func (o *UpdatePipelineUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update pipeline unprocessable entity response a status code equal to that given +func (o *UpdatePipelineUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update pipeline unprocessable entity response +func (o *UpdatePipelineUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdatePipelineUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineUnprocessableEntity %s", 422, payload) +} + +func (o *UpdatePipelineUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipelineUnprocessableEntity %s", 422, payload) } func (o *UpdatePipelineUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *UpdatePipelineUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *UpdatePipelineUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewUpdatePipelineDefault(code int) *UpdatePipelineDefault { } } -/*UpdatePipelineDefault handles this case with default header values. +/* +UpdatePipelineDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdatePipelineDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update pipeline default response has a 2xx status code +func (o *UpdatePipelineDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update pipeline default response has a 3xx status code +func (o *UpdatePipelineDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update pipeline default response has a 4xx status code +func (o *UpdatePipelineDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update pipeline default response has a 5xx status code +func (o *UpdatePipelineDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update pipeline default response a status code equal to that given +func (o *UpdatePipelineDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update pipeline default response func (o *UpdatePipelineDefault) Code() int { return o._statusCode } func (o *UpdatePipelineDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipeline default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipeline default %s", o._statusCode, payload) +} + +func (o *UpdatePipelineDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}][%d] updatePipeline default %s", o._statusCode, payload) } func (o *UpdatePipelineDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *UpdatePipelineDefault) GetPayload() *models.ErrorPayload { func (o *UpdatePipelineDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *UpdatePipelineDefault) readResponse(response runtime.ClientResponse, co return nil } -/*UpdatePipelineOKBody update pipeline o k body +/* +UpdatePipelineOKBody update pipeline o k body swagger:model UpdatePipelineOKBody */ type UpdatePipelineOKBody struct { @@ -342,6 +586,39 @@ func (o *UpdatePipelineOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updatePipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updatePipelineOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update pipeline o k body based on the context it is used +func (o *UpdatePipelineOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdatePipelineOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updatePipelineOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updatePipelineOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines_jobs/clear_task_cache_parameters.go b/client/client/organization_pipelines_jobs/clear_task_cache_parameters.go index c7f41cdd..ff7d3985 100644 --- a/client/client/organization_pipelines_jobs/clear_task_cache_parameters.go +++ b/client/client/organization_pipelines_jobs/clear_task_cache_parameters.go @@ -13,94 +13,87 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewClearTaskCacheParams creates a new ClearTaskCacheParams object -// with the default values initialized. +// NewClearTaskCacheParams creates a new ClearTaskCacheParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewClearTaskCacheParams() *ClearTaskCacheParams { - var ( - cachePathDefault = string("") - ) return &ClearTaskCacheParams{ - CachePath: &cachePathDefault, - timeout: cr.DefaultTimeout, } } // NewClearTaskCacheParamsWithTimeout creates a new ClearTaskCacheParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewClearTaskCacheParamsWithTimeout(timeout time.Duration) *ClearTaskCacheParams { - var ( - cachePathDefault = string("") - ) return &ClearTaskCacheParams{ - CachePath: &cachePathDefault, - timeout: timeout, } } // NewClearTaskCacheParamsWithContext creates a new ClearTaskCacheParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewClearTaskCacheParamsWithContext(ctx context.Context) *ClearTaskCacheParams { - var ( - cachePathDefault = string("") - ) return &ClearTaskCacheParams{ - CachePath: &cachePathDefault, - Context: ctx, } } // NewClearTaskCacheParamsWithHTTPClient creates a new ClearTaskCacheParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewClearTaskCacheParamsWithHTTPClient(client *http.Client) *ClearTaskCacheParams { - var ( - cachePathDefault = string("") - ) return &ClearTaskCacheParams{ - CachePath: &cachePathDefault, HTTPClient: client, } } -/*ClearTaskCacheParams contains all the parameters to send to the API endpoint -for the clear task cache operation typically these are written to a http.Request +/* +ClearTaskCacheParams contains all the parameters to send to the API endpoint + + for the clear task cache operation. + + Typically these are written to a http.Request. */ type ClearTaskCacheParams struct { - /*CachePath - The cache path to use as part of a clearTaskCache request + /* CachePath. + The cache path to use as part of a clearTaskCache request */ CachePath *string - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string - /*StepName - A step name from a job task + /* StepName. + + A step name from a job task */ StepName string @@ -109,6 +102,32 @@ type ClearTaskCacheParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the clear task cache params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ClearTaskCacheParams) WithDefaults() *ClearTaskCacheParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the clear task cache params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ClearTaskCacheParams) SetDefaults() { + var ( + cachePathDefault = string("") + ) + + val := ClearTaskCacheParams{ + CachePath: &cachePathDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the clear task cache params func (o *ClearTaskCacheParams) WithTimeout(timeout time.Duration) *ClearTaskCacheParams { o.SetTimeout(timeout) @@ -220,16 +239,17 @@ func (o *ClearTaskCacheParams) WriteToRequest(r runtime.ClientRequest, reg strfm // query param cache_path var qrCachePath string + if o.CachePath != nil { qrCachePath = *o.CachePath } qCachePath := qrCachePath if qCachePath != "" { + if err := r.SetQueryParam("cache_path", qCachePath); err != nil { return err } } - } // path param inpath_pipeline_name diff --git a/client/client/organization_pipelines_jobs/clear_task_cache_responses.go b/client/client/organization_pipelines_jobs/clear_task_cache_responses.go index acac30ad..91ec866d 100644 --- a/client/client/organization_pipelines_jobs/clear_task_cache_responses.go +++ b/client/client/organization_pipelines_jobs/clear_task_cache_responses.go @@ -6,17 +6,18 @@ package organization_pipelines_jobs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ClearTaskCacheReader is a Reader for the ClearTaskCache structure. @@ -62,7 +63,8 @@ func NewClearTaskCacheOK() *ClearTaskCacheOK { return &ClearTaskCacheOK{} } -/*ClearTaskCacheOK handles this case with default header values. +/* +ClearTaskCacheOK describes a response with status code 200, with default header values. Cache has been cleared. */ @@ -70,8 +72,44 @@ type ClearTaskCacheOK struct { Payload *ClearTaskCacheOKBody } +// IsSuccess returns true when this clear task cache o k response has a 2xx status code +func (o *ClearTaskCacheOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this clear task cache o k response has a 3xx status code +func (o *ClearTaskCacheOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this clear task cache o k response has a 4xx status code +func (o *ClearTaskCacheOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this clear task cache o k response has a 5xx status code +func (o *ClearTaskCacheOK) IsServerError() bool { + return false +} + +// IsCode returns true when this clear task cache o k response a status code equal to that given +func (o *ClearTaskCacheOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the clear task cache o k response +func (o *ClearTaskCacheOK) Code() int { + return 200 +} + func (o *ClearTaskCacheOK) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheOK %s", 200, payload) +} + +func (o *ClearTaskCacheOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheOK %s", 200, payload) } func (o *ClearTaskCacheOK) GetPayload() *ClearTaskCacheOKBody { @@ -95,20 +133,60 @@ func NewClearTaskCacheForbidden() *ClearTaskCacheForbidden { return &ClearTaskCacheForbidden{} } -/*ClearTaskCacheForbidden handles this case with default header values. +/* +ClearTaskCacheForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ClearTaskCacheForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this clear task cache forbidden response has a 2xx status code +func (o *ClearTaskCacheForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this clear task cache forbidden response has a 3xx status code +func (o *ClearTaskCacheForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this clear task cache forbidden response has a 4xx status code +func (o *ClearTaskCacheForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this clear task cache forbidden response has a 5xx status code +func (o *ClearTaskCacheForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this clear task cache forbidden response a status code equal to that given +func (o *ClearTaskCacheForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the clear task cache forbidden response +func (o *ClearTaskCacheForbidden) Code() int { + return 403 +} + func (o *ClearTaskCacheForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheForbidden %s", 403, payload) +} + +func (o *ClearTaskCacheForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheForbidden %s", 403, payload) } func (o *ClearTaskCacheForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *ClearTaskCacheForbidden) GetPayload() *models.ErrorPayload { func (o *ClearTaskCacheForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewClearTaskCacheNotFound() *ClearTaskCacheNotFound { return &ClearTaskCacheNotFound{} } -/*ClearTaskCacheNotFound handles this case with default header values. +/* +ClearTaskCacheNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type ClearTaskCacheNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this clear task cache not found response has a 2xx status code +func (o *ClearTaskCacheNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this clear task cache not found response has a 3xx status code +func (o *ClearTaskCacheNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this clear task cache not found response has a 4xx status code +func (o *ClearTaskCacheNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this clear task cache not found response has a 5xx status code +func (o *ClearTaskCacheNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this clear task cache not found response a status code equal to that given +func (o *ClearTaskCacheNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the clear task cache not found response +func (o *ClearTaskCacheNotFound) Code() int { + return 404 +} + func (o *ClearTaskCacheNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheNotFound %s", 404, payload) +} + +func (o *ClearTaskCacheNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCacheNotFound %s", 404, payload) } func (o *ClearTaskCacheNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *ClearTaskCacheNotFound) GetPayload() *models.ErrorPayload { func (o *ClearTaskCacheNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewClearTaskCacheDefault(code int) *ClearTaskCacheDefault { } } -/*ClearTaskCacheDefault handles this case with default header values. +/* +ClearTaskCacheDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ClearTaskCacheDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this clear task cache default response has a 2xx status code +func (o *ClearTaskCacheDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this clear task cache default response has a 3xx status code +func (o *ClearTaskCacheDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this clear task cache default response has a 4xx status code +func (o *ClearTaskCacheDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this clear task cache default response has a 5xx status code +func (o *ClearTaskCacheDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this clear task cache default response a status code equal to that given +func (o *ClearTaskCacheDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the clear task cache default response func (o *ClearTaskCacheDefault) Code() int { return o._statusCode } func (o *ClearTaskCacheDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCache default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCache default %s", o._statusCode, payload) +} + +func (o *ClearTaskCacheDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache][%d] clearTaskCache default %s", o._statusCode, payload) } func (o *ClearTaskCacheDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *ClearTaskCacheDefault) GetPayload() *models.ErrorPayload { func (o *ClearTaskCacheDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *ClearTaskCacheDefault) readResponse(response runtime.ClientResponse, co return nil } -/*ClearTaskCacheOKBody clear task cache o k body +/* +ClearTaskCacheOKBody clear task cache o k body swagger:model ClearTaskCacheOKBody */ type ClearTaskCacheOKBody struct { @@ -265,6 +430,39 @@ func (o *ClearTaskCacheOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("clearTaskCacheOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("clearTaskCacheOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this clear task cache o k body based on the context it is used +func (o *ClearTaskCacheOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ClearTaskCacheOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("clearTaskCacheOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("clearTaskCacheOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines_jobs/get_job_parameters.go b/client/client/organization_pipelines_jobs/get_job_parameters.go index 7e3008d8..96ebeb12 100644 --- a/client/client/organization_pipelines_jobs/get_job_parameters.go +++ b/client/client/organization_pipelines_jobs/get_job_parameters.go @@ -13,72 +13,75 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetJobParams creates a new GetJobParams object -// with the default values initialized. +// NewGetJobParams creates a new GetJobParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetJobParams() *GetJobParams { - var () return &GetJobParams{ - timeout: cr.DefaultTimeout, } } // NewGetJobParamsWithTimeout creates a new GetJobParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetJobParamsWithTimeout(timeout time.Duration) *GetJobParams { - var () return &GetJobParams{ - timeout: timeout, } } // NewGetJobParamsWithContext creates a new GetJobParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetJobParamsWithContext(ctx context.Context) *GetJobParams { - var () return &GetJobParams{ - Context: ctx, } } // NewGetJobParamsWithHTTPClient creates a new GetJobParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetJobParamsWithHTTPClient(client *http.Client) *GetJobParams { - var () return &GetJobParams{ HTTPClient: client, } } -/*GetJobParams contains all the parameters to send to the API endpoint -for the get job operation typically these are written to a http.Request +/* +GetJobParams contains all the parameters to send to the API endpoint + + for the get job operation. + + Typically these are written to a http.Request. */ type GetJobParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -87,6 +90,21 @@ type GetJobParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetJobParams) WithDefaults() *GetJobParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetJobParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get job params func (o *GetJobParams) WithTimeout(timeout time.Duration) *GetJobParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs/get_job_responses.go b/client/client/organization_pipelines_jobs/get_job_responses.go index 981df18e..b2c3ecee 100644 --- a/client/client/organization_pipelines_jobs/get_job_responses.go +++ b/client/client/organization_pipelines_jobs/get_job_responses.go @@ -6,17 +6,18 @@ package organization_pipelines_jobs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetJobReader is a Reader for the GetJob structure. @@ -62,7 +63,8 @@ func NewGetJobOK() *GetJobOK { return &GetJobOK{} } -/*GetJobOK handles this case with default header values. +/* +GetJobOK describes a response with status code 200, with default header values. The configuration of the job which has the specified name. */ @@ -70,8 +72,44 @@ type GetJobOK struct { Payload *GetJobOKBody } +// IsSuccess returns true when this get job o k response has a 2xx status code +func (o *GetJobOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get job o k response has a 3xx status code +func (o *GetJobOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get job o k response has a 4xx status code +func (o *GetJobOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get job o k response has a 5xx status code +func (o *GetJobOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get job o k response a status code equal to that given +func (o *GetJobOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get job o k response +func (o *GetJobOK) Code() int { + return 200 +} + func (o *GetJobOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobOK %s", 200, payload) +} + +func (o *GetJobOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobOK %s", 200, payload) } func (o *GetJobOK) GetPayload() *GetJobOKBody { @@ -95,20 +133,60 @@ func NewGetJobForbidden() *GetJobForbidden { return &GetJobForbidden{} } -/*GetJobForbidden handles this case with default header values. +/* +GetJobForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetJobForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get job forbidden response has a 2xx status code +func (o *GetJobForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get job forbidden response has a 3xx status code +func (o *GetJobForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get job forbidden response has a 4xx status code +func (o *GetJobForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get job forbidden response has a 5xx status code +func (o *GetJobForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get job forbidden response a status code equal to that given +func (o *GetJobForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get job forbidden response +func (o *GetJobForbidden) Code() int { + return 403 +} + func (o *GetJobForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobForbidden %s", 403, payload) +} + +func (o *GetJobForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobForbidden %s", 403, payload) } func (o *GetJobForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetJobForbidden) GetPayload() *models.ErrorPayload { func (o *GetJobForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetJobNotFound() *GetJobNotFound { return &GetJobNotFound{} } -/*GetJobNotFound handles this case with default header values. +/* +GetJobNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetJobNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get job not found response has a 2xx status code +func (o *GetJobNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get job not found response has a 3xx status code +func (o *GetJobNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get job not found response has a 4xx status code +func (o *GetJobNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get job not found response has a 5xx status code +func (o *GetJobNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get job not found response a status code equal to that given +func (o *GetJobNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get job not found response +func (o *GetJobNotFound) Code() int { + return 404 +} + func (o *GetJobNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobNotFound %s", 404, payload) +} + +func (o *GetJobNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJobNotFound %s", 404, payload) } func (o *GetJobNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetJobNotFound) GetPayload() *models.ErrorPayload { func (o *GetJobNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetJobDefault(code int) *GetJobDefault { } } -/*GetJobDefault handles this case with default header values. +/* +GetJobDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetJobDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get job default response has a 2xx status code +func (o *GetJobDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get job default response has a 3xx status code +func (o *GetJobDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get job default response has a 4xx status code +func (o *GetJobDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get job default response has a 5xx status code +func (o *GetJobDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get job default response a status code equal to that given +func (o *GetJobDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get job default response func (o *GetJobDefault) Code() int { return o._statusCode } func (o *GetJobDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJob default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJob default %s", o._statusCode, payload) +} + +func (o *GetJobDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}][%d] getJob default %s", o._statusCode, payload) } func (o *GetJobDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetJobDefault) GetPayload() *models.ErrorPayload { func (o *GetJobDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetJobDefault) readResponse(response runtime.ClientResponse, consumer r return nil } -/*GetJobOKBody get job o k body +/* +GetJobOKBody get job o k body swagger:model GetJobOKBody */ type GetJobOKBody struct { @@ -265,6 +430,39 @@ func (o *GetJobOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getJobOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getJobOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get job o k body based on the context it is used +func (o *GetJobOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetJobOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getJobOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getJobOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines_jobs/get_jobs_parameters.go b/client/client/organization_pipelines_jobs/get_jobs_parameters.go index 9c0e587a..921345ad 100644 --- a/client/client/organization_pipelines_jobs/get_jobs_parameters.go +++ b/client/client/organization_pipelines_jobs/get_jobs_parameters.go @@ -13,98 +13,88 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetJobsParams creates a new GetJobsParams object -// with the default values initialized. +// NewGetJobsParams creates a new GetJobsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetJobsParams() *GetJobsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetJobsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetJobsParamsWithTimeout creates a new GetJobsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetJobsParamsWithTimeout(timeout time.Duration) *GetJobsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetJobsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetJobsParamsWithContext creates a new GetJobsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetJobsParamsWithContext(ctx context.Context) *GetJobsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetJobsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetJobsParamsWithHTTPClient creates a new GetJobsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetJobsParamsWithHTTPClient(client *http.Client) *GetJobsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetJobsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetJobsParams contains all the parameters to send to the API endpoint -for the get jobs operation typically these are written to a http.Request +/* +GetJobsParams contains all the parameters to send to the API endpoint + + for the get jobs operation. + + Typically these are written to a http.Request. */ type GetJobsParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -113,6 +103,35 @@ type GetJobsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get jobs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetJobsParams) WithDefaults() *GetJobsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get jobs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetJobsParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetJobsParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get jobs params func (o *GetJobsParams) WithTimeout(timeout time.Duration) *GetJobsParams { o.SetTimeout(timeout) @@ -223,32 +242,34 @@ func (o *GetJobsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regis // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } // path param project_canonical diff --git a/client/client/organization_pipelines_jobs/get_jobs_responses.go b/client/client/organization_pipelines_jobs/get_jobs_responses.go index d99e987f..d267c8c5 100644 --- a/client/client/organization_pipelines_jobs/get_jobs_responses.go +++ b/client/client/organization_pipelines_jobs/get_jobs_responses.go @@ -6,18 +6,19 @@ package organization_pipelines_jobs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetJobsReader is a Reader for the GetJobs structure. @@ -69,7 +70,8 @@ func NewGetJobsOK() *GetJobsOK { return &GetJobsOK{} } -/*GetJobsOK handles this case with default header values. +/* +GetJobsOK describes a response with status code 200, with default header values. List of the pipeline's jobs which authenticated user has access to. */ @@ -77,8 +79,44 @@ type GetJobsOK struct { Payload *GetJobsOKBody } +// IsSuccess returns true when this get jobs o k response has a 2xx status code +func (o *GetJobsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get jobs o k response has a 3xx status code +func (o *GetJobsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get jobs o k response has a 4xx status code +func (o *GetJobsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get jobs o k response has a 5xx status code +func (o *GetJobsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get jobs o k response a status code equal to that given +func (o *GetJobsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get jobs o k response +func (o *GetJobsOK) Code() int { + return 200 +} + func (o *GetJobsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsOK %s", 200, payload) +} + +func (o *GetJobsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsOK %s", 200, payload) } func (o *GetJobsOK) GetPayload() *GetJobsOKBody { @@ -102,20 +140,60 @@ func NewGetJobsForbidden() *GetJobsForbidden { return &GetJobsForbidden{} } -/*GetJobsForbidden handles this case with default header values. +/* +GetJobsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetJobsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get jobs forbidden response has a 2xx status code +func (o *GetJobsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get jobs forbidden response has a 3xx status code +func (o *GetJobsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get jobs forbidden response has a 4xx status code +func (o *GetJobsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get jobs forbidden response has a 5xx status code +func (o *GetJobsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get jobs forbidden response a status code equal to that given +func (o *GetJobsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get jobs forbidden response +func (o *GetJobsForbidden) Code() int { + return 403 +} + func (o *GetJobsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsForbidden %s", 403, payload) +} + +func (o *GetJobsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsForbidden %s", 403, payload) } func (o *GetJobsForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetJobsForbidden) GetPayload() *models.ErrorPayload { func (o *GetJobsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetJobsNotFound() *GetJobsNotFound { return &GetJobsNotFound{} } -/*GetJobsNotFound handles this case with default header values. +/* +GetJobsNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetJobsNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get jobs not found response has a 2xx status code +func (o *GetJobsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get jobs not found response has a 3xx status code +func (o *GetJobsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get jobs not found response has a 4xx status code +func (o *GetJobsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get jobs not found response has a 5xx status code +func (o *GetJobsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get jobs not found response a status code equal to that given +func (o *GetJobsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get jobs not found response +func (o *GetJobsNotFound) Code() int { + return 404 +} + func (o *GetJobsNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsNotFound %s", 404, payload) +} + +func (o *GetJobsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsNotFound %s", 404, payload) } func (o *GetJobsNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetJobsNotFound) GetPayload() *models.ErrorPayload { func (o *GetJobsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetJobsUnprocessableEntity() *GetJobsUnprocessableEntity { return &GetJobsUnprocessableEntity{} } -/*GetJobsUnprocessableEntity handles this case with default header values. +/* +GetJobsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetJobsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get jobs unprocessable entity response has a 2xx status code +func (o *GetJobsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get jobs unprocessable entity response has a 3xx status code +func (o *GetJobsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get jobs unprocessable entity response has a 4xx status code +func (o *GetJobsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get jobs unprocessable entity response has a 5xx status code +func (o *GetJobsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get jobs unprocessable entity response a status code equal to that given +func (o *GetJobsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get jobs unprocessable entity response +func (o *GetJobsUnprocessableEntity) Code() int { + return 422 +} + func (o *GetJobsUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsUnprocessableEntity %s", 422, payload) +} + +func (o *GetJobsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobsUnprocessableEntity %s", 422, payload) } func (o *GetJobsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetJobsUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetJobsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetJobsDefault(code int) *GetJobsDefault { } } -/*GetJobsDefault handles this case with default header values. +/* +GetJobsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetJobsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get jobs default response has a 2xx status code +func (o *GetJobsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get jobs default response has a 3xx status code +func (o *GetJobsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get jobs default response has a 4xx status code +func (o *GetJobsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get jobs default response has a 5xx status code +func (o *GetJobsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get jobs default response a status code equal to that given +func (o *GetJobsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get jobs default response func (o *GetJobsDefault) Code() int { return o._statusCode } func (o *GetJobsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobs default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobs default %s", o._statusCode, payload) +} + +func (o *GetJobsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs][%d] getJobs default %s", o._statusCode, payload) } func (o *GetJobsDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetJobsDefault) GetPayload() *models.ErrorPayload { func (o *GetJobsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetJobsDefault) readResponse(response runtime.ClientResponse, consumer return nil } -/*GetJobsOKBody get jobs o k body +/* +GetJobsOKBody get jobs o k body swagger:model GetJobsOKBody */ type GetJobsOKBody struct { @@ -329,6 +538,8 @@ func (o *GetJobsOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getJobsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getJobsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -349,6 +560,68 @@ func (o *GetJobsOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getJobsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getJobsOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get jobs o k body based on the context it is used +func (o *GetJobsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetJobsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getJobsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getJobsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetJobsOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getJobsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getJobsOK" + "." + "pagination") } return err } diff --git a/client/client/organization_pipelines_jobs/organization_pipelines_jobs_client.go b/client/client/organization_pipelines_jobs/organization_pipelines_jobs_client.go index b00824b9..b5051624 100644 --- a/client/client/organization_pipelines_jobs/organization_pipelines_jobs_client.go +++ b/client/client/organization_pipelines_jobs/organization_pipelines_jobs_client.go @@ -7,15 +7,40 @@ package organization_pipelines_jobs import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization pipelines jobs API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization pipelines jobs API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization pipelines jobs API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization pipelines jobs API */ @@ -24,16 +49,82 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + ClearTaskCache(params *ClearTaskCacheParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ClearTaskCacheOK, error) + + GetJob(params *GetJobParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetJobOK, error) + + GetJobs(params *GetJobsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetJobsOK, error) + + PauseJob(params *PauseJobParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PauseJobNoContent, error) + + UnpauseJob(params *UnpauseJobParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnpauseJobNoContent, error) + + SetTransport(transport runtime.ClientTransport) +} + /* ClearTaskCache Clear task cache */ -func (a *Client) ClearTaskCache(params *ClearTaskCacheParams, authInfo runtime.ClientAuthInfoWriter) (*ClearTaskCacheOK, error) { +func (a *Client) ClearTaskCache(params *ClearTaskCacheParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ClearTaskCacheOK, error) { // TODO: Validate the params before sending if params == nil { params = NewClearTaskCacheParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "clearTaskCache", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/tasks/{step_name}/cache", @@ -45,7 +136,12 @@ func (a *Client) ClearTaskCache(params *ClearTaskCacheParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +157,12 @@ func (a *Client) ClearTaskCache(params *ClearTaskCacheParams, authInfo runtime.C /* GetJob Get the information of the job. */ -func (a *Client) GetJob(params *GetJobParams, authInfo runtime.ClientAuthInfoWriter) (*GetJobOK, error) { +func (a *Client) GetJob(params *GetJobParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetJobOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetJobParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getJob", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}", @@ -79,7 +174,12 @@ func (a *Client) GetJob(params *GetJobParams, authInfo runtime.ClientAuthInfoWri AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +195,12 @@ func (a *Client) GetJob(params *GetJobParams, authInfo runtime.ClientAuthInfoWri /* GetJobs Get the jobs of the pipeline that the authenticated user has access to. */ -func (a *Client) GetJobs(params *GetJobsParams, authInfo runtime.ClientAuthInfoWriter) (*GetJobsOK, error) { +func (a *Client) GetJobs(params *GetJobsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetJobsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetJobsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getJobs", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs", @@ -113,7 +212,12 @@ func (a *Client) GetJobs(params *GetJobsParams, authInfo runtime.ClientAuthInfoW AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +233,12 @@ func (a *Client) GetJobs(params *GetJobsParams, authInfo runtime.ClientAuthInfoW /* PauseJob Pause a job */ -func (a *Client) PauseJob(params *PauseJobParams, authInfo runtime.ClientAuthInfoWriter) (*PauseJobNoContent, error) { +func (a *Client) PauseJob(params *PauseJobParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PauseJobNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewPauseJobParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "pauseJob", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause", @@ -147,7 +250,12 @@ func (a *Client) PauseJob(params *PauseJobParams, authInfo runtime.ClientAuthInf AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +271,12 @@ func (a *Client) PauseJob(params *PauseJobParams, authInfo runtime.ClientAuthInf /* UnpauseJob Unpause a job */ -func (a *Client) UnpauseJob(params *UnpauseJobParams, authInfo runtime.ClientAuthInfoWriter) (*UnpauseJobNoContent, error) { +func (a *Client) UnpauseJob(params *UnpauseJobParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnpauseJobNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewUnpauseJobParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "unpauseJob", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause", @@ -181,7 +288,12 @@ func (a *Client) UnpauseJob(params *UnpauseJobParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_pipelines_jobs/pause_job_parameters.go b/client/client/organization_pipelines_jobs/pause_job_parameters.go index 299145ba..ae6efa95 100644 --- a/client/client/organization_pipelines_jobs/pause_job_parameters.go +++ b/client/client/organization_pipelines_jobs/pause_job_parameters.go @@ -13,72 +13,75 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewPauseJobParams creates a new PauseJobParams object -// with the default values initialized. +// NewPauseJobParams creates a new PauseJobParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewPauseJobParams() *PauseJobParams { - var () return &PauseJobParams{ - timeout: cr.DefaultTimeout, } } // NewPauseJobParamsWithTimeout creates a new PauseJobParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPauseJobParamsWithTimeout(timeout time.Duration) *PauseJobParams { - var () return &PauseJobParams{ - timeout: timeout, } } // NewPauseJobParamsWithContext creates a new PauseJobParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPauseJobParamsWithContext(ctx context.Context) *PauseJobParams { - var () return &PauseJobParams{ - Context: ctx, } } // NewPauseJobParamsWithHTTPClient creates a new PauseJobParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPauseJobParamsWithHTTPClient(client *http.Client) *PauseJobParams { - var () return &PauseJobParams{ HTTPClient: client, } } -/*PauseJobParams contains all the parameters to send to the API endpoint -for the pause job operation typically these are written to a http.Request +/* +PauseJobParams contains all the parameters to send to the API endpoint + + for the pause job operation. + + Typically these are written to a http.Request. */ type PauseJobParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -87,6 +90,21 @@ type PauseJobParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the pause job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PauseJobParams) WithDefaults() *PauseJobParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pause job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PauseJobParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the pause job params func (o *PauseJobParams) WithTimeout(timeout time.Duration) *PauseJobParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs/pause_job_responses.go b/client/client/organization_pipelines_jobs/pause_job_responses.go index 2be01686..4d80756b 100644 --- a/client/client/organization_pipelines_jobs/pause_job_responses.go +++ b/client/client/organization_pipelines_jobs/pause_job_responses.go @@ -6,16 +6,16 @@ package organization_pipelines_jobs // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // PauseJobReader is a Reader for the PauseJob structure. @@ -61,15 +61,50 @@ func NewPauseJobNoContent() *PauseJobNoContent { return &PauseJobNoContent{} } -/*PauseJobNoContent handles this case with default header values. +/* +PauseJobNoContent describes a response with status code 204, with default header values. Job has been paused. */ type PauseJobNoContent struct { } +// IsSuccess returns true when this pause job no content response has a 2xx status code +func (o *PauseJobNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this pause job no content response has a 3xx status code +func (o *PauseJobNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this pause job no content response has a 4xx status code +func (o *PauseJobNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this pause job no content response has a 5xx status code +func (o *PauseJobNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this pause job no content response a status code equal to that given +func (o *PauseJobNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the pause job no content response +func (o *PauseJobNoContent) Code() int { + return 204 +} + func (o *PauseJobNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobNoContent", 204) +} + +func (o *PauseJobNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobNoContent", 204) } func (o *PauseJobNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewPauseJobForbidden() *PauseJobForbidden { return &PauseJobForbidden{} } -/*PauseJobForbidden handles this case with default header values. +/* +PauseJobForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type PauseJobForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this pause job forbidden response has a 2xx status code +func (o *PauseJobForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this pause job forbidden response has a 3xx status code +func (o *PauseJobForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this pause job forbidden response has a 4xx status code +func (o *PauseJobForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this pause job forbidden response has a 5xx status code +func (o *PauseJobForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this pause job forbidden response a status code equal to that given +func (o *PauseJobForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the pause job forbidden response +func (o *PauseJobForbidden) Code() int { + return 403 +} + func (o *PauseJobForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobForbidden %s", 403, payload) +} + +func (o *PauseJobForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobForbidden %s", 403, payload) } func (o *PauseJobForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *PauseJobForbidden) GetPayload() *models.ErrorPayload { func (o *PauseJobForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewPauseJobNotFound() *PauseJobNotFound { return &PauseJobNotFound{} } -/*PauseJobNotFound handles this case with default header values. +/* +PauseJobNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type PauseJobNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this pause job not found response has a 2xx status code +func (o *PauseJobNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this pause job not found response has a 3xx status code +func (o *PauseJobNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this pause job not found response has a 4xx status code +func (o *PauseJobNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this pause job not found response has a 5xx status code +func (o *PauseJobNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this pause job not found response a status code equal to that given +func (o *PauseJobNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the pause job not found response +func (o *PauseJobNotFound) Code() int { + return 404 +} + func (o *PauseJobNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobNotFound %s", 404, payload) +} + +func (o *PauseJobNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJobNotFound %s", 404, payload) } func (o *PauseJobNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *PauseJobNotFound) GetPayload() *models.ErrorPayload { func (o *PauseJobNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewPauseJobDefault(code int) *PauseJobDefault { } } -/*PauseJobDefault handles this case with default header values. +/* +PauseJobDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type PauseJobDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this pause job default response has a 2xx status code +func (o *PauseJobDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this pause job default response has a 3xx status code +func (o *PauseJobDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this pause job default response has a 4xx status code +func (o *PauseJobDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this pause job default response has a 5xx status code +func (o *PauseJobDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this pause job default response a status code equal to that given +func (o *PauseJobDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the pause job default response func (o *PauseJobDefault) Code() int { return o._statusCode } func (o *PauseJobDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJob default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJob default %s", o._statusCode, payload) +} + +func (o *PauseJobDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/pause][%d] pauseJob default %s", o._statusCode, payload) } func (o *PauseJobDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *PauseJobDefault) GetPayload() *models.ErrorPayload { func (o *PauseJobDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_pipelines_jobs/unpause_job_parameters.go b/client/client/organization_pipelines_jobs/unpause_job_parameters.go index 8951caed..fc9496f9 100644 --- a/client/client/organization_pipelines_jobs/unpause_job_parameters.go +++ b/client/client/organization_pipelines_jobs/unpause_job_parameters.go @@ -13,72 +13,75 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewUnpauseJobParams creates a new UnpauseJobParams object -// with the default values initialized. +// NewUnpauseJobParams creates a new UnpauseJobParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUnpauseJobParams() *UnpauseJobParams { - var () return &UnpauseJobParams{ - timeout: cr.DefaultTimeout, } } // NewUnpauseJobParamsWithTimeout creates a new UnpauseJobParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUnpauseJobParamsWithTimeout(timeout time.Duration) *UnpauseJobParams { - var () return &UnpauseJobParams{ - timeout: timeout, } } // NewUnpauseJobParamsWithContext creates a new UnpauseJobParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUnpauseJobParamsWithContext(ctx context.Context) *UnpauseJobParams { - var () return &UnpauseJobParams{ - Context: ctx, } } // NewUnpauseJobParamsWithHTTPClient creates a new UnpauseJobParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUnpauseJobParamsWithHTTPClient(client *http.Client) *UnpauseJobParams { - var () return &UnpauseJobParams{ HTTPClient: client, } } -/*UnpauseJobParams contains all the parameters to send to the API endpoint -for the unpause job operation typically these are written to a http.Request +/* +UnpauseJobParams contains all the parameters to send to the API endpoint + + for the unpause job operation. + + Typically these are written to a http.Request. */ type UnpauseJobParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -87,6 +90,21 @@ type UnpauseJobParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the unpause job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UnpauseJobParams) WithDefaults() *UnpauseJobParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the unpause job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UnpauseJobParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the unpause job params func (o *UnpauseJobParams) WithTimeout(timeout time.Duration) *UnpauseJobParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs/unpause_job_responses.go b/client/client/organization_pipelines_jobs/unpause_job_responses.go index 1e32db61..5eec0b51 100644 --- a/client/client/organization_pipelines_jobs/unpause_job_responses.go +++ b/client/client/organization_pipelines_jobs/unpause_job_responses.go @@ -6,16 +6,16 @@ package organization_pipelines_jobs // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UnpauseJobReader is a Reader for the UnpauseJob structure. @@ -61,15 +61,50 @@ func NewUnpauseJobNoContent() *UnpauseJobNoContent { return &UnpauseJobNoContent{} } -/*UnpauseJobNoContent handles this case with default header values. +/* +UnpauseJobNoContent describes a response with status code 204, with default header values. Job has been unpause. */ type UnpauseJobNoContent struct { } +// IsSuccess returns true when this unpause job no content response has a 2xx status code +func (o *UnpauseJobNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this unpause job no content response has a 3xx status code +func (o *UnpauseJobNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unpause job no content response has a 4xx status code +func (o *UnpauseJobNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this unpause job no content response has a 5xx status code +func (o *UnpauseJobNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this unpause job no content response a status code equal to that given +func (o *UnpauseJobNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the unpause job no content response +func (o *UnpauseJobNoContent) Code() int { + return 204 +} + func (o *UnpauseJobNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobNoContent", 204) +} + +func (o *UnpauseJobNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobNoContent", 204) } func (o *UnpauseJobNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewUnpauseJobForbidden() *UnpauseJobForbidden { return &UnpauseJobForbidden{} } -/*UnpauseJobForbidden handles this case with default header values. +/* +UnpauseJobForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UnpauseJobForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this unpause job forbidden response has a 2xx status code +func (o *UnpauseJobForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this unpause job forbidden response has a 3xx status code +func (o *UnpauseJobForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unpause job forbidden response has a 4xx status code +func (o *UnpauseJobForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this unpause job forbidden response has a 5xx status code +func (o *UnpauseJobForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this unpause job forbidden response a status code equal to that given +func (o *UnpauseJobForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the unpause job forbidden response +func (o *UnpauseJobForbidden) Code() int { + return 403 +} + func (o *UnpauseJobForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobForbidden %s", 403, payload) +} + +func (o *UnpauseJobForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobForbidden %s", 403, payload) } func (o *UnpauseJobForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *UnpauseJobForbidden) GetPayload() *models.ErrorPayload { func (o *UnpauseJobForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewUnpauseJobNotFound() *UnpauseJobNotFound { return &UnpauseJobNotFound{} } -/*UnpauseJobNotFound handles this case with default header values. +/* +UnpauseJobNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UnpauseJobNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this unpause job not found response has a 2xx status code +func (o *UnpauseJobNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this unpause job not found response has a 3xx status code +func (o *UnpauseJobNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unpause job not found response has a 4xx status code +func (o *UnpauseJobNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this unpause job not found response has a 5xx status code +func (o *UnpauseJobNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this unpause job not found response a status code equal to that given +func (o *UnpauseJobNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the unpause job not found response +func (o *UnpauseJobNotFound) Code() int { + return 404 +} + func (o *UnpauseJobNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobNotFound %s", 404, payload) +} + +func (o *UnpauseJobNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJobNotFound %s", 404, payload) } func (o *UnpauseJobNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *UnpauseJobNotFound) GetPayload() *models.ErrorPayload { func (o *UnpauseJobNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewUnpauseJobDefault(code int) *UnpauseJobDefault { } } -/*UnpauseJobDefault handles this case with default header values. +/* +UnpauseJobDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UnpauseJobDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this unpause job default response has a 2xx status code +func (o *UnpauseJobDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this unpause job default response has a 3xx status code +func (o *UnpauseJobDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this unpause job default response has a 4xx status code +func (o *UnpauseJobDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this unpause job default response has a 5xx status code +func (o *UnpauseJobDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this unpause job default response a status code equal to that given +func (o *UnpauseJobDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the unpause job default response func (o *UnpauseJobDefault) Code() int { return o._statusCode } func (o *UnpauseJobDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJob default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJob default %s", o._statusCode, payload) +} + +func (o *UnpauseJobDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/unpause][%d] unpauseJob default %s", o._statusCode, payload) } func (o *UnpauseJobDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *UnpauseJobDefault) GetPayload() *models.ErrorPayload { func (o *UnpauseJobDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_pipelines_jobs_build/abort_build_parameters.go b/client/client/organization_pipelines_jobs_build/abort_build_parameters.go index cf8b25ee..1371503e 100644 --- a/client/client/organization_pipelines_jobs_build/abort_build_parameters.go +++ b/client/client/organization_pipelines_jobs_build/abort_build_parameters.go @@ -13,77 +13,81 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewAbortBuildParams creates a new AbortBuildParams object -// with the default values initialized. +// NewAbortBuildParams creates a new AbortBuildParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewAbortBuildParams() *AbortBuildParams { - var () return &AbortBuildParams{ - timeout: cr.DefaultTimeout, } } // NewAbortBuildParamsWithTimeout creates a new AbortBuildParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewAbortBuildParamsWithTimeout(timeout time.Duration) *AbortBuildParams { - var () return &AbortBuildParams{ - timeout: timeout, } } // NewAbortBuildParamsWithContext creates a new AbortBuildParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewAbortBuildParamsWithContext(ctx context.Context) *AbortBuildParams { - var () return &AbortBuildParams{ - Context: ctx, } } // NewAbortBuildParamsWithHTTPClient creates a new AbortBuildParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewAbortBuildParamsWithHTTPClient(client *http.Client) *AbortBuildParams { - var () return &AbortBuildParams{ HTTPClient: client, } } -/*AbortBuildParams contains all the parameters to send to the API endpoint -for the abort build operation typically these are written to a http.Request +/* +AbortBuildParams contains all the parameters to send to the API endpoint + + for the abort build operation. + + Typically these are written to a http.Request. */ type AbortBuildParams struct { - /*BuildID - A build id + /* BuildID. + A build id */ BuildID string - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -92,6 +96,21 @@ type AbortBuildParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the abort build params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *AbortBuildParams) WithDefaults() *AbortBuildParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the abort build params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *AbortBuildParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the abort build params func (o *AbortBuildParams) WithTimeout(timeout time.Duration) *AbortBuildParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs_build/abort_build_responses.go b/client/client/organization_pipelines_jobs_build/abort_build_responses.go index 0b9a264e..5bd01a12 100644 --- a/client/client/organization_pipelines_jobs_build/abort_build_responses.go +++ b/client/client/organization_pipelines_jobs_build/abort_build_responses.go @@ -6,16 +6,16 @@ package organization_pipelines_jobs_build // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // AbortBuildReader is a Reader for the AbortBuild structure. @@ -61,15 +61,50 @@ func NewAbortBuildNoContent() *AbortBuildNoContent { return &AbortBuildNoContent{} } -/*AbortBuildNoContent handles this case with default header values. +/* +AbortBuildNoContent describes a response with status code 204, with default header values. The build has been aborted. */ type AbortBuildNoContent struct { } +// IsSuccess returns true when this abort build no content response has a 2xx status code +func (o *AbortBuildNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this abort build no content response has a 3xx status code +func (o *AbortBuildNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this abort build no content response has a 4xx status code +func (o *AbortBuildNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this abort build no content response has a 5xx status code +func (o *AbortBuildNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this abort build no content response a status code equal to that given +func (o *AbortBuildNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the abort build no content response +func (o *AbortBuildNoContent) Code() int { + return 204 +} + func (o *AbortBuildNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildNoContent", 204) +} + +func (o *AbortBuildNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildNoContent", 204) } func (o *AbortBuildNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewAbortBuildForbidden() *AbortBuildForbidden { return &AbortBuildForbidden{} } -/*AbortBuildForbidden handles this case with default header values. +/* +AbortBuildForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type AbortBuildForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this abort build forbidden response has a 2xx status code +func (o *AbortBuildForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this abort build forbidden response has a 3xx status code +func (o *AbortBuildForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this abort build forbidden response has a 4xx status code +func (o *AbortBuildForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this abort build forbidden response has a 5xx status code +func (o *AbortBuildForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this abort build forbidden response a status code equal to that given +func (o *AbortBuildForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the abort build forbidden response +func (o *AbortBuildForbidden) Code() int { + return 403 +} + func (o *AbortBuildForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildForbidden %s", 403, payload) +} + +func (o *AbortBuildForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildForbidden %s", 403, payload) } func (o *AbortBuildForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *AbortBuildForbidden) GetPayload() *models.ErrorPayload { func (o *AbortBuildForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewAbortBuildNotFound() *AbortBuildNotFound { return &AbortBuildNotFound{} } -/*AbortBuildNotFound handles this case with default header values. +/* +AbortBuildNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type AbortBuildNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this abort build not found response has a 2xx status code +func (o *AbortBuildNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this abort build not found response has a 3xx status code +func (o *AbortBuildNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this abort build not found response has a 4xx status code +func (o *AbortBuildNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this abort build not found response has a 5xx status code +func (o *AbortBuildNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this abort build not found response a status code equal to that given +func (o *AbortBuildNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the abort build not found response +func (o *AbortBuildNotFound) Code() int { + return 404 +} + func (o *AbortBuildNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildNotFound %s", 404, payload) +} + +func (o *AbortBuildNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuildNotFound %s", 404, payload) } func (o *AbortBuildNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *AbortBuildNotFound) GetPayload() *models.ErrorPayload { func (o *AbortBuildNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewAbortBuildDefault(code int) *AbortBuildDefault { } } -/*AbortBuildDefault handles this case with default header values. +/* +AbortBuildDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type AbortBuildDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this abort build default response has a 2xx status code +func (o *AbortBuildDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this abort build default response has a 3xx status code +func (o *AbortBuildDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this abort build default response has a 4xx status code +func (o *AbortBuildDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this abort build default response has a 5xx status code +func (o *AbortBuildDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this abort build default response a status code equal to that given +func (o *AbortBuildDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the abort build default response func (o *AbortBuildDefault) Code() int { return o._statusCode } func (o *AbortBuildDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuild default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuild default %s", o._statusCode, payload) +} + +func (o *AbortBuildDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort][%d] abortBuild default %s", o._statusCode, payload) } func (o *AbortBuildDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *AbortBuildDefault) GetPayload() *models.ErrorPayload { func (o *AbortBuildDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_pipelines_jobs_build/create_build_parameters.go b/client/client/organization_pipelines_jobs_build/create_build_parameters.go index bf50b35e..b493f834 100644 --- a/client/client/organization_pipelines_jobs_build/create_build_parameters.go +++ b/client/client/organization_pipelines_jobs_build/create_build_parameters.go @@ -13,72 +13,75 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewCreateBuildParams creates a new CreateBuildParams object -// with the default values initialized. +// NewCreateBuildParams creates a new CreateBuildParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateBuildParams() *CreateBuildParams { - var () return &CreateBuildParams{ - timeout: cr.DefaultTimeout, } } // NewCreateBuildParamsWithTimeout creates a new CreateBuildParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateBuildParamsWithTimeout(timeout time.Duration) *CreateBuildParams { - var () return &CreateBuildParams{ - timeout: timeout, } } // NewCreateBuildParamsWithContext creates a new CreateBuildParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateBuildParamsWithContext(ctx context.Context) *CreateBuildParams { - var () return &CreateBuildParams{ - Context: ctx, } } // NewCreateBuildParamsWithHTTPClient creates a new CreateBuildParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateBuildParamsWithHTTPClient(client *http.Client) *CreateBuildParams { - var () return &CreateBuildParams{ HTTPClient: client, } } -/*CreateBuildParams contains all the parameters to send to the API endpoint -for the create build operation typically these are written to a http.Request +/* +CreateBuildParams contains all the parameters to send to the API endpoint + + for the create build operation. + + Typically these are written to a http.Request. */ type CreateBuildParams struct { - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -87,6 +90,21 @@ type CreateBuildParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create build params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateBuildParams) WithDefaults() *CreateBuildParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create build params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateBuildParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create build params func (o *CreateBuildParams) WithTimeout(timeout time.Duration) *CreateBuildParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs_build/create_build_responses.go b/client/client/organization_pipelines_jobs_build/create_build_responses.go index 3d4d1b31..74c2000e 100644 --- a/client/client/organization_pipelines_jobs_build/create_build_responses.go +++ b/client/client/organization_pipelines_jobs_build/create_build_responses.go @@ -6,17 +6,18 @@ package organization_pipelines_jobs_build // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateBuildReader is a Reader for the CreateBuild structure. @@ -62,7 +63,8 @@ func NewCreateBuildOK() *CreateBuildOK { return &CreateBuildOK{} } -/*CreateBuildOK handles this case with default header values. +/* +CreateBuildOK describes a response with status code 200, with default header values. Create a new build for the pipeline's job and returns its details */ @@ -70,8 +72,44 @@ type CreateBuildOK struct { Payload *CreateBuildOKBody } +// IsSuccess returns true when this create build o k response has a 2xx status code +func (o *CreateBuildOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create build o k response has a 3xx status code +func (o *CreateBuildOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create build o k response has a 4xx status code +func (o *CreateBuildOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create build o k response has a 5xx status code +func (o *CreateBuildOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create build o k response a status code equal to that given +func (o *CreateBuildOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create build o k response +func (o *CreateBuildOK) Code() int { + return 200 +} + func (o *CreateBuildOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildOK %s", 200, payload) +} + +func (o *CreateBuildOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildOK %s", 200, payload) } func (o *CreateBuildOK) GetPayload() *CreateBuildOKBody { @@ -95,20 +133,60 @@ func NewCreateBuildForbidden() *CreateBuildForbidden { return &CreateBuildForbidden{} } -/*CreateBuildForbidden handles this case with default header values. +/* +CreateBuildForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateBuildForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create build forbidden response has a 2xx status code +func (o *CreateBuildForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create build forbidden response has a 3xx status code +func (o *CreateBuildForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create build forbidden response has a 4xx status code +func (o *CreateBuildForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create build forbidden response has a 5xx status code +func (o *CreateBuildForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create build forbidden response a status code equal to that given +func (o *CreateBuildForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create build forbidden response +func (o *CreateBuildForbidden) Code() int { + return 403 +} + func (o *CreateBuildForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildForbidden %s", 403, payload) +} + +func (o *CreateBuildForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildForbidden %s", 403, payload) } func (o *CreateBuildForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *CreateBuildForbidden) GetPayload() *models.ErrorPayload { func (o *CreateBuildForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewCreateBuildNotFound() *CreateBuildNotFound { return &CreateBuildNotFound{} } -/*CreateBuildNotFound handles this case with default header values. +/* +CreateBuildNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateBuildNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create build not found response has a 2xx status code +func (o *CreateBuildNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create build not found response has a 3xx status code +func (o *CreateBuildNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create build not found response has a 4xx status code +func (o *CreateBuildNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create build not found response has a 5xx status code +func (o *CreateBuildNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create build not found response a status code equal to that given +func (o *CreateBuildNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create build not found response +func (o *CreateBuildNotFound) Code() int { + return 404 +} + func (o *CreateBuildNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildNotFound %s", 404, payload) +} + +func (o *CreateBuildNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuildNotFound %s", 404, payload) } func (o *CreateBuildNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *CreateBuildNotFound) GetPayload() *models.ErrorPayload { func (o *CreateBuildNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewCreateBuildDefault(code int) *CreateBuildDefault { } } -/*CreateBuildDefault handles this case with default header values. +/* +CreateBuildDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateBuildDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create build default response has a 2xx status code +func (o *CreateBuildDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create build default response has a 3xx status code +func (o *CreateBuildDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create build default response has a 4xx status code +func (o *CreateBuildDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create build default response has a 5xx status code +func (o *CreateBuildDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create build default response a status code equal to that given +func (o *CreateBuildDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create build default response func (o *CreateBuildDefault) Code() int { return o._statusCode } func (o *CreateBuildDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuild default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuild default %s", o._statusCode, payload) +} + +func (o *CreateBuildDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] createBuild default %s", o._statusCode, payload) } func (o *CreateBuildDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *CreateBuildDefault) GetPayload() *models.ErrorPayload { func (o *CreateBuildDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *CreateBuildDefault) readResponse(response runtime.ClientResponse, consu return nil } -/*CreateBuildOKBody create build o k body +/* +CreateBuildOKBody create build o k body swagger:model CreateBuildOKBody */ type CreateBuildOKBody struct { @@ -265,6 +430,39 @@ func (o *CreateBuildOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createBuildOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createBuildOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create build o k body based on the context it is used +func (o *CreateBuildOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateBuildOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createBuildOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createBuildOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines_jobs_build/get_build_parameters.go b/client/client/organization_pipelines_jobs_build/get_build_parameters.go index 630dfb3c..d4c49c43 100644 --- a/client/client/organization_pipelines_jobs_build/get_build_parameters.go +++ b/client/client/organization_pipelines_jobs_build/get_build_parameters.go @@ -13,77 +13,81 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetBuildParams creates a new GetBuildParams object -// with the default values initialized. +// NewGetBuildParams creates a new GetBuildParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetBuildParams() *GetBuildParams { - var () return &GetBuildParams{ - timeout: cr.DefaultTimeout, } } // NewGetBuildParamsWithTimeout creates a new GetBuildParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetBuildParamsWithTimeout(timeout time.Duration) *GetBuildParams { - var () return &GetBuildParams{ - timeout: timeout, } } // NewGetBuildParamsWithContext creates a new GetBuildParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetBuildParamsWithContext(ctx context.Context) *GetBuildParams { - var () return &GetBuildParams{ - Context: ctx, } } // NewGetBuildParamsWithHTTPClient creates a new GetBuildParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetBuildParamsWithHTTPClient(client *http.Client) *GetBuildParams { - var () return &GetBuildParams{ HTTPClient: client, } } -/*GetBuildParams contains all the parameters to send to the API endpoint -for the get build operation typically these are written to a http.Request +/* +GetBuildParams contains all the parameters to send to the API endpoint + + for the get build operation. + + Typically these are written to a http.Request. */ type GetBuildParams struct { - /*BuildID - A build id + /* BuildID. + A build id */ BuildID string - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -92,6 +96,21 @@ type GetBuildParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get build params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildParams) WithDefaults() *GetBuildParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get build params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get build params func (o *GetBuildParams) WithTimeout(timeout time.Duration) *GetBuildParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs_build/get_build_plan_parameters.go b/client/client/organization_pipelines_jobs_build/get_build_plan_parameters.go index f89eb29f..eab86361 100644 --- a/client/client/organization_pipelines_jobs_build/get_build_plan_parameters.go +++ b/client/client/organization_pipelines_jobs_build/get_build_plan_parameters.go @@ -13,77 +13,81 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetBuildPlanParams creates a new GetBuildPlanParams object -// with the default values initialized. +// NewGetBuildPlanParams creates a new GetBuildPlanParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetBuildPlanParams() *GetBuildPlanParams { - var () return &GetBuildPlanParams{ - timeout: cr.DefaultTimeout, } } // NewGetBuildPlanParamsWithTimeout creates a new GetBuildPlanParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetBuildPlanParamsWithTimeout(timeout time.Duration) *GetBuildPlanParams { - var () return &GetBuildPlanParams{ - timeout: timeout, } } // NewGetBuildPlanParamsWithContext creates a new GetBuildPlanParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetBuildPlanParamsWithContext(ctx context.Context) *GetBuildPlanParams { - var () return &GetBuildPlanParams{ - Context: ctx, } } // NewGetBuildPlanParamsWithHTTPClient creates a new GetBuildPlanParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetBuildPlanParamsWithHTTPClient(client *http.Client) *GetBuildPlanParams { - var () return &GetBuildPlanParams{ HTTPClient: client, } } -/*GetBuildPlanParams contains all the parameters to send to the API endpoint -for the get build plan operation typically these are written to a http.Request +/* +GetBuildPlanParams contains all the parameters to send to the API endpoint + + for the get build plan operation. + + Typically these are written to a http.Request. */ type GetBuildPlanParams struct { - /*BuildID - A build id + /* BuildID. + A build id */ BuildID string - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -92,6 +96,21 @@ type GetBuildPlanParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get build plan params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildPlanParams) WithDefaults() *GetBuildPlanParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get build plan params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildPlanParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get build plan params func (o *GetBuildPlanParams) WithTimeout(timeout time.Duration) *GetBuildPlanParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs_build/get_build_plan_responses.go b/client/client/organization_pipelines_jobs_build/get_build_plan_responses.go index 4032947b..6f4c7c85 100644 --- a/client/client/organization_pipelines_jobs_build/get_build_plan_responses.go +++ b/client/client/organization_pipelines_jobs_build/get_build_plan_responses.go @@ -6,17 +6,18 @@ package organization_pipelines_jobs_build // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetBuildPlanReader is a Reader for the GetBuildPlan structure. @@ -62,7 +63,8 @@ func NewGetBuildPlanOK() *GetBuildPlanOK { return &GetBuildPlanOK{} } -/*GetBuildPlanOK handles this case with default header values. +/* +GetBuildPlanOK describes a response with status code 200, with default header values. The information of the build's plan which has the specified id. */ @@ -70,8 +72,44 @@ type GetBuildPlanOK struct { Payload *GetBuildPlanOKBody } +// IsSuccess returns true when this get build plan o k response has a 2xx status code +func (o *GetBuildPlanOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get build plan o k response has a 3xx status code +func (o *GetBuildPlanOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build plan o k response has a 4xx status code +func (o *GetBuildPlanOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get build plan o k response has a 5xx status code +func (o *GetBuildPlanOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get build plan o k response a status code equal to that given +func (o *GetBuildPlanOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get build plan o k response +func (o *GetBuildPlanOK) Code() int { + return 200 +} + func (o *GetBuildPlanOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanOK %s", 200, payload) +} + +func (o *GetBuildPlanOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanOK %s", 200, payload) } func (o *GetBuildPlanOK) GetPayload() *GetBuildPlanOKBody { @@ -95,20 +133,60 @@ func NewGetBuildPlanForbidden() *GetBuildPlanForbidden { return &GetBuildPlanForbidden{} } -/*GetBuildPlanForbidden handles this case with default header values. +/* +GetBuildPlanForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetBuildPlanForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build plan forbidden response has a 2xx status code +func (o *GetBuildPlanForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get build plan forbidden response has a 3xx status code +func (o *GetBuildPlanForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build plan forbidden response has a 4xx status code +func (o *GetBuildPlanForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get build plan forbidden response has a 5xx status code +func (o *GetBuildPlanForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get build plan forbidden response a status code equal to that given +func (o *GetBuildPlanForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get build plan forbidden response +func (o *GetBuildPlanForbidden) Code() int { + return 403 +} + func (o *GetBuildPlanForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanForbidden %s", 403, payload) +} + +func (o *GetBuildPlanForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanForbidden %s", 403, payload) } func (o *GetBuildPlanForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetBuildPlanForbidden) GetPayload() *models.ErrorPayload { func (o *GetBuildPlanForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetBuildPlanNotFound() *GetBuildPlanNotFound { return &GetBuildPlanNotFound{} } -/*GetBuildPlanNotFound handles this case with default header values. +/* +GetBuildPlanNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetBuildPlanNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build plan not found response has a 2xx status code +func (o *GetBuildPlanNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get build plan not found response has a 3xx status code +func (o *GetBuildPlanNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build plan not found response has a 4xx status code +func (o *GetBuildPlanNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get build plan not found response has a 5xx status code +func (o *GetBuildPlanNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get build plan not found response a status code equal to that given +func (o *GetBuildPlanNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get build plan not found response +func (o *GetBuildPlanNotFound) Code() int { + return 404 +} + func (o *GetBuildPlanNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanNotFound %s", 404, payload) +} + +func (o *GetBuildPlanNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlanNotFound %s", 404, payload) } func (o *GetBuildPlanNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetBuildPlanNotFound) GetPayload() *models.ErrorPayload { func (o *GetBuildPlanNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetBuildPlanDefault(code int) *GetBuildPlanDefault { } } -/*GetBuildPlanDefault handles this case with default header values. +/* +GetBuildPlanDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetBuildPlanDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build plan default response has a 2xx status code +func (o *GetBuildPlanDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get build plan default response has a 3xx status code +func (o *GetBuildPlanDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get build plan default response has a 4xx status code +func (o *GetBuildPlanDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get build plan default response has a 5xx status code +func (o *GetBuildPlanDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get build plan default response a status code equal to that given +func (o *GetBuildPlanDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get build plan default response func (o *GetBuildPlanDefault) Code() int { return o._statusCode } func (o *GetBuildPlanDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlan default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlan default %s", o._statusCode, payload) +} + +func (o *GetBuildPlanDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan][%d] getBuildPlan default %s", o._statusCode, payload) } func (o *GetBuildPlanDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetBuildPlanDefault) GetPayload() *models.ErrorPayload { func (o *GetBuildPlanDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetBuildPlanDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*GetBuildPlanOKBody get build plan o k body +/* +GetBuildPlanOKBody get build plan o k body swagger:model GetBuildPlanOKBody */ type GetBuildPlanOKBody struct { @@ -265,6 +430,39 @@ func (o *GetBuildPlanOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getBuildPlanOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildPlanOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get build plan o k body based on the context it is used +func (o *GetBuildPlanOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetBuildPlanOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getBuildPlanOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildPlanOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines_jobs_build/get_build_preparation_parameters.go b/client/client/organization_pipelines_jobs_build/get_build_preparation_parameters.go index 1223dfcf..050b650c 100644 --- a/client/client/organization_pipelines_jobs_build/get_build_preparation_parameters.go +++ b/client/client/organization_pipelines_jobs_build/get_build_preparation_parameters.go @@ -13,77 +13,81 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetBuildPreparationParams creates a new GetBuildPreparationParams object -// with the default values initialized. +// NewGetBuildPreparationParams creates a new GetBuildPreparationParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetBuildPreparationParams() *GetBuildPreparationParams { - var () return &GetBuildPreparationParams{ - timeout: cr.DefaultTimeout, } } // NewGetBuildPreparationParamsWithTimeout creates a new GetBuildPreparationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetBuildPreparationParamsWithTimeout(timeout time.Duration) *GetBuildPreparationParams { - var () return &GetBuildPreparationParams{ - timeout: timeout, } } // NewGetBuildPreparationParamsWithContext creates a new GetBuildPreparationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetBuildPreparationParamsWithContext(ctx context.Context) *GetBuildPreparationParams { - var () return &GetBuildPreparationParams{ - Context: ctx, } } // NewGetBuildPreparationParamsWithHTTPClient creates a new GetBuildPreparationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetBuildPreparationParamsWithHTTPClient(client *http.Client) *GetBuildPreparationParams { - var () return &GetBuildPreparationParams{ HTTPClient: client, } } -/*GetBuildPreparationParams contains all the parameters to send to the API endpoint -for the get build preparation operation typically these are written to a http.Request +/* +GetBuildPreparationParams contains all the parameters to send to the API endpoint + + for the get build preparation operation. + + Typically these are written to a http.Request. */ type GetBuildPreparationParams struct { - /*BuildID - A build id + /* BuildID. + A build id */ BuildID string - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -92,6 +96,21 @@ type GetBuildPreparationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get build preparation params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildPreparationParams) WithDefaults() *GetBuildPreparationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get build preparation params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildPreparationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get build preparation params func (o *GetBuildPreparationParams) WithTimeout(timeout time.Duration) *GetBuildPreparationParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs_build/get_build_preparation_responses.go b/client/client/organization_pipelines_jobs_build/get_build_preparation_responses.go index 52dcd0d1..9a8ce46e 100644 --- a/client/client/organization_pipelines_jobs_build/get_build_preparation_responses.go +++ b/client/client/organization_pipelines_jobs_build/get_build_preparation_responses.go @@ -6,17 +6,18 @@ package organization_pipelines_jobs_build // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetBuildPreparationReader is a Reader for the GetBuildPreparation structure. @@ -62,7 +63,8 @@ func NewGetBuildPreparationOK() *GetBuildPreparationOK { return &GetBuildPreparationOK{} } -/*GetBuildPreparationOK handles this case with default header values. +/* +GetBuildPreparationOK describes a response with status code 200, with default header values. Return the Preparation */ @@ -70,8 +72,44 @@ type GetBuildPreparationOK struct { Payload *GetBuildPreparationOKBody } +// IsSuccess returns true when this get build preparation o k response has a 2xx status code +func (o *GetBuildPreparationOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get build preparation o k response has a 3xx status code +func (o *GetBuildPreparationOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build preparation o k response has a 4xx status code +func (o *GetBuildPreparationOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get build preparation o k response has a 5xx status code +func (o *GetBuildPreparationOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get build preparation o k response a status code equal to that given +func (o *GetBuildPreparationOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get build preparation o k response +func (o *GetBuildPreparationOK) Code() int { + return 200 +} + func (o *GetBuildPreparationOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationOK %s", 200, payload) +} + +func (o *GetBuildPreparationOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationOK %s", 200, payload) } func (o *GetBuildPreparationOK) GetPayload() *GetBuildPreparationOKBody { @@ -95,20 +133,60 @@ func NewGetBuildPreparationForbidden() *GetBuildPreparationForbidden { return &GetBuildPreparationForbidden{} } -/*GetBuildPreparationForbidden handles this case with default header values. +/* +GetBuildPreparationForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetBuildPreparationForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build preparation forbidden response has a 2xx status code +func (o *GetBuildPreparationForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get build preparation forbidden response has a 3xx status code +func (o *GetBuildPreparationForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build preparation forbidden response has a 4xx status code +func (o *GetBuildPreparationForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get build preparation forbidden response has a 5xx status code +func (o *GetBuildPreparationForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get build preparation forbidden response a status code equal to that given +func (o *GetBuildPreparationForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get build preparation forbidden response +func (o *GetBuildPreparationForbidden) Code() int { + return 403 +} + func (o *GetBuildPreparationForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationForbidden %s", 403, payload) +} + +func (o *GetBuildPreparationForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationForbidden %s", 403, payload) } func (o *GetBuildPreparationForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetBuildPreparationForbidden) GetPayload() *models.ErrorPayload { func (o *GetBuildPreparationForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetBuildPreparationNotFound() *GetBuildPreparationNotFound { return &GetBuildPreparationNotFound{} } -/*GetBuildPreparationNotFound handles this case with default header values. +/* +GetBuildPreparationNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetBuildPreparationNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build preparation not found response has a 2xx status code +func (o *GetBuildPreparationNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get build preparation not found response has a 3xx status code +func (o *GetBuildPreparationNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build preparation not found response has a 4xx status code +func (o *GetBuildPreparationNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get build preparation not found response has a 5xx status code +func (o *GetBuildPreparationNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get build preparation not found response a status code equal to that given +func (o *GetBuildPreparationNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get build preparation not found response +func (o *GetBuildPreparationNotFound) Code() int { + return 404 +} + func (o *GetBuildPreparationNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationNotFound %s", 404, payload) +} + +func (o *GetBuildPreparationNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparationNotFound %s", 404, payload) } func (o *GetBuildPreparationNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetBuildPreparationNotFound) GetPayload() *models.ErrorPayload { func (o *GetBuildPreparationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetBuildPreparationDefault(code int) *GetBuildPreparationDefault { } } -/*GetBuildPreparationDefault handles this case with default header values. +/* +GetBuildPreparationDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetBuildPreparationDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build preparation default response has a 2xx status code +func (o *GetBuildPreparationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get build preparation default response has a 3xx status code +func (o *GetBuildPreparationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get build preparation default response has a 4xx status code +func (o *GetBuildPreparationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get build preparation default response has a 5xx status code +func (o *GetBuildPreparationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get build preparation default response a status code equal to that given +func (o *GetBuildPreparationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get build preparation default response func (o *GetBuildPreparationDefault) Code() int { return o._statusCode } func (o *GetBuildPreparationDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparation default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparation default %s", o._statusCode, payload) +} + +func (o *GetBuildPreparationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation][%d] getBuildPreparation default %s", o._statusCode, payload) } func (o *GetBuildPreparationDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetBuildPreparationDefault) GetPayload() *models.ErrorPayload { func (o *GetBuildPreparationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetBuildPreparationDefault) readResponse(response runtime.ClientRespons return nil } -/*GetBuildPreparationOKBody get build preparation o k body +/* +GetBuildPreparationOKBody get build preparation o k body swagger:model GetBuildPreparationOKBody */ type GetBuildPreparationOKBody struct { @@ -265,6 +430,39 @@ func (o *GetBuildPreparationOKBody) validateData(formats strfmt.Registry) error if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getBuildPreparationOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildPreparationOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get build preparation o k body based on the context it is used +func (o *GetBuildPreparationOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetBuildPreparationOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getBuildPreparationOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildPreparationOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines_jobs_build/get_build_resources_parameters.go b/client/client/organization_pipelines_jobs_build/get_build_resources_parameters.go index 024c786c..4b4b9e04 100644 --- a/client/client/organization_pipelines_jobs_build/get_build_resources_parameters.go +++ b/client/client/organization_pipelines_jobs_build/get_build_resources_parameters.go @@ -13,108 +13,100 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetBuildResourcesParams creates a new GetBuildResourcesParams object -// with the default values initialized. +// NewGetBuildResourcesParams creates a new GetBuildResourcesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetBuildResourcesParams() *GetBuildResourcesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetBuildResourcesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetBuildResourcesParamsWithTimeout creates a new GetBuildResourcesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetBuildResourcesParamsWithTimeout(timeout time.Duration) *GetBuildResourcesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetBuildResourcesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetBuildResourcesParamsWithContext creates a new GetBuildResourcesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetBuildResourcesParamsWithContext(ctx context.Context) *GetBuildResourcesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetBuildResourcesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetBuildResourcesParamsWithHTTPClient creates a new GetBuildResourcesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetBuildResourcesParamsWithHTTPClient(client *http.Client) *GetBuildResourcesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetBuildResourcesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetBuildResourcesParams contains all the parameters to send to the API endpoint -for the get build resources operation typically these are written to a http.Request +/* +GetBuildResourcesParams contains all the parameters to send to the API endpoint + + for the get build resources operation. + + Typically these are written to a http.Request. */ type GetBuildResourcesParams struct { - /*BuildID - A build id + /* BuildID. + A build id */ BuildID string - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -123,6 +115,35 @@ type GetBuildResourcesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get build resources params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildResourcesParams) WithDefaults() *GetBuildResourcesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get build resources params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildResourcesParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetBuildResourcesParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get build resources params func (o *GetBuildResourcesParams) WithTimeout(timeout time.Duration) *GetBuildResourcesParams { o.SetTimeout(timeout) @@ -265,32 +286,34 @@ func (o *GetBuildResourcesParams) WriteToRequest(r runtime.ClientRequest, reg st // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } // path param project_canonical diff --git a/client/client/organization_pipelines_jobs_build/get_build_resources_responses.go b/client/client/organization_pipelines_jobs_build/get_build_resources_responses.go index efc3f47d..726432f1 100644 --- a/client/client/organization_pipelines_jobs_build/get_build_resources_responses.go +++ b/client/client/organization_pipelines_jobs_build/get_build_resources_responses.go @@ -6,17 +6,18 @@ package organization_pipelines_jobs_build // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetBuildResourcesReader is a Reader for the GetBuildResources structure. @@ -62,7 +63,8 @@ func NewGetBuildResourcesOK() *GetBuildResourcesOK { return &GetBuildResourcesOK{} } -/*GetBuildResourcesOK handles this case with default header values. +/* +GetBuildResourcesOK describes a response with status code 200, with default header values. The resources of the build's which has the specified id. */ @@ -70,8 +72,44 @@ type GetBuildResourcesOK struct { Payload *GetBuildResourcesOKBody } +// IsSuccess returns true when this get build resources o k response has a 2xx status code +func (o *GetBuildResourcesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get build resources o k response has a 3xx status code +func (o *GetBuildResourcesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build resources o k response has a 4xx status code +func (o *GetBuildResourcesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get build resources o k response has a 5xx status code +func (o *GetBuildResourcesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get build resources o k response a status code equal to that given +func (o *GetBuildResourcesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get build resources o k response +func (o *GetBuildResourcesOK) Code() int { + return 200 +} + func (o *GetBuildResourcesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesOK %s", 200, payload) +} + +func (o *GetBuildResourcesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesOK %s", 200, payload) } func (o *GetBuildResourcesOK) GetPayload() *GetBuildResourcesOKBody { @@ -95,20 +133,60 @@ func NewGetBuildResourcesForbidden() *GetBuildResourcesForbidden { return &GetBuildResourcesForbidden{} } -/*GetBuildResourcesForbidden handles this case with default header values. +/* +GetBuildResourcesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetBuildResourcesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build resources forbidden response has a 2xx status code +func (o *GetBuildResourcesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get build resources forbidden response has a 3xx status code +func (o *GetBuildResourcesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build resources forbidden response has a 4xx status code +func (o *GetBuildResourcesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get build resources forbidden response has a 5xx status code +func (o *GetBuildResourcesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get build resources forbidden response a status code equal to that given +func (o *GetBuildResourcesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get build resources forbidden response +func (o *GetBuildResourcesForbidden) Code() int { + return 403 +} + func (o *GetBuildResourcesForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesForbidden %s", 403, payload) +} + +func (o *GetBuildResourcesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesForbidden %s", 403, payload) } func (o *GetBuildResourcesForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetBuildResourcesForbidden) GetPayload() *models.ErrorPayload { func (o *GetBuildResourcesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetBuildResourcesNotFound() *GetBuildResourcesNotFound { return &GetBuildResourcesNotFound{} } -/*GetBuildResourcesNotFound handles this case with default header values. +/* +GetBuildResourcesNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetBuildResourcesNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build resources not found response has a 2xx status code +func (o *GetBuildResourcesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get build resources not found response has a 3xx status code +func (o *GetBuildResourcesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build resources not found response has a 4xx status code +func (o *GetBuildResourcesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get build resources not found response has a 5xx status code +func (o *GetBuildResourcesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get build resources not found response a status code equal to that given +func (o *GetBuildResourcesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get build resources not found response +func (o *GetBuildResourcesNotFound) Code() int { + return 404 +} + func (o *GetBuildResourcesNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesNotFound %s", 404, payload) +} + +func (o *GetBuildResourcesNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResourcesNotFound %s", 404, payload) } func (o *GetBuildResourcesNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetBuildResourcesNotFound) GetPayload() *models.ErrorPayload { func (o *GetBuildResourcesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetBuildResourcesDefault(code int) *GetBuildResourcesDefault { } } -/*GetBuildResourcesDefault handles this case with default header values. +/* +GetBuildResourcesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetBuildResourcesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build resources default response has a 2xx status code +func (o *GetBuildResourcesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get build resources default response has a 3xx status code +func (o *GetBuildResourcesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get build resources default response has a 4xx status code +func (o *GetBuildResourcesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get build resources default response has a 5xx status code +func (o *GetBuildResourcesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get build resources default response a status code equal to that given +func (o *GetBuildResourcesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get build resources default response func (o *GetBuildResourcesDefault) Code() int { return o._statusCode } func (o *GetBuildResourcesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResources default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResources default %s", o._statusCode, payload) +} + +func (o *GetBuildResourcesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources][%d] getBuildResources default %s", o._statusCode, payload) } func (o *GetBuildResourcesDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetBuildResourcesDefault) GetPayload() *models.ErrorPayload { func (o *GetBuildResourcesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetBuildResourcesDefault) readResponse(response runtime.ClientResponse, return nil } -/*GetBuildResourcesOKBody get build resources o k body +/* +GetBuildResourcesOKBody get build resources o k body swagger:model GetBuildResourcesOKBody */ type GetBuildResourcesOKBody struct { @@ -265,6 +430,39 @@ func (o *GetBuildResourcesOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getBuildResourcesOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildResourcesOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get build resources o k body based on the context it is used +func (o *GetBuildResourcesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetBuildResourcesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getBuildResourcesOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildResourcesOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines_jobs_build/get_build_responses.go b/client/client/organization_pipelines_jobs_build/get_build_responses.go index 9c496b4d..3ac1bf57 100644 --- a/client/client/organization_pipelines_jobs_build/get_build_responses.go +++ b/client/client/organization_pipelines_jobs_build/get_build_responses.go @@ -6,17 +6,18 @@ package organization_pipelines_jobs_build // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetBuildReader is a Reader for the GetBuild structure. @@ -62,7 +63,8 @@ func NewGetBuildOK() *GetBuildOK { return &GetBuildOK{} } -/*GetBuildOK handles this case with default header values. +/* +GetBuildOK describes a response with status code 200, with default header values. The information of the build which has the specified id. */ @@ -70,8 +72,44 @@ type GetBuildOK struct { Payload *GetBuildOKBody } +// IsSuccess returns true when this get build o k response has a 2xx status code +func (o *GetBuildOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get build o k response has a 3xx status code +func (o *GetBuildOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build o k response has a 4xx status code +func (o *GetBuildOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get build o k response has a 5xx status code +func (o *GetBuildOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get build o k response a status code equal to that given +func (o *GetBuildOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get build o k response +func (o *GetBuildOK) Code() int { + return 200 +} + func (o *GetBuildOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildOK %s", 200, payload) +} + +func (o *GetBuildOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildOK %s", 200, payload) } func (o *GetBuildOK) GetPayload() *GetBuildOKBody { @@ -95,20 +133,60 @@ func NewGetBuildForbidden() *GetBuildForbidden { return &GetBuildForbidden{} } -/*GetBuildForbidden handles this case with default header values. +/* +GetBuildForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetBuildForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build forbidden response has a 2xx status code +func (o *GetBuildForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get build forbidden response has a 3xx status code +func (o *GetBuildForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build forbidden response has a 4xx status code +func (o *GetBuildForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get build forbidden response has a 5xx status code +func (o *GetBuildForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get build forbidden response a status code equal to that given +func (o *GetBuildForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get build forbidden response +func (o *GetBuildForbidden) Code() int { + return 403 +} + func (o *GetBuildForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildForbidden %s", 403, payload) +} + +func (o *GetBuildForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildForbidden %s", 403, payload) } func (o *GetBuildForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetBuildForbidden) GetPayload() *models.ErrorPayload { func (o *GetBuildForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetBuildNotFound() *GetBuildNotFound { return &GetBuildNotFound{} } -/*GetBuildNotFound handles this case with default header values. +/* +GetBuildNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetBuildNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build not found response has a 2xx status code +func (o *GetBuildNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get build not found response has a 3xx status code +func (o *GetBuildNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get build not found response has a 4xx status code +func (o *GetBuildNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get build not found response has a 5xx status code +func (o *GetBuildNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get build not found response a status code equal to that given +func (o *GetBuildNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get build not found response +func (o *GetBuildNotFound) Code() int { + return 404 +} + func (o *GetBuildNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildNotFound %s", 404, payload) +} + +func (o *GetBuildNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuildNotFound %s", 404, payload) } func (o *GetBuildNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetBuildNotFound) GetPayload() *models.ErrorPayload { func (o *GetBuildNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetBuildDefault(code int) *GetBuildDefault { } } -/*GetBuildDefault handles this case with default header values. +/* +GetBuildDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetBuildDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get build default response has a 2xx status code +func (o *GetBuildDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get build default response has a 3xx status code +func (o *GetBuildDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get build default response has a 4xx status code +func (o *GetBuildDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get build default response has a 5xx status code +func (o *GetBuildDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get build default response a status code equal to that given +func (o *GetBuildDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get build default response func (o *GetBuildDefault) Code() int { return o._statusCode } func (o *GetBuildDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuild default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuild default %s", o._statusCode, payload) +} + +func (o *GetBuildDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] getBuild default %s", o._statusCode, payload) } func (o *GetBuildDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetBuildDefault) GetPayload() *models.ErrorPayload { func (o *GetBuildDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetBuildDefault) readResponse(response runtime.ClientResponse, consumer return nil } -/*GetBuildOKBody get build o k body +/* +GetBuildOKBody get build o k body swagger:model GetBuildOKBody */ type GetBuildOKBody struct { @@ -265,6 +430,39 @@ func (o *GetBuildOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getBuildOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get build o k body based on the context it is used +func (o *GetBuildOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetBuildOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getBuildOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildOK" + "." + "data") } return err } diff --git a/client/client/organization_pipelines_jobs_build/get_builds_parameters.go b/client/client/organization_pipelines_jobs_build/get_builds_parameters.go index b2ae4bb3..c8593566 100644 --- a/client/client/organization_pipelines_jobs_build/get_builds_parameters.go +++ b/client/client/organization_pipelines_jobs_build/get_builds_parameters.go @@ -13,116 +13,101 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetBuildsParams creates a new GetBuildsParams object -// with the default values initialized. +// NewGetBuildsParams creates a new GetBuildsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetBuildsParams() *GetBuildsParams { - var ( - concoursePageLimitDefault = uint64(10) - concoursePageSinceDefault = uint64(0) - concoursePageUntilDefault = uint64(0) - ) return &GetBuildsParams{ - ConcoursePageLimit: &concoursePageLimitDefault, - ConcoursePageSince: &concoursePageSinceDefault, - ConcoursePageUntil: &concoursePageUntilDefault, - timeout: cr.DefaultTimeout, } } // NewGetBuildsParamsWithTimeout creates a new GetBuildsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetBuildsParamsWithTimeout(timeout time.Duration) *GetBuildsParams { - var ( - concoursePageLimitDefault = uint64(10) - concoursePageSinceDefault = uint64(0) - concoursePageUntilDefault = uint64(0) - ) return &GetBuildsParams{ - ConcoursePageLimit: &concoursePageLimitDefault, - ConcoursePageSince: &concoursePageSinceDefault, - ConcoursePageUntil: &concoursePageUntilDefault, - timeout: timeout, } } // NewGetBuildsParamsWithContext creates a new GetBuildsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetBuildsParamsWithContext(ctx context.Context) *GetBuildsParams { - var ( - concoursePageLimitDefault = uint64(10) - concoursePageSinceDefault = uint64(0) - concoursePageUntilDefault = uint64(0) - ) return &GetBuildsParams{ - ConcoursePageLimit: &concoursePageLimitDefault, - ConcoursePageSince: &concoursePageSinceDefault, - ConcoursePageUntil: &concoursePageUntilDefault, - Context: ctx, } } // NewGetBuildsParamsWithHTTPClient creates a new GetBuildsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetBuildsParamsWithHTTPClient(client *http.Client) *GetBuildsParams { - var ( - concoursePageLimitDefault = uint64(10) - concoursePageSinceDefault = uint64(0) - concoursePageUntilDefault = uint64(0) - ) return &GetBuildsParams{ - ConcoursePageLimit: &concoursePageLimitDefault, - ConcoursePageSince: &concoursePageSinceDefault, - ConcoursePageUntil: &concoursePageUntilDefault, - HTTPClient: client, + HTTPClient: client, } } -/*GetBuildsParams contains all the parameters to send to the API endpoint -for the get builds operation typically these are written to a http.Request +/* +GetBuildsParams contains all the parameters to send to the API endpoint + + for the get builds operation. + + Typically these are written to a http.Request. */ type GetBuildsParams struct { - /*ConcoursePageLimit - The number of items at most which the response can have. + /* ConcoursePageLimit. + + The number of items at most which the response can have. + Format: uint64 + Default: 10 */ ConcoursePageLimit *uint64 - /*ConcoursePageSince - The time after which we should look for entities to return. + /* ConcoursePageSince. + + The time after which we should look for entities to return. + + Format: uint64 */ ConcoursePageSince *uint64 - /*ConcoursePageUntil - The time before which we should look for entities to return. + /* ConcoursePageUntil. + + The time before which we should look for entities to return. + + Format: uint64 */ ConcoursePageUntil *uint64 - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -131,6 +116,38 @@ type GetBuildsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get builds params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildsParams) WithDefaults() *GetBuildsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get builds params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetBuildsParams) SetDefaults() { + var ( + concoursePageLimitDefault = uint64(10) + + concoursePageSinceDefault = uint64(0) + + concoursePageUntilDefault = uint64(0) + ) + + val := GetBuildsParams{ + ConcoursePageLimit: &concoursePageLimitDefault, + ConcoursePageSince: &concoursePageSinceDefault, + ConcoursePageUntil: &concoursePageUntilDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get builds params func (o *GetBuildsParams) WithTimeout(timeout time.Duration) *GetBuildsParams { o.SetTimeout(timeout) @@ -253,48 +270,51 @@ func (o *GetBuildsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg // query param concourse_page_limit var qrConcoursePageLimit uint64 + if o.ConcoursePageLimit != nil { qrConcoursePageLimit = *o.ConcoursePageLimit } qConcoursePageLimit := swag.FormatUint64(qrConcoursePageLimit) if qConcoursePageLimit != "" { + if err := r.SetQueryParam("concourse_page_limit", qConcoursePageLimit); err != nil { return err } } - } if o.ConcoursePageSince != nil { // query param concourse_page_since var qrConcoursePageSince uint64 + if o.ConcoursePageSince != nil { qrConcoursePageSince = *o.ConcoursePageSince } qConcoursePageSince := swag.FormatUint64(qrConcoursePageSince) if qConcoursePageSince != "" { + if err := r.SetQueryParam("concourse_page_since", qConcoursePageSince); err != nil { return err } } - } if o.ConcoursePageUntil != nil { // query param concourse_page_until var qrConcoursePageUntil uint64 + if o.ConcoursePageUntil != nil { qrConcoursePageUntil = *o.ConcoursePageUntil } qConcoursePageUntil := swag.FormatUint64(qrConcoursePageUntil) if qConcoursePageUntil != "" { + if err := r.SetQueryParam("concourse_page_until", qConcoursePageUntil); err != nil { return err } } - } // path param inpath_pipeline_name diff --git a/client/client/organization_pipelines_jobs_build/get_builds_responses.go b/client/client/organization_pipelines_jobs_build/get_builds_responses.go index 9a2befcd..85dddc36 100644 --- a/client/client/organization_pipelines_jobs_build/get_builds_responses.go +++ b/client/client/organization_pipelines_jobs_build/get_builds_responses.go @@ -6,18 +6,19 @@ package organization_pipelines_jobs_build // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetBuildsReader is a Reader for the GetBuilds structure. @@ -69,7 +70,8 @@ func NewGetBuildsOK() *GetBuildsOK { return &GetBuildsOK{} } -/*GetBuildsOK handles this case with default header values. +/* +GetBuildsOK describes a response with status code 200, with default header values. List the pipeline job's builds which authenticated user has access to. */ @@ -77,8 +79,44 @@ type GetBuildsOK struct { Payload *GetBuildsOKBody } +// IsSuccess returns true when this get builds o k response has a 2xx status code +func (o *GetBuildsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get builds o k response has a 3xx status code +func (o *GetBuildsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get builds o k response has a 4xx status code +func (o *GetBuildsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get builds o k response has a 5xx status code +func (o *GetBuildsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get builds o k response a status code equal to that given +func (o *GetBuildsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get builds o k response +func (o *GetBuildsOK) Code() int { + return 200 +} + func (o *GetBuildsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsOK %s", 200, payload) +} + +func (o *GetBuildsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsOK %s", 200, payload) } func (o *GetBuildsOK) GetPayload() *GetBuildsOKBody { @@ -102,20 +140,60 @@ func NewGetBuildsForbidden() *GetBuildsForbidden { return &GetBuildsForbidden{} } -/*GetBuildsForbidden handles this case with default header values. +/* +GetBuildsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetBuildsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get builds forbidden response has a 2xx status code +func (o *GetBuildsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get builds forbidden response has a 3xx status code +func (o *GetBuildsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get builds forbidden response has a 4xx status code +func (o *GetBuildsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get builds forbidden response has a 5xx status code +func (o *GetBuildsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get builds forbidden response a status code equal to that given +func (o *GetBuildsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get builds forbidden response +func (o *GetBuildsForbidden) Code() int { + return 403 +} + func (o *GetBuildsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsForbidden %s", 403, payload) +} + +func (o *GetBuildsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsForbidden %s", 403, payload) } func (o *GetBuildsForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetBuildsForbidden) GetPayload() *models.ErrorPayload { func (o *GetBuildsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetBuildsNotFound() *GetBuildsNotFound { return &GetBuildsNotFound{} } -/*GetBuildsNotFound handles this case with default header values. +/* +GetBuildsNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetBuildsNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get builds not found response has a 2xx status code +func (o *GetBuildsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get builds not found response has a 3xx status code +func (o *GetBuildsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get builds not found response has a 4xx status code +func (o *GetBuildsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get builds not found response has a 5xx status code +func (o *GetBuildsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get builds not found response a status code equal to that given +func (o *GetBuildsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get builds not found response +func (o *GetBuildsNotFound) Code() int { + return 404 +} + func (o *GetBuildsNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsNotFound %s", 404, payload) +} + +func (o *GetBuildsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsNotFound %s", 404, payload) } func (o *GetBuildsNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetBuildsNotFound) GetPayload() *models.ErrorPayload { func (o *GetBuildsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetBuildsUnprocessableEntity() *GetBuildsUnprocessableEntity { return &GetBuildsUnprocessableEntity{} } -/*GetBuildsUnprocessableEntity handles this case with default header values. +/* +GetBuildsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetBuildsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get builds unprocessable entity response has a 2xx status code +func (o *GetBuildsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get builds unprocessable entity response has a 3xx status code +func (o *GetBuildsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get builds unprocessable entity response has a 4xx status code +func (o *GetBuildsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get builds unprocessable entity response has a 5xx status code +func (o *GetBuildsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get builds unprocessable entity response a status code equal to that given +func (o *GetBuildsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get builds unprocessable entity response +func (o *GetBuildsUnprocessableEntity) Code() int { + return 422 +} + func (o *GetBuildsUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsUnprocessableEntity %s", 422, payload) +} + +func (o *GetBuildsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuildsUnprocessableEntity %s", 422, payload) } func (o *GetBuildsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetBuildsUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetBuildsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetBuildsDefault(code int) *GetBuildsDefault { } } -/*GetBuildsDefault handles this case with default header values. +/* +GetBuildsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetBuildsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get builds default response has a 2xx status code +func (o *GetBuildsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get builds default response has a 3xx status code +func (o *GetBuildsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get builds default response has a 4xx status code +func (o *GetBuildsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get builds default response has a 5xx status code +func (o *GetBuildsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get builds default response a status code equal to that given +func (o *GetBuildsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get builds default response func (o *GetBuildsDefault) Code() int { return o._statusCode } func (o *GetBuildsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuilds default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuilds default %s", o._statusCode, payload) +} + +func (o *GetBuildsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds][%d] getBuilds default %s", o._statusCode, payload) } func (o *GetBuildsDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetBuildsDefault) GetPayload() *models.ErrorPayload { func (o *GetBuildsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetBuildsDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*GetBuildsOKBody get builds o k body +/* +GetBuildsOKBody get builds o k body swagger:model GetBuildsOKBody */ type GetBuildsOKBody struct { @@ -329,6 +538,8 @@ func (o *GetBuildsOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getBuildsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -349,6 +560,68 @@ func (o *GetBuildsOKBody) validatePaginationConcourse(formats strfmt.Registry) e if err := o.PaginationConcourse.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getBuildsOK" + "." + "pagination_concourse") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildsOK" + "." + "pagination_concourse") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get builds o k body based on the context it is used +func (o *GetBuildsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePaginationConcourse(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetBuildsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getBuildsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetBuildsOKBody) contextValidatePaginationConcourse(ctx context.Context, formats strfmt.Registry) error { + + if o.PaginationConcourse != nil { + + if err := o.PaginationConcourse.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getBuildsOK" + "." + "pagination_concourse") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getBuildsOK" + "." + "pagination_concourse") } return err } diff --git a/client/client/organization_pipelines_jobs_build/organization_pipelines_jobs_build_client.go b/client/client/organization_pipelines_jobs_build/organization_pipelines_jobs_build_client.go index e6f43780..3bb79d8b 100644 --- a/client/client/organization_pipelines_jobs_build/organization_pipelines_jobs_build_client.go +++ b/client/client/organization_pipelines_jobs_build/organization_pipelines_jobs_build_client.go @@ -7,15 +7,40 @@ package organization_pipelines_jobs_build import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization pipelines jobs build API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization pipelines jobs build API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization pipelines jobs build API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization pipelines jobs build API */ @@ -24,16 +49,88 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + AbortBuild(params *AbortBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AbortBuildNoContent, error) + + CreateBuild(params *CreateBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateBuildOK, error) + + GetBuild(params *GetBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildOK, error) + + GetBuildPlan(params *GetBuildPlanParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildPlanOK, error) + + GetBuildPreparation(params *GetBuildPreparationParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildPreparationOK, error) + + GetBuildResources(params *GetBuildResourcesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildResourcesOK, error) + + GetBuilds(params *GetBuildsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildsOK, error) + + RerunBuild(params *RerunBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RerunBuildOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* AbortBuild Abort a specific build. */ -func (a *Client) AbortBuild(params *AbortBuildParams, authInfo runtime.ClientAuthInfoWriter) (*AbortBuildNoContent, error) { +func (a *Client) AbortBuild(params *AbortBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AbortBuildNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewAbortBuildParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "abortBuild", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/abort", @@ -45,7 +142,12 @@ func (a *Client) AbortBuild(params *AbortBuildParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +163,12 @@ func (a *Client) AbortBuild(params *AbortBuildParams, authInfo runtime.ClientAut /* CreateBuild Create a new build for the job */ -func (a *Client) CreateBuild(params *CreateBuildParams, authInfo runtime.ClientAuthInfoWriter) (*CreateBuildOK, error) { +func (a *Client) CreateBuild(params *CreateBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateBuildOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateBuildParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createBuild", Method: "POST", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds", @@ -79,7 +180,12 @@ func (a *Client) CreateBuild(params *CreateBuildParams, authInfo runtime.ClientA AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +201,12 @@ func (a *Client) CreateBuild(params *CreateBuildParams, authInfo runtime.ClientA /* GetBuild Get the information of the build. */ -func (a *Client) GetBuild(params *GetBuildParams, authInfo runtime.ClientAuthInfoWriter) (*GetBuildOK, error) { +func (a *Client) GetBuild(params *GetBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetBuildParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getBuild", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}", @@ -113,7 +218,12 @@ func (a *Client) GetBuild(params *GetBuildParams, authInfo runtime.ClientAuthInf AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +239,12 @@ func (a *Client) GetBuild(params *GetBuildParams, authInfo runtime.ClientAuthInf /* GetBuildPlan Get the plan of the build. */ -func (a *Client) GetBuildPlan(params *GetBuildPlanParams, authInfo runtime.ClientAuthInfoWriter) (*GetBuildPlanOK, error) { +func (a *Client) GetBuildPlan(params *GetBuildPlanParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildPlanOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetBuildPlanParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getBuildPlan", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/plan", @@ -147,7 +256,12 @@ func (a *Client) GetBuildPlan(params *GetBuildPlanParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +277,12 @@ func (a *Client) GetBuildPlan(params *GetBuildPlanParams, authInfo runtime.Clien /* GetBuildPreparation Get the preparation of the Build. */ -func (a *Client) GetBuildPreparation(params *GetBuildPreparationParams, authInfo runtime.ClientAuthInfoWriter) (*GetBuildPreparationOK, error) { +func (a *Client) GetBuildPreparation(params *GetBuildPreparationParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildPreparationOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetBuildPreparationParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getBuildPreparation", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/preparation", @@ -181,7 +294,12 @@ func (a *Client) GetBuildPreparation(params *GetBuildPreparationParams, authInfo AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -197,13 +315,12 @@ func (a *Client) GetBuildPreparation(params *GetBuildPreparationParams, authInfo /* GetBuildResources Get the resources of the build. */ -func (a *Client) GetBuildResources(params *GetBuildResourcesParams, authInfo runtime.ClientAuthInfoWriter) (*GetBuildResourcesOK, error) { +func (a *Client) GetBuildResources(params *GetBuildResourcesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildResourcesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetBuildResourcesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getBuildResources", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}/resources", @@ -215,7 +332,12 @@ func (a *Client) GetBuildResources(params *GetBuildResourcesParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -231,13 +353,12 @@ func (a *Client) GetBuildResources(params *GetBuildResourcesParams, authInfo run /* GetBuilds Get the pipeline job's builds that the authenticated user has access to. */ -func (a *Client) GetBuilds(params *GetBuildsParams, authInfo runtime.ClientAuthInfoWriter) (*GetBuildsOK, error) { +func (a *Client) GetBuilds(params *GetBuildsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetBuildsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetBuildsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getBuilds", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds", @@ -249,7 +370,12 @@ func (a *Client) GetBuilds(params *GetBuildsParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -265,13 +391,12 @@ func (a *Client) GetBuilds(params *GetBuildsParams, authInfo runtime.ClientAuthI /* RerunBuild Reruns a specific build. */ -func (a *Client) RerunBuild(params *RerunBuildParams, authInfo runtime.ClientAuthInfoWriter) (*RerunBuildOK, error) { +func (a *Client) RerunBuild(params *RerunBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RerunBuildOK, error) { // TODO: Validate the params before sending if params == nil { params = NewRerunBuildParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "rerunBuild", Method: "POST", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}", @@ -283,7 +408,12 @@ func (a *Client) RerunBuild(params *RerunBuildParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_pipelines_jobs_build/rerun_build_parameters.go b/client/client/organization_pipelines_jobs_build/rerun_build_parameters.go index c5cdcbf7..aadf718b 100644 --- a/client/client/organization_pipelines_jobs_build/rerun_build_parameters.go +++ b/client/client/organization_pipelines_jobs_build/rerun_build_parameters.go @@ -13,77 +13,81 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewRerunBuildParams creates a new RerunBuildParams object -// with the default values initialized. +// NewRerunBuildParams creates a new RerunBuildParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewRerunBuildParams() *RerunBuildParams { - var () return &RerunBuildParams{ - timeout: cr.DefaultTimeout, } } // NewRerunBuildParamsWithTimeout creates a new RerunBuildParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewRerunBuildParamsWithTimeout(timeout time.Duration) *RerunBuildParams { - var () return &RerunBuildParams{ - timeout: timeout, } } // NewRerunBuildParamsWithContext creates a new RerunBuildParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewRerunBuildParamsWithContext(ctx context.Context) *RerunBuildParams { - var () return &RerunBuildParams{ - Context: ctx, } } // NewRerunBuildParamsWithHTTPClient creates a new RerunBuildParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewRerunBuildParamsWithHTTPClient(client *http.Client) *RerunBuildParams { - var () return &RerunBuildParams{ HTTPClient: client, } } -/*RerunBuildParams contains all the parameters to send to the API endpoint -for the rerun build operation typically these are written to a http.Request +/* +RerunBuildParams contains all the parameters to send to the API endpoint + + for the rerun build operation. + + Typically these are written to a http.Request. */ type RerunBuildParams struct { - /*BuildID - A build id + /* BuildID. + A build id */ BuildID string - /*InpathPipelineName - A pipeline name + /* InpathPipelineName. + + A pipeline name */ InpathPipelineName string - /*JobName - A job name + /* JobName. + + A job name */ JobName string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -92,6 +96,21 @@ type RerunBuildParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the rerun build params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RerunBuildParams) WithDefaults() *RerunBuildParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the rerun build params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RerunBuildParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the rerun build params func (o *RerunBuildParams) WithTimeout(timeout time.Duration) *RerunBuildParams { o.SetTimeout(timeout) diff --git a/client/client/organization_pipelines_jobs_build/rerun_build_responses.go b/client/client/organization_pipelines_jobs_build/rerun_build_responses.go index 1225adf4..86487929 100644 --- a/client/client/organization_pipelines_jobs_build/rerun_build_responses.go +++ b/client/client/organization_pipelines_jobs_build/rerun_build_responses.go @@ -6,17 +6,18 @@ package organization_pipelines_jobs_build // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // RerunBuildReader is a Reader for the RerunBuild structure. @@ -62,7 +63,8 @@ func NewRerunBuildOK() *RerunBuildOK { return &RerunBuildOK{} } -/*RerunBuildOK handles this case with default header values. +/* +RerunBuildOK describes a response with status code 200, with default header values. Returns the new build created from the specified build ID. */ @@ -70,8 +72,44 @@ type RerunBuildOK struct { Payload *RerunBuildOKBody } +// IsSuccess returns true when this rerun build o k response has a 2xx status code +func (o *RerunBuildOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this rerun build o k response has a 3xx status code +func (o *RerunBuildOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this rerun build o k response has a 4xx status code +func (o *RerunBuildOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this rerun build o k response has a 5xx status code +func (o *RerunBuildOK) IsServerError() bool { + return false +} + +// IsCode returns true when this rerun build o k response a status code equal to that given +func (o *RerunBuildOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the rerun build o k response +func (o *RerunBuildOK) Code() int { + return 200 +} + func (o *RerunBuildOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildOK %s", 200, payload) +} + +func (o *RerunBuildOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildOK %s", 200, payload) } func (o *RerunBuildOK) GetPayload() *RerunBuildOKBody { @@ -95,20 +133,60 @@ func NewRerunBuildForbidden() *RerunBuildForbidden { return &RerunBuildForbidden{} } -/*RerunBuildForbidden handles this case with default header values. +/* +RerunBuildForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type RerunBuildForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this rerun build forbidden response has a 2xx status code +func (o *RerunBuildForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this rerun build forbidden response has a 3xx status code +func (o *RerunBuildForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this rerun build forbidden response has a 4xx status code +func (o *RerunBuildForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this rerun build forbidden response has a 5xx status code +func (o *RerunBuildForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this rerun build forbidden response a status code equal to that given +func (o *RerunBuildForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the rerun build forbidden response +func (o *RerunBuildForbidden) Code() int { + return 403 +} + func (o *RerunBuildForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildForbidden %s", 403, payload) +} + +func (o *RerunBuildForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildForbidden %s", 403, payload) } func (o *RerunBuildForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *RerunBuildForbidden) GetPayload() *models.ErrorPayload { func (o *RerunBuildForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewRerunBuildNotFound() *RerunBuildNotFound { return &RerunBuildNotFound{} } -/*RerunBuildNotFound handles this case with default header values. +/* +RerunBuildNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type RerunBuildNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this rerun build not found response has a 2xx status code +func (o *RerunBuildNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this rerun build not found response has a 3xx status code +func (o *RerunBuildNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this rerun build not found response has a 4xx status code +func (o *RerunBuildNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this rerun build not found response has a 5xx status code +func (o *RerunBuildNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this rerun build not found response a status code equal to that given +func (o *RerunBuildNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the rerun build not found response +func (o *RerunBuildNotFound) Code() int { + return 404 +} + func (o *RerunBuildNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildNotFound %s", 404, payload) +} + +func (o *RerunBuildNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuildNotFound %s", 404, payload) } func (o *RerunBuildNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *RerunBuildNotFound) GetPayload() *models.ErrorPayload { func (o *RerunBuildNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewRerunBuildDefault(code int) *RerunBuildDefault { } } -/*RerunBuildDefault handles this case with default header values. +/* +RerunBuildDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type RerunBuildDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this rerun build default response has a 2xx status code +func (o *RerunBuildDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this rerun build default response has a 3xx status code +func (o *RerunBuildDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this rerun build default response has a 4xx status code +func (o *RerunBuildDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this rerun build default response has a 5xx status code +func (o *RerunBuildDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this rerun build default response a status code equal to that given +func (o *RerunBuildDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the rerun build default response func (o *RerunBuildDefault) Code() int { return o._statusCode } func (o *RerunBuildDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuild default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuild default %s", o._statusCode, payload) +} + +func (o *RerunBuildDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/pipelines/{inpath_pipeline_name}/jobs/{job_name}/builds/{build_id}][%d] rerunBuild default %s", o._statusCode, payload) } func (o *RerunBuildDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *RerunBuildDefault) GetPayload() *models.ErrorPayload { func (o *RerunBuildDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *RerunBuildDefault) readResponse(response runtime.ClientResponse, consum return nil } -/*RerunBuildOKBody rerun build o k body +/* +RerunBuildOKBody rerun build o k body swagger:model RerunBuildOKBody */ type RerunBuildOKBody struct { @@ -265,6 +430,39 @@ func (o *RerunBuildOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("rerunBuildOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rerunBuildOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this rerun build o k body based on the context it is used +func (o *RerunBuildOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *RerunBuildOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rerunBuildOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rerunBuildOK" + "." + "data") } return err } diff --git a/client/client/organization_projects/create_project_favorite_parameters.go b/client/client/organization_projects/create_project_favorite_parameters.go index 6e240c0c..7f2a569e 100644 --- a/client/client/organization_projects/create_project_favorite_parameters.go +++ b/client/client/organization_projects/create_project_favorite_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewCreateProjectFavoriteParams creates a new CreateProjectFavoriteParams object -// with the default values initialized. +// NewCreateProjectFavoriteParams creates a new CreateProjectFavoriteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateProjectFavoriteParams() *CreateProjectFavoriteParams { - var () return &CreateProjectFavoriteParams{ - timeout: cr.DefaultTimeout, } } // NewCreateProjectFavoriteParamsWithTimeout creates a new CreateProjectFavoriteParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateProjectFavoriteParamsWithTimeout(timeout time.Duration) *CreateProjectFavoriteParams { - var () return &CreateProjectFavoriteParams{ - timeout: timeout, } } // NewCreateProjectFavoriteParamsWithContext creates a new CreateProjectFavoriteParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateProjectFavoriteParamsWithContext(ctx context.Context) *CreateProjectFavoriteParams { - var () return &CreateProjectFavoriteParams{ - Context: ctx, } } // NewCreateProjectFavoriteParamsWithHTTPClient creates a new CreateProjectFavoriteParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateProjectFavoriteParamsWithHTTPClient(client *http.Client) *CreateProjectFavoriteParams { - var () return &CreateProjectFavoriteParams{ HTTPClient: client, } } -/*CreateProjectFavoriteParams contains all the parameters to send to the API endpoint -for the create project favorite operation typically these are written to a http.Request +/* +CreateProjectFavoriteParams contains all the parameters to send to the API endpoint + + for the create project favorite operation. + + Typically these are written to a http.Request. */ type CreateProjectFavoriteParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -77,6 +78,21 @@ type CreateProjectFavoriteParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create project favorite params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateProjectFavoriteParams) WithDefaults() *CreateProjectFavoriteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create project favorite params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateProjectFavoriteParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create project favorite params func (o *CreateProjectFavoriteParams) WithTimeout(timeout time.Duration) *CreateProjectFavoriteParams { o.SetTimeout(timeout) diff --git a/client/client/organization_projects/create_project_favorite_responses.go b/client/client/organization_projects/create_project_favorite_responses.go index 014e02f9..b0529e66 100644 --- a/client/client/organization_projects/create_project_favorite_responses.go +++ b/client/client/organization_projects/create_project_favorite_responses.go @@ -6,16 +6,16 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateProjectFavoriteReader is a Reader for the CreateProjectFavorite structure. @@ -67,15 +67,50 @@ func NewCreateProjectFavoriteNoContent() *CreateProjectFavoriteNoContent { return &CreateProjectFavoriteNoContent{} } -/*CreateProjectFavoriteNoContent handles this case with default header values. +/* +CreateProjectFavoriteNoContent describes a response with status code 204, with default header values. The project has been added to user favorites list. */ type CreateProjectFavoriteNoContent struct { } +// IsSuccess returns true when this create project favorite no content response has a 2xx status code +func (o *CreateProjectFavoriteNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create project favorite no content response has a 3xx status code +func (o *CreateProjectFavoriteNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create project favorite no content response has a 4xx status code +func (o *CreateProjectFavoriteNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this create project favorite no content response has a 5xx status code +func (o *CreateProjectFavoriteNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this create project favorite no content response a status code equal to that given +func (o *CreateProjectFavoriteNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the create project favorite no content response +func (o *CreateProjectFavoriteNoContent) Code() int { + return 204 +} + func (o *CreateProjectFavoriteNoContent) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteNoContent ", 204) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteNoContent", 204) +} + +func (o *CreateProjectFavoriteNoContent) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteNoContent", 204) } func (o *CreateProjectFavoriteNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -88,20 +123,60 @@ func NewCreateProjectFavoriteForbidden() *CreateProjectFavoriteForbidden { return &CreateProjectFavoriteForbidden{} } -/*CreateProjectFavoriteForbidden handles this case with default header values. +/* +CreateProjectFavoriteForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateProjectFavoriteForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create project favorite forbidden response has a 2xx status code +func (o *CreateProjectFavoriteForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create project favorite forbidden response has a 3xx status code +func (o *CreateProjectFavoriteForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create project favorite forbidden response has a 4xx status code +func (o *CreateProjectFavoriteForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create project favorite forbidden response has a 5xx status code +func (o *CreateProjectFavoriteForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create project favorite forbidden response a status code equal to that given +func (o *CreateProjectFavoriteForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create project favorite forbidden response +func (o *CreateProjectFavoriteForbidden) Code() int { + return 403 +} + func (o *CreateProjectFavoriteForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteForbidden %s", 403, payload) +} + +func (o *CreateProjectFavoriteForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteForbidden %s", 403, payload) } func (o *CreateProjectFavoriteForbidden) GetPayload() *models.ErrorPayload { @@ -110,12 +185,16 @@ func (o *CreateProjectFavoriteForbidden) GetPayload() *models.ErrorPayload { func (o *CreateProjectFavoriteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -132,20 +211,60 @@ func NewCreateProjectFavoriteNotFound() *CreateProjectFavoriteNotFound { return &CreateProjectFavoriteNotFound{} } -/*CreateProjectFavoriteNotFound handles this case with default header values. +/* +CreateProjectFavoriteNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateProjectFavoriteNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create project favorite not found response has a 2xx status code +func (o *CreateProjectFavoriteNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create project favorite not found response has a 3xx status code +func (o *CreateProjectFavoriteNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create project favorite not found response has a 4xx status code +func (o *CreateProjectFavoriteNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create project favorite not found response has a 5xx status code +func (o *CreateProjectFavoriteNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create project favorite not found response a status code equal to that given +func (o *CreateProjectFavoriteNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create project favorite not found response +func (o *CreateProjectFavoriteNotFound) Code() int { + return 404 +} + func (o *CreateProjectFavoriteNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteNotFound %s", 404, payload) +} + +func (o *CreateProjectFavoriteNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteNotFound %s", 404, payload) } func (o *CreateProjectFavoriteNotFound) GetPayload() *models.ErrorPayload { @@ -154,12 +273,16 @@ func (o *CreateProjectFavoriteNotFound) GetPayload() *models.ErrorPayload { func (o *CreateProjectFavoriteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -176,20 +299,60 @@ func NewCreateProjectFavoriteUnprocessableEntity() *CreateProjectFavoriteUnproce return &CreateProjectFavoriteUnprocessableEntity{} } -/*CreateProjectFavoriteUnprocessableEntity handles this case with default header values. +/* +CreateProjectFavoriteUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateProjectFavoriteUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create project favorite unprocessable entity response has a 2xx status code +func (o *CreateProjectFavoriteUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create project favorite unprocessable entity response has a 3xx status code +func (o *CreateProjectFavoriteUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create project favorite unprocessable entity response has a 4xx status code +func (o *CreateProjectFavoriteUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create project favorite unprocessable entity response has a 5xx status code +func (o *CreateProjectFavoriteUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create project favorite unprocessable entity response a status code equal to that given +func (o *CreateProjectFavoriteUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create project favorite unprocessable entity response +func (o *CreateProjectFavoriteUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateProjectFavoriteUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteUnprocessableEntity %s", 422, payload) +} + +func (o *CreateProjectFavoriteUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavoriteUnprocessableEntity %s", 422, payload) } func (o *CreateProjectFavoriteUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -198,12 +361,16 @@ func (o *CreateProjectFavoriteUnprocessableEntity) GetPayload() *models.ErrorPay func (o *CreateProjectFavoriteUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -222,27 +389,61 @@ func NewCreateProjectFavoriteDefault(code int) *CreateProjectFavoriteDefault { } } -/*CreateProjectFavoriteDefault handles this case with default header values. +/* +CreateProjectFavoriteDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateProjectFavoriteDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create project favorite default response has a 2xx status code +func (o *CreateProjectFavoriteDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create project favorite default response has a 3xx status code +func (o *CreateProjectFavoriteDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create project favorite default response has a 4xx status code +func (o *CreateProjectFavoriteDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create project favorite default response has a 5xx status code +func (o *CreateProjectFavoriteDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create project favorite default response a status code equal to that given +func (o *CreateProjectFavoriteDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create project favorite default response func (o *CreateProjectFavoriteDefault) Code() int { return o._statusCode } func (o *CreateProjectFavoriteDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavorite default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavorite default %s", o._statusCode, payload) +} + +func (o *CreateProjectFavoriteDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] createProjectFavorite default %s", o._statusCode, payload) } func (o *CreateProjectFavoriteDefault) GetPayload() *models.ErrorPayload { @@ -251,12 +452,16 @@ func (o *CreateProjectFavoriteDefault) GetPayload() *models.ErrorPayload { func (o *CreateProjectFavoriteDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_projects/create_project_parameters.go b/client/client/organization_projects/create_project_parameters.go index f0d3d0b6..c4452dc5 100644 --- a/client/client/organization_projects/create_project_parameters.go +++ b/client/client/organization_projects/create_project_parameters.go @@ -13,66 +13,67 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateProjectParams creates a new CreateProjectParams object -// with the default values initialized. +// NewCreateProjectParams creates a new CreateProjectParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateProjectParams() *CreateProjectParams { - var () return &CreateProjectParams{ - timeout: cr.DefaultTimeout, } } // NewCreateProjectParamsWithTimeout creates a new CreateProjectParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateProjectParamsWithTimeout(timeout time.Duration) *CreateProjectParams { - var () return &CreateProjectParams{ - timeout: timeout, } } // NewCreateProjectParamsWithContext creates a new CreateProjectParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateProjectParamsWithContext(ctx context.Context) *CreateProjectParams { - var () return &CreateProjectParams{ - Context: ctx, } } // NewCreateProjectParamsWithHTTPClient creates a new CreateProjectParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateProjectParamsWithHTTPClient(client *http.Client) *CreateProjectParams { - var () return &CreateProjectParams{ HTTPClient: client, } } -/*CreateProjectParams contains all the parameters to send to the API endpoint -for the create project operation typically these are written to a http.Request +/* +CreateProjectParams contains all the parameters to send to the API endpoint + + for the create project operation. + + Typically these are written to a http.Request. */ type CreateProjectParams struct { - /*Body - The information of the project to create and optionally its configuration inputs. - If the configuration inputs are not sent the project configuration is not generated and should be generated separately. + /* Body. + The information of the project to create and optionally its configuration inputs. + If the configuration inputs are not sent the project configuration is not generated and should be generated separately. */ Body *models.NewProject - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -81,6 +82,21 @@ type CreateProjectParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create project params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateProjectParams) WithDefaults() *CreateProjectParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create project params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateProjectParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create project params func (o *CreateProjectParams) WithTimeout(timeout time.Duration) *CreateProjectParams { o.SetTimeout(timeout) @@ -143,7 +159,6 @@ func (o *CreateProjectParams) WriteToRequest(r runtime.ClientRequest, reg strfmt return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_projects/create_project_responses.go b/client/client/organization_projects/create_project_responses.go index 7eabdb50..19277a79 100644 --- a/client/client/organization_projects/create_project_responses.go +++ b/client/client/organization_projects/create_project_responses.go @@ -6,17 +6,18 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateProjectReader is a Reader for the CreateProject structure. @@ -68,7 +69,8 @@ func NewCreateProjectOK() *CreateProjectOK { return &CreateProjectOK{} } -/*CreateProjectOK handles this case with default header values. +/* +CreateProjectOK describes a response with status code 200, with default header values. Project created. The body contains the information of the new project of the organization. */ @@ -76,8 +78,44 @@ type CreateProjectOK struct { Payload *CreateProjectOKBody } +// IsSuccess returns true when this create project o k response has a 2xx status code +func (o *CreateProjectOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create project o k response has a 3xx status code +func (o *CreateProjectOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create project o k response has a 4xx status code +func (o *CreateProjectOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create project o k response has a 5xx status code +func (o *CreateProjectOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create project o k response a status code equal to that given +func (o *CreateProjectOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create project o k response +func (o *CreateProjectOK) Code() int { + return 200 +} + func (o *CreateProjectOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectOK %s", 200, payload) +} + +func (o *CreateProjectOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectOK %s", 200, payload) } func (o *CreateProjectOK) GetPayload() *CreateProjectOKBody { @@ -101,20 +139,60 @@ func NewCreateProjectNotFound() *CreateProjectNotFound { return &CreateProjectNotFound{} } -/*CreateProjectNotFound handles this case with default header values. +/* +CreateProjectNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateProjectNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create project not found response has a 2xx status code +func (o *CreateProjectNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create project not found response has a 3xx status code +func (o *CreateProjectNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create project not found response has a 4xx status code +func (o *CreateProjectNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create project not found response has a 5xx status code +func (o *CreateProjectNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create project not found response a status code equal to that given +func (o *CreateProjectNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create project not found response +func (o *CreateProjectNotFound) Code() int { + return 404 +} + func (o *CreateProjectNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectNotFound %s", 404, payload) +} + +func (o *CreateProjectNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectNotFound %s", 404, payload) } func (o *CreateProjectNotFound) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *CreateProjectNotFound) GetPayload() *models.ErrorPayload { func (o *CreateProjectNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,15 +227,50 @@ func NewCreateProjectLengthRequired() *CreateProjectLengthRequired { return &CreateProjectLengthRequired{} } -/*CreateProjectLengthRequired handles this case with default header values. +/* +CreateProjectLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreateProjectLengthRequired struct { } +// IsSuccess returns true when this create project length required response has a 2xx status code +func (o *CreateProjectLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create project length required response has a 3xx status code +func (o *CreateProjectLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create project length required response has a 4xx status code +func (o *CreateProjectLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create project length required response has a 5xx status code +func (o *CreateProjectLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create project length required response a status code equal to that given +func (o *CreateProjectLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create project length required response +func (o *CreateProjectLengthRequired) Code() int { + return 411 +} + func (o *CreateProjectLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectLengthRequired", 411) +} + +func (o *CreateProjectLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectLengthRequired", 411) } func (o *CreateProjectLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -166,20 +283,60 @@ func NewCreateProjectUnprocessableEntity() *CreateProjectUnprocessableEntity { return &CreateProjectUnprocessableEntity{} } -/*CreateProjectUnprocessableEntity handles this case with default header values. +/* +CreateProjectUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateProjectUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create project unprocessable entity response has a 2xx status code +func (o *CreateProjectUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create project unprocessable entity response has a 3xx status code +func (o *CreateProjectUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create project unprocessable entity response has a 4xx status code +func (o *CreateProjectUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create project unprocessable entity response has a 5xx status code +func (o *CreateProjectUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create project unprocessable entity response a status code equal to that given +func (o *CreateProjectUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create project unprocessable entity response +func (o *CreateProjectUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateProjectUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectUnprocessableEntity %s", 422, payload) +} + +func (o *CreateProjectUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProjectUnprocessableEntity %s", 422, payload) } func (o *CreateProjectUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -188,12 +345,16 @@ func (o *CreateProjectUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *CreateProjectUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -212,27 +373,61 @@ func NewCreateProjectDefault(code int) *CreateProjectDefault { } } -/*CreateProjectDefault handles this case with default header values. +/* +CreateProjectDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateProjectDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create project default response has a 2xx status code +func (o *CreateProjectDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create project default response has a 3xx status code +func (o *CreateProjectDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create project default response has a 4xx status code +func (o *CreateProjectDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create project default response has a 5xx status code +func (o *CreateProjectDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create project default response a status code equal to that given +func (o *CreateProjectDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create project default response func (o *CreateProjectDefault) Code() int { return o._statusCode } func (o *CreateProjectDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProject default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProject default %s", o._statusCode, payload) +} + +func (o *CreateProjectDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/projects][%d] createProject default %s", o._statusCode, payload) } func (o *CreateProjectDefault) GetPayload() *models.ErrorPayload { @@ -241,12 +436,16 @@ func (o *CreateProjectDefault) GetPayload() *models.ErrorPayload { func (o *CreateProjectDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -258,7 +457,8 @@ func (o *CreateProjectDefault) readResponse(response runtime.ClientResponse, con return nil } -/*CreateProjectOKBody create project o k body +/* +CreateProjectOKBody create project o k body swagger:model CreateProjectOKBody */ type CreateProjectOKBody struct { @@ -292,6 +492,39 @@ func (o *CreateProjectOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createProjectOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createProjectOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create project o k body based on the context it is used +func (o *CreateProjectOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateProjectOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createProjectOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createProjectOK" + "." + "data") } return err } diff --git a/client/client/organization_projects/delete_project_environment_parameters.go b/client/client/organization_projects/delete_project_environment_parameters.go index 1a93c447..f7b1b543 100644 --- a/client/client/organization_projects/delete_project_environment_parameters.go +++ b/client/client/organization_projects/delete_project_environment_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteProjectEnvironmentParams creates a new DeleteProjectEnvironmentParams object -// with the default values initialized. +// NewDeleteProjectEnvironmentParams creates a new DeleteProjectEnvironmentParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteProjectEnvironmentParams() *DeleteProjectEnvironmentParams { - var () return &DeleteProjectEnvironmentParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteProjectEnvironmentParamsWithTimeout creates a new DeleteProjectEnvironmentParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteProjectEnvironmentParamsWithTimeout(timeout time.Duration) *DeleteProjectEnvironmentParams { - var () return &DeleteProjectEnvironmentParams{ - timeout: timeout, } } // NewDeleteProjectEnvironmentParamsWithContext creates a new DeleteProjectEnvironmentParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteProjectEnvironmentParamsWithContext(ctx context.Context) *DeleteProjectEnvironmentParams { - var () return &DeleteProjectEnvironmentParams{ - Context: ctx, } } // NewDeleteProjectEnvironmentParamsWithHTTPClient creates a new DeleteProjectEnvironmentParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteProjectEnvironmentParamsWithHTTPClient(client *http.Client) *DeleteProjectEnvironmentParams { - var () return &DeleteProjectEnvironmentParams{ HTTPClient: client, } } -/*DeleteProjectEnvironmentParams contains all the parameters to send to the API endpoint -for the delete project environment operation typically these are written to a http.Request +/* +DeleteProjectEnvironmentParams contains all the parameters to send to the API endpoint + + for the delete project environment operation. + + Typically these are written to a http.Request. */ type DeleteProjectEnvironmentParams struct { - /*EnvironmentCanonical - The environment canonical to use as part of a path + /* EnvironmentCanonical. + The environment canonical to use as part of a path */ EnvironmentCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -82,6 +84,21 @@ type DeleteProjectEnvironmentParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete project environment params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteProjectEnvironmentParams) WithDefaults() *DeleteProjectEnvironmentParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete project environment params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteProjectEnvironmentParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete project environment params func (o *DeleteProjectEnvironmentParams) WithTimeout(timeout time.Duration) *DeleteProjectEnvironmentParams { o.SetTimeout(timeout) diff --git a/client/client/organization_projects/delete_project_environment_responses.go b/client/client/organization_projects/delete_project_environment_responses.go index bc395e12..85dc2876 100644 --- a/client/client/organization_projects/delete_project_environment_responses.go +++ b/client/client/organization_projects/delete_project_environment_responses.go @@ -6,16 +6,16 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteProjectEnvironmentReader is a Reader for the DeleteProjectEnvironment structure. @@ -61,15 +61,50 @@ func NewDeleteProjectEnvironmentNoContent() *DeleteProjectEnvironmentNoContent { return &DeleteProjectEnvironmentNoContent{} } -/*DeleteProjectEnvironmentNoContent handles this case with default header values. +/* +DeleteProjectEnvironmentNoContent describes a response with status code 204, with default header values. Project environment has been deleted. */ type DeleteProjectEnvironmentNoContent struct { } +// IsSuccess returns true when this delete project environment no content response has a 2xx status code +func (o *DeleteProjectEnvironmentNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete project environment no content response has a 3xx status code +func (o *DeleteProjectEnvironmentNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project environment no content response has a 4xx status code +func (o *DeleteProjectEnvironmentNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete project environment no content response has a 5xx status code +func (o *DeleteProjectEnvironmentNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project environment no content response a status code equal to that given +func (o *DeleteProjectEnvironmentNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete project environment no content response +func (o *DeleteProjectEnvironmentNoContent) Code() int { + return 204 +} + func (o *DeleteProjectEnvironmentNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentNoContent", 204) +} + +func (o *DeleteProjectEnvironmentNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentNoContent", 204) } func (o *DeleteProjectEnvironmentNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteProjectEnvironmentForbidden() *DeleteProjectEnvironmentForbidden { return &DeleteProjectEnvironmentForbidden{} } -/*DeleteProjectEnvironmentForbidden handles this case with default header values. +/* +DeleteProjectEnvironmentForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteProjectEnvironmentForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project environment forbidden response has a 2xx status code +func (o *DeleteProjectEnvironmentForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete project environment forbidden response has a 3xx status code +func (o *DeleteProjectEnvironmentForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project environment forbidden response has a 4xx status code +func (o *DeleteProjectEnvironmentForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete project environment forbidden response has a 5xx status code +func (o *DeleteProjectEnvironmentForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project environment forbidden response a status code equal to that given +func (o *DeleteProjectEnvironmentForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete project environment forbidden response +func (o *DeleteProjectEnvironmentForbidden) Code() int { + return 403 +} + func (o *DeleteProjectEnvironmentForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentForbidden %s", 403, payload) +} + +func (o *DeleteProjectEnvironmentForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentForbidden %s", 403, payload) } func (o *DeleteProjectEnvironmentForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteProjectEnvironmentForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteProjectEnvironmentForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteProjectEnvironmentNotFound() *DeleteProjectEnvironmentNotFound { return &DeleteProjectEnvironmentNotFound{} } -/*DeleteProjectEnvironmentNotFound handles this case with default header values. +/* +DeleteProjectEnvironmentNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteProjectEnvironmentNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project environment not found response has a 2xx status code +func (o *DeleteProjectEnvironmentNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete project environment not found response has a 3xx status code +func (o *DeleteProjectEnvironmentNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project environment not found response has a 4xx status code +func (o *DeleteProjectEnvironmentNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete project environment not found response has a 5xx status code +func (o *DeleteProjectEnvironmentNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project environment not found response a status code equal to that given +func (o *DeleteProjectEnvironmentNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete project environment not found response +func (o *DeleteProjectEnvironmentNotFound) Code() int { + return 404 +} + func (o *DeleteProjectEnvironmentNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentNotFound %s", 404, payload) +} + +func (o *DeleteProjectEnvironmentNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironmentNotFound %s", 404, payload) } func (o *DeleteProjectEnvironmentNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteProjectEnvironmentNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteProjectEnvironmentNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteProjectEnvironmentDefault(code int) *DeleteProjectEnvironmentDefau } } -/*DeleteProjectEnvironmentDefault handles this case with default header values. +/* +DeleteProjectEnvironmentDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteProjectEnvironmentDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project environment default response has a 2xx status code +func (o *DeleteProjectEnvironmentDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete project environment default response has a 3xx status code +func (o *DeleteProjectEnvironmentDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete project environment default response has a 4xx status code +func (o *DeleteProjectEnvironmentDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete project environment default response has a 5xx status code +func (o *DeleteProjectEnvironmentDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete project environment default response a status code equal to that given +func (o *DeleteProjectEnvironmentDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete project environment default response func (o *DeleteProjectEnvironmentDefault) Code() int { return o._statusCode } func (o *DeleteProjectEnvironmentDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironment default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironment default %s", o._statusCode, payload) +} + +func (o *DeleteProjectEnvironmentDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}][%d] deleteProjectEnvironment default %s", o._statusCode, payload) } func (o *DeleteProjectEnvironmentDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteProjectEnvironmentDefault) GetPayload() *models.ErrorPayload { func (o *DeleteProjectEnvironmentDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_projects/delete_project_favorite_parameters.go b/client/client/organization_projects/delete_project_favorite_parameters.go index c70e6012..84a6f628 100644 --- a/client/client/organization_projects/delete_project_favorite_parameters.go +++ b/client/client/organization_projects/delete_project_favorite_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteProjectFavoriteParams creates a new DeleteProjectFavoriteParams object -// with the default values initialized. +// NewDeleteProjectFavoriteParams creates a new DeleteProjectFavoriteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteProjectFavoriteParams() *DeleteProjectFavoriteParams { - var () return &DeleteProjectFavoriteParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteProjectFavoriteParamsWithTimeout creates a new DeleteProjectFavoriteParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteProjectFavoriteParamsWithTimeout(timeout time.Duration) *DeleteProjectFavoriteParams { - var () return &DeleteProjectFavoriteParams{ - timeout: timeout, } } // NewDeleteProjectFavoriteParamsWithContext creates a new DeleteProjectFavoriteParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteProjectFavoriteParamsWithContext(ctx context.Context) *DeleteProjectFavoriteParams { - var () return &DeleteProjectFavoriteParams{ - Context: ctx, } } // NewDeleteProjectFavoriteParamsWithHTTPClient creates a new DeleteProjectFavoriteParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteProjectFavoriteParamsWithHTTPClient(client *http.Client) *DeleteProjectFavoriteParams { - var () return &DeleteProjectFavoriteParams{ HTTPClient: client, } } -/*DeleteProjectFavoriteParams contains all the parameters to send to the API endpoint -for the delete project favorite operation typically these are written to a http.Request +/* +DeleteProjectFavoriteParams contains all the parameters to send to the API endpoint + + for the delete project favorite operation. + + Typically these are written to a http.Request. */ type DeleteProjectFavoriteParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -77,6 +78,21 @@ type DeleteProjectFavoriteParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete project favorite params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteProjectFavoriteParams) WithDefaults() *DeleteProjectFavoriteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete project favorite params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteProjectFavoriteParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete project favorite params func (o *DeleteProjectFavoriteParams) WithTimeout(timeout time.Duration) *DeleteProjectFavoriteParams { o.SetTimeout(timeout) diff --git a/client/client/organization_projects/delete_project_favorite_responses.go b/client/client/organization_projects/delete_project_favorite_responses.go index aefa3acf..584607d2 100644 --- a/client/client/organization_projects/delete_project_favorite_responses.go +++ b/client/client/organization_projects/delete_project_favorite_responses.go @@ -6,16 +6,16 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteProjectFavoriteReader is a Reader for the DeleteProjectFavorite structure. @@ -61,15 +61,50 @@ func NewDeleteProjectFavoriteNoContent() *DeleteProjectFavoriteNoContent { return &DeleteProjectFavoriteNoContent{} } -/*DeleteProjectFavoriteNoContent handles this case with default header values. +/* +DeleteProjectFavoriteNoContent describes a response with status code 204, with default header values. The project has been removed from user favorites list. */ type DeleteProjectFavoriteNoContent struct { } +// IsSuccess returns true when this delete project favorite no content response has a 2xx status code +func (o *DeleteProjectFavoriteNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete project favorite no content response has a 3xx status code +func (o *DeleteProjectFavoriteNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project favorite no content response has a 4xx status code +func (o *DeleteProjectFavoriteNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete project favorite no content response has a 5xx status code +func (o *DeleteProjectFavoriteNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project favorite no content response a status code equal to that given +func (o *DeleteProjectFavoriteNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete project favorite no content response +func (o *DeleteProjectFavoriteNoContent) Code() int { + return 204 +} + func (o *DeleteProjectFavoriteNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteNoContent", 204) +} + +func (o *DeleteProjectFavoriteNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteNoContent", 204) } func (o *DeleteProjectFavoriteNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteProjectFavoriteForbidden() *DeleteProjectFavoriteForbidden { return &DeleteProjectFavoriteForbidden{} } -/*DeleteProjectFavoriteForbidden handles this case with default header values. +/* +DeleteProjectFavoriteForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteProjectFavoriteForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project favorite forbidden response has a 2xx status code +func (o *DeleteProjectFavoriteForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete project favorite forbidden response has a 3xx status code +func (o *DeleteProjectFavoriteForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project favorite forbidden response has a 4xx status code +func (o *DeleteProjectFavoriteForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete project favorite forbidden response has a 5xx status code +func (o *DeleteProjectFavoriteForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project favorite forbidden response a status code equal to that given +func (o *DeleteProjectFavoriteForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete project favorite forbidden response +func (o *DeleteProjectFavoriteForbidden) Code() int { + return 403 +} + func (o *DeleteProjectFavoriteForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteForbidden %s", 403, payload) +} + +func (o *DeleteProjectFavoriteForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteForbidden %s", 403, payload) } func (o *DeleteProjectFavoriteForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteProjectFavoriteForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteProjectFavoriteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteProjectFavoriteNotFound() *DeleteProjectFavoriteNotFound { return &DeleteProjectFavoriteNotFound{} } -/*DeleteProjectFavoriteNotFound handles this case with default header values. +/* +DeleteProjectFavoriteNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteProjectFavoriteNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project favorite not found response has a 2xx status code +func (o *DeleteProjectFavoriteNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete project favorite not found response has a 3xx status code +func (o *DeleteProjectFavoriteNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project favorite not found response has a 4xx status code +func (o *DeleteProjectFavoriteNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete project favorite not found response has a 5xx status code +func (o *DeleteProjectFavoriteNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project favorite not found response a status code equal to that given +func (o *DeleteProjectFavoriteNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete project favorite not found response +func (o *DeleteProjectFavoriteNotFound) Code() int { + return 404 +} + func (o *DeleteProjectFavoriteNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteNotFound %s", 404, payload) +} + +func (o *DeleteProjectFavoriteNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavoriteNotFound %s", 404, payload) } func (o *DeleteProjectFavoriteNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteProjectFavoriteNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteProjectFavoriteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteProjectFavoriteDefault(code int) *DeleteProjectFavoriteDefault { } } -/*DeleteProjectFavoriteDefault handles this case with default header values. +/* +DeleteProjectFavoriteDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteProjectFavoriteDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project favorite default response has a 2xx status code +func (o *DeleteProjectFavoriteDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete project favorite default response has a 3xx status code +func (o *DeleteProjectFavoriteDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete project favorite default response has a 4xx status code +func (o *DeleteProjectFavoriteDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete project favorite default response has a 5xx status code +func (o *DeleteProjectFavoriteDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete project favorite default response a status code equal to that given +func (o *DeleteProjectFavoriteDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete project favorite default response func (o *DeleteProjectFavoriteDefault) Code() int { return o._statusCode } func (o *DeleteProjectFavoriteDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavorite default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavorite default %s", o._statusCode, payload) +} + +func (o *DeleteProjectFavoriteDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}/favorites][%d] deleteProjectFavorite default %s", o._statusCode, payload) } func (o *DeleteProjectFavoriteDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteProjectFavoriteDefault) GetPayload() *models.ErrorPayload { func (o *DeleteProjectFavoriteDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_projects/delete_project_parameters.go b/client/client/organization_projects/delete_project_parameters.go index b4114dc9..7374c902 100644 --- a/client/client/organization_projects/delete_project_parameters.go +++ b/client/client/organization_projects/delete_project_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteProjectParams creates a new DeleteProjectParams object -// with the default values initialized. +// NewDeleteProjectParams creates a new DeleteProjectParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteProjectParams() *DeleteProjectParams { - var () return &DeleteProjectParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteProjectParamsWithTimeout creates a new DeleteProjectParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteProjectParamsWithTimeout(timeout time.Duration) *DeleteProjectParams { - var () return &DeleteProjectParams{ - timeout: timeout, } } // NewDeleteProjectParamsWithContext creates a new DeleteProjectParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteProjectParamsWithContext(ctx context.Context) *DeleteProjectParams { - var () return &DeleteProjectParams{ - Context: ctx, } } // NewDeleteProjectParamsWithHTTPClient creates a new DeleteProjectParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteProjectParamsWithHTTPClient(client *http.Client) *DeleteProjectParams { - var () return &DeleteProjectParams{ HTTPClient: client, } } -/*DeleteProjectParams contains all the parameters to send to the API endpoint -for the delete project operation typically these are written to a http.Request +/* +DeleteProjectParams contains all the parameters to send to the API endpoint + + for the delete project operation. + + Typically these are written to a http.Request. */ type DeleteProjectParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -77,6 +78,21 @@ type DeleteProjectParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete project params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteProjectParams) WithDefaults() *DeleteProjectParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete project params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteProjectParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete project params func (o *DeleteProjectParams) WithTimeout(timeout time.Duration) *DeleteProjectParams { o.SetTimeout(timeout) diff --git a/client/client/organization_projects/delete_project_responses.go b/client/client/organization_projects/delete_project_responses.go index e342c5d9..ef78238c 100644 --- a/client/client/organization_projects/delete_project_responses.go +++ b/client/client/organization_projects/delete_project_responses.go @@ -6,16 +6,16 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteProjectReader is a Reader for the DeleteProject structure. @@ -61,15 +61,50 @@ func NewDeleteProjectNoContent() *DeleteProjectNoContent { return &DeleteProjectNoContent{} } -/*DeleteProjectNoContent handles this case with default header values. +/* +DeleteProjectNoContent describes a response with status code 204, with default header values. Project has been deleted. */ type DeleteProjectNoContent struct { } +// IsSuccess returns true when this delete project no content response has a 2xx status code +func (o *DeleteProjectNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete project no content response has a 3xx status code +func (o *DeleteProjectNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project no content response has a 4xx status code +func (o *DeleteProjectNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete project no content response has a 5xx status code +func (o *DeleteProjectNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project no content response a status code equal to that given +func (o *DeleteProjectNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete project no content response +func (o *DeleteProjectNoContent) Code() int { + return 204 +} + func (o *DeleteProjectNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectNoContent", 204) +} + +func (o *DeleteProjectNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectNoContent", 204) } func (o *DeleteProjectNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteProjectForbidden() *DeleteProjectForbidden { return &DeleteProjectForbidden{} } -/*DeleteProjectForbidden handles this case with default header values. +/* +DeleteProjectForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteProjectForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project forbidden response has a 2xx status code +func (o *DeleteProjectForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete project forbidden response has a 3xx status code +func (o *DeleteProjectForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project forbidden response has a 4xx status code +func (o *DeleteProjectForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete project forbidden response has a 5xx status code +func (o *DeleteProjectForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project forbidden response a status code equal to that given +func (o *DeleteProjectForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete project forbidden response +func (o *DeleteProjectForbidden) Code() int { + return 403 +} + func (o *DeleteProjectForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectForbidden %s", 403, payload) +} + +func (o *DeleteProjectForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectForbidden %s", 403, payload) } func (o *DeleteProjectForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteProjectForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteProjectForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteProjectNotFound() *DeleteProjectNotFound { return &DeleteProjectNotFound{} } -/*DeleteProjectNotFound handles this case with default header values. +/* +DeleteProjectNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteProjectNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project not found response has a 2xx status code +func (o *DeleteProjectNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete project not found response has a 3xx status code +func (o *DeleteProjectNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete project not found response has a 4xx status code +func (o *DeleteProjectNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete project not found response has a 5xx status code +func (o *DeleteProjectNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete project not found response a status code equal to that given +func (o *DeleteProjectNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete project not found response +func (o *DeleteProjectNotFound) Code() int { + return 404 +} + func (o *DeleteProjectNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectNotFound %s", 404, payload) +} + +func (o *DeleteProjectNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProjectNotFound %s", 404, payload) } func (o *DeleteProjectNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteProjectNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteProjectNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteProjectDefault(code int) *DeleteProjectDefault { } } -/*DeleteProjectDefault handles this case with default header values. +/* +DeleteProjectDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteProjectDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete project default response has a 2xx status code +func (o *DeleteProjectDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete project default response has a 3xx status code +func (o *DeleteProjectDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete project default response has a 4xx status code +func (o *DeleteProjectDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete project default response has a 5xx status code +func (o *DeleteProjectDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete project default response a status code equal to that given +func (o *DeleteProjectDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete project default response func (o *DeleteProjectDefault) Code() int { return o._statusCode } func (o *DeleteProjectDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProject default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProject default %s", o._statusCode, payload) +} + +func (o *DeleteProjectDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/projects/{project_canonical}][%d] deleteProject default %s", o._statusCode, payload) } func (o *DeleteProjectDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteProjectDefault) GetPayload() *models.ErrorPayload { func (o *DeleteProjectDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_projects/get_project_config_parameters.go b/client/client/organization_projects/get_project_config_parameters.go index 1544fb32..e29ca9cc 100644 --- a/client/client/organization_projects/get_project_config_parameters.go +++ b/client/client/organization_projects/get_project_config_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetProjectConfigParams creates a new GetProjectConfigParams object -// with the default values initialized. +// NewGetProjectConfigParams creates a new GetProjectConfigParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetProjectConfigParams() *GetProjectConfigParams { - var () return &GetProjectConfigParams{ - timeout: cr.DefaultTimeout, } } // NewGetProjectConfigParamsWithTimeout creates a new GetProjectConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetProjectConfigParamsWithTimeout(timeout time.Duration) *GetProjectConfigParams { - var () return &GetProjectConfigParams{ - timeout: timeout, } } // NewGetProjectConfigParamsWithContext creates a new GetProjectConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetProjectConfigParamsWithContext(ctx context.Context) *GetProjectConfigParams { - var () return &GetProjectConfigParams{ - Context: ctx, } } // NewGetProjectConfigParamsWithHTTPClient creates a new GetProjectConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetProjectConfigParamsWithHTTPClient(client *http.Client) *GetProjectConfigParams { - var () return &GetProjectConfigParams{ HTTPClient: client, } } -/*GetProjectConfigParams contains all the parameters to send to the API endpoint -for the get project config operation typically these are written to a http.Request +/* +GetProjectConfigParams contains all the parameters to send to the API endpoint + + for the get project config operation. + + Typically these are written to a http.Request. */ type GetProjectConfigParams struct { - /*EnvironmentCanonical - The environment canonical to use as part of a path + /* EnvironmentCanonical. + The environment canonical to use as part of a path */ EnvironmentCanonical string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -82,6 +84,21 @@ type GetProjectConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get project config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetProjectConfigParams) WithDefaults() *GetProjectConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get project config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetProjectConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get project config params func (o *GetProjectConfigParams) WithTimeout(timeout time.Duration) *GetProjectConfigParams { o.SetTimeout(timeout) diff --git a/client/client/organization_projects/get_project_config_responses.go b/client/client/organization_projects/get_project_config_responses.go index f5b67398..efaeca78 100644 --- a/client/client/organization_projects/get_project_config_responses.go +++ b/client/client/organization_projects/get_project_config_responses.go @@ -6,16 +6,17 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetProjectConfigReader is a Reader for the GetProjectConfig structure. @@ -67,20 +68,60 @@ func NewGetProjectConfigOK() *GetProjectConfigOK { return &GetProjectConfigOK{} } -/*GetProjectConfigOK handles this case with default header values. +/* +GetProjectConfigOK describes a response with status code 200, with default header values. Set of config to create the project / push onto repositories */ type GetProjectConfigOK struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *GetProjectConfigOKBody } +// IsSuccess returns true when this get project config o k response has a 2xx status code +func (o *GetProjectConfigOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get project config o k response has a 3xx status code +func (o *GetProjectConfigOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project config o k response has a 4xx status code +func (o *GetProjectConfigOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get project config o k response has a 5xx status code +func (o *GetProjectConfigOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get project config o k response a status code equal to that given +func (o *GetProjectConfigOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get project config o k response +func (o *GetProjectConfigOK) Code() int { + return 200 +} + func (o *GetProjectConfigOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigOK %s", 200, payload) +} + +func (o *GetProjectConfigOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigOK %s", 200, payload) } func (o *GetProjectConfigOK) GetPayload() *GetProjectConfigOKBody { @@ -89,12 +130,16 @@ func (o *GetProjectConfigOK) GetPayload() *GetProjectConfigOKBody { func (o *GetProjectConfigOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(GetProjectConfigOKBody) @@ -111,20 +156,60 @@ func NewGetProjectConfigForbidden() *GetProjectConfigForbidden { return &GetProjectConfigForbidden{} } -/*GetProjectConfigForbidden handles this case with default header values. +/* +GetProjectConfigForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetProjectConfigForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project config forbidden response has a 2xx status code +func (o *GetProjectConfigForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get project config forbidden response has a 3xx status code +func (o *GetProjectConfigForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project config forbidden response has a 4xx status code +func (o *GetProjectConfigForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get project config forbidden response has a 5xx status code +func (o *GetProjectConfigForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get project config forbidden response a status code equal to that given +func (o *GetProjectConfigForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get project config forbidden response +func (o *GetProjectConfigForbidden) Code() int { + return 403 +} + func (o *GetProjectConfigForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigForbidden %s", 403, payload) +} + +func (o *GetProjectConfigForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigForbidden %s", 403, payload) } func (o *GetProjectConfigForbidden) GetPayload() *models.ErrorPayload { @@ -133,12 +218,16 @@ func (o *GetProjectConfigForbidden) GetPayload() *models.ErrorPayload { func (o *GetProjectConfigForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -155,20 +244,60 @@ func NewGetProjectConfigNotFound() *GetProjectConfigNotFound { return &GetProjectConfigNotFound{} } -/*GetProjectConfigNotFound handles this case with default header values. +/* +GetProjectConfigNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetProjectConfigNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project config not found response has a 2xx status code +func (o *GetProjectConfigNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get project config not found response has a 3xx status code +func (o *GetProjectConfigNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project config not found response has a 4xx status code +func (o *GetProjectConfigNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get project config not found response has a 5xx status code +func (o *GetProjectConfigNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get project config not found response a status code equal to that given +func (o *GetProjectConfigNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get project config not found response +func (o *GetProjectConfigNotFound) Code() int { + return 404 +} + func (o *GetProjectConfigNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigNotFound %s", 404, payload) +} + +func (o *GetProjectConfigNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigNotFound %s", 404, payload) } func (o *GetProjectConfigNotFound) GetPayload() *models.ErrorPayload { @@ -177,12 +306,16 @@ func (o *GetProjectConfigNotFound) GetPayload() *models.ErrorPayload { func (o *GetProjectConfigNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -199,20 +332,60 @@ func NewGetProjectConfigUnprocessableEntity() *GetProjectConfigUnprocessableEnti return &GetProjectConfigUnprocessableEntity{} } -/*GetProjectConfigUnprocessableEntity handles this case with default header values. +/* +GetProjectConfigUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetProjectConfigUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project config unprocessable entity response has a 2xx status code +func (o *GetProjectConfigUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get project config unprocessable entity response has a 3xx status code +func (o *GetProjectConfigUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project config unprocessable entity response has a 4xx status code +func (o *GetProjectConfigUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get project config unprocessable entity response has a 5xx status code +func (o *GetProjectConfigUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get project config unprocessable entity response a status code equal to that given +func (o *GetProjectConfigUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get project config unprocessable entity response +func (o *GetProjectConfigUnprocessableEntity) Code() int { + return 422 +} + func (o *GetProjectConfigUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigUnprocessableEntity %s", 422, payload) +} + +func (o *GetProjectConfigUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfigUnprocessableEntity %s", 422, payload) } func (o *GetProjectConfigUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -221,12 +394,16 @@ func (o *GetProjectConfigUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *GetProjectConfigUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -245,27 +422,61 @@ func NewGetProjectConfigDefault(code int) *GetProjectConfigDefault { } } -/*GetProjectConfigDefault handles this case with default header values. +/* +GetProjectConfigDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetProjectConfigDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project config default response has a 2xx status code +func (o *GetProjectConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get project config default response has a 3xx status code +func (o *GetProjectConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get project config default response has a 4xx status code +func (o *GetProjectConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get project config default response has a 5xx status code +func (o *GetProjectConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get project config default response a status code equal to that given +func (o *GetProjectConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get project config default response func (o *GetProjectConfigDefault) Code() int { return o._statusCode } func (o *GetProjectConfigDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfig default %s", o._statusCode, payload) +} + +func (o *GetProjectConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config][%d] getProjectConfig default %s", o._statusCode, payload) } func (o *GetProjectConfigDefault) GetPayload() *models.ErrorPayload { @@ -274,12 +485,16 @@ func (o *GetProjectConfigDefault) GetPayload() *models.ErrorPayload { func (o *GetProjectConfigDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -291,7 +506,8 @@ func (o *GetProjectConfigDefault) readResponse(response runtime.ClientResponse, return nil } -/*GetProjectConfigOKBody get project config o k body +/* +GetProjectConfigOKBody get project config o k body swagger:model GetProjectConfigOKBody */ type GetProjectConfigOKBody struct { @@ -315,7 +531,6 @@ func (o *GetProjectConfigOKBody) Validate(formats strfmt.Registry) error { } func (o *GetProjectConfigOKBody) validateData(formats strfmt.Registry) error { - if swag.IsZero(o.Data) { // not required return nil } @@ -324,6 +539,43 @@ func (o *GetProjectConfigOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getProjectConfigOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectConfigOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get project config o k body based on the context it is used +func (o *GetProjectConfigOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetProjectConfigOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if swag.IsZero(o.Data) { // not required + return nil + } + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getProjectConfigOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectConfigOK" + "." + "data") } return err } diff --git a/client/client/organization_projects/get_project_parameters.go b/client/client/organization_projects/get_project_parameters.go index 3e95ba7a..73ca7363 100644 --- a/client/client/organization_projects/get_project_parameters.go +++ b/client/client/organization_projects/get_project_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetProjectParams creates a new GetProjectParams object -// with the default values initialized. +// NewGetProjectParams creates a new GetProjectParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetProjectParams() *GetProjectParams { - var () return &GetProjectParams{ - timeout: cr.DefaultTimeout, } } // NewGetProjectParamsWithTimeout creates a new GetProjectParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetProjectParamsWithTimeout(timeout time.Duration) *GetProjectParams { - var () return &GetProjectParams{ - timeout: timeout, } } // NewGetProjectParamsWithContext creates a new GetProjectParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetProjectParamsWithContext(ctx context.Context) *GetProjectParams { - var () return &GetProjectParams{ - Context: ctx, } } // NewGetProjectParamsWithHTTPClient creates a new GetProjectParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetProjectParamsWithHTTPClient(client *http.Client) *GetProjectParams { - var () return &GetProjectParams{ HTTPClient: client, } } -/*GetProjectParams contains all the parameters to send to the API endpoint -for the get project operation typically these are written to a http.Request +/* +GetProjectParams contains all the parameters to send to the API endpoint + + for the get project operation. + + Typically these are written to a http.Request. */ type GetProjectParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -77,6 +78,21 @@ type GetProjectParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get project params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetProjectParams) WithDefaults() *GetProjectParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get project params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetProjectParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get project params func (o *GetProjectParams) WithTimeout(timeout time.Duration) *GetProjectParams { o.SetTimeout(timeout) diff --git a/client/client/organization_projects/get_project_responses.go b/client/client/organization_projects/get_project_responses.go index 21c5040a..9f2d5297 100644 --- a/client/client/organization_projects/get_project_responses.go +++ b/client/client/organization_projects/get_project_responses.go @@ -6,17 +6,18 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetProjectReader is a Reader for the GetProject structure. @@ -62,7 +63,8 @@ func NewGetProjectOK() *GetProjectOK { return &GetProjectOK{} } -/*GetProjectOK handles this case with default header values. +/* +GetProjectOK describes a response with status code 200, with default header values. The information of the project of the organization which has the specified ID. */ @@ -70,8 +72,44 @@ type GetProjectOK struct { Payload *GetProjectOKBody } +// IsSuccess returns true when this get project o k response has a 2xx status code +func (o *GetProjectOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get project o k response has a 3xx status code +func (o *GetProjectOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project o k response has a 4xx status code +func (o *GetProjectOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get project o k response has a 5xx status code +func (o *GetProjectOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get project o k response a status code equal to that given +func (o *GetProjectOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get project o k response +func (o *GetProjectOK) Code() int { + return 200 +} + func (o *GetProjectOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectOK %s", 200, payload) +} + +func (o *GetProjectOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectOK %s", 200, payload) } func (o *GetProjectOK) GetPayload() *GetProjectOKBody { @@ -95,20 +133,60 @@ func NewGetProjectForbidden() *GetProjectForbidden { return &GetProjectForbidden{} } -/*GetProjectForbidden handles this case with default header values. +/* +GetProjectForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetProjectForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project forbidden response has a 2xx status code +func (o *GetProjectForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get project forbidden response has a 3xx status code +func (o *GetProjectForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project forbidden response has a 4xx status code +func (o *GetProjectForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get project forbidden response has a 5xx status code +func (o *GetProjectForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get project forbidden response a status code equal to that given +func (o *GetProjectForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get project forbidden response +func (o *GetProjectForbidden) Code() int { + return 403 +} + func (o *GetProjectForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectForbidden %s", 403, payload) +} + +func (o *GetProjectForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectForbidden %s", 403, payload) } func (o *GetProjectForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetProjectForbidden) GetPayload() *models.ErrorPayload { func (o *GetProjectForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetProjectNotFound() *GetProjectNotFound { return &GetProjectNotFound{} } -/*GetProjectNotFound handles this case with default header values. +/* +GetProjectNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetProjectNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project not found response has a 2xx status code +func (o *GetProjectNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get project not found response has a 3xx status code +func (o *GetProjectNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get project not found response has a 4xx status code +func (o *GetProjectNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get project not found response has a 5xx status code +func (o *GetProjectNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get project not found response a status code equal to that given +func (o *GetProjectNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get project not found response +func (o *GetProjectNotFound) Code() int { + return 404 +} + func (o *GetProjectNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectNotFound %s", 404, payload) +} + +func (o *GetProjectNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProjectNotFound %s", 404, payload) } func (o *GetProjectNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetProjectNotFound) GetPayload() *models.ErrorPayload { func (o *GetProjectNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetProjectDefault(code int) *GetProjectDefault { } } -/*GetProjectDefault handles this case with default header values. +/* +GetProjectDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetProjectDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get project default response has a 2xx status code +func (o *GetProjectDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get project default response has a 3xx status code +func (o *GetProjectDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get project default response has a 4xx status code +func (o *GetProjectDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get project default response has a 5xx status code +func (o *GetProjectDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get project default response a status code equal to that given +func (o *GetProjectDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get project default response func (o *GetProjectDefault) Code() int { return o._statusCode } func (o *GetProjectDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProject default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProject default %s", o._statusCode, payload) +} + +func (o *GetProjectDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects/{project_canonical}][%d] getProject default %s", o._statusCode, payload) } func (o *GetProjectDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetProjectDefault) GetPayload() *models.ErrorPayload { func (o *GetProjectDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetProjectDefault) readResponse(response runtime.ClientResponse, consum return nil } -/*GetProjectOKBody get project o k body +/* +GetProjectOKBody get project o k body swagger:model GetProjectOKBody */ type GetProjectOKBody struct { @@ -265,6 +430,39 @@ func (o *GetProjectOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getProjectOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get project o k body based on the context it is used +func (o *GetProjectOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetProjectOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getProjectOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectOK" + "." + "data") } return err } diff --git a/client/client/organization_projects/get_projects_parameters.go b/client/client/organization_projects/get_projects_parameters.go index 180c5ff8..fa519341 100644 --- a/client/client/organization_projects/get_projects_parameters.go +++ b/client/client/organization_projects/get_projects_parameters.go @@ -13,135 +13,136 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetProjectsParams creates a new GetProjectsParams object -// with the default values initialized. +// NewGetProjectsParams creates a new GetProjectsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetProjectsParams() *GetProjectsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetProjectsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetProjectsParamsWithTimeout creates a new GetProjectsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetProjectsParamsWithTimeout(timeout time.Duration) *GetProjectsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetProjectsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetProjectsParamsWithContext creates a new GetProjectsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetProjectsParamsWithContext(ctx context.Context) *GetProjectsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetProjectsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetProjectsParamsWithHTTPClient creates a new GetProjectsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetProjectsParamsWithHTTPClient(client *http.Client) *GetProjectsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetProjectsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetProjectsParams contains all the parameters to send to the API endpoint -for the get projects operation typically these are written to a http.Request +/* +GetProjectsParams contains all the parameters to send to the API endpoint + + for the get projects operation. + + Typically these are written to a http.Request. */ type GetProjectsParams struct { - /*EnvironmentCanonical - A list of environments' canonical to filter from + /* EnvironmentCanonical. + A list of environments' canonical to filter from */ - EnvironmentCanonical []string - /*Favorite - Flag to retrieve favorite data from the members favorite list. + EnvironmentCanonical *string + + /* Favorite. + Flag to retrieve favorite data from the members favorite list. */ Favorite *bool - /*MemberID - Search by entity's owner + /* MemberID. + + Search by entity's owner + + Format: uint32 */ MemberID *uint32 - /*OrderBy - Allows to order the list of items. Example usage: field_name:asc + /* OrderBy. + + Allows to order the list of items. Example usage: field_name:asc */ OrderBy *string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*ProjectConfigRepositoryCanonical - Search by project's config repository's canonical + /* ProjectConfigRepositoryCanonical. + + Search by project's config repository's canonical */ ProjectConfigRepositoryCanonical *string - /*ProjectCreatedAt - Search by project's creation date + /* ProjectCreatedAt. + + Search by project's creation date + + Format: uint64 */ ProjectCreatedAt *uint64 - /*ProjectDescription - Search by project's description + /* ProjectDescription. + + Search by project's description */ ProjectDescription *string - /*ProjectName - Search by project's name + /* ProjectName. + + Search by project's name */ ProjectName *string - /*ServiceCatalogSourceCanonical - Organization Service Catalog Sources canonical + /* ServiceCatalogSourceCanonical. + + Organization Service Catalog Sources canonical */ ServiceCatalogSourceCanonical *string @@ -150,6 +151,35 @@ type GetProjectsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get projects params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetProjectsParams) WithDefaults() *GetProjectsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get projects params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetProjectsParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetProjectsParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get projects params func (o *GetProjectsParams) WithTimeout(timeout time.Duration) *GetProjectsParams { o.SetTimeout(timeout) @@ -184,13 +214,13 @@ func (o *GetProjectsParams) SetHTTPClient(client *http.Client) { } // WithEnvironmentCanonical adds the environmentCanonical to the get projects params -func (o *GetProjectsParams) WithEnvironmentCanonical(environmentCanonical []string) *GetProjectsParams { +func (o *GetProjectsParams) WithEnvironmentCanonical(environmentCanonical *string) *GetProjectsParams { o.SetEnvironmentCanonical(environmentCanonical) return o } // SetEnvironmentCanonical adds the environmentCanonical to the get projects params -func (o *GetProjectsParams) SetEnvironmentCanonical(environmentCanonical []string) { +func (o *GetProjectsParams) SetEnvironmentCanonical(environmentCanonical *string) { o.EnvironmentCanonical = environmentCanonical } @@ -323,60 +353,72 @@ func (o *GetProjectsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R } var res []error - valuesEnvironmentCanonical := o.EnvironmentCanonical + if o.EnvironmentCanonical != nil { - joinedEnvironmentCanonical := swag.JoinByFormat(valuesEnvironmentCanonical, "") - // query array param environment_canonical - if err := r.SetQueryParam("environment_canonical", joinedEnvironmentCanonical...); err != nil { - return err + // query param environment_canonical + var qrEnvironmentCanonical string + + if o.EnvironmentCanonical != nil { + qrEnvironmentCanonical = *o.EnvironmentCanonical + } + qEnvironmentCanonical := qrEnvironmentCanonical + if qEnvironmentCanonical != "" { + + if err := r.SetQueryParam("environment_canonical", qEnvironmentCanonical); err != nil { + return err + } + } } if o.Favorite != nil { // query param favorite var qrFavorite bool + if o.Favorite != nil { qrFavorite = *o.Favorite } qFavorite := swag.FormatBool(qrFavorite) if qFavorite != "" { + if err := r.SetQueryParam("favorite", qFavorite); err != nil { return err } } - } if o.MemberID != nil { // query param member_id var qrMemberID uint32 + if o.MemberID != nil { qrMemberID = *o.MemberID } qMemberID := swag.FormatUint32(qrMemberID) if qMemberID != "" { + if err := r.SetQueryParam("member_id", qMemberID); err != nil { return err } } - } if o.OrderBy != nil { // query param order_by var qrOrderBy string + if o.OrderBy != nil { qrOrderBy = *o.OrderBy } qOrderBy := qrOrderBy if qOrderBy != "" { + if err := r.SetQueryParam("order_by", qOrderBy); err != nil { return err } } - } // path param organization_canonical @@ -388,112 +430,119 @@ func (o *GetProjectsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if o.ProjectConfigRepositoryCanonical != nil { // query param project_config_repository_canonical var qrProjectConfigRepositoryCanonical string + if o.ProjectConfigRepositoryCanonical != nil { qrProjectConfigRepositoryCanonical = *o.ProjectConfigRepositoryCanonical } qProjectConfigRepositoryCanonical := qrProjectConfigRepositoryCanonical if qProjectConfigRepositoryCanonical != "" { + if err := r.SetQueryParam("project_config_repository_canonical", qProjectConfigRepositoryCanonical); err != nil { return err } } - } if o.ProjectCreatedAt != nil { // query param project_created_at var qrProjectCreatedAt uint64 + if o.ProjectCreatedAt != nil { qrProjectCreatedAt = *o.ProjectCreatedAt } qProjectCreatedAt := swag.FormatUint64(qrProjectCreatedAt) if qProjectCreatedAt != "" { + if err := r.SetQueryParam("project_created_at", qProjectCreatedAt); err != nil { return err } } - } if o.ProjectDescription != nil { // query param project_description var qrProjectDescription string + if o.ProjectDescription != nil { qrProjectDescription = *o.ProjectDescription } qProjectDescription := qrProjectDescription if qProjectDescription != "" { + if err := r.SetQueryParam("project_description", qProjectDescription); err != nil { return err } } - } if o.ProjectName != nil { // query param project_name var qrProjectName string + if o.ProjectName != nil { qrProjectName = *o.ProjectName } qProjectName := qrProjectName if qProjectName != "" { + if err := r.SetQueryParam("project_name", qProjectName); err != nil { return err } } - } if o.ServiceCatalogSourceCanonical != nil { // query param service_catalog_source_canonical var qrServiceCatalogSourceCanonical string + if o.ServiceCatalogSourceCanonical != nil { qrServiceCatalogSourceCanonical = *o.ServiceCatalogSourceCanonical } qServiceCatalogSourceCanonical := qrServiceCatalogSourceCanonical if qServiceCatalogSourceCanonical != "" { + if err := r.SetQueryParam("service_catalog_source_canonical", qServiceCatalogSourceCanonical); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_projects/get_projects_responses.go b/client/client/organization_projects/get_projects_responses.go index 67e75888..3b346c61 100644 --- a/client/client/organization_projects/get_projects_responses.go +++ b/client/client/organization_projects/get_projects_responses.go @@ -6,18 +6,19 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetProjectsReader is a Reader for the GetProjects structure. @@ -69,7 +70,8 @@ func NewGetProjectsOK() *GetProjectsOK { return &GetProjectsOK{} } -/*GetProjectsOK handles this case with default header values. +/* +GetProjectsOK describes a response with status code 200, with default header values. List of the projects which the organization has. */ @@ -77,8 +79,44 @@ type GetProjectsOK struct { Payload *GetProjectsOKBody } +// IsSuccess returns true when this get projects o k response has a 2xx status code +func (o *GetProjectsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get projects o k response has a 3xx status code +func (o *GetProjectsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get projects o k response has a 4xx status code +func (o *GetProjectsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get projects o k response has a 5xx status code +func (o *GetProjectsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get projects o k response a status code equal to that given +func (o *GetProjectsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get projects o k response +func (o *GetProjectsOK) Code() int { + return 200 +} + func (o *GetProjectsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsOK %s", 200, payload) +} + +func (o *GetProjectsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsOK %s", 200, payload) } func (o *GetProjectsOK) GetPayload() *GetProjectsOKBody { @@ -102,20 +140,60 @@ func NewGetProjectsForbidden() *GetProjectsForbidden { return &GetProjectsForbidden{} } -/*GetProjectsForbidden handles this case with default header values. +/* +GetProjectsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetProjectsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get projects forbidden response has a 2xx status code +func (o *GetProjectsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get projects forbidden response has a 3xx status code +func (o *GetProjectsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get projects forbidden response has a 4xx status code +func (o *GetProjectsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get projects forbidden response has a 5xx status code +func (o *GetProjectsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get projects forbidden response a status code equal to that given +func (o *GetProjectsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get projects forbidden response +func (o *GetProjectsForbidden) Code() int { + return 403 +} + func (o *GetProjectsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsForbidden %s", 403, payload) +} + +func (o *GetProjectsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsForbidden %s", 403, payload) } func (o *GetProjectsForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetProjectsForbidden) GetPayload() *models.ErrorPayload { func (o *GetProjectsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetProjectsNotFound() *GetProjectsNotFound { return &GetProjectsNotFound{} } -/*GetProjectsNotFound handles this case with default header values. +/* +GetProjectsNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetProjectsNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get projects not found response has a 2xx status code +func (o *GetProjectsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get projects not found response has a 3xx status code +func (o *GetProjectsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get projects not found response has a 4xx status code +func (o *GetProjectsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get projects not found response has a 5xx status code +func (o *GetProjectsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get projects not found response a status code equal to that given +func (o *GetProjectsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get projects not found response +func (o *GetProjectsNotFound) Code() int { + return 404 +} + func (o *GetProjectsNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsNotFound %s", 404, payload) +} + +func (o *GetProjectsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsNotFound %s", 404, payload) } func (o *GetProjectsNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetProjectsNotFound) GetPayload() *models.ErrorPayload { func (o *GetProjectsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetProjectsUnprocessableEntity() *GetProjectsUnprocessableEntity { return &GetProjectsUnprocessableEntity{} } -/*GetProjectsUnprocessableEntity handles this case with default header values. +/* +GetProjectsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetProjectsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get projects unprocessable entity response has a 2xx status code +func (o *GetProjectsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get projects unprocessable entity response has a 3xx status code +func (o *GetProjectsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get projects unprocessable entity response has a 4xx status code +func (o *GetProjectsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get projects unprocessable entity response has a 5xx status code +func (o *GetProjectsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get projects unprocessable entity response a status code equal to that given +func (o *GetProjectsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get projects unprocessable entity response +func (o *GetProjectsUnprocessableEntity) Code() int { + return 422 +} + func (o *GetProjectsUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsUnprocessableEntity %s", 422, payload) +} + +func (o *GetProjectsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjectsUnprocessableEntity %s", 422, payload) } func (o *GetProjectsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetProjectsUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetProjectsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetProjectsDefault(code int) *GetProjectsDefault { } } -/*GetProjectsDefault handles this case with default header values. +/* +GetProjectsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetProjectsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get projects default response has a 2xx status code +func (o *GetProjectsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get projects default response has a 3xx status code +func (o *GetProjectsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get projects default response has a 4xx status code +func (o *GetProjectsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get projects default response has a 5xx status code +func (o *GetProjectsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get projects default response a status code equal to that given +func (o *GetProjectsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get projects default response func (o *GetProjectsDefault) Code() int { return o._statusCode } func (o *GetProjectsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjects default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjects default %s", o._statusCode, payload) +} + +func (o *GetProjectsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/projects][%d] getProjects default %s", o._statusCode, payload) } func (o *GetProjectsDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetProjectsDefault) GetPayload() *models.ErrorPayload { func (o *GetProjectsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetProjectsDefault) readResponse(response runtime.ClientResponse, consu return nil } -/*GetProjectsOKBody get projects o k body +/* +GetProjectsOKBody get projects o k body swagger:model GetProjectsOKBody */ type GetProjectsOKBody struct { @@ -329,6 +538,8 @@ func (o *GetProjectsOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getProjectsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -349,6 +560,68 @@ func (o *GetProjectsOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getProjectsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectsOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get projects o k body based on the context it is used +func (o *GetProjectsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetProjectsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getProjectsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetProjectsOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getProjectsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getProjectsOK" + "." + "pagination") } return err } diff --git a/client/client/organization_projects/organization_projects_client.go b/client/client/organization_projects/organization_projects_client.go index 6d7d2905..5ace38d1 100644 --- a/client/client/organization_projects/organization_projects_client.go +++ b/client/client/organization_projects/organization_projects_client.go @@ -7,15 +7,40 @@ package organization_projects import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization projects API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization projects API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization projects API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization projects API */ @@ -24,16 +49,90 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateProject(params *CreateProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateProjectOK, error) + + CreateProjectFavorite(params *CreateProjectFavoriteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateProjectFavoriteNoContent, error) + + DeleteProject(params *DeleteProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteProjectNoContent, error) + + DeleteProjectEnvironment(params *DeleteProjectEnvironmentParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteProjectEnvironmentNoContent, error) + + DeleteProjectFavorite(params *DeleteProjectFavoriteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteProjectFavoriteNoContent, error) + + GetProject(params *GetProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectOK, error) + + GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectConfigOK, error) + + GetProjects(params *GetProjectsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectsOK, error) + + UpdateProject(params *UpdateProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateProjectOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateProject Create a new project with envs and pipelines in the organization. */ -func (a *Client) CreateProject(params *CreateProjectParams, authInfo runtime.ClientAuthInfoWriter) (*CreateProjectOK, error) { +func (a *Client) CreateProject(params *CreateProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateProjectOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateProjectParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createProject", Method: "POST", PathPattern: "/organizations/{organization_canonical}/projects", @@ -45,7 +144,12 @@ func (a *Client) CreateProject(params *CreateProjectParams, authInfo runtime.Cli AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +165,12 @@ func (a *Client) CreateProject(params *CreateProjectParams, authInfo runtime.Cli /* CreateProjectFavorite Add a new project in the user favorites list. */ -func (a *Client) CreateProjectFavorite(params *CreateProjectFavoriteParams, authInfo runtime.ClientAuthInfoWriter) (*CreateProjectFavoriteNoContent, error) { +func (a *Client) CreateProjectFavorite(params *CreateProjectFavoriteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateProjectFavoriteNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateProjectFavoriteParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createProjectFavorite", Method: "POST", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/favorites", @@ -79,7 +182,12 @@ func (a *Client) CreateProjectFavorite(params *CreateProjectFavoriteParams, auth AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +203,12 @@ func (a *Client) CreateProjectFavorite(params *CreateProjectFavoriteParams, auth /* DeleteProject Delete a project of the organization. */ -func (a *Client) DeleteProject(params *DeleteProjectParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteProjectNoContent, error) { +func (a *Client) DeleteProject(params *DeleteProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteProjectNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteProjectParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteProject", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}", @@ -113,7 +220,12 @@ func (a *Client) DeleteProject(params *DeleteProjectParams, authInfo runtime.Cli AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +241,12 @@ func (a *Client) DeleteProject(params *DeleteProjectParams, authInfo runtime.Cli /* DeleteProjectEnvironment Delete a project environment of the organization, and the project itself if it's the last environment. */ -func (a *Client) DeleteProjectEnvironment(params *DeleteProjectEnvironmentParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteProjectEnvironmentNoContent, error) { +func (a *Client) DeleteProjectEnvironment(params *DeleteProjectEnvironmentParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteProjectEnvironmentNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteProjectEnvironmentParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteProjectEnvironment", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/environments/{environment_canonical}", @@ -147,7 +258,12 @@ func (a *Client) DeleteProjectEnvironment(params *DeleteProjectEnvironmentParams AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +279,12 @@ func (a *Client) DeleteProjectEnvironment(params *DeleteProjectEnvironmentParams /* DeleteProjectFavorite Remove a project from the user favorites list. */ -func (a *Client) DeleteProjectFavorite(params *DeleteProjectFavoriteParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteProjectFavoriteNoContent, error) { +func (a *Client) DeleteProjectFavorite(params *DeleteProjectFavoriteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteProjectFavoriteNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteProjectFavoriteParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteProjectFavorite", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/favorites", @@ -181,7 +296,12 @@ func (a *Client) DeleteProjectFavorite(params *DeleteProjectFavoriteParams, auth AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -197,13 +317,12 @@ func (a *Client) DeleteProjectFavorite(params *DeleteProjectFavoriteParams, auth /* GetProject Get a project of the organization. */ -func (a *Client) GetProject(params *GetProjectParams, authInfo runtime.ClientAuthInfoWriter) (*GetProjectOK, error) { +func (a *Client) GetProject(params *GetProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetProjectParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getProject", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}", @@ -215,7 +334,12 @@ func (a *Client) GetProject(params *GetProjectParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -231,13 +355,12 @@ func (a *Client) GetProject(params *GetProjectParams, authInfo runtime.ClientAut /* GetProjectConfig Fetch the current project's environment's configuration. */ -func (a *Client) GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter) (*GetProjectConfigOK, error) { +func (a *Client) GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectConfigOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetProjectConfigParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getProjectConfig", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config", @@ -249,7 +372,12 @@ func (a *Client) GetProjectConfig(params *GetProjectConfigParams, authInfo runti AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -265,13 +393,12 @@ func (a *Client) GetProjectConfig(params *GetProjectConfigParams, authInfo runti /* GetProjects Get list of projects of the organization. */ -func (a *Client) GetProjects(params *GetProjectsParams, authInfo runtime.ClientAuthInfoWriter) (*GetProjectsOK, error) { +func (a *Client) GetProjects(params *GetProjectsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetProjectsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getProjects", Method: "GET", PathPattern: "/organizations/{organization_canonical}/projects", @@ -283,7 +410,12 @@ func (a *Client) GetProjects(params *GetProjectsParams, authInfo runtime.ClientA AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -299,13 +431,12 @@ func (a *Client) GetProjects(params *GetProjectsParams, authInfo runtime.ClientA /* UpdateProject Update the information of a project of the organization. If the project has some information on the fields which aren't required and they are not sent or set to their default values, which depend of their types, the information will be removed. */ -func (a *Client) UpdateProject(params *UpdateProjectParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateProjectOK, error) { +func (a *Client) UpdateProject(params *UpdateProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateProjectOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateProjectParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateProject", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}", @@ -317,7 +448,12 @@ func (a *Client) UpdateProject(params *UpdateProjectParams, authInfo runtime.Cli AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_projects/update_project_parameters.go b/client/client/organization_projects/update_project_parameters.go index c674a796..0970fd67 100644 --- a/client/client/organization_projects/update_project_parameters.go +++ b/client/client/organization_projects/update_project_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateProjectParams creates a new UpdateProjectParams object -// with the default values initialized. +// NewUpdateProjectParams creates a new UpdateProjectParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateProjectParams() *UpdateProjectParams { - var () return &UpdateProjectParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateProjectParamsWithTimeout creates a new UpdateProjectParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateProjectParamsWithTimeout(timeout time.Duration) *UpdateProjectParams { - var () return &UpdateProjectParams{ - timeout: timeout, } } // NewUpdateProjectParamsWithContext creates a new UpdateProjectParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateProjectParamsWithContext(ctx context.Context) *UpdateProjectParams { - var () return &UpdateProjectParams{ - Context: ctx, } } // NewUpdateProjectParamsWithHTTPClient creates a new UpdateProjectParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateProjectParamsWithHTTPClient(client *http.Client) *UpdateProjectParams { - var () return &UpdateProjectParams{ HTTPClient: client, } } -/*UpdateProjectParams contains all the parameters to send to the API endpoint -for the update project operation typically these are written to a http.Request +/* +UpdateProjectParams contains all the parameters to send to the API endpoint + + for the update project operation. + + Typically these are written to a http.Request. */ type UpdateProjectParams struct { - /*Body - The information of the project to update. + /* Body. + The information of the project to update. */ Body *models.UpdateProject - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ProjectCanonical - A canonical of a project. + /* ProjectCanonical. + + A canonical of a project. */ ProjectCanonical string @@ -84,6 +86,21 @@ type UpdateProjectParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update project params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateProjectParams) WithDefaults() *UpdateProjectParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update project params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateProjectParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update project params func (o *UpdateProjectParams) WithTimeout(timeout time.Duration) *UpdateProjectParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateProjectParams) WriteToRequest(r runtime.ClientRequest, reg strfmt return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_projects/update_project_responses.go b/client/client/organization_projects/update_project_responses.go index 59e5597a..ca99eccc 100644 --- a/client/client/organization_projects/update_project_responses.go +++ b/client/client/organization_projects/update_project_responses.go @@ -6,17 +6,18 @@ package organization_projects // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateProjectReader is a Reader for the UpdateProject structure. @@ -74,7 +75,8 @@ func NewUpdateProjectOK() *UpdateProjectOK { return &UpdateProjectOK{} } -/*UpdateProjectOK handles this case with default header values. +/* +UpdateProjectOK describes a response with status code 200, with default header values. Project updated. The body contains information of the updated project. */ @@ -82,8 +84,44 @@ type UpdateProjectOK struct { Payload *UpdateProjectOKBody } +// IsSuccess returns true when this update project o k response has a 2xx status code +func (o *UpdateProjectOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update project o k response has a 3xx status code +func (o *UpdateProjectOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update project o k response has a 4xx status code +func (o *UpdateProjectOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update project o k response has a 5xx status code +func (o *UpdateProjectOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update project o k response a status code equal to that given +func (o *UpdateProjectOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update project o k response +func (o *UpdateProjectOK) Code() int { + return 200 +} + func (o *UpdateProjectOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectOK %s", 200, payload) +} + +func (o *UpdateProjectOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectOK %s", 200, payload) } func (o *UpdateProjectOK) GetPayload() *UpdateProjectOKBody { @@ -107,20 +145,60 @@ func NewUpdateProjectForbidden() *UpdateProjectForbidden { return &UpdateProjectForbidden{} } -/*UpdateProjectForbidden handles this case with default header values. +/* +UpdateProjectForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateProjectForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update project forbidden response has a 2xx status code +func (o *UpdateProjectForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update project forbidden response has a 3xx status code +func (o *UpdateProjectForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update project forbidden response has a 4xx status code +func (o *UpdateProjectForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update project forbidden response has a 5xx status code +func (o *UpdateProjectForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update project forbidden response a status code equal to that given +func (o *UpdateProjectForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update project forbidden response +func (o *UpdateProjectForbidden) Code() int { + return 403 +} + func (o *UpdateProjectForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectForbidden %s", 403, payload) +} + +func (o *UpdateProjectForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectForbidden %s", 403, payload) } func (o *UpdateProjectForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *UpdateProjectForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateProjectForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewUpdateProjectNotFound() *UpdateProjectNotFound { return &UpdateProjectNotFound{} } -/*UpdateProjectNotFound handles this case with default header values. +/* +UpdateProjectNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateProjectNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update project not found response has a 2xx status code +func (o *UpdateProjectNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update project not found response has a 3xx status code +func (o *UpdateProjectNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update project not found response has a 4xx status code +func (o *UpdateProjectNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update project not found response has a 5xx status code +func (o *UpdateProjectNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update project not found response a status code equal to that given +func (o *UpdateProjectNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update project not found response +func (o *UpdateProjectNotFound) Code() int { + return 404 +} + func (o *UpdateProjectNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectNotFound %s", 404, payload) +} + +func (o *UpdateProjectNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectNotFound %s", 404, payload) } func (o *UpdateProjectNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *UpdateProjectNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateProjectNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewUpdateProjectLengthRequired() *UpdateProjectLengthRequired { return &UpdateProjectLengthRequired{} } -/*UpdateProjectLengthRequired handles this case with default header values. +/* +UpdateProjectLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateProjectLengthRequired struct { } +// IsSuccess returns true when this update project length required response has a 2xx status code +func (o *UpdateProjectLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update project length required response has a 3xx status code +func (o *UpdateProjectLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update project length required response has a 4xx status code +func (o *UpdateProjectLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update project length required response has a 5xx status code +func (o *UpdateProjectLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update project length required response a status code equal to that given +func (o *UpdateProjectLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update project length required response +func (o *UpdateProjectLengthRequired) Code() int { + return 411 +} + func (o *UpdateProjectLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectLengthRequired", 411) +} + +func (o *UpdateProjectLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectLengthRequired", 411) } func (o *UpdateProjectLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewUpdateProjectUnprocessableEntity() *UpdateProjectUnprocessableEntity { return &UpdateProjectUnprocessableEntity{} } -/*UpdateProjectUnprocessableEntity handles this case with default header values. +/* +UpdateProjectUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateProjectUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update project unprocessable entity response has a 2xx status code +func (o *UpdateProjectUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update project unprocessable entity response has a 3xx status code +func (o *UpdateProjectUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update project unprocessable entity response has a 4xx status code +func (o *UpdateProjectUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update project unprocessable entity response has a 5xx status code +func (o *UpdateProjectUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update project unprocessable entity response a status code equal to that given +func (o *UpdateProjectUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update project unprocessable entity response +func (o *UpdateProjectUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateProjectUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateProjectUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProjectUnprocessableEntity %s", 422, payload) } func (o *UpdateProjectUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *UpdateProjectUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *UpdateProjectUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewUpdateProjectDefault(code int) *UpdateProjectDefault { } } -/*UpdateProjectDefault handles this case with default header values. +/* +UpdateProjectDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateProjectDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update project default response has a 2xx status code +func (o *UpdateProjectDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update project default response has a 3xx status code +func (o *UpdateProjectDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update project default response has a 4xx status code +func (o *UpdateProjectDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update project default response has a 5xx status code +func (o *UpdateProjectDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update project default response a status code equal to that given +func (o *UpdateProjectDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update project default response func (o *UpdateProjectDefault) Code() int { return o._statusCode } func (o *UpdateProjectDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProject default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProject default %s", o._statusCode, payload) +} + +func (o *UpdateProjectDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/projects/{project_canonical}][%d] updateProject default %s", o._statusCode, payload) } func (o *UpdateProjectDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *UpdateProjectDefault) GetPayload() *models.ErrorPayload { func (o *UpdateProjectDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *UpdateProjectDefault) readResponse(response runtime.ClientResponse, con return nil } -/*UpdateProjectOKBody update project o k body +/* +UpdateProjectOKBody update project o k body swagger:model UpdateProjectOKBody */ type UpdateProjectOKBody struct { @@ -342,6 +586,39 @@ func (o *UpdateProjectOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateProjectOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateProjectOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update project o k body based on the context it is used +func (o *UpdateProjectOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateProjectOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateProjectOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateProjectOK" + "." + "data") } return err } diff --git a/client/client/organization_roles/create_role_parameters.go b/client/client/organization_roles/create_role_parameters.go index 4fd186d3..e622fe4f 100644 --- a/client/client/organization_roles/create_role_parameters.go +++ b/client/client/organization_roles/create_role_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateRoleParams creates a new CreateRoleParams object -// with the default values initialized. +// NewCreateRoleParams creates a new CreateRoleParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateRoleParams() *CreateRoleParams { - var () return &CreateRoleParams{ - timeout: cr.DefaultTimeout, } } // NewCreateRoleParamsWithTimeout creates a new CreateRoleParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateRoleParamsWithTimeout(timeout time.Duration) *CreateRoleParams { - var () return &CreateRoleParams{ - timeout: timeout, } } // NewCreateRoleParamsWithContext creates a new CreateRoleParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateRoleParamsWithContext(ctx context.Context) *CreateRoleParams { - var () return &CreateRoleParams{ - Context: ctx, } } // NewCreateRoleParamsWithHTTPClient creates a new CreateRoleParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateRoleParamsWithHTTPClient(client *http.Client) *CreateRoleParams { - var () return &CreateRoleParams{ HTTPClient: client, } } -/*CreateRoleParams contains all the parameters to send to the API endpoint -for the create role operation typically these are written to a http.Request +/* +CreateRoleParams contains all the parameters to send to the API endpoint + + for the create role operation. + + Typically these are written to a http.Request. */ type CreateRoleParams struct { - /*Body - The information of the organization's role to create. + /* Body. + The information of the organization's role to create. */ Body *models.NewRole - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type CreateRoleParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create role params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateRoleParams) WithDefaults() *CreateRoleParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create role params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateRoleParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create role params func (o *CreateRoleParams) WithTimeout(timeout time.Duration) *CreateRoleParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CreateRoleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_roles/create_role_responses.go b/client/client/organization_roles/create_role_responses.go index a28e5fdb..357f9211 100644 --- a/client/client/organization_roles/create_role_responses.go +++ b/client/client/organization_roles/create_role_responses.go @@ -6,17 +6,18 @@ package organization_roles // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateRoleReader is a Reader for the CreateRole structure. @@ -68,7 +69,8 @@ func NewCreateRoleOK() *CreateRoleOK { return &CreateRoleOK{} } -/*CreateRoleOK handles this case with default header values. +/* +CreateRoleOK describes a response with status code 200, with default header values. New role created in the organization. */ @@ -76,8 +78,44 @@ type CreateRoleOK struct { Payload *CreateRoleOKBody } +// IsSuccess returns true when this create role o k response has a 2xx status code +func (o *CreateRoleOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create role o k response has a 3xx status code +func (o *CreateRoleOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create role o k response has a 4xx status code +func (o *CreateRoleOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create role o k response has a 5xx status code +func (o *CreateRoleOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create role o k response a status code equal to that given +func (o *CreateRoleOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create role o k response +func (o *CreateRoleOK) Code() int { + return 200 +} + func (o *CreateRoleOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleOK %s", 200, payload) +} + +func (o *CreateRoleOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleOK %s", 200, payload) } func (o *CreateRoleOK) GetPayload() *CreateRoleOKBody { @@ -101,20 +139,60 @@ func NewCreateRoleForbidden() *CreateRoleForbidden { return &CreateRoleForbidden{} } -/*CreateRoleForbidden handles this case with default header values. +/* +CreateRoleForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateRoleForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create role forbidden response has a 2xx status code +func (o *CreateRoleForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create role forbidden response has a 3xx status code +func (o *CreateRoleForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create role forbidden response has a 4xx status code +func (o *CreateRoleForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create role forbidden response has a 5xx status code +func (o *CreateRoleForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create role forbidden response a status code equal to that given +func (o *CreateRoleForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create role forbidden response +func (o *CreateRoleForbidden) Code() int { + return 403 +} + func (o *CreateRoleForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleForbidden %s", 403, payload) +} + +func (o *CreateRoleForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleForbidden %s", 403, payload) } func (o *CreateRoleForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *CreateRoleForbidden) GetPayload() *models.ErrorPayload { func (o *CreateRoleForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewCreateRoleNotFound() *CreateRoleNotFound { return &CreateRoleNotFound{} } -/*CreateRoleNotFound handles this case with default header values. +/* +CreateRoleNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateRoleNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create role not found response has a 2xx status code +func (o *CreateRoleNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create role not found response has a 3xx status code +func (o *CreateRoleNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create role not found response has a 4xx status code +func (o *CreateRoleNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create role not found response has a 5xx status code +func (o *CreateRoleNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create role not found response a status code equal to that given +func (o *CreateRoleNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create role not found response +func (o *CreateRoleNotFound) Code() int { + return 404 +} + func (o *CreateRoleNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleNotFound %s", 404, payload) +} + +func (o *CreateRoleNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleNotFound %s", 404, payload) } func (o *CreateRoleNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *CreateRoleNotFound) GetPayload() *models.ErrorPayload { func (o *CreateRoleNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewCreateRoleUnprocessableEntity() *CreateRoleUnprocessableEntity { return &CreateRoleUnprocessableEntity{} } -/*CreateRoleUnprocessableEntity handles this case with default header values. +/* +CreateRoleUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateRoleUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create role unprocessable entity response has a 2xx status code +func (o *CreateRoleUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create role unprocessable entity response has a 3xx status code +func (o *CreateRoleUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create role unprocessable entity response has a 4xx status code +func (o *CreateRoleUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create role unprocessable entity response has a 5xx status code +func (o *CreateRoleUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create role unprocessable entity response a status code equal to that given +func (o *CreateRoleUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create role unprocessable entity response +func (o *CreateRoleUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateRoleUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleUnprocessableEntity %s", 422, payload) +} + +func (o *CreateRoleUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRoleUnprocessableEntity %s", 422, payload) } func (o *CreateRoleUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *CreateRoleUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *CreateRoleUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewCreateRoleDefault(code int) *CreateRoleDefault { } } -/*CreateRoleDefault handles this case with default header values. +/* +CreateRoleDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateRoleDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create role default response has a 2xx status code +func (o *CreateRoleDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create role default response has a 3xx status code +func (o *CreateRoleDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create role default response has a 4xx status code +func (o *CreateRoleDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create role default response has a 5xx status code +func (o *CreateRoleDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create role default response a status code equal to that given +func (o *CreateRoleDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create role default response func (o *CreateRoleDefault) Code() int { return o._statusCode } func (o *CreateRoleDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRole default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRole default %s", o._statusCode, payload) +} + +func (o *CreateRoleDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/roles][%d] createRole default %s", o._statusCode, payload) } func (o *CreateRoleDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *CreateRoleDefault) GetPayload() *models.ErrorPayload { func (o *CreateRoleDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *CreateRoleDefault) readResponse(response runtime.ClientResponse, consum return nil } -/*CreateRoleOKBody create role o k body +/* +CreateRoleOKBody create role o k body swagger:model CreateRoleOKBody */ type CreateRoleOKBody struct { @@ -315,6 +524,39 @@ func (o *CreateRoleOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createRoleOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createRoleOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create role o k body based on the context it is used +func (o *CreateRoleOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateRoleOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createRoleOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createRoleOK" + "." + "data") } return err } diff --git a/client/client/organization_roles/delete_role_parameters.go b/client/client/organization_roles/delete_role_parameters.go index 342650ea..aaa3c2b2 100644 --- a/client/client/organization_roles/delete_role_parameters.go +++ b/client/client/organization_roles/delete_role_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteRoleParams creates a new DeleteRoleParams object -// with the default values initialized. +// NewDeleteRoleParams creates a new DeleteRoleParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteRoleParams() *DeleteRoleParams { - var () return &DeleteRoleParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteRoleParamsWithTimeout creates a new DeleteRoleParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteRoleParamsWithTimeout(timeout time.Duration) *DeleteRoleParams { - var () return &DeleteRoleParams{ - timeout: timeout, } } // NewDeleteRoleParamsWithContext creates a new DeleteRoleParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteRoleParamsWithContext(ctx context.Context) *DeleteRoleParams { - var () return &DeleteRoleParams{ - Context: ctx, } } // NewDeleteRoleParamsWithHTTPClient creates a new DeleteRoleParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteRoleParamsWithHTTPClient(client *http.Client) *DeleteRoleParams { - var () return &DeleteRoleParams{ HTTPClient: client, } } -/*DeleteRoleParams contains all the parameters to send to the API endpoint -for the delete role operation typically these are written to a http.Request +/* +DeleteRoleParams contains all the parameters to send to the API endpoint + + for the delete role operation. + + Typically these are written to a http.Request. */ type DeleteRoleParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*RoleCanonical - Organization Role canonical + /* RoleCanonical. + + Organization Role canonical */ RoleCanonical string @@ -77,6 +78,21 @@ type DeleteRoleParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete role params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteRoleParams) WithDefaults() *DeleteRoleParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete role params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteRoleParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete role params func (o *DeleteRoleParams) WithTimeout(timeout time.Duration) *DeleteRoleParams { o.SetTimeout(timeout) diff --git a/client/client/organization_roles/delete_role_responses.go b/client/client/organization_roles/delete_role_responses.go index 117ba9d9..9b58bfac 100644 --- a/client/client/organization_roles/delete_role_responses.go +++ b/client/client/organization_roles/delete_role_responses.go @@ -6,16 +6,16 @@ package organization_roles // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteRoleReader is a Reader for the DeleteRole structure. @@ -61,15 +61,50 @@ func NewDeleteRoleNoContent() *DeleteRoleNoContent { return &DeleteRoleNoContent{} } -/*DeleteRoleNoContent handles this case with default header values. +/* +DeleteRoleNoContent describes a response with status code 204, with default header values. Organization role has been deleted. */ type DeleteRoleNoContent struct { } +// IsSuccess returns true when this delete role no content response has a 2xx status code +func (o *DeleteRoleNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete role no content response has a 3xx status code +func (o *DeleteRoleNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete role no content response has a 4xx status code +func (o *DeleteRoleNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete role no content response has a 5xx status code +func (o *DeleteRoleNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete role no content response a status code equal to that given +func (o *DeleteRoleNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete role no content response +func (o *DeleteRoleNoContent) Code() int { + return 204 +} + func (o *DeleteRoleNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleNoContent", 204) +} + +func (o *DeleteRoleNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleNoContent", 204) } func (o *DeleteRoleNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteRoleForbidden() *DeleteRoleForbidden { return &DeleteRoleForbidden{} } -/*DeleteRoleForbidden handles this case with default header values. +/* +DeleteRoleForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteRoleForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete role forbidden response has a 2xx status code +func (o *DeleteRoleForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete role forbidden response has a 3xx status code +func (o *DeleteRoleForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete role forbidden response has a 4xx status code +func (o *DeleteRoleForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete role forbidden response has a 5xx status code +func (o *DeleteRoleForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete role forbidden response a status code equal to that given +func (o *DeleteRoleForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete role forbidden response +func (o *DeleteRoleForbidden) Code() int { + return 403 +} + func (o *DeleteRoleForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleForbidden %s", 403, payload) +} + +func (o *DeleteRoleForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleForbidden %s", 403, payload) } func (o *DeleteRoleForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteRoleForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteRoleForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteRoleNotFound() *DeleteRoleNotFound { return &DeleteRoleNotFound{} } -/*DeleteRoleNotFound handles this case with default header values. +/* +DeleteRoleNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteRoleNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete role not found response has a 2xx status code +func (o *DeleteRoleNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete role not found response has a 3xx status code +func (o *DeleteRoleNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete role not found response has a 4xx status code +func (o *DeleteRoleNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete role not found response has a 5xx status code +func (o *DeleteRoleNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete role not found response a status code equal to that given +func (o *DeleteRoleNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete role not found response +func (o *DeleteRoleNotFound) Code() int { + return 404 +} + func (o *DeleteRoleNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleNotFound %s", 404, payload) +} + +func (o *DeleteRoleNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRoleNotFound %s", 404, payload) } func (o *DeleteRoleNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteRoleNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteRoleNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteRoleDefault(code int) *DeleteRoleDefault { } } -/*DeleteRoleDefault handles this case with default header values. +/* +DeleteRoleDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteRoleDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete role default response has a 2xx status code +func (o *DeleteRoleDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete role default response has a 3xx status code +func (o *DeleteRoleDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete role default response has a 4xx status code +func (o *DeleteRoleDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete role default response has a 5xx status code +func (o *DeleteRoleDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete role default response a status code equal to that given +func (o *DeleteRoleDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete role default response func (o *DeleteRoleDefault) Code() int { return o._statusCode } func (o *DeleteRoleDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRole default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRole default %s", o._statusCode, payload) +} + +func (o *DeleteRoleDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/roles/{role_canonical}][%d] deleteRole default %s", o._statusCode, payload) } func (o *DeleteRoleDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteRoleDefault) GetPayload() *models.ErrorPayload { func (o *DeleteRoleDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_roles/get_role_parameters.go b/client/client/organization_roles/get_role_parameters.go index ec7f9c9a..ece7ce11 100644 --- a/client/client/organization_roles/get_role_parameters.go +++ b/client/client/organization_roles/get_role_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetRoleParams creates a new GetRoleParams object -// with the default values initialized. +// NewGetRoleParams creates a new GetRoleParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetRoleParams() *GetRoleParams { - var () return &GetRoleParams{ - timeout: cr.DefaultTimeout, } } // NewGetRoleParamsWithTimeout creates a new GetRoleParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetRoleParamsWithTimeout(timeout time.Duration) *GetRoleParams { - var () return &GetRoleParams{ - timeout: timeout, } } // NewGetRoleParamsWithContext creates a new GetRoleParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetRoleParamsWithContext(ctx context.Context) *GetRoleParams { - var () return &GetRoleParams{ - Context: ctx, } } // NewGetRoleParamsWithHTTPClient creates a new GetRoleParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetRoleParamsWithHTTPClient(client *http.Client) *GetRoleParams { - var () return &GetRoleParams{ HTTPClient: client, } } -/*GetRoleParams contains all the parameters to send to the API endpoint -for the get role operation typically these are written to a http.Request +/* +GetRoleParams contains all the parameters to send to the API endpoint + + for the get role operation. + + Typically these are written to a http.Request. */ type GetRoleParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*RoleCanonical - Organization Role canonical + /* RoleCanonical. + + Organization Role canonical */ RoleCanonical string @@ -77,6 +78,21 @@ type GetRoleParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get role params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetRoleParams) WithDefaults() *GetRoleParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get role params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetRoleParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get role params func (o *GetRoleParams) WithTimeout(timeout time.Duration) *GetRoleParams { o.SetTimeout(timeout) diff --git a/client/client/organization_roles/get_role_responses.go b/client/client/organization_roles/get_role_responses.go index 812fae00..93da9237 100644 --- a/client/client/organization_roles/get_role_responses.go +++ b/client/client/organization_roles/get_role_responses.go @@ -6,17 +6,18 @@ package organization_roles // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetRoleReader is a Reader for the GetRole structure. @@ -62,7 +63,8 @@ func NewGetRoleOK() *GetRoleOK { return &GetRoleOK{} } -/*GetRoleOK handles this case with default header values. +/* +GetRoleOK describes a response with status code 200, with default header values. Role available in the organization with such canonical. */ @@ -70,8 +72,44 @@ type GetRoleOK struct { Payload *GetRoleOKBody } +// IsSuccess returns true when this get role o k response has a 2xx status code +func (o *GetRoleOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get role o k response has a 3xx status code +func (o *GetRoleOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get role o k response has a 4xx status code +func (o *GetRoleOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get role o k response has a 5xx status code +func (o *GetRoleOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get role o k response a status code equal to that given +func (o *GetRoleOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get role o k response +func (o *GetRoleOK) Code() int { + return 200 +} + func (o *GetRoleOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleOK %s", 200, payload) +} + +func (o *GetRoleOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleOK %s", 200, payload) } func (o *GetRoleOK) GetPayload() *GetRoleOKBody { @@ -95,20 +133,60 @@ func NewGetRoleForbidden() *GetRoleForbidden { return &GetRoleForbidden{} } -/*GetRoleForbidden handles this case with default header values. +/* +GetRoleForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetRoleForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get role forbidden response has a 2xx status code +func (o *GetRoleForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get role forbidden response has a 3xx status code +func (o *GetRoleForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get role forbidden response has a 4xx status code +func (o *GetRoleForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get role forbidden response has a 5xx status code +func (o *GetRoleForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get role forbidden response a status code equal to that given +func (o *GetRoleForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get role forbidden response +func (o *GetRoleForbidden) Code() int { + return 403 +} + func (o *GetRoleForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleForbidden %s", 403, payload) +} + +func (o *GetRoleForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleForbidden %s", 403, payload) } func (o *GetRoleForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetRoleForbidden) GetPayload() *models.ErrorPayload { func (o *GetRoleForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetRoleNotFound() *GetRoleNotFound { return &GetRoleNotFound{} } -/*GetRoleNotFound handles this case with default header values. +/* +GetRoleNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetRoleNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get role not found response has a 2xx status code +func (o *GetRoleNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get role not found response has a 3xx status code +func (o *GetRoleNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get role not found response has a 4xx status code +func (o *GetRoleNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get role not found response has a 5xx status code +func (o *GetRoleNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get role not found response a status code equal to that given +func (o *GetRoleNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get role not found response +func (o *GetRoleNotFound) Code() int { + return 404 +} + func (o *GetRoleNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleNotFound %s", 404, payload) +} + +func (o *GetRoleNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRoleNotFound %s", 404, payload) } func (o *GetRoleNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetRoleNotFound) GetPayload() *models.ErrorPayload { func (o *GetRoleNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetRoleDefault(code int) *GetRoleDefault { } } -/*GetRoleDefault handles this case with default header values. +/* +GetRoleDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetRoleDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get role default response has a 2xx status code +func (o *GetRoleDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get role default response has a 3xx status code +func (o *GetRoleDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get role default response has a 4xx status code +func (o *GetRoleDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get role default response has a 5xx status code +func (o *GetRoleDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get role default response a status code equal to that given +func (o *GetRoleDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get role default response func (o *GetRoleDefault) Code() int { return o._statusCode } func (o *GetRoleDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRole default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRole default %s", o._statusCode, payload) +} + +func (o *GetRoleDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles/{role_canonical}][%d] getRole default %s", o._statusCode, payload) } func (o *GetRoleDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetRoleDefault) GetPayload() *models.ErrorPayload { func (o *GetRoleDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetRoleDefault) readResponse(response runtime.ClientResponse, consumer return nil } -/*GetRoleOKBody get role o k body +/* +GetRoleOKBody get role o k body swagger:model GetRoleOKBody */ type GetRoleOKBody struct { @@ -265,6 +430,39 @@ func (o *GetRoleOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getRoleOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getRoleOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get role o k body based on the context it is used +func (o *GetRoleOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetRoleOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getRoleOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getRoleOK" + "." + "data") } return err } diff --git a/client/client/organization_roles/get_roles_parameters.go b/client/client/organization_roles/get_roles_parameters.go index ba315e20..bf05156a 100644 --- a/client/client/organization_roles/get_roles_parameters.go +++ b/client/client/organization_roles/get_roles_parameters.go @@ -13,88 +13,76 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetRolesParams creates a new GetRolesParams object -// with the default values initialized. +// NewGetRolesParams creates a new GetRolesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetRolesParams() *GetRolesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetRolesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetRolesParamsWithTimeout creates a new GetRolesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetRolesParamsWithTimeout(timeout time.Duration) *GetRolesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetRolesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetRolesParamsWithContext creates a new GetRolesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetRolesParamsWithContext(ctx context.Context) *GetRolesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetRolesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetRolesParamsWithHTTPClient creates a new GetRolesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetRolesParamsWithHTTPClient(client *http.Client) *GetRolesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetRolesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetRolesParams contains all the parameters to send to the API endpoint -for the get roles operation typically these are written to a http.Request +/* +GetRolesParams contains all the parameters to send to the API endpoint + + for the get roles operation. + + Typically these are written to a http.Request. */ type GetRolesParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -103,6 +91,35 @@ type GetRolesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get roles params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetRolesParams) WithDefaults() *GetRolesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get roles params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetRolesParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetRolesParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get roles params func (o *GetRolesParams) WithTimeout(timeout time.Duration) *GetRolesParams { o.SetTimeout(timeout) @@ -186,32 +203,34 @@ func (o *GetRolesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regi // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_roles/get_roles_responses.go b/client/client/organization_roles/get_roles_responses.go index e4012387..558bf332 100644 --- a/client/client/organization_roles/get_roles_responses.go +++ b/client/client/organization_roles/get_roles_responses.go @@ -6,18 +6,19 @@ package organization_roles // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetRolesReader is a Reader for the GetRoles structure. @@ -63,7 +64,8 @@ func NewGetRolesOK() *GetRolesOK { return &GetRolesOK{} } -/*GetRolesOK handles this case with default header values. +/* +GetRolesOK describes a response with status code 200, with default header values. List of roles which are available in the organization. */ @@ -71,8 +73,44 @@ type GetRolesOK struct { Payload *GetRolesOKBody } +// IsSuccess returns true when this get roles o k response has a 2xx status code +func (o *GetRolesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get roles o k response has a 3xx status code +func (o *GetRolesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get roles o k response has a 4xx status code +func (o *GetRolesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get roles o k response has a 5xx status code +func (o *GetRolesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get roles o k response a status code equal to that given +func (o *GetRolesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get roles o k response +func (o *GetRolesOK) Code() int { + return 200 +} + func (o *GetRolesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesOK %s", 200, payload) +} + +func (o *GetRolesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesOK %s", 200, payload) } func (o *GetRolesOK) GetPayload() *GetRolesOKBody { @@ -96,20 +134,60 @@ func NewGetRolesForbidden() *GetRolesForbidden { return &GetRolesForbidden{} } -/*GetRolesForbidden handles this case with default header values. +/* +GetRolesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetRolesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get roles forbidden response has a 2xx status code +func (o *GetRolesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get roles forbidden response has a 3xx status code +func (o *GetRolesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get roles forbidden response has a 4xx status code +func (o *GetRolesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get roles forbidden response has a 5xx status code +func (o *GetRolesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get roles forbidden response a status code equal to that given +func (o *GetRolesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get roles forbidden response +func (o *GetRolesForbidden) Code() int { + return 403 +} + func (o *GetRolesForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesForbidden %s", 403, payload) +} + +func (o *GetRolesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesForbidden %s", 403, payload) } func (o *GetRolesForbidden) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *GetRolesForbidden) GetPayload() *models.ErrorPayload { func (o *GetRolesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewGetRolesNotFound() *GetRolesNotFound { return &GetRolesNotFound{} } -/*GetRolesNotFound handles this case with default header values. +/* +GetRolesNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetRolesNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get roles not found response has a 2xx status code +func (o *GetRolesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get roles not found response has a 3xx status code +func (o *GetRolesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get roles not found response has a 4xx status code +func (o *GetRolesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get roles not found response has a 5xx status code +func (o *GetRolesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get roles not found response a status code equal to that given +func (o *GetRolesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get roles not found response +func (o *GetRolesNotFound) Code() int { + return 404 +} + func (o *GetRolesNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesNotFound %s", 404, payload) +} + +func (o *GetRolesNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRolesNotFound %s", 404, payload) } func (o *GetRolesNotFound) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *GetRolesNotFound) GetPayload() *models.ErrorPayload { func (o *GetRolesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewGetRolesDefault(code int) *GetRolesDefault { } } -/*GetRolesDefault handles this case with default header values. +/* +GetRolesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetRolesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get roles default response has a 2xx status code +func (o *GetRolesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get roles default response has a 3xx status code +func (o *GetRolesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get roles default response has a 4xx status code +func (o *GetRolesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get roles default response has a 5xx status code +func (o *GetRolesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get roles default response a status code equal to that given +func (o *GetRolesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get roles default response func (o *GetRolesDefault) Code() int { return o._statusCode } func (o *GetRolesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRoles default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRoles default %s", o._statusCode, payload) +} + +func (o *GetRolesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/roles][%d] getRoles default %s", o._statusCode, payload) } func (o *GetRolesDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *GetRolesDefault) GetPayload() *models.ErrorPayload { func (o *GetRolesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *GetRolesDefault) readResponse(response runtime.ClientResponse, consumer return nil } -/*GetRolesOKBody get roles o k body +/* +GetRolesOKBody get roles o k body swagger:model GetRolesOKBody */ type GetRolesOKBody struct { @@ -279,6 +444,8 @@ func (o *GetRolesOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getRolesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getRolesOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -299,6 +466,68 @@ func (o *GetRolesOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getRolesOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getRolesOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get roles o k body based on the context it is used +func (o *GetRolesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetRolesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getRolesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getRolesOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetRolesOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getRolesOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getRolesOK" + "." + "pagination") } return err } diff --git a/client/client/organization_roles/organization_roles_client.go b/client/client/organization_roles/organization_roles_client.go index b3a9640a..496e4541 100644 --- a/client/client/organization_roles/organization_roles_client.go +++ b/client/client/organization_roles/organization_roles_client.go @@ -7,15 +7,40 @@ package organization_roles import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization roles API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization roles API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization roles API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization roles API */ @@ -24,16 +49,82 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateRole(params *CreateRoleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRoleOK, error) + + DeleteRole(params *DeleteRoleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteRoleNoContent, error) + + GetRole(params *GetRoleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRoleOK, error) + + GetRoles(params *GetRolesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRolesOK, error) + + UpdateRole(params *UpdateRoleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateRoleOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateRole Create a new role available in the organization. */ -func (a *Client) CreateRole(params *CreateRoleParams, authInfo runtime.ClientAuthInfoWriter) (*CreateRoleOK, error) { +func (a *Client) CreateRole(params *CreateRoleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRoleOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateRoleParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createRole", Method: "POST", PathPattern: "/organizations/{organization_canonical}/roles", @@ -45,7 +136,12 @@ func (a *Client) CreateRole(params *CreateRoleParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +157,12 @@ func (a *Client) CreateRole(params *CreateRoleParams, authInfo runtime.ClientAut /* DeleteRole Delete an existing role in the organization. */ -func (a *Client) DeleteRole(params *DeleteRoleParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteRoleNoContent, error) { +func (a *Client) DeleteRole(params *DeleteRoleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteRoleNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteRoleParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteRole", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/roles/{role_canonical}", @@ -79,7 +174,12 @@ func (a *Client) DeleteRole(params *DeleteRoleParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +195,12 @@ func (a *Client) DeleteRole(params *DeleteRoleParams, authInfo runtime.ClientAut /* GetRole Get the role available in the organization with an canonical */ -func (a *Client) GetRole(params *GetRoleParams, authInfo runtime.ClientAuthInfoWriter) (*GetRoleOK, error) { +func (a *Client) GetRole(params *GetRoleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRoleOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetRoleParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getRole", Method: "GET", PathPattern: "/organizations/{organization_canonical}/roles/{role_canonical}", @@ -113,7 +212,12 @@ func (a *Client) GetRole(params *GetRoleParams, authInfo runtime.ClientAuthInfoW AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +233,12 @@ func (a *Client) GetRole(params *GetRoleParams, authInfo runtime.ClientAuthInfoW /* GetRoles Get the list of roles available in the organization. */ -func (a *Client) GetRoles(params *GetRolesParams, authInfo runtime.ClientAuthInfoWriter) (*GetRolesOK, error) { +func (a *Client) GetRoles(params *GetRolesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRolesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetRolesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getRoles", Method: "GET", PathPattern: "/organizations/{organization_canonical}/roles", @@ -147,7 +250,12 @@ func (a *Client) GetRoles(params *GetRolesParams, authInfo runtime.ClientAuthInf AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +271,12 @@ func (a *Client) GetRoles(params *GetRolesParams, authInfo runtime.ClientAuthInf /* UpdateRole Update an existing role in the organization. */ -func (a *Client) UpdateRole(params *UpdateRoleParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateRoleOK, error) { +func (a *Client) UpdateRole(params *UpdateRoleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateRoleOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateRoleParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateRole", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/roles/{role_canonical}", @@ -181,7 +288,12 @@ func (a *Client) UpdateRole(params *UpdateRoleParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_roles/update_role_parameters.go b/client/client/organization_roles/update_role_parameters.go index 056a940e..1edce4ae 100644 --- a/client/client/organization_roles/update_role_parameters.go +++ b/client/client/organization_roles/update_role_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateRoleParams creates a new UpdateRoleParams object -// with the default values initialized. +// NewUpdateRoleParams creates a new UpdateRoleParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateRoleParams() *UpdateRoleParams { - var () return &UpdateRoleParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateRoleParamsWithTimeout creates a new UpdateRoleParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateRoleParamsWithTimeout(timeout time.Duration) *UpdateRoleParams { - var () return &UpdateRoleParams{ - timeout: timeout, } } // NewUpdateRoleParamsWithContext creates a new UpdateRoleParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateRoleParamsWithContext(ctx context.Context) *UpdateRoleParams { - var () return &UpdateRoleParams{ - Context: ctx, } } // NewUpdateRoleParamsWithHTTPClient creates a new UpdateRoleParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateRoleParamsWithHTTPClient(client *http.Client) *UpdateRoleParams { - var () return &UpdateRoleParams{ HTTPClient: client, } } -/*UpdateRoleParams contains all the parameters to send to the API endpoint -for the update role operation typically these are written to a http.Request +/* +UpdateRoleParams contains all the parameters to send to the API endpoint + + for the update role operation. + + Typically these are written to a http.Request. */ type UpdateRoleParams struct { - /*Body - The information of the organization's role to update. + /* Body. + The information of the organization's role to update. */ Body *models.NewRole - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*RoleCanonical - Organization Role canonical + /* RoleCanonical. + + Organization Role canonical */ RoleCanonical string @@ -84,6 +86,21 @@ type UpdateRoleParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update role params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateRoleParams) WithDefaults() *UpdateRoleParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update role params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateRoleParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update role params func (o *UpdateRoleParams) WithTimeout(timeout time.Duration) *UpdateRoleParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateRoleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_roles/update_role_responses.go b/client/client/organization_roles/update_role_responses.go index 8bde0a02..621cc6be 100644 --- a/client/client/organization_roles/update_role_responses.go +++ b/client/client/organization_roles/update_role_responses.go @@ -6,17 +6,18 @@ package organization_roles // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateRoleReader is a Reader for the UpdateRole structure. @@ -68,7 +69,8 @@ func NewUpdateRoleOK() *UpdateRoleOK { return &UpdateRoleOK{} } -/*UpdateRoleOK handles this case with default header values. +/* +UpdateRoleOK describes a response with status code 200, with default header values. Updated role belonging to the organization. */ @@ -76,8 +78,44 @@ type UpdateRoleOK struct { Payload *UpdateRoleOKBody } +// IsSuccess returns true when this update role o k response has a 2xx status code +func (o *UpdateRoleOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update role o k response has a 3xx status code +func (o *UpdateRoleOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update role o k response has a 4xx status code +func (o *UpdateRoleOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update role o k response has a 5xx status code +func (o *UpdateRoleOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update role o k response a status code equal to that given +func (o *UpdateRoleOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update role o k response +func (o *UpdateRoleOK) Code() int { + return 200 +} + func (o *UpdateRoleOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleOK %s", 200, payload) +} + +func (o *UpdateRoleOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleOK %s", 200, payload) } func (o *UpdateRoleOK) GetPayload() *UpdateRoleOKBody { @@ -101,20 +139,60 @@ func NewUpdateRoleForbidden() *UpdateRoleForbidden { return &UpdateRoleForbidden{} } -/*UpdateRoleForbidden handles this case with default header values. +/* +UpdateRoleForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateRoleForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update role forbidden response has a 2xx status code +func (o *UpdateRoleForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update role forbidden response has a 3xx status code +func (o *UpdateRoleForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update role forbidden response has a 4xx status code +func (o *UpdateRoleForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update role forbidden response has a 5xx status code +func (o *UpdateRoleForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update role forbidden response a status code equal to that given +func (o *UpdateRoleForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update role forbidden response +func (o *UpdateRoleForbidden) Code() int { + return 403 +} + func (o *UpdateRoleForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleForbidden %s", 403, payload) +} + +func (o *UpdateRoleForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleForbidden %s", 403, payload) } func (o *UpdateRoleForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *UpdateRoleForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateRoleForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewUpdateRoleNotFound() *UpdateRoleNotFound { return &UpdateRoleNotFound{} } -/*UpdateRoleNotFound handles this case with default header values. +/* +UpdateRoleNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateRoleNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update role not found response has a 2xx status code +func (o *UpdateRoleNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update role not found response has a 3xx status code +func (o *UpdateRoleNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update role not found response has a 4xx status code +func (o *UpdateRoleNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update role not found response has a 5xx status code +func (o *UpdateRoleNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update role not found response a status code equal to that given +func (o *UpdateRoleNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update role not found response +func (o *UpdateRoleNotFound) Code() int { + return 404 +} + func (o *UpdateRoleNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleNotFound %s", 404, payload) +} + +func (o *UpdateRoleNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleNotFound %s", 404, payload) } func (o *UpdateRoleNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *UpdateRoleNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateRoleNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewUpdateRoleUnprocessableEntity() *UpdateRoleUnprocessableEntity { return &UpdateRoleUnprocessableEntity{} } -/*UpdateRoleUnprocessableEntity handles this case with default header values. +/* +UpdateRoleUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateRoleUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update role unprocessable entity response has a 2xx status code +func (o *UpdateRoleUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update role unprocessable entity response has a 3xx status code +func (o *UpdateRoleUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update role unprocessable entity response has a 4xx status code +func (o *UpdateRoleUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update role unprocessable entity response has a 5xx status code +func (o *UpdateRoleUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update role unprocessable entity response a status code equal to that given +func (o *UpdateRoleUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update role unprocessable entity response +func (o *UpdateRoleUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateRoleUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateRoleUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRoleUnprocessableEntity %s", 422, payload) } func (o *UpdateRoleUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *UpdateRoleUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *UpdateRoleUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewUpdateRoleDefault(code int) *UpdateRoleDefault { } } -/*UpdateRoleDefault handles this case with default header values. +/* +UpdateRoleDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateRoleDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update role default response has a 2xx status code +func (o *UpdateRoleDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update role default response has a 3xx status code +func (o *UpdateRoleDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update role default response has a 4xx status code +func (o *UpdateRoleDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update role default response has a 5xx status code +func (o *UpdateRoleDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update role default response a status code equal to that given +func (o *UpdateRoleDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update role default response func (o *UpdateRoleDefault) Code() int { return o._statusCode } func (o *UpdateRoleDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRole default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRole default %s", o._statusCode, payload) +} + +func (o *UpdateRoleDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/roles/{role_canonical}][%d] updateRole default %s", o._statusCode, payload) } func (o *UpdateRoleDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *UpdateRoleDefault) GetPayload() *models.ErrorPayload { func (o *UpdateRoleDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *UpdateRoleDefault) readResponse(response runtime.ClientResponse, consum return nil } -/*UpdateRoleOKBody update role o k body +/* +UpdateRoleOKBody update role o k body swagger:model UpdateRoleOKBody */ type UpdateRoleOKBody struct { @@ -315,6 +524,39 @@ func (o *UpdateRoleOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateRoleOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateRoleOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update role o k body based on the context it is used +func (o *UpdateRoleOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateRoleOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateRoleOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateRoleOK" + "." + "data") } return err } diff --git a/client/client/organization_service_catalog_sources/create_service_catalog_source_parameters.go b/client/client/organization_service_catalog_sources/create_service_catalog_source_parameters.go index c744b19f..051ddbd8 100644 --- a/client/client/organization_service_catalog_sources/create_service_catalog_source_parameters.go +++ b/client/client/organization_service_catalog_sources/create_service_catalog_source_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateServiceCatalogSourceParams creates a new CreateServiceCatalogSourceParams object -// with the default values initialized. +// NewCreateServiceCatalogSourceParams creates a new CreateServiceCatalogSourceParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateServiceCatalogSourceParams() *CreateServiceCatalogSourceParams { - var () return &CreateServiceCatalogSourceParams{ - timeout: cr.DefaultTimeout, } } // NewCreateServiceCatalogSourceParamsWithTimeout creates a new CreateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateServiceCatalogSourceParamsWithTimeout(timeout time.Duration) *CreateServiceCatalogSourceParams { - var () return &CreateServiceCatalogSourceParams{ - timeout: timeout, } } // NewCreateServiceCatalogSourceParamsWithContext creates a new CreateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateServiceCatalogSourceParamsWithContext(ctx context.Context) *CreateServiceCatalogSourceParams { - var () return &CreateServiceCatalogSourceParams{ - Context: ctx, } } // NewCreateServiceCatalogSourceParamsWithHTTPClient creates a new CreateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateServiceCatalogSourceParamsWithHTTPClient(client *http.Client) *CreateServiceCatalogSourceParams { - var () return &CreateServiceCatalogSourceParams{ HTTPClient: client, } } -/*CreateServiceCatalogSourceParams contains all the parameters to send to the API endpoint -for the create service catalog source operation typically these are written to a http.Request +/* +CreateServiceCatalogSourceParams contains all the parameters to send to the API endpoint + + for the create service catalog source operation. + + Typically these are written to a http.Request. */ type CreateServiceCatalogSourceParams struct { - /*Body - The information of the organization to create. + /* Body. + The information of the organization to create. */ Body *models.NewServiceCatalogSource - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type CreateServiceCatalogSourceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateServiceCatalogSourceParams) WithDefaults() *CreateServiceCatalogSourceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateServiceCatalogSourceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create service catalog source params func (o *CreateServiceCatalogSourceParams) WithTimeout(timeout time.Duration) *CreateServiceCatalogSourceParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CreateServiceCatalogSourceParams) WriteToRequest(r runtime.ClientReques return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_service_catalog_sources/create_service_catalog_source_responses.go b/client/client/organization_service_catalog_sources/create_service_catalog_source_responses.go index 8219b171..02397ff3 100644 --- a/client/client/organization_service_catalog_sources/create_service_catalog_source_responses.go +++ b/client/client/organization_service_catalog_sources/create_service_catalog_source_responses.go @@ -6,17 +6,18 @@ package organization_service_catalog_sources // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateServiceCatalogSourceReader is a Reader for the CreateServiceCatalogSource structure. @@ -68,7 +69,8 @@ func NewCreateServiceCatalogSourceOK() *CreateServiceCatalogSourceOK { return &CreateServiceCatalogSourceOK{} } -/*CreateServiceCatalogSourceOK handles this case with default header values. +/* +CreateServiceCatalogSourceOK describes a response with status code 200, with default header values. Success creation */ @@ -76,8 +78,44 @@ type CreateServiceCatalogSourceOK struct { Payload *CreateServiceCatalogSourceOKBody } +// IsSuccess returns true when this create service catalog source o k response has a 2xx status code +func (o *CreateServiceCatalogSourceOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create service catalog source o k response has a 3xx status code +func (o *CreateServiceCatalogSourceOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog source o k response has a 4xx status code +func (o *CreateServiceCatalogSourceOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create service catalog source o k response has a 5xx status code +func (o *CreateServiceCatalogSourceOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog source o k response a status code equal to that given +func (o *CreateServiceCatalogSourceOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create service catalog source o k response +func (o *CreateServiceCatalogSourceOK) Code() int { + return 200 +} + func (o *CreateServiceCatalogSourceOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceOK %s", 200, payload) +} + +func (o *CreateServiceCatalogSourceOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceOK %s", 200, payload) } func (o *CreateServiceCatalogSourceOK) GetPayload() *CreateServiceCatalogSourceOKBody { @@ -101,20 +139,60 @@ func NewCreateServiceCatalogSourceNotFound() *CreateServiceCatalogSourceNotFound return &CreateServiceCatalogSourceNotFound{} } -/*CreateServiceCatalogSourceNotFound handles this case with default header values. +/* +CreateServiceCatalogSourceNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateServiceCatalogSourceNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog source not found response has a 2xx status code +func (o *CreateServiceCatalogSourceNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog source not found response has a 3xx status code +func (o *CreateServiceCatalogSourceNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog source not found response has a 4xx status code +func (o *CreateServiceCatalogSourceNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog source not found response has a 5xx status code +func (o *CreateServiceCatalogSourceNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog source not found response a status code equal to that given +func (o *CreateServiceCatalogSourceNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create service catalog source not found response +func (o *CreateServiceCatalogSourceNotFound) Code() int { + return 404 +} + func (o *CreateServiceCatalogSourceNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceNotFound %s", 404, payload) +} + +func (o *CreateServiceCatalogSourceNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceNotFound %s", 404, payload) } func (o *CreateServiceCatalogSourceNotFound) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *CreateServiceCatalogSourceNotFound) GetPayload() *models.ErrorPayload { func (o *CreateServiceCatalogSourceNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,15 +227,50 @@ func NewCreateServiceCatalogSourceLengthRequired() *CreateServiceCatalogSourceLe return &CreateServiceCatalogSourceLengthRequired{} } -/*CreateServiceCatalogSourceLengthRequired handles this case with default header values. +/* +CreateServiceCatalogSourceLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreateServiceCatalogSourceLengthRequired struct { } +// IsSuccess returns true when this create service catalog source length required response has a 2xx status code +func (o *CreateServiceCatalogSourceLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog source length required response has a 3xx status code +func (o *CreateServiceCatalogSourceLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog source length required response has a 4xx status code +func (o *CreateServiceCatalogSourceLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog source length required response has a 5xx status code +func (o *CreateServiceCatalogSourceLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog source length required response a status code equal to that given +func (o *CreateServiceCatalogSourceLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create service catalog source length required response +func (o *CreateServiceCatalogSourceLengthRequired) Code() int { + return 411 +} + func (o *CreateServiceCatalogSourceLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceLengthRequired", 411) +} + +func (o *CreateServiceCatalogSourceLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceLengthRequired", 411) } func (o *CreateServiceCatalogSourceLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -166,20 +283,60 @@ func NewCreateServiceCatalogSourceUnprocessableEntity() *CreateServiceCatalogSou return &CreateServiceCatalogSourceUnprocessableEntity{} } -/*CreateServiceCatalogSourceUnprocessableEntity handles this case with default header values. +/* +CreateServiceCatalogSourceUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateServiceCatalogSourceUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog source unprocessable entity response has a 2xx status code +func (o *CreateServiceCatalogSourceUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog source unprocessable entity response has a 3xx status code +func (o *CreateServiceCatalogSourceUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog source unprocessable entity response has a 4xx status code +func (o *CreateServiceCatalogSourceUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog source unprocessable entity response has a 5xx status code +func (o *CreateServiceCatalogSourceUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog source unprocessable entity response a status code equal to that given +func (o *CreateServiceCatalogSourceUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create service catalog source unprocessable entity response +func (o *CreateServiceCatalogSourceUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateServiceCatalogSourceUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceUnprocessableEntity %s", 422, payload) +} + +func (o *CreateServiceCatalogSourceUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSourceUnprocessableEntity %s", 422, payload) } func (o *CreateServiceCatalogSourceUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -188,12 +345,16 @@ func (o *CreateServiceCatalogSourceUnprocessableEntity) GetPayload() *models.Err func (o *CreateServiceCatalogSourceUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -212,27 +373,61 @@ func NewCreateServiceCatalogSourceDefault(code int) *CreateServiceCatalogSourceD } } -/*CreateServiceCatalogSourceDefault handles this case with default header values. +/* +CreateServiceCatalogSourceDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateServiceCatalogSourceDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog source default response has a 2xx status code +func (o *CreateServiceCatalogSourceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create service catalog source default response has a 3xx status code +func (o *CreateServiceCatalogSourceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create service catalog source default response has a 4xx status code +func (o *CreateServiceCatalogSourceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create service catalog source default response has a 5xx status code +func (o *CreateServiceCatalogSourceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create service catalog source default response a status code equal to that given +func (o *CreateServiceCatalogSourceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create service catalog source default response func (o *CreateServiceCatalogSourceDefault) Code() int { return o._statusCode } func (o *CreateServiceCatalogSourceDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSource default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSource default %s", o._statusCode, payload) +} + +func (o *CreateServiceCatalogSourceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources][%d] createServiceCatalogSource default %s", o._statusCode, payload) } func (o *CreateServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { @@ -241,12 +436,16 @@ func (o *CreateServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { func (o *CreateServiceCatalogSourceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -258,7 +457,8 @@ func (o *CreateServiceCatalogSourceDefault) readResponse(response runtime.Client return nil } -/*CreateServiceCatalogSourceOKBody create service catalog source o k body +/* +CreateServiceCatalogSourceOKBody create service catalog source o k body swagger:model CreateServiceCatalogSourceOKBody */ type CreateServiceCatalogSourceOKBody struct { @@ -292,6 +492,39 @@ func (o *CreateServiceCatalogSourceOKBody) validateData(formats strfmt.Registry) if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createServiceCatalogSourceOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createServiceCatalogSourceOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create service catalog source o k body based on the context it is used +func (o *CreateServiceCatalogSourceOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateServiceCatalogSourceOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createServiceCatalogSourceOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createServiceCatalogSourceOK" + "." + "data") } return err } diff --git a/client/client/organization_service_catalog_sources/delete_service_catalog_source_parameters.go b/client/client/organization_service_catalog_sources/delete_service_catalog_source_parameters.go index 289ecb3a..e10a31ad 100644 --- a/client/client/organization_service_catalog_sources/delete_service_catalog_source_parameters.go +++ b/client/client/organization_service_catalog_sources/delete_service_catalog_source_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteServiceCatalogSourceParams creates a new DeleteServiceCatalogSourceParams object -// with the default values initialized. +// NewDeleteServiceCatalogSourceParams creates a new DeleteServiceCatalogSourceParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteServiceCatalogSourceParams() *DeleteServiceCatalogSourceParams { - var () return &DeleteServiceCatalogSourceParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteServiceCatalogSourceParamsWithTimeout creates a new DeleteServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteServiceCatalogSourceParamsWithTimeout(timeout time.Duration) *DeleteServiceCatalogSourceParams { - var () return &DeleteServiceCatalogSourceParams{ - timeout: timeout, } } // NewDeleteServiceCatalogSourceParamsWithContext creates a new DeleteServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteServiceCatalogSourceParamsWithContext(ctx context.Context) *DeleteServiceCatalogSourceParams { - var () return &DeleteServiceCatalogSourceParams{ - Context: ctx, } } // NewDeleteServiceCatalogSourceParamsWithHTTPClient creates a new DeleteServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteServiceCatalogSourceParamsWithHTTPClient(client *http.Client) *DeleteServiceCatalogSourceParams { - var () return &DeleteServiceCatalogSourceParams{ HTTPClient: client, } } -/*DeleteServiceCatalogSourceParams contains all the parameters to send to the API endpoint -for the delete service catalog source operation typically these are written to a http.Request +/* +DeleteServiceCatalogSourceParams contains all the parameters to send to the API endpoint + + for the delete service catalog source operation. + + Typically these are written to a http.Request. */ type DeleteServiceCatalogSourceParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogSourceCanonical - Organization Service Catalog Sources canonical + /* ServiceCatalogSourceCanonical. + + Organization Service Catalog Sources canonical */ ServiceCatalogSourceCanonical string @@ -77,6 +78,21 @@ type DeleteServiceCatalogSourceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteServiceCatalogSourceParams) WithDefaults() *DeleteServiceCatalogSourceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteServiceCatalogSourceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete service catalog source params func (o *DeleteServiceCatalogSourceParams) WithTimeout(timeout time.Duration) *DeleteServiceCatalogSourceParams { o.SetTimeout(timeout) diff --git a/client/client/organization_service_catalog_sources/delete_service_catalog_source_responses.go b/client/client/organization_service_catalog_sources/delete_service_catalog_source_responses.go index c59e5749..e74fd776 100644 --- a/client/client/organization_service_catalog_sources/delete_service_catalog_source_responses.go +++ b/client/client/organization_service_catalog_sources/delete_service_catalog_source_responses.go @@ -6,16 +6,16 @@ package organization_service_catalog_sources // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteServiceCatalogSourceReader is a Reader for the DeleteServiceCatalogSource structure. @@ -49,15 +49,50 @@ func NewDeleteServiceCatalogSourceNoContent() *DeleteServiceCatalogSourceNoConte return &DeleteServiceCatalogSourceNoContent{} } -/*DeleteServiceCatalogSourceNoContent handles this case with default header values. +/* +DeleteServiceCatalogSourceNoContent describes a response with status code 204, with default header values. Organization Service Catalog Sources has been deleted */ type DeleteServiceCatalogSourceNoContent struct { } +// IsSuccess returns true when this delete service catalog source no content response has a 2xx status code +func (o *DeleteServiceCatalogSourceNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete service catalog source no content response has a 3xx status code +func (o *DeleteServiceCatalogSourceNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete service catalog source no content response has a 4xx status code +func (o *DeleteServiceCatalogSourceNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete service catalog source no content response has a 5xx status code +func (o *DeleteServiceCatalogSourceNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete service catalog source no content response a status code equal to that given +func (o *DeleteServiceCatalogSourceNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete service catalog source no content response +func (o *DeleteServiceCatalogSourceNoContent) Code() int { + return 204 +} + func (o *DeleteServiceCatalogSourceNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] deleteServiceCatalogSourceNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] deleteServiceCatalogSourceNoContent", 204) +} + +func (o *DeleteServiceCatalogSourceNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] deleteServiceCatalogSourceNoContent", 204) } func (o *DeleteServiceCatalogSourceNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -72,27 +107,61 @@ func NewDeleteServiceCatalogSourceDefault(code int) *DeleteServiceCatalogSourceD } } -/*DeleteServiceCatalogSourceDefault handles this case with default header values. +/* +DeleteServiceCatalogSourceDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteServiceCatalogSourceDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete service catalog source default response has a 2xx status code +func (o *DeleteServiceCatalogSourceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete service catalog source default response has a 3xx status code +func (o *DeleteServiceCatalogSourceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete service catalog source default response has a 4xx status code +func (o *DeleteServiceCatalogSourceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete service catalog source default response has a 5xx status code +func (o *DeleteServiceCatalogSourceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete service catalog source default response a status code equal to that given +func (o *DeleteServiceCatalogSourceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete service catalog source default response func (o *DeleteServiceCatalogSourceDefault) Code() int { return o._statusCode } func (o *DeleteServiceCatalogSourceDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] deleteServiceCatalogSource default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] deleteServiceCatalogSource default %s", o._statusCode, payload) +} + +func (o *DeleteServiceCatalogSourceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] deleteServiceCatalogSource default %s", o._statusCode, payload) } func (o *DeleteServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { @@ -101,12 +170,16 @@ func (o *DeleteServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { func (o *DeleteServiceCatalogSourceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_service_catalog_sources/get_service_catalog_source_parameters.go b/client/client/organization_service_catalog_sources/get_service_catalog_source_parameters.go index 5164b90f..5e685ecd 100644 --- a/client/client/organization_service_catalog_sources/get_service_catalog_source_parameters.go +++ b/client/client/organization_service_catalog_sources/get_service_catalog_source_parameters.go @@ -13,93 +13,82 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetServiceCatalogSourceParams creates a new GetServiceCatalogSourceParams object -// with the default values initialized. +// NewGetServiceCatalogSourceParams creates a new GetServiceCatalogSourceParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetServiceCatalogSourceParams() *GetServiceCatalogSourceParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetServiceCatalogSourceParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetServiceCatalogSourceParamsWithTimeout creates a new GetServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetServiceCatalogSourceParamsWithTimeout(timeout time.Duration) *GetServiceCatalogSourceParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetServiceCatalogSourceParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetServiceCatalogSourceParamsWithContext creates a new GetServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetServiceCatalogSourceParamsWithContext(ctx context.Context) *GetServiceCatalogSourceParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetServiceCatalogSourceParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetServiceCatalogSourceParamsWithHTTPClient creates a new GetServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetServiceCatalogSourceParamsWithHTTPClient(client *http.Client) *GetServiceCatalogSourceParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetServiceCatalogSourceParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetServiceCatalogSourceParams contains all the parameters to send to the API endpoint -for the get service catalog source operation typically these are written to a http.Request +/* +GetServiceCatalogSourceParams contains all the parameters to send to the API endpoint + + for the get service catalog source operation. + + Typically these are written to a http.Request. */ type GetServiceCatalogSourceParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*ServiceCatalogSourceCanonical - Organization Service Catalog Sources canonical + /* ServiceCatalogSourceCanonical. + + Organization Service Catalog Sources canonical */ ServiceCatalogSourceCanonical string @@ -108,6 +97,35 @@ type GetServiceCatalogSourceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogSourceParams) WithDefaults() *GetServiceCatalogSourceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogSourceParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetServiceCatalogSourceParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get service catalog source params func (o *GetServiceCatalogSourceParams) WithTimeout(timeout time.Duration) *GetServiceCatalogSourceParams { o.SetTimeout(timeout) @@ -202,32 +220,34 @@ func (o *GetServiceCatalogSourceParams) WriteToRequest(r runtime.ClientRequest, // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } // path param service_catalog_source_canonical diff --git a/client/client/organization_service_catalog_sources/get_service_catalog_source_responses.go b/client/client/organization_service_catalog_sources/get_service_catalog_source_responses.go index e4ae2759..b00d1246 100644 --- a/client/client/organization_service_catalog_sources/get_service_catalog_source_responses.go +++ b/client/client/organization_service_catalog_sources/get_service_catalog_source_responses.go @@ -6,17 +6,18 @@ package organization_service_catalog_sources // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetServiceCatalogSourceReader is a Reader for the GetServiceCatalogSource structure. @@ -62,7 +63,8 @@ func NewGetServiceCatalogSourceOK() *GetServiceCatalogSourceOK { return &GetServiceCatalogSourceOK{} } -/*GetServiceCatalogSourceOK handles this case with default header values. +/* +GetServiceCatalogSourceOK describes a response with status code 200, with default header values. Organization Service Catalog Sources. */ @@ -70,8 +72,44 @@ type GetServiceCatalogSourceOK struct { Payload *GetServiceCatalogSourceOKBody } +// IsSuccess returns true when this get service catalog source o k response has a 2xx status code +func (o *GetServiceCatalogSourceOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get service catalog source o k response has a 3xx status code +func (o *GetServiceCatalogSourceOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog source o k response has a 4xx status code +func (o *GetServiceCatalogSourceOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service catalog source o k response has a 5xx status code +func (o *GetServiceCatalogSourceOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog source o k response a status code equal to that given +func (o *GetServiceCatalogSourceOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get service catalog source o k response +func (o *GetServiceCatalogSourceOK) Code() int { + return 200 +} + func (o *GetServiceCatalogSourceOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceOK %s", 200, payload) +} + +func (o *GetServiceCatalogSourceOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceOK %s", 200, payload) } func (o *GetServiceCatalogSourceOK) GetPayload() *GetServiceCatalogSourceOKBody { @@ -95,20 +133,60 @@ func NewGetServiceCatalogSourceForbidden() *GetServiceCatalogSourceForbidden { return &GetServiceCatalogSourceForbidden{} } -/*GetServiceCatalogSourceForbidden handles this case with default header values. +/* +GetServiceCatalogSourceForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetServiceCatalogSourceForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog source forbidden response has a 2xx status code +func (o *GetServiceCatalogSourceForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog source forbidden response has a 3xx status code +func (o *GetServiceCatalogSourceForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog source forbidden response has a 4xx status code +func (o *GetServiceCatalogSourceForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog source forbidden response has a 5xx status code +func (o *GetServiceCatalogSourceForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog source forbidden response a status code equal to that given +func (o *GetServiceCatalogSourceForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get service catalog source forbidden response +func (o *GetServiceCatalogSourceForbidden) Code() int { + return 403 +} + func (o *GetServiceCatalogSourceForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceForbidden %s", 403, payload) +} + +func (o *GetServiceCatalogSourceForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceForbidden %s", 403, payload) } func (o *GetServiceCatalogSourceForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetServiceCatalogSourceForbidden) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogSourceForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetServiceCatalogSourceUnprocessableEntity() *GetServiceCatalogSourceUnp return &GetServiceCatalogSourceUnprocessableEntity{} } -/*GetServiceCatalogSourceUnprocessableEntity handles this case with default header values. +/* +GetServiceCatalogSourceUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetServiceCatalogSourceUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog source unprocessable entity response has a 2xx status code +func (o *GetServiceCatalogSourceUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog source unprocessable entity response has a 3xx status code +func (o *GetServiceCatalogSourceUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog source unprocessable entity response has a 4xx status code +func (o *GetServiceCatalogSourceUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog source unprocessable entity response has a 5xx status code +func (o *GetServiceCatalogSourceUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog source unprocessable entity response a status code equal to that given +func (o *GetServiceCatalogSourceUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get service catalog source unprocessable entity response +func (o *GetServiceCatalogSourceUnprocessableEntity) Code() int { + return 422 +} + func (o *GetServiceCatalogSourceUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceUnprocessableEntity %s", 422, payload) +} + +func (o *GetServiceCatalogSourceUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSourceUnprocessableEntity %s", 422, payload) } func (o *GetServiceCatalogSourceUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetServiceCatalogSourceUnprocessableEntity) GetPayload() *models.ErrorP func (o *GetServiceCatalogSourceUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetServiceCatalogSourceDefault(code int) *GetServiceCatalogSourceDefault } } -/*GetServiceCatalogSourceDefault handles this case with default header values. +/* +GetServiceCatalogSourceDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetServiceCatalogSourceDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog source default response has a 2xx status code +func (o *GetServiceCatalogSourceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get service catalog source default response has a 3xx status code +func (o *GetServiceCatalogSourceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get service catalog source default response has a 4xx status code +func (o *GetServiceCatalogSourceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get service catalog source default response has a 5xx status code +func (o *GetServiceCatalogSourceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get service catalog source default response a status code equal to that given +func (o *GetServiceCatalogSourceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get service catalog source default response func (o *GetServiceCatalogSourceDefault) Code() int { return o._statusCode } func (o *GetServiceCatalogSourceDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSource default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSource default %s", o._statusCode, payload) +} + +func (o *GetServiceCatalogSourceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] getServiceCatalogSource default %s", o._statusCode, payload) } func (o *GetServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogSourceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetServiceCatalogSourceDefault) readResponse(response runtime.ClientRes return nil } -/*GetServiceCatalogSourceOKBody get service catalog source o k body +/* +GetServiceCatalogSourceOKBody get service catalog source o k body swagger:model GetServiceCatalogSourceOKBody */ type GetServiceCatalogSourceOKBody struct { @@ -265,6 +430,39 @@ func (o *GetServiceCatalogSourceOKBody) validateData(formats strfmt.Registry) er if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getServiceCatalogSourceOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogSourceOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get service catalog source o k body based on the context it is used +func (o *GetServiceCatalogSourceOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetServiceCatalogSourceOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getServiceCatalogSourceOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogSourceOK" + "." + "data") } return err } diff --git a/client/client/organization_service_catalog_sources/get_service_catalog_sources_parameters.go b/client/client/organization_service_catalog_sources/get_service_catalog_sources_parameters.go index 8f04275d..1034b552 100644 --- a/client/client/organization_service_catalog_sources/get_service_catalog_sources_parameters.go +++ b/client/client/organization_service_catalog_sources/get_service_catalog_sources_parameters.go @@ -13,88 +13,76 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetServiceCatalogSourcesParams creates a new GetServiceCatalogSourcesParams object -// with the default values initialized. +// NewGetServiceCatalogSourcesParams creates a new GetServiceCatalogSourcesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetServiceCatalogSourcesParams() *GetServiceCatalogSourcesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetServiceCatalogSourcesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetServiceCatalogSourcesParamsWithTimeout creates a new GetServiceCatalogSourcesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetServiceCatalogSourcesParamsWithTimeout(timeout time.Duration) *GetServiceCatalogSourcesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetServiceCatalogSourcesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetServiceCatalogSourcesParamsWithContext creates a new GetServiceCatalogSourcesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetServiceCatalogSourcesParamsWithContext(ctx context.Context) *GetServiceCatalogSourcesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetServiceCatalogSourcesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetServiceCatalogSourcesParamsWithHTTPClient creates a new GetServiceCatalogSourcesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetServiceCatalogSourcesParamsWithHTTPClient(client *http.Client) *GetServiceCatalogSourcesParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetServiceCatalogSourcesParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetServiceCatalogSourcesParams contains all the parameters to send to the API endpoint -for the get service catalog sources operation typically these are written to a http.Request +/* +GetServiceCatalogSourcesParams contains all the parameters to send to the API endpoint + + for the get service catalog sources operation. + + Typically these are written to a http.Request. */ type GetServiceCatalogSourcesParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -103,6 +91,35 @@ type GetServiceCatalogSourcesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get service catalog sources params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogSourcesParams) WithDefaults() *GetServiceCatalogSourcesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get service catalog sources params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogSourcesParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetServiceCatalogSourcesParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get service catalog sources params func (o *GetServiceCatalogSourcesParams) WithTimeout(timeout time.Duration) *GetServiceCatalogSourcesParams { o.SetTimeout(timeout) @@ -186,32 +203,34 @@ func (o *GetServiceCatalogSourcesParams) WriteToRequest(r runtime.ClientRequest, // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_service_catalog_sources/get_service_catalog_sources_responses.go b/client/client/organization_service_catalog_sources/get_service_catalog_sources_responses.go index ce4cc9af..73b6ee4d 100644 --- a/client/client/organization_service_catalog_sources/get_service_catalog_sources_responses.go +++ b/client/client/organization_service_catalog_sources/get_service_catalog_sources_responses.go @@ -6,18 +6,19 @@ package organization_service_catalog_sources // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetServiceCatalogSourcesReader is a Reader for the GetServiceCatalogSources structure. @@ -63,7 +64,8 @@ func NewGetServiceCatalogSourcesOK() *GetServiceCatalogSourcesOK { return &GetServiceCatalogSourcesOK{} } -/*GetServiceCatalogSourcesOK handles this case with default header values. +/* +GetServiceCatalogSourcesOK describes a response with status code 200, with default header values. List of the private service catalogs. */ @@ -71,8 +73,44 @@ type GetServiceCatalogSourcesOK struct { Payload *GetServiceCatalogSourcesOKBody } +// IsSuccess returns true when this get service catalog sources o k response has a 2xx status code +func (o *GetServiceCatalogSourcesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get service catalog sources o k response has a 3xx status code +func (o *GetServiceCatalogSourcesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog sources o k response has a 4xx status code +func (o *GetServiceCatalogSourcesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service catalog sources o k response has a 5xx status code +func (o *GetServiceCatalogSourcesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog sources o k response a status code equal to that given +func (o *GetServiceCatalogSourcesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get service catalog sources o k response +func (o *GetServiceCatalogSourcesOK) Code() int { + return 200 +} + func (o *GetServiceCatalogSourcesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesOK %s", 200, payload) +} + +func (o *GetServiceCatalogSourcesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesOK %s", 200, payload) } func (o *GetServiceCatalogSourcesOK) GetPayload() *GetServiceCatalogSourcesOKBody { @@ -96,20 +134,60 @@ func NewGetServiceCatalogSourcesForbidden() *GetServiceCatalogSourcesForbidden { return &GetServiceCatalogSourcesForbidden{} } -/*GetServiceCatalogSourcesForbidden handles this case with default header values. +/* +GetServiceCatalogSourcesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetServiceCatalogSourcesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog sources forbidden response has a 2xx status code +func (o *GetServiceCatalogSourcesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog sources forbidden response has a 3xx status code +func (o *GetServiceCatalogSourcesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog sources forbidden response has a 4xx status code +func (o *GetServiceCatalogSourcesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog sources forbidden response has a 5xx status code +func (o *GetServiceCatalogSourcesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog sources forbidden response a status code equal to that given +func (o *GetServiceCatalogSourcesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get service catalog sources forbidden response +func (o *GetServiceCatalogSourcesForbidden) Code() int { + return 403 +} + func (o *GetServiceCatalogSourcesForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesForbidden %s", 403, payload) +} + +func (o *GetServiceCatalogSourcesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesForbidden %s", 403, payload) } func (o *GetServiceCatalogSourcesForbidden) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *GetServiceCatalogSourcesForbidden) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogSourcesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewGetServiceCatalogSourcesUnprocessableEntity() *GetServiceCatalogSourcesU return &GetServiceCatalogSourcesUnprocessableEntity{} } -/*GetServiceCatalogSourcesUnprocessableEntity handles this case with default header values. +/* +GetServiceCatalogSourcesUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetServiceCatalogSourcesUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog sources unprocessable entity response has a 2xx status code +func (o *GetServiceCatalogSourcesUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog sources unprocessable entity response has a 3xx status code +func (o *GetServiceCatalogSourcesUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog sources unprocessable entity response has a 4xx status code +func (o *GetServiceCatalogSourcesUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog sources unprocessable entity response has a 5xx status code +func (o *GetServiceCatalogSourcesUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog sources unprocessable entity response a status code equal to that given +func (o *GetServiceCatalogSourcesUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get service catalog sources unprocessable entity response +func (o *GetServiceCatalogSourcesUnprocessableEntity) Code() int { + return 422 +} + func (o *GetServiceCatalogSourcesUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesUnprocessableEntity %s", 422, payload) +} + +func (o *GetServiceCatalogSourcesUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSourcesUnprocessableEntity %s", 422, payload) } func (o *GetServiceCatalogSourcesUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *GetServiceCatalogSourcesUnprocessableEntity) GetPayload() *models.Error func (o *GetServiceCatalogSourcesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewGetServiceCatalogSourcesDefault(code int) *GetServiceCatalogSourcesDefau } } -/*GetServiceCatalogSourcesDefault handles this case with default header values. +/* +GetServiceCatalogSourcesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetServiceCatalogSourcesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog sources default response has a 2xx status code +func (o *GetServiceCatalogSourcesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get service catalog sources default response has a 3xx status code +func (o *GetServiceCatalogSourcesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get service catalog sources default response has a 4xx status code +func (o *GetServiceCatalogSourcesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get service catalog sources default response has a 5xx status code +func (o *GetServiceCatalogSourcesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get service catalog sources default response a status code equal to that given +func (o *GetServiceCatalogSourcesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get service catalog sources default response func (o *GetServiceCatalogSourcesDefault) Code() int { return o._statusCode } func (o *GetServiceCatalogSourcesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSources default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSources default %s", o._statusCode, payload) +} + +func (o *GetServiceCatalogSourcesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalog_sources][%d] getServiceCatalogSources default %s", o._statusCode, payload) } func (o *GetServiceCatalogSourcesDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *GetServiceCatalogSourcesDefault) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogSourcesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *GetServiceCatalogSourcesDefault) readResponse(response runtime.ClientRe return nil } -/*GetServiceCatalogSourcesOKBody get service catalog sources o k body +/* +GetServiceCatalogSourcesOKBody get service catalog sources o k body swagger:model GetServiceCatalogSourcesOKBody */ type GetServiceCatalogSourcesOKBody struct { @@ -271,6 +436,47 @@ func (o *GetServiceCatalogSourcesOKBody) validateData(formats strfmt.Registry) e if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getServiceCatalogSourcesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogSourcesOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this get service catalog sources o k body based on the context it is used +func (o *GetServiceCatalogSourcesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetServiceCatalogSourcesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getServiceCatalogSourcesOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogSourcesOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } diff --git a/client/client/organization_service_catalog_sources/organization_service_catalog_sources_client.go b/client/client/organization_service_catalog_sources/organization_service_catalog_sources_client.go index 0bd54eb3..103a320c 100644 --- a/client/client/organization_service_catalog_sources/organization_service_catalog_sources_client.go +++ b/client/client/organization_service_catalog_sources/organization_service_catalog_sources_client.go @@ -7,15 +7,40 @@ package organization_service_catalog_sources import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization service catalog sources API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization service catalog sources API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization service catalog sources API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization service catalog sources API */ @@ -24,16 +49,86 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateServiceCatalogSource(params *CreateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateServiceCatalogSourceOK, error) + + DeleteServiceCatalogSource(params *DeleteServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteServiceCatalogSourceNoContent, error) + + GetServiceCatalogSource(params *GetServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogSourceOK, error) + + GetServiceCatalogSources(params *GetServiceCatalogSourcesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogSourcesOK, error) + + RefreshServiceCatalogSource(params *RefreshServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RefreshServiceCatalogSourceOK, error) + + UpdateServiceCatalogSource(params *UpdateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogSourceOK, error) + + ValidateServiceCatalogSource(params *ValidateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValidateServiceCatalogSourceNoContent, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateServiceCatalogSource Creates a Service catalog source */ -func (a *Client) CreateServiceCatalogSource(params *CreateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter) (*CreateServiceCatalogSourceOK, error) { +func (a *Client) CreateServiceCatalogSource(params *CreateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateServiceCatalogSourceOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateServiceCatalogSourceParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createServiceCatalogSource", Method: "POST", PathPattern: "/organizations/{organization_canonical}/service_catalog_sources", @@ -45,7 +140,12 @@ func (a *Client) CreateServiceCatalogSource(params *CreateServiceCatalogSourcePa AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -61,13 +161,12 @@ func (a *Client) CreateServiceCatalogSource(params *CreateServiceCatalogSourcePa /* DeleteServiceCatalogSource delete a Service catalog source */ -func (a *Client) DeleteServiceCatalogSource(params *DeleteServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteServiceCatalogSourceNoContent, error) { +func (a *Client) DeleteServiceCatalogSource(params *DeleteServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteServiceCatalogSourceNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteServiceCatalogSourceParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteServiceCatalogSource", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}", @@ -79,7 +178,12 @@ func (a *Client) DeleteServiceCatalogSource(params *DeleteServiceCatalogSourcePa AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -95,13 +199,12 @@ func (a *Client) DeleteServiceCatalogSource(params *DeleteServiceCatalogSourcePa /* GetServiceCatalogSource Return the Service Catalog Source */ -func (a *Client) GetServiceCatalogSource(params *GetServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter) (*GetServiceCatalogSourceOK, error) { +func (a *Client) GetServiceCatalogSource(params *GetServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogSourceOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetServiceCatalogSourceParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getServiceCatalogSource", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}", @@ -113,7 +216,12 @@ func (a *Client) GetServiceCatalogSource(params *GetServiceCatalogSourceParams, AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -129,13 +237,12 @@ func (a *Client) GetServiceCatalogSource(params *GetServiceCatalogSourceParams, /* GetServiceCatalogSources Return all the private service catalogs */ -func (a *Client) GetServiceCatalogSources(params *GetServiceCatalogSourcesParams, authInfo runtime.ClientAuthInfoWriter) (*GetServiceCatalogSourcesOK, error) { +func (a *Client) GetServiceCatalogSources(params *GetServiceCatalogSourcesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogSourcesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetServiceCatalogSourcesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getServiceCatalogSources", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalog_sources", @@ -147,7 +254,12 @@ func (a *Client) GetServiceCatalogSources(params *GetServiceCatalogSourcesParams AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,13 +275,12 @@ func (a *Client) GetServiceCatalogSources(params *GetServiceCatalogSourcesParams /* RefreshServiceCatalogSource Refresh a Service catalog source */ -func (a *Client) RefreshServiceCatalogSource(params *RefreshServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter) (*RefreshServiceCatalogSourceOK, error) { +func (a *Client) RefreshServiceCatalogSource(params *RefreshServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RefreshServiceCatalogSourceOK, error) { // TODO: Validate the params before sending if params == nil { params = NewRefreshServiceCatalogSourceParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "refreshServiceCatalogSource", Method: "POST", PathPattern: "/organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh", @@ -181,7 +292,12 @@ func (a *Client) RefreshServiceCatalogSource(params *RefreshServiceCatalogSource AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -197,13 +313,12 @@ func (a *Client) RefreshServiceCatalogSource(params *RefreshServiceCatalogSource /* UpdateServiceCatalogSource Update a Service catalog source */ -func (a *Client) UpdateServiceCatalogSource(params *UpdateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateServiceCatalogSourceOK, error) { +func (a *Client) UpdateServiceCatalogSource(params *UpdateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogSourceOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateServiceCatalogSourceParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateServiceCatalogSource", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}", @@ -215,7 +330,12 @@ func (a *Client) UpdateServiceCatalogSource(params *UpdateServiceCatalogSourcePa AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -231,13 +351,12 @@ func (a *Client) UpdateServiceCatalogSource(params *UpdateServiceCatalogSourcePa /* ValidateServiceCatalogSource Validate a Service catalog source */ -func (a *Client) ValidateServiceCatalogSource(params *ValidateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter) (*ValidateServiceCatalogSourceNoContent, error) { +func (a *Client) ValidateServiceCatalogSource(params *ValidateServiceCatalogSourceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValidateServiceCatalogSourceNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewValidateServiceCatalogSourceParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "validateServiceCatalogSource", Method: "POST", PathPattern: "/organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate", @@ -249,7 +368,12 @@ func (a *Client) ValidateServiceCatalogSource(params *ValidateServiceCatalogSour AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organization_service_catalog_sources/refresh_service_catalog_source_parameters.go b/client/client/organization_service_catalog_sources/refresh_service_catalog_source_parameters.go index ce55f031..d17b86c4 100644 --- a/client/client/organization_service_catalog_sources/refresh_service_catalog_source_parameters.go +++ b/client/client/organization_service_catalog_sources/refresh_service_catalog_source_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewRefreshServiceCatalogSourceParams creates a new RefreshServiceCatalogSourceParams object -// with the default values initialized. +// NewRefreshServiceCatalogSourceParams creates a new RefreshServiceCatalogSourceParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewRefreshServiceCatalogSourceParams() *RefreshServiceCatalogSourceParams { - var () return &RefreshServiceCatalogSourceParams{ - timeout: cr.DefaultTimeout, } } // NewRefreshServiceCatalogSourceParamsWithTimeout creates a new RefreshServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewRefreshServiceCatalogSourceParamsWithTimeout(timeout time.Duration) *RefreshServiceCatalogSourceParams { - var () return &RefreshServiceCatalogSourceParams{ - timeout: timeout, } } // NewRefreshServiceCatalogSourceParamsWithContext creates a new RefreshServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewRefreshServiceCatalogSourceParamsWithContext(ctx context.Context) *RefreshServiceCatalogSourceParams { - var () return &RefreshServiceCatalogSourceParams{ - Context: ctx, } } // NewRefreshServiceCatalogSourceParamsWithHTTPClient creates a new RefreshServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewRefreshServiceCatalogSourceParamsWithHTTPClient(client *http.Client) *RefreshServiceCatalogSourceParams { - var () return &RefreshServiceCatalogSourceParams{ HTTPClient: client, } } -/*RefreshServiceCatalogSourceParams contains all the parameters to send to the API endpoint -for the refresh service catalog source operation typically these are written to a http.Request +/* +RefreshServiceCatalogSourceParams contains all the parameters to send to the API endpoint + + for the refresh service catalog source operation. + + Typically these are written to a http.Request. */ type RefreshServiceCatalogSourceParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogSourceCanonical - Organization Service Catalog Sources canonical + /* ServiceCatalogSourceCanonical. + + Organization Service Catalog Sources canonical */ ServiceCatalogSourceCanonical string @@ -77,6 +78,21 @@ type RefreshServiceCatalogSourceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the refresh service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RefreshServiceCatalogSourceParams) WithDefaults() *RefreshServiceCatalogSourceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the refresh service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RefreshServiceCatalogSourceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the refresh service catalog source params func (o *RefreshServiceCatalogSourceParams) WithTimeout(timeout time.Duration) *RefreshServiceCatalogSourceParams { o.SetTimeout(timeout) diff --git a/client/client/organization_service_catalog_sources/refresh_service_catalog_source_responses.go b/client/client/organization_service_catalog_sources/refresh_service_catalog_source_responses.go index 9fedbd50..c73312cf 100644 --- a/client/client/organization_service_catalog_sources/refresh_service_catalog_source_responses.go +++ b/client/client/organization_service_catalog_sources/refresh_service_catalog_source_responses.go @@ -6,17 +6,18 @@ package organization_service_catalog_sources // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // RefreshServiceCatalogSourceReader is a Reader for the RefreshServiceCatalogSource structure. @@ -68,7 +69,8 @@ func NewRefreshServiceCatalogSourceOK() *RefreshServiceCatalogSourceOK { return &RefreshServiceCatalogSourceOK{} } -/*RefreshServiceCatalogSourceOK handles this case with default header values. +/* +RefreshServiceCatalogSourceOK describes a response with status code 200, with default header values. Success refresh */ @@ -76,8 +78,44 @@ type RefreshServiceCatalogSourceOK struct { Payload *RefreshServiceCatalogSourceOKBody } +// IsSuccess returns true when this refresh service catalog source o k response has a 2xx status code +func (o *RefreshServiceCatalogSourceOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this refresh service catalog source o k response has a 3xx status code +func (o *RefreshServiceCatalogSourceOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this refresh service catalog source o k response has a 4xx status code +func (o *RefreshServiceCatalogSourceOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this refresh service catalog source o k response has a 5xx status code +func (o *RefreshServiceCatalogSourceOK) IsServerError() bool { + return false +} + +// IsCode returns true when this refresh service catalog source o k response a status code equal to that given +func (o *RefreshServiceCatalogSourceOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the refresh service catalog source o k response +func (o *RefreshServiceCatalogSourceOK) Code() int { + return 200 +} + func (o *RefreshServiceCatalogSourceOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceOK %s", 200, payload) +} + +func (o *RefreshServiceCatalogSourceOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceOK %s", 200, payload) } func (o *RefreshServiceCatalogSourceOK) GetPayload() *RefreshServiceCatalogSourceOKBody { @@ -101,20 +139,60 @@ func NewRefreshServiceCatalogSourceNotFound() *RefreshServiceCatalogSourceNotFou return &RefreshServiceCatalogSourceNotFound{} } -/*RefreshServiceCatalogSourceNotFound handles this case with default header values. +/* +RefreshServiceCatalogSourceNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type RefreshServiceCatalogSourceNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this refresh service catalog source not found response has a 2xx status code +func (o *RefreshServiceCatalogSourceNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this refresh service catalog source not found response has a 3xx status code +func (o *RefreshServiceCatalogSourceNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this refresh service catalog source not found response has a 4xx status code +func (o *RefreshServiceCatalogSourceNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this refresh service catalog source not found response has a 5xx status code +func (o *RefreshServiceCatalogSourceNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this refresh service catalog source not found response a status code equal to that given +func (o *RefreshServiceCatalogSourceNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the refresh service catalog source not found response +func (o *RefreshServiceCatalogSourceNotFound) Code() int { + return 404 +} + func (o *RefreshServiceCatalogSourceNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceNotFound %s", 404, payload) +} + +func (o *RefreshServiceCatalogSourceNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceNotFound %s", 404, payload) } func (o *RefreshServiceCatalogSourceNotFound) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *RefreshServiceCatalogSourceNotFound) GetPayload() *models.ErrorPayload func (o *RefreshServiceCatalogSourceNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,15 +227,50 @@ func NewRefreshServiceCatalogSourceLengthRequired() *RefreshServiceCatalogSource return &RefreshServiceCatalogSourceLengthRequired{} } -/*RefreshServiceCatalogSourceLengthRequired handles this case with default header values. +/* +RefreshServiceCatalogSourceLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type RefreshServiceCatalogSourceLengthRequired struct { } +// IsSuccess returns true when this refresh service catalog source length required response has a 2xx status code +func (o *RefreshServiceCatalogSourceLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this refresh service catalog source length required response has a 3xx status code +func (o *RefreshServiceCatalogSourceLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this refresh service catalog source length required response has a 4xx status code +func (o *RefreshServiceCatalogSourceLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this refresh service catalog source length required response has a 5xx status code +func (o *RefreshServiceCatalogSourceLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this refresh service catalog source length required response a status code equal to that given +func (o *RefreshServiceCatalogSourceLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the refresh service catalog source length required response +func (o *RefreshServiceCatalogSourceLengthRequired) Code() int { + return 411 +} + func (o *RefreshServiceCatalogSourceLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceLengthRequired", 411) +} + +func (o *RefreshServiceCatalogSourceLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceLengthRequired", 411) } func (o *RefreshServiceCatalogSourceLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -166,20 +283,60 @@ func NewRefreshServiceCatalogSourceUnprocessableEntity() *RefreshServiceCatalogS return &RefreshServiceCatalogSourceUnprocessableEntity{} } -/*RefreshServiceCatalogSourceUnprocessableEntity handles this case with default header values. +/* +RefreshServiceCatalogSourceUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type RefreshServiceCatalogSourceUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this refresh service catalog source unprocessable entity response has a 2xx status code +func (o *RefreshServiceCatalogSourceUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this refresh service catalog source unprocessable entity response has a 3xx status code +func (o *RefreshServiceCatalogSourceUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this refresh service catalog source unprocessable entity response has a 4xx status code +func (o *RefreshServiceCatalogSourceUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this refresh service catalog source unprocessable entity response has a 5xx status code +func (o *RefreshServiceCatalogSourceUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this refresh service catalog source unprocessable entity response a status code equal to that given +func (o *RefreshServiceCatalogSourceUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the refresh service catalog source unprocessable entity response +func (o *RefreshServiceCatalogSourceUnprocessableEntity) Code() int { + return 422 +} + func (o *RefreshServiceCatalogSourceUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceUnprocessableEntity %s", 422, payload) +} + +func (o *RefreshServiceCatalogSourceUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSourceUnprocessableEntity %s", 422, payload) } func (o *RefreshServiceCatalogSourceUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -188,12 +345,16 @@ func (o *RefreshServiceCatalogSourceUnprocessableEntity) GetPayload() *models.Er func (o *RefreshServiceCatalogSourceUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -212,27 +373,61 @@ func NewRefreshServiceCatalogSourceDefault(code int) *RefreshServiceCatalogSourc } } -/*RefreshServiceCatalogSourceDefault handles this case with default header values. +/* +RefreshServiceCatalogSourceDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type RefreshServiceCatalogSourceDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this refresh service catalog source default response has a 2xx status code +func (o *RefreshServiceCatalogSourceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this refresh service catalog source default response has a 3xx status code +func (o *RefreshServiceCatalogSourceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this refresh service catalog source default response has a 4xx status code +func (o *RefreshServiceCatalogSourceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this refresh service catalog source default response has a 5xx status code +func (o *RefreshServiceCatalogSourceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this refresh service catalog source default response a status code equal to that given +func (o *RefreshServiceCatalogSourceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the refresh service catalog source default response func (o *RefreshServiceCatalogSourceDefault) Code() int { return o._statusCode } func (o *RefreshServiceCatalogSourceDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSource default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSource default %s", o._statusCode, payload) +} + +func (o *RefreshServiceCatalogSourceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/refresh][%d] refreshServiceCatalogSource default %s", o._statusCode, payload) } func (o *RefreshServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { @@ -241,12 +436,16 @@ func (o *RefreshServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { func (o *RefreshServiceCatalogSourceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -258,7 +457,8 @@ func (o *RefreshServiceCatalogSourceDefault) readResponse(response runtime.Clien return nil } -/*RefreshServiceCatalogSourceOKBody refresh service catalog source o k body +/* +RefreshServiceCatalogSourceOKBody refresh service catalog source o k body swagger:model RefreshServiceCatalogSourceOKBody */ type RefreshServiceCatalogSourceOKBody struct { @@ -292,6 +492,39 @@ func (o *RefreshServiceCatalogSourceOKBody) validateData(formats strfmt.Registry if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("refreshServiceCatalogSourceOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("refreshServiceCatalogSourceOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this refresh service catalog source o k body based on the context it is used +func (o *RefreshServiceCatalogSourceOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *RefreshServiceCatalogSourceOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("refreshServiceCatalogSourceOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("refreshServiceCatalogSourceOK" + "." + "data") } return err } diff --git a/client/client/organization_service_catalog_sources/update_service_catalog_source_parameters.go b/client/client/organization_service_catalog_sources/update_service_catalog_source_parameters.go index 1355326a..e22d4dce 100644 --- a/client/client/organization_service_catalog_sources/update_service_catalog_source_parameters.go +++ b/client/client/organization_service_catalog_sources/update_service_catalog_source_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateServiceCatalogSourceParams creates a new UpdateServiceCatalogSourceParams object -// with the default values initialized. +// NewUpdateServiceCatalogSourceParams creates a new UpdateServiceCatalogSourceParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateServiceCatalogSourceParams() *UpdateServiceCatalogSourceParams { - var () return &UpdateServiceCatalogSourceParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateServiceCatalogSourceParamsWithTimeout creates a new UpdateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateServiceCatalogSourceParamsWithTimeout(timeout time.Duration) *UpdateServiceCatalogSourceParams { - var () return &UpdateServiceCatalogSourceParams{ - timeout: timeout, } } // NewUpdateServiceCatalogSourceParamsWithContext creates a new UpdateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateServiceCatalogSourceParamsWithContext(ctx context.Context) *UpdateServiceCatalogSourceParams { - var () return &UpdateServiceCatalogSourceParams{ - Context: ctx, } } // NewUpdateServiceCatalogSourceParamsWithHTTPClient creates a new UpdateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateServiceCatalogSourceParamsWithHTTPClient(client *http.Client) *UpdateServiceCatalogSourceParams { - var () return &UpdateServiceCatalogSourceParams{ HTTPClient: client, } } -/*UpdateServiceCatalogSourceParams contains all the parameters to send to the API endpoint -for the update service catalog source operation typically these are written to a http.Request +/* +UpdateServiceCatalogSourceParams contains all the parameters to send to the API endpoint + + for the update service catalog source operation. + + Typically these are written to a http.Request. */ type UpdateServiceCatalogSourceParams struct { - /*Body - The information of the organization to create. + /* Body. + The information of the organization to create. */ Body *models.UpdateServiceCatalogSource - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogSourceCanonical - Organization Service Catalog Sources canonical + /* ServiceCatalogSourceCanonical. + + Organization Service Catalog Sources canonical */ ServiceCatalogSourceCanonical string @@ -84,6 +86,21 @@ type UpdateServiceCatalogSourceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogSourceParams) WithDefaults() *UpdateServiceCatalogSourceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogSourceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update service catalog source params func (o *UpdateServiceCatalogSourceParams) WithTimeout(timeout time.Duration) *UpdateServiceCatalogSourceParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateServiceCatalogSourceParams) WriteToRequest(r runtime.ClientReques return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organization_service_catalog_sources/update_service_catalog_source_responses.go b/client/client/organization_service_catalog_sources/update_service_catalog_source_responses.go index b6d93f9f..7a86e38a 100644 --- a/client/client/organization_service_catalog_sources/update_service_catalog_source_responses.go +++ b/client/client/organization_service_catalog_sources/update_service_catalog_source_responses.go @@ -6,17 +6,18 @@ package organization_service_catalog_sources // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateServiceCatalogSourceReader is a Reader for the UpdateServiceCatalogSource structure. @@ -62,7 +63,8 @@ func NewUpdateServiceCatalogSourceOK() *UpdateServiceCatalogSourceOK { return &UpdateServiceCatalogSourceOK{} } -/*UpdateServiceCatalogSourceOK handles this case with default header values. +/* +UpdateServiceCatalogSourceOK describes a response with status code 200, with default header values. Success update */ @@ -70,8 +72,44 @@ type UpdateServiceCatalogSourceOK struct { Payload *UpdateServiceCatalogSourceOKBody } +// IsSuccess returns true when this update service catalog source o k response has a 2xx status code +func (o *UpdateServiceCatalogSourceOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update service catalog source o k response has a 3xx status code +func (o *UpdateServiceCatalogSourceOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog source o k response has a 4xx status code +func (o *UpdateServiceCatalogSourceOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update service catalog source o k response has a 5xx status code +func (o *UpdateServiceCatalogSourceOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog source o k response a status code equal to that given +func (o *UpdateServiceCatalogSourceOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update service catalog source o k response +func (o *UpdateServiceCatalogSourceOK) Code() int { + return 200 +} + func (o *UpdateServiceCatalogSourceOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceOK %s", 200, payload) +} + +func (o *UpdateServiceCatalogSourceOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceOK %s", 200, payload) } func (o *UpdateServiceCatalogSourceOK) GetPayload() *UpdateServiceCatalogSourceOKBody { @@ -95,20 +133,60 @@ func NewUpdateServiceCatalogSourceNotFound() *UpdateServiceCatalogSourceNotFound return &UpdateServiceCatalogSourceNotFound{} } -/*UpdateServiceCatalogSourceNotFound handles this case with default header values. +/* +UpdateServiceCatalogSourceNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateServiceCatalogSourceNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog source not found response has a 2xx status code +func (o *UpdateServiceCatalogSourceNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog source not found response has a 3xx status code +func (o *UpdateServiceCatalogSourceNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog source not found response has a 4xx status code +func (o *UpdateServiceCatalogSourceNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog source not found response has a 5xx status code +func (o *UpdateServiceCatalogSourceNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog source not found response a status code equal to that given +func (o *UpdateServiceCatalogSourceNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update service catalog source not found response +func (o *UpdateServiceCatalogSourceNotFound) Code() int { + return 404 +} + func (o *UpdateServiceCatalogSourceNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceNotFound %s", 404, payload) +} + +func (o *UpdateServiceCatalogSourceNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceNotFound %s", 404, payload) } func (o *UpdateServiceCatalogSourceNotFound) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *UpdateServiceCatalogSourceNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateServiceCatalogSourceNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,15 +221,50 @@ func NewUpdateServiceCatalogSourceLengthRequired() *UpdateServiceCatalogSourceLe return &UpdateServiceCatalogSourceLengthRequired{} } -/*UpdateServiceCatalogSourceLengthRequired handles this case with default header values. +/* +UpdateServiceCatalogSourceLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateServiceCatalogSourceLengthRequired struct { } +// IsSuccess returns true when this update service catalog source length required response has a 2xx status code +func (o *UpdateServiceCatalogSourceLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog source length required response has a 3xx status code +func (o *UpdateServiceCatalogSourceLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog source length required response has a 4xx status code +func (o *UpdateServiceCatalogSourceLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog source length required response has a 5xx status code +func (o *UpdateServiceCatalogSourceLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog source length required response a status code equal to that given +func (o *UpdateServiceCatalogSourceLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update service catalog source length required response +func (o *UpdateServiceCatalogSourceLengthRequired) Code() int { + return 411 +} + func (o *UpdateServiceCatalogSourceLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceLengthRequired", 411) +} + +func (o *UpdateServiceCatalogSourceLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSourceLengthRequired", 411) } func (o *UpdateServiceCatalogSourceLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -162,27 +279,61 @@ func NewUpdateServiceCatalogSourceDefault(code int) *UpdateServiceCatalogSourceD } } -/*UpdateServiceCatalogSourceDefault handles this case with default header values. +/* +UpdateServiceCatalogSourceDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateServiceCatalogSourceDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog source default response has a 2xx status code +func (o *UpdateServiceCatalogSourceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update service catalog source default response has a 3xx status code +func (o *UpdateServiceCatalogSourceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update service catalog source default response has a 4xx status code +func (o *UpdateServiceCatalogSourceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update service catalog source default response has a 5xx status code +func (o *UpdateServiceCatalogSourceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update service catalog source default response a status code equal to that given +func (o *UpdateServiceCatalogSourceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update service catalog source default response func (o *UpdateServiceCatalogSourceDefault) Code() int { return o._statusCode } func (o *UpdateServiceCatalogSourceDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSource default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSource default %s", o._statusCode, payload) +} + +func (o *UpdateServiceCatalogSourceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}][%d] updateServiceCatalogSource default %s", o._statusCode, payload) } func (o *UpdateServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { @@ -191,12 +342,16 @@ func (o *UpdateServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { func (o *UpdateServiceCatalogSourceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -208,7 +363,8 @@ func (o *UpdateServiceCatalogSourceDefault) readResponse(response runtime.Client return nil } -/*UpdateServiceCatalogSourceOKBody update service catalog source o k body +/* +UpdateServiceCatalogSourceOKBody update service catalog source o k body swagger:model UpdateServiceCatalogSourceOKBody */ type UpdateServiceCatalogSourceOKBody struct { @@ -242,6 +398,39 @@ func (o *UpdateServiceCatalogSourceOKBody) validateData(formats strfmt.Registry) if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateServiceCatalogSourceOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateServiceCatalogSourceOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update service catalog source o k body based on the context it is used +func (o *UpdateServiceCatalogSourceOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateServiceCatalogSourceOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateServiceCatalogSourceOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateServiceCatalogSourceOK" + "." + "data") } return err } diff --git a/client/client/organization_service_catalog_sources/validate_service_catalog_source_parameters.go b/client/client/organization_service_catalog_sources/validate_service_catalog_source_parameters.go index e27971c1..8356ddb5 100644 --- a/client/client/organization_service_catalog_sources/validate_service_catalog_source_parameters.go +++ b/client/client/organization_service_catalog_sources/validate_service_catalog_source_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewValidateServiceCatalogSourceParams creates a new ValidateServiceCatalogSourceParams object -// with the default values initialized. +// NewValidateServiceCatalogSourceParams creates a new ValidateServiceCatalogSourceParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewValidateServiceCatalogSourceParams() *ValidateServiceCatalogSourceParams { - var () return &ValidateServiceCatalogSourceParams{ - timeout: cr.DefaultTimeout, } } // NewValidateServiceCatalogSourceParamsWithTimeout creates a new ValidateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewValidateServiceCatalogSourceParamsWithTimeout(timeout time.Duration) *ValidateServiceCatalogSourceParams { - var () return &ValidateServiceCatalogSourceParams{ - timeout: timeout, } } // NewValidateServiceCatalogSourceParamsWithContext creates a new ValidateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewValidateServiceCatalogSourceParamsWithContext(ctx context.Context) *ValidateServiceCatalogSourceParams { - var () return &ValidateServiceCatalogSourceParams{ - Context: ctx, } } // NewValidateServiceCatalogSourceParamsWithHTTPClient creates a new ValidateServiceCatalogSourceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewValidateServiceCatalogSourceParamsWithHTTPClient(client *http.Client) *ValidateServiceCatalogSourceParams { - var () return &ValidateServiceCatalogSourceParams{ HTTPClient: client, } } -/*ValidateServiceCatalogSourceParams contains all the parameters to send to the API endpoint -for the validate service catalog source operation typically these are written to a http.Request +/* +ValidateServiceCatalogSourceParams contains all the parameters to send to the API endpoint + + for the validate service catalog source operation. + + Typically these are written to a http.Request. */ type ValidateServiceCatalogSourceParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogSourceCanonical - Organization Service Catalog Sources canonical + /* ServiceCatalogSourceCanonical. + + Organization Service Catalog Sources canonical */ ServiceCatalogSourceCanonical string @@ -77,6 +78,21 @@ type ValidateServiceCatalogSourceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the validate service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValidateServiceCatalogSourceParams) WithDefaults() *ValidateServiceCatalogSourceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the validate service catalog source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValidateServiceCatalogSourceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the validate service catalog source params func (o *ValidateServiceCatalogSourceParams) WithTimeout(timeout time.Duration) *ValidateServiceCatalogSourceParams { o.SetTimeout(timeout) diff --git a/client/client/organization_service_catalog_sources/validate_service_catalog_source_responses.go b/client/client/organization_service_catalog_sources/validate_service_catalog_source_responses.go index 3e9702c3..4b54740a 100644 --- a/client/client/organization_service_catalog_sources/validate_service_catalog_source_responses.go +++ b/client/client/organization_service_catalog_sources/validate_service_catalog_source_responses.go @@ -6,16 +6,16 @@ package organization_service_catalog_sources // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ValidateServiceCatalogSourceReader is a Reader for the ValidateServiceCatalogSource structure. @@ -73,15 +73,50 @@ func NewValidateServiceCatalogSourceNoContent() *ValidateServiceCatalogSourceNoC return &ValidateServiceCatalogSourceNoContent{} } -/*ValidateServiceCatalogSourceNoContent handles this case with default header values. +/* +ValidateServiceCatalogSourceNoContent describes a response with status code 204, with default header values. The SCS has been validated */ type ValidateServiceCatalogSourceNoContent struct { } +// IsSuccess returns true when this validate service catalog source no content response has a 2xx status code +func (o *ValidateServiceCatalogSourceNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this validate service catalog source no content response has a 3xx status code +func (o *ValidateServiceCatalogSourceNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate service catalog source no content response has a 4xx status code +func (o *ValidateServiceCatalogSourceNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this validate service catalog source no content response has a 5xx status code +func (o *ValidateServiceCatalogSourceNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this validate service catalog source no content response a status code equal to that given +func (o *ValidateServiceCatalogSourceNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the validate service catalog source no content response +func (o *ValidateServiceCatalogSourceNoContent) Code() int { + return 204 +} + func (o *ValidateServiceCatalogSourceNoContent) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceNoContent ", 204) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceNoContent", 204) +} + +func (o *ValidateServiceCatalogSourceNoContent) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceNoContent", 204) } func (o *ValidateServiceCatalogSourceNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -94,20 +129,60 @@ func NewValidateServiceCatalogSourceForbidden() *ValidateServiceCatalogSourceFor return &ValidateServiceCatalogSourceForbidden{} } -/*ValidateServiceCatalogSourceForbidden handles this case with default header values. +/* +ValidateServiceCatalogSourceForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ValidateServiceCatalogSourceForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate service catalog source forbidden response has a 2xx status code +func (o *ValidateServiceCatalogSourceForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate service catalog source forbidden response has a 3xx status code +func (o *ValidateServiceCatalogSourceForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate service catalog source forbidden response has a 4xx status code +func (o *ValidateServiceCatalogSourceForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate service catalog source forbidden response has a 5xx status code +func (o *ValidateServiceCatalogSourceForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this validate service catalog source forbidden response a status code equal to that given +func (o *ValidateServiceCatalogSourceForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the validate service catalog source forbidden response +func (o *ValidateServiceCatalogSourceForbidden) Code() int { + return 403 +} + func (o *ValidateServiceCatalogSourceForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceForbidden %s", 403, payload) +} + +func (o *ValidateServiceCatalogSourceForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceForbidden %s", 403, payload) } func (o *ValidateServiceCatalogSourceForbidden) GetPayload() *models.ErrorPayload { @@ -116,12 +191,16 @@ func (o *ValidateServiceCatalogSourceForbidden) GetPayload() *models.ErrorPayloa func (o *ValidateServiceCatalogSourceForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -138,20 +217,60 @@ func NewValidateServiceCatalogSourceNotFound() *ValidateServiceCatalogSourceNotF return &ValidateServiceCatalogSourceNotFound{} } -/*ValidateServiceCatalogSourceNotFound handles this case with default header values. +/* +ValidateServiceCatalogSourceNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type ValidateServiceCatalogSourceNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate service catalog source not found response has a 2xx status code +func (o *ValidateServiceCatalogSourceNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate service catalog source not found response has a 3xx status code +func (o *ValidateServiceCatalogSourceNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate service catalog source not found response has a 4xx status code +func (o *ValidateServiceCatalogSourceNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate service catalog source not found response has a 5xx status code +func (o *ValidateServiceCatalogSourceNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this validate service catalog source not found response a status code equal to that given +func (o *ValidateServiceCatalogSourceNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the validate service catalog source not found response +func (o *ValidateServiceCatalogSourceNotFound) Code() int { + return 404 +} + func (o *ValidateServiceCatalogSourceNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceNotFound %s", 404, payload) +} + +func (o *ValidateServiceCatalogSourceNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceNotFound %s", 404, payload) } func (o *ValidateServiceCatalogSourceNotFound) GetPayload() *models.ErrorPayload { @@ -160,12 +279,16 @@ func (o *ValidateServiceCatalogSourceNotFound) GetPayload() *models.ErrorPayload func (o *ValidateServiceCatalogSourceNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -182,15 +305,50 @@ func NewValidateServiceCatalogSourceLengthRequired() *ValidateServiceCatalogSour return &ValidateServiceCatalogSourceLengthRequired{} } -/*ValidateServiceCatalogSourceLengthRequired handles this case with default header values. +/* +ValidateServiceCatalogSourceLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type ValidateServiceCatalogSourceLengthRequired struct { } +// IsSuccess returns true when this validate service catalog source length required response has a 2xx status code +func (o *ValidateServiceCatalogSourceLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate service catalog source length required response has a 3xx status code +func (o *ValidateServiceCatalogSourceLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate service catalog source length required response has a 4xx status code +func (o *ValidateServiceCatalogSourceLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate service catalog source length required response has a 5xx status code +func (o *ValidateServiceCatalogSourceLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this validate service catalog source length required response a status code equal to that given +func (o *ValidateServiceCatalogSourceLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the validate service catalog source length required response +func (o *ValidateServiceCatalogSourceLengthRequired) Code() int { + return 411 +} + func (o *ValidateServiceCatalogSourceLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceLengthRequired", 411) +} + +func (o *ValidateServiceCatalogSourceLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceLengthRequired", 411) } func (o *ValidateServiceCatalogSourceLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -203,20 +361,60 @@ func NewValidateServiceCatalogSourceUnprocessableEntity() *ValidateServiceCatalo return &ValidateServiceCatalogSourceUnprocessableEntity{} } -/*ValidateServiceCatalogSourceUnprocessableEntity handles this case with default header values. +/* +ValidateServiceCatalogSourceUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type ValidateServiceCatalogSourceUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate service catalog source unprocessable entity response has a 2xx status code +func (o *ValidateServiceCatalogSourceUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate service catalog source unprocessable entity response has a 3xx status code +func (o *ValidateServiceCatalogSourceUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate service catalog source unprocessable entity response has a 4xx status code +func (o *ValidateServiceCatalogSourceUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate service catalog source unprocessable entity response has a 5xx status code +func (o *ValidateServiceCatalogSourceUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this validate service catalog source unprocessable entity response a status code equal to that given +func (o *ValidateServiceCatalogSourceUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the validate service catalog source unprocessable entity response +func (o *ValidateServiceCatalogSourceUnprocessableEntity) Code() int { + return 422 +} + func (o *ValidateServiceCatalogSourceUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceUnprocessableEntity %s", 422, payload) +} + +func (o *ValidateServiceCatalogSourceUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSourceUnprocessableEntity %s", 422, payload) } func (o *ValidateServiceCatalogSourceUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -225,12 +423,16 @@ func (o *ValidateServiceCatalogSourceUnprocessableEntity) GetPayload() *models.E func (o *ValidateServiceCatalogSourceUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -249,27 +451,61 @@ func NewValidateServiceCatalogSourceDefault(code int) *ValidateServiceCatalogSou } } -/*ValidateServiceCatalogSourceDefault handles this case with default header values. +/* +ValidateServiceCatalogSourceDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ValidateServiceCatalogSourceDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate service catalog source default response has a 2xx status code +func (o *ValidateServiceCatalogSourceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this validate service catalog source default response has a 3xx status code +func (o *ValidateServiceCatalogSourceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this validate service catalog source default response has a 4xx status code +func (o *ValidateServiceCatalogSourceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this validate service catalog source default response has a 5xx status code +func (o *ValidateServiceCatalogSourceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this validate service catalog source default response a status code equal to that given +func (o *ValidateServiceCatalogSourceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the validate service catalog source default response func (o *ValidateServiceCatalogSourceDefault) Code() int { return o._statusCode } func (o *ValidateServiceCatalogSourceDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSource default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSource default %s", o._statusCode, payload) +} + +func (o *ValidateServiceCatalogSourceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalog_sources/{service_catalog_source_canonical}/validate][%d] validateServiceCatalogSource default %s", o._statusCode, payload) } func (o *ValidateServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload { @@ -278,12 +514,16 @@ func (o *ValidateServiceCatalogSourceDefault) GetPayload() *models.ErrorPayload func (o *ValidateServiceCatalogSourceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organization_workers/get_workers_parameters.go b/client/client/organization_workers/get_workers_parameters.go index 168f8f1b..f31a86a4 100644 --- a/client/client/organization_workers/get_workers_parameters.go +++ b/client/client/organization_workers/get_workers_parameters.go @@ -13,88 +13,76 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetWorkersParams creates a new GetWorkersParams object -// with the default values initialized. +// NewGetWorkersParams creates a new GetWorkersParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetWorkersParams() *GetWorkersParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetWorkersParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetWorkersParamsWithTimeout creates a new GetWorkersParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetWorkersParamsWithTimeout(timeout time.Duration) *GetWorkersParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetWorkersParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetWorkersParamsWithContext creates a new GetWorkersParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetWorkersParamsWithContext(ctx context.Context) *GetWorkersParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetWorkersParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetWorkersParamsWithHTTPClient creates a new GetWorkersParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetWorkersParamsWithHTTPClient(client *http.Client) *GetWorkersParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetWorkersParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetWorkersParams contains all the parameters to send to the API endpoint -for the get workers operation typically these are written to a http.Request +/* +GetWorkersParams contains all the parameters to send to the API endpoint + + for the get workers operation. + + Typically these are written to a http.Request. */ type GetWorkersParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -103,6 +91,35 @@ type GetWorkersParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get workers params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetWorkersParams) WithDefaults() *GetWorkersParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get workers params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetWorkersParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetWorkersParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get workers params func (o *GetWorkersParams) WithTimeout(timeout time.Duration) *GetWorkersParams { o.SetTimeout(timeout) @@ -186,32 +203,34 @@ func (o *GetWorkersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organization_workers/get_workers_responses.go b/client/client/organization_workers/get_workers_responses.go index 97ebf61b..421d5b3e 100644 --- a/client/client/organization_workers/get_workers_responses.go +++ b/client/client/organization_workers/get_workers_responses.go @@ -6,18 +6,19 @@ package organization_workers // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetWorkersReader is a Reader for the GetWorkers structure. @@ -63,7 +64,8 @@ func NewGetWorkersOK() *GetWorkersOK { return &GetWorkersOK{} } -/*GetWorkersOK handles this case with default header values. +/* +GetWorkersOK describes a response with status code 200, with default header values. List of the workers which authenticated user has access to. */ @@ -71,8 +73,44 @@ type GetWorkersOK struct { Payload *GetWorkersOKBody } +// IsSuccess returns true when this get workers o k response has a 2xx status code +func (o *GetWorkersOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get workers o k response has a 3xx status code +func (o *GetWorkersOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get workers o k response has a 4xx status code +func (o *GetWorkersOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get workers o k response has a 5xx status code +func (o *GetWorkersOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get workers o k response a status code equal to that given +func (o *GetWorkersOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get workers o k response +func (o *GetWorkersOK) Code() int { + return 200 +} + func (o *GetWorkersOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersOK %s", 200, payload) +} + +func (o *GetWorkersOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersOK %s", 200, payload) } func (o *GetWorkersOK) GetPayload() *GetWorkersOKBody { @@ -96,20 +134,60 @@ func NewGetWorkersNotFound() *GetWorkersNotFound { return &GetWorkersNotFound{} } -/*GetWorkersNotFound handles this case with default header values. +/* +GetWorkersNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetWorkersNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get workers not found response has a 2xx status code +func (o *GetWorkersNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get workers not found response has a 3xx status code +func (o *GetWorkersNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get workers not found response has a 4xx status code +func (o *GetWorkersNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get workers not found response has a 5xx status code +func (o *GetWorkersNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get workers not found response a status code equal to that given +func (o *GetWorkersNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get workers not found response +func (o *GetWorkersNotFound) Code() int { + return 404 +} + func (o *GetWorkersNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersNotFound %s", 404, payload) +} + +func (o *GetWorkersNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersNotFound %s", 404, payload) } func (o *GetWorkersNotFound) GetPayload() *models.ErrorPayload { @@ -118,12 +196,16 @@ func (o *GetWorkersNotFound) GetPayload() *models.ErrorPayload { func (o *GetWorkersNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -140,20 +222,60 @@ func NewGetWorkersUnprocessableEntity() *GetWorkersUnprocessableEntity { return &GetWorkersUnprocessableEntity{} } -/*GetWorkersUnprocessableEntity handles this case with default header values. +/* +GetWorkersUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetWorkersUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get workers unprocessable entity response has a 2xx status code +func (o *GetWorkersUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get workers unprocessable entity response has a 3xx status code +func (o *GetWorkersUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get workers unprocessable entity response has a 4xx status code +func (o *GetWorkersUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get workers unprocessable entity response has a 5xx status code +func (o *GetWorkersUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get workers unprocessable entity response a status code equal to that given +func (o *GetWorkersUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get workers unprocessable entity response +func (o *GetWorkersUnprocessableEntity) Code() int { + return 422 +} + func (o *GetWorkersUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersUnprocessableEntity %s", 422, payload) +} + +func (o *GetWorkersUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkersUnprocessableEntity %s", 422, payload) } func (o *GetWorkersUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -162,12 +284,16 @@ func (o *GetWorkersUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetWorkersUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -186,27 +312,61 @@ func NewGetWorkersDefault(code int) *GetWorkersDefault { } } -/*GetWorkersDefault handles this case with default header values. +/* +GetWorkersDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetWorkersDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get workers default response has a 2xx status code +func (o *GetWorkersDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get workers default response has a 3xx status code +func (o *GetWorkersDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get workers default response has a 4xx status code +func (o *GetWorkersDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get workers default response has a 5xx status code +func (o *GetWorkersDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get workers default response a status code equal to that given +func (o *GetWorkersDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get workers default response func (o *GetWorkersDefault) Code() int { return o._statusCode } func (o *GetWorkersDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkers default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkers default %s", o._statusCode, payload) +} + +func (o *GetWorkersDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/workers][%d] getWorkers default %s", o._statusCode, payload) } func (o *GetWorkersDefault) GetPayload() *models.ErrorPayload { @@ -215,12 +375,16 @@ func (o *GetWorkersDefault) GetPayload() *models.ErrorPayload { func (o *GetWorkersDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -232,7 +396,8 @@ func (o *GetWorkersDefault) readResponse(response runtime.ClientResponse, consum return nil } -/*GetWorkersOKBody get workers o k body +/* +GetWorkersOKBody get workers o k body swagger:model GetWorkersOKBody */ type GetWorkersOKBody struct { @@ -279,6 +444,8 @@ func (o *GetWorkersOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getWorkersOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getWorkersOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -299,6 +466,68 @@ func (o *GetWorkersOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getWorkersOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getWorkersOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get workers o k body based on the context it is used +func (o *GetWorkersOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetWorkersOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getWorkersOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getWorkersOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetWorkersOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getWorkersOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getWorkersOK" + "." + "pagination") } return err } diff --git a/client/client/organization_workers/organization_workers_client.go b/client/client/organization_workers/organization_workers_client.go index 33255d86..1b05377f 100644 --- a/client/client/organization_workers/organization_workers_client.go +++ b/client/client/organization_workers/organization_workers_client.go @@ -7,15 +7,40 @@ package organization_workers import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organization workers API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organization workers API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organization workers API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organization workers API */ @@ -24,16 +49,74 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + GetWorkers(params *GetWorkersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetWorkersOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* GetWorkers Get the workers that the authenticated user has access to. */ -func (a *Client) GetWorkers(params *GetWorkersParams, authInfo runtime.ClientAuthInfoWriter) (*GetWorkersOK, error) { +func (a *Client) GetWorkers(params *GetWorkersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetWorkersOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetWorkersParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getWorkers", Method: "GET", PathPattern: "/organizations/{organization_canonical}/workers", @@ -45,7 +128,12 @@ func (a *Client) GetWorkers(params *GetWorkersParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organizations/can_do_parameters.go b/client/client/organizations/can_do_parameters.go index 72196763..466168ea 100644 --- a/client/client/organizations/can_do_parameters.go +++ b/client/client/organizations/can_do_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCanDoParams creates a new CanDoParams object -// with the default values initialized. +// NewCanDoParams creates a new CanDoParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCanDoParams() *CanDoParams { - var () return &CanDoParams{ - timeout: cr.DefaultTimeout, } } // NewCanDoParamsWithTimeout creates a new CanDoParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCanDoParamsWithTimeout(timeout time.Duration) *CanDoParams { - var () return &CanDoParams{ - timeout: timeout, } } // NewCanDoParamsWithContext creates a new CanDoParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCanDoParamsWithContext(ctx context.Context) *CanDoParams { - var () return &CanDoParams{ - Context: ctx, } } // NewCanDoParamsWithHTTPClient creates a new CanDoParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCanDoParamsWithHTTPClient(client *http.Client) *CanDoParams { - var () return &CanDoParams{ HTTPClient: client, } } -/*CanDoParams contains all the parameters to send to the API endpoint -for the can do operation typically these are written to a http.Request +/* +CanDoParams contains all the parameters to send to the API endpoint + + for the can do operation. + + Typically these are written to a http.Request. */ type CanDoParams struct { - /*Body - The information of the authorization + /* Body. + The information of the authorization */ Body *models.CanDoInput - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type CanDoParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the can do params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CanDoParams) WithDefaults() *CanDoParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the can do params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CanDoParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the can do params func (o *CanDoParams) WithTimeout(timeout time.Duration) *CanDoParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CanDoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registr return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organizations/can_do_responses.go b/client/client/organizations/can_do_responses.go index be55c667..facf0909 100644 --- a/client/client/organizations/can_do_responses.go +++ b/client/client/organizations/can_do_responses.go @@ -6,17 +6,18 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CanDoReader is a Reader for the CanDo structure. @@ -68,7 +69,8 @@ func NewCanDoOK() *CanDoOK { return &CanDoOK{} } -/*CanDoOK handles this case with default header values. +/* +CanDoOK describes a response with status code 200, with default header values. The information of the possibility to do the action */ @@ -76,8 +78,44 @@ type CanDoOK struct { Payload *CanDoOKBody } +// IsSuccess returns true when this can do o k response has a 2xx status code +func (o *CanDoOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this can do o k response has a 3xx status code +func (o *CanDoOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this can do o k response has a 4xx status code +func (o *CanDoOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this can do o k response has a 5xx status code +func (o *CanDoOK) IsServerError() bool { + return false +} + +// IsCode returns true when this can do o k response a status code equal to that given +func (o *CanDoOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the can do o k response +func (o *CanDoOK) Code() int { + return 200 +} + func (o *CanDoOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoOK %s", 200, payload) +} + +func (o *CanDoOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoOK %s", 200, payload) } func (o *CanDoOK) GetPayload() *CanDoOKBody { @@ -101,20 +139,60 @@ func NewCanDoForbidden() *CanDoForbidden { return &CanDoForbidden{} } -/*CanDoForbidden handles this case with default header values. +/* +CanDoForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CanDoForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this can do forbidden response has a 2xx status code +func (o *CanDoForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this can do forbidden response has a 3xx status code +func (o *CanDoForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this can do forbidden response has a 4xx status code +func (o *CanDoForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this can do forbidden response has a 5xx status code +func (o *CanDoForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this can do forbidden response a status code equal to that given +func (o *CanDoForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the can do forbidden response +func (o *CanDoForbidden) Code() int { + return 403 +} + func (o *CanDoForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoForbidden %s", 403, payload) +} + +func (o *CanDoForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoForbidden %s", 403, payload) } func (o *CanDoForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *CanDoForbidden) GetPayload() *models.ErrorPayload { func (o *CanDoForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewCanDoNotFound() *CanDoNotFound { return &CanDoNotFound{} } -/*CanDoNotFound handles this case with default header values. +/* +CanDoNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CanDoNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this can do not found response has a 2xx status code +func (o *CanDoNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this can do not found response has a 3xx status code +func (o *CanDoNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this can do not found response has a 4xx status code +func (o *CanDoNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this can do not found response has a 5xx status code +func (o *CanDoNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this can do not found response a status code equal to that given +func (o *CanDoNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the can do not found response +func (o *CanDoNotFound) Code() int { + return 404 +} + func (o *CanDoNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoNotFound %s", 404, payload) +} + +func (o *CanDoNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoNotFound %s", 404, payload) } func (o *CanDoNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *CanDoNotFound) GetPayload() *models.ErrorPayload { func (o *CanDoNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewCanDoUnprocessableEntity() *CanDoUnprocessableEntity { return &CanDoUnprocessableEntity{} } -/*CanDoUnprocessableEntity handles this case with default header values. +/* +CanDoUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CanDoUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this can do unprocessable entity response has a 2xx status code +func (o *CanDoUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this can do unprocessable entity response has a 3xx status code +func (o *CanDoUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this can do unprocessable entity response has a 4xx status code +func (o *CanDoUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this can do unprocessable entity response has a 5xx status code +func (o *CanDoUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this can do unprocessable entity response a status code equal to that given +func (o *CanDoUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the can do unprocessable entity response +func (o *CanDoUnprocessableEntity) Code() int { + return 422 +} + func (o *CanDoUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoUnprocessableEntity %s", 422, payload) +} + +func (o *CanDoUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDoUnprocessableEntity %s", 422, payload) } func (o *CanDoUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *CanDoUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *CanDoUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewCanDoDefault(code int) *CanDoDefault { } } -/*CanDoDefault handles this case with default header values. +/* +CanDoDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CanDoDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this can do default response has a 2xx status code +func (o *CanDoDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this can do default response has a 3xx status code +func (o *CanDoDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this can do default response has a 4xx status code +func (o *CanDoDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this can do default response has a 5xx status code +func (o *CanDoDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this can do default response a status code equal to that given +func (o *CanDoDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the can do default response func (o *CanDoDefault) Code() int { return o._statusCode } func (o *CanDoDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDo default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDo default %s", o._statusCode, payload) +} + +func (o *CanDoDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/can_do][%d] canDo default %s", o._statusCode, payload) } func (o *CanDoDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *CanDoDefault) GetPayload() *models.ErrorPayload { func (o *CanDoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *CanDoDefault) readResponse(response runtime.ClientResponse, consumer ru return nil } -/*CanDoOKBody can do o k body +/* +CanDoOKBody can do o k body swagger:model CanDoOKBody */ type CanDoOKBody struct { @@ -315,6 +524,39 @@ func (o *CanDoOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("canDoOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("canDoOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this can do o k body based on the context it is used +func (o *CanDoOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CanDoOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("canDoOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("canDoOK" + "." + "data") } return err } diff --git a/client/client/organizations/create_org_parameters.go b/client/client/organizations/create_org_parameters.go index 2141a539..44427450 100644 --- a/client/client/organizations/create_org_parameters.go +++ b/client/client/organizations/create_org_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateOrgParams creates a new CreateOrgParams object -// with the default values initialized. +// NewCreateOrgParams creates a new CreateOrgParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateOrgParams() *CreateOrgParams { - var () return &CreateOrgParams{ - timeout: cr.DefaultTimeout, } } // NewCreateOrgParamsWithTimeout creates a new CreateOrgParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateOrgParamsWithTimeout(timeout time.Duration) *CreateOrgParams { - var () return &CreateOrgParams{ - timeout: timeout, } } // NewCreateOrgParamsWithContext creates a new CreateOrgParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateOrgParamsWithContext(ctx context.Context) *CreateOrgParams { - var () return &CreateOrgParams{ - Context: ctx, } } // NewCreateOrgParamsWithHTTPClient creates a new CreateOrgParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateOrgParamsWithHTTPClient(client *http.Client) *CreateOrgParams { - var () return &CreateOrgParams{ HTTPClient: client, } } -/*CreateOrgParams contains all the parameters to send to the API endpoint -for the create org operation typically these are written to a http.Request +/* +CreateOrgParams contains all the parameters to send to the API endpoint + + for the create org operation. + + Typically these are written to a http.Request. */ type CreateOrgParams struct { - /*Body - The information of the organization to create. + /* Body. + The information of the organization to create. */ Body *models.NewOrganization @@ -74,6 +74,21 @@ type CreateOrgParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateOrgParams) WithDefaults() *CreateOrgParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateOrgParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create org params func (o *CreateOrgParams) WithTimeout(timeout time.Duration) *CreateOrgParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *CreateOrgParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organizations/create_org_responses.go b/client/client/organizations/create_org_responses.go index 4713596c..ed04860c 100644 --- a/client/client/organizations/create_org_responses.go +++ b/client/client/organizations/create_org_responses.go @@ -6,17 +6,18 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateOrgReader is a Reader for the CreateOrg structure. @@ -62,7 +63,8 @@ func NewCreateOrgOK() *CreateOrgOK { return &CreateOrgOK{} } -/*CreateOrgOK handles this case with default header values. +/* +CreateOrgOK describes a response with status code 200, with default header values. Organization created. The body contains the information of the new created organization. */ @@ -70,8 +72,44 @@ type CreateOrgOK struct { Payload *CreateOrgOKBody } +// IsSuccess returns true when this create org o k response has a 2xx status code +func (o *CreateOrgOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create org o k response has a 3xx status code +func (o *CreateOrgOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create org o k response has a 4xx status code +func (o *CreateOrgOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create org o k response has a 5xx status code +func (o *CreateOrgOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create org o k response a status code equal to that given +func (o *CreateOrgOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create org o k response +func (o *CreateOrgOK) Code() int { + return 200 +} + func (o *CreateOrgOK) Error() string { - return fmt.Sprintf("[POST /organizations][%d] createOrgOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations][%d] createOrgOK %s", 200, payload) +} + +func (o *CreateOrgOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations][%d] createOrgOK %s", 200, payload) } func (o *CreateOrgOK) GetPayload() *CreateOrgOKBody { @@ -95,15 +133,50 @@ func NewCreateOrgLengthRequired() *CreateOrgLengthRequired { return &CreateOrgLengthRequired{} } -/*CreateOrgLengthRequired handles this case with default header values. +/* +CreateOrgLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type CreateOrgLengthRequired struct { } +// IsSuccess returns true when this create org length required response has a 2xx status code +func (o *CreateOrgLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create org length required response has a 3xx status code +func (o *CreateOrgLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create org length required response has a 4xx status code +func (o *CreateOrgLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this create org length required response has a 5xx status code +func (o *CreateOrgLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this create org length required response a status code equal to that given +func (o *CreateOrgLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the create org length required response +func (o *CreateOrgLengthRequired) Code() int { + return 411 +} + func (o *CreateOrgLengthRequired) Error() string { - return fmt.Sprintf("[POST /organizations][%d] createOrgLengthRequired ", 411) + return fmt.Sprintf("[POST /organizations][%d] createOrgLengthRequired", 411) +} + +func (o *CreateOrgLengthRequired) String() string { + return fmt.Sprintf("[POST /organizations][%d] createOrgLengthRequired", 411) } func (o *CreateOrgLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -116,20 +189,60 @@ func NewCreateOrgUnprocessableEntity() *CreateOrgUnprocessableEntity { return &CreateOrgUnprocessableEntity{} } -/*CreateOrgUnprocessableEntity handles this case with default header values. +/* +CreateOrgUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateOrgUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create org unprocessable entity response has a 2xx status code +func (o *CreateOrgUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create org unprocessable entity response has a 3xx status code +func (o *CreateOrgUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create org unprocessable entity response has a 4xx status code +func (o *CreateOrgUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create org unprocessable entity response has a 5xx status code +func (o *CreateOrgUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create org unprocessable entity response a status code equal to that given +func (o *CreateOrgUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create org unprocessable entity response +func (o *CreateOrgUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateOrgUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations][%d] createOrgUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations][%d] createOrgUnprocessableEntity %s", 422, payload) +} + +func (o *CreateOrgUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations][%d] createOrgUnprocessableEntity %s", 422, payload) } func (o *CreateOrgUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -138,12 +251,16 @@ func (o *CreateOrgUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *CreateOrgUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -162,27 +279,61 @@ func NewCreateOrgDefault(code int) *CreateOrgDefault { } } -/*CreateOrgDefault handles this case with default header values. +/* +CreateOrgDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateOrgDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create org default response has a 2xx status code +func (o *CreateOrgDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create org default response has a 3xx status code +func (o *CreateOrgDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create org default response has a 4xx status code +func (o *CreateOrgDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create org default response has a 5xx status code +func (o *CreateOrgDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create org default response a status code equal to that given +func (o *CreateOrgDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create org default response func (o *CreateOrgDefault) Code() int { return o._statusCode } func (o *CreateOrgDefault) Error() string { - return fmt.Sprintf("[POST /organizations][%d] createOrg default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations][%d] createOrg default %s", o._statusCode, payload) +} + +func (o *CreateOrgDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations][%d] createOrg default %s", o._statusCode, payload) } func (o *CreateOrgDefault) GetPayload() *models.ErrorPayload { @@ -191,12 +342,16 @@ func (o *CreateOrgDefault) GetPayload() *models.ErrorPayload { func (o *CreateOrgDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -208,7 +363,8 @@ func (o *CreateOrgDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*CreateOrgOKBody create org o k body +/* +CreateOrgOKBody create org o k body swagger:model CreateOrgOKBody */ type CreateOrgOKBody struct { @@ -242,6 +398,39 @@ func (o *CreateOrgOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createOrgOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createOrgOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create org o k body based on the context it is used +func (o *CreateOrgOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateOrgOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createOrgOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createOrgOK" + "." + "data") } return err } diff --git a/client/client/organizations/delete_org_parameters.go b/client/client/organizations/delete_org_parameters.go index 10c0e218..82b35635 100644 --- a/client/client/organizations/delete_org_parameters.go +++ b/client/client/organizations/delete_org_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteOrgParams creates a new DeleteOrgParams object -// with the default values initialized. +// NewDeleteOrgParams creates a new DeleteOrgParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteOrgParams() *DeleteOrgParams { - var () return &DeleteOrgParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteOrgParamsWithTimeout creates a new DeleteOrgParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteOrgParamsWithTimeout(timeout time.Duration) *DeleteOrgParams { - var () return &DeleteOrgParams{ - timeout: timeout, } } // NewDeleteOrgParamsWithContext creates a new DeleteOrgParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteOrgParamsWithContext(ctx context.Context) *DeleteOrgParams { - var () return &DeleteOrgParams{ - Context: ctx, } } // NewDeleteOrgParamsWithHTTPClient creates a new DeleteOrgParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteOrgParamsWithHTTPClient(client *http.Client) *DeleteOrgParams { - var () return &DeleteOrgParams{ HTTPClient: client, } } -/*DeleteOrgParams contains all the parameters to send to the API endpoint -for the delete org operation typically these are written to a http.Request +/* +DeleteOrgParams contains all the parameters to send to the API endpoint + + for the delete org operation. + + Typically these are written to a http.Request. */ type DeleteOrgParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string @@ -72,6 +72,21 @@ type DeleteOrgParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteOrgParams) WithDefaults() *DeleteOrgParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteOrgParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete org params func (o *DeleteOrgParams) WithTimeout(timeout time.Duration) *DeleteOrgParams { o.SetTimeout(timeout) diff --git a/client/client/organizations/delete_org_responses.go b/client/client/organizations/delete_org_responses.go index b90caa2f..7d9ee36f 100644 --- a/client/client/organizations/delete_org_responses.go +++ b/client/client/organizations/delete_org_responses.go @@ -6,16 +6,16 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteOrgReader is a Reader for the DeleteOrg structure. @@ -61,15 +61,50 @@ func NewDeleteOrgNoContent() *DeleteOrgNoContent { return &DeleteOrgNoContent{} } -/*DeleteOrgNoContent handles this case with default header values. +/* +DeleteOrgNoContent describes a response with status code 204, with default header values. Organization has been deleted. */ type DeleteOrgNoContent struct { } +// IsSuccess returns true when this delete org no content response has a 2xx status code +func (o *DeleteOrgNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete org no content response has a 3xx status code +func (o *DeleteOrgNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete org no content response has a 4xx status code +func (o *DeleteOrgNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete org no content response has a 5xx status code +func (o *DeleteOrgNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete org no content response a status code equal to that given +func (o *DeleteOrgNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete org no content response +func (o *DeleteOrgNoContent) Code() int { + return 204 +} + func (o *DeleteOrgNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgNoContent", 204) +} + +func (o *DeleteOrgNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgNoContent", 204) } func (o *DeleteOrgNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewDeleteOrgForbidden() *DeleteOrgForbidden { return &DeleteOrgForbidden{} } -/*DeleteOrgForbidden handles this case with default header values. +/* +DeleteOrgForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteOrgForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete org forbidden response has a 2xx status code +func (o *DeleteOrgForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete org forbidden response has a 3xx status code +func (o *DeleteOrgForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete org forbidden response has a 4xx status code +func (o *DeleteOrgForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete org forbidden response has a 5xx status code +func (o *DeleteOrgForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete org forbidden response a status code equal to that given +func (o *DeleteOrgForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete org forbidden response +func (o *DeleteOrgForbidden) Code() int { + return 403 +} + func (o *DeleteOrgForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgForbidden %s", 403, payload) +} + +func (o *DeleteOrgForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgForbidden %s", 403, payload) } func (o *DeleteOrgForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *DeleteOrgForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteOrgForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewDeleteOrgNotFound() *DeleteOrgNotFound { return &DeleteOrgNotFound{} } -/*DeleteOrgNotFound handles this case with default header values. +/* +DeleteOrgNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteOrgNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete org not found response has a 2xx status code +func (o *DeleteOrgNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete org not found response has a 3xx status code +func (o *DeleteOrgNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete org not found response has a 4xx status code +func (o *DeleteOrgNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete org not found response has a 5xx status code +func (o *DeleteOrgNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete org not found response a status code equal to that given +func (o *DeleteOrgNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete org not found response +func (o *DeleteOrgNotFound) Code() int { + return 404 +} + func (o *DeleteOrgNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgNotFound %s", 404, payload) +} + +func (o *DeleteOrgNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrgNotFound %s", 404, payload) } func (o *DeleteOrgNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *DeleteOrgNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteOrgNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewDeleteOrgDefault(code int) *DeleteOrgDefault { } } -/*DeleteOrgDefault handles this case with default header values. +/* +DeleteOrgDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteOrgDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete org default response has a 2xx status code +func (o *DeleteOrgDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete org default response has a 3xx status code +func (o *DeleteOrgDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete org default response has a 4xx status code +func (o *DeleteOrgDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete org default response has a 5xx status code +func (o *DeleteOrgDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete org default response a status code equal to that given +func (o *DeleteOrgDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete org default response func (o *DeleteOrgDefault) Code() int { return o._statusCode } func (o *DeleteOrgDefault) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrg default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrg default %s", o._statusCode, payload) +} + +func (o *DeleteOrgDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}][%d] deleteOrg default %s", o._statusCode, payload) } func (o *DeleteOrgDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *DeleteOrgDefault) GetPayload() *models.ErrorPayload { func (o *DeleteOrgDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/organizations/get_ancestors_parameters.go b/client/client/organizations/get_ancestors_parameters.go index 8a5c0a0f..4d39830a 100644 --- a/client/client/organizations/get_ancestors_parameters.go +++ b/client/client/organizations/get_ancestors_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetAncestorsParams creates a new GetAncestorsParams object -// with the default values initialized. +// NewGetAncestorsParams creates a new GetAncestorsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetAncestorsParams() *GetAncestorsParams { - var () return &GetAncestorsParams{ - timeout: cr.DefaultTimeout, } } // NewGetAncestorsParamsWithTimeout creates a new GetAncestorsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetAncestorsParamsWithTimeout(timeout time.Duration) *GetAncestorsParams { - var () return &GetAncestorsParams{ - timeout: timeout, } } // NewGetAncestorsParamsWithContext creates a new GetAncestorsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetAncestorsParamsWithContext(ctx context.Context) *GetAncestorsParams { - var () return &GetAncestorsParams{ - Context: ctx, } } // NewGetAncestorsParamsWithHTTPClient creates a new GetAncestorsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetAncestorsParamsWithHTTPClient(client *http.Client) *GetAncestorsParams { - var () return &GetAncestorsParams{ HTTPClient: client, } } -/*GetAncestorsParams contains all the parameters to send to the API endpoint -for the get ancestors operation typically these are written to a http.Request +/* +GetAncestorsParams contains all the parameters to send to the API endpoint + + for the get ancestors operation. + + Typically these are written to a http.Request. */ type GetAncestorsParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string @@ -72,6 +72,21 @@ type GetAncestorsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get ancestors params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAncestorsParams) WithDefaults() *GetAncestorsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get ancestors params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAncestorsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get ancestors params func (o *GetAncestorsParams) WithTimeout(timeout time.Duration) *GetAncestorsParams { o.SetTimeout(timeout) diff --git a/client/client/organizations/get_ancestors_responses.go b/client/client/organizations/get_ancestors_responses.go index 327e02ea..92b54c70 100644 --- a/client/client/organizations/get_ancestors_responses.go +++ b/client/client/organizations/get_ancestors_responses.go @@ -6,18 +6,19 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetAncestorsReader is a Reader for the GetAncestors structure. @@ -57,7 +58,8 @@ func NewGetAncestorsOK() *GetAncestorsOK { return &GetAncestorsOK{} } -/*GetAncestorsOK handles this case with default header values. +/* +GetAncestorsOK describes a response with status code 200, with default header values. Get all the ancestors between the Organization and the User with the shortest path. 0 index is the parent and n is the searched child */ @@ -65,8 +67,44 @@ type GetAncestorsOK struct { Payload *GetAncestorsOKBody } +// IsSuccess returns true when this get ancestors o k response has a 2xx status code +func (o *GetAncestorsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get ancestors o k response has a 3xx status code +func (o *GetAncestorsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get ancestors o k response has a 4xx status code +func (o *GetAncestorsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get ancestors o k response has a 5xx status code +func (o *GetAncestorsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get ancestors o k response a status code equal to that given +func (o *GetAncestorsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get ancestors o k response +func (o *GetAncestorsOK) Code() int { + return 200 +} + func (o *GetAncestorsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestorsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestorsOK %s", 200, payload) +} + +func (o *GetAncestorsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestorsOK %s", 200, payload) } func (o *GetAncestorsOK) GetPayload() *GetAncestorsOKBody { @@ -90,20 +128,60 @@ func NewGetAncestorsUnauthorized() *GetAncestorsUnauthorized { return &GetAncestorsUnauthorized{} } -/*GetAncestorsUnauthorized handles this case with default header values. +/* +GetAncestorsUnauthorized describes a response with status code 401, with default header values. The user cannot be authenticated with the credentials which she/he has used. */ type GetAncestorsUnauthorized struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get ancestors unauthorized response has a 2xx status code +func (o *GetAncestorsUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get ancestors unauthorized response has a 3xx status code +func (o *GetAncestorsUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get ancestors unauthorized response has a 4xx status code +func (o *GetAncestorsUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get ancestors unauthorized response has a 5xx status code +func (o *GetAncestorsUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get ancestors unauthorized response a status code equal to that given +func (o *GetAncestorsUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get ancestors unauthorized response +func (o *GetAncestorsUnauthorized) Code() int { + return 401 +} + func (o *GetAncestorsUnauthorized) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestorsUnauthorized %+v", 401, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestorsUnauthorized %s", 401, payload) +} + +func (o *GetAncestorsUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestorsUnauthorized %s", 401, payload) } func (o *GetAncestorsUnauthorized) GetPayload() *models.ErrorPayload { @@ -112,12 +190,16 @@ func (o *GetAncestorsUnauthorized) GetPayload() *models.ErrorPayload { func (o *GetAncestorsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -136,27 +218,61 @@ func NewGetAncestorsDefault(code int) *GetAncestorsDefault { } } -/*GetAncestorsDefault handles this case with default header values. +/* +GetAncestorsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetAncestorsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get ancestors default response has a 2xx status code +func (o *GetAncestorsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get ancestors default response has a 3xx status code +func (o *GetAncestorsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get ancestors default response has a 4xx status code +func (o *GetAncestorsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get ancestors default response has a 5xx status code +func (o *GetAncestorsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get ancestors default response a status code equal to that given +func (o *GetAncestorsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get ancestors default response func (o *GetAncestorsDefault) Code() int { return o._statusCode } func (o *GetAncestorsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestors default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestors default %s", o._statusCode, payload) +} + +func (o *GetAncestorsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/ancestors][%d] getAncestors default %s", o._statusCode, payload) } func (o *GetAncestorsDefault) GetPayload() *models.ErrorPayload { @@ -165,12 +281,16 @@ func (o *GetAncestorsDefault) GetPayload() *models.ErrorPayload { func (o *GetAncestorsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -182,7 +302,8 @@ func (o *GetAncestorsDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*GetAncestorsOKBody get ancestors o k body +/* +GetAncestorsOKBody get ancestors o k body swagger:model GetAncestorsOKBody */ type GetAncestorsOKBody struct { @@ -229,6 +350,8 @@ func (o *GetAncestorsOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getAncestorsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getAncestorsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -249,6 +372,68 @@ func (o *GetAncestorsOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getAncestorsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getAncestorsOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get ancestors o k body based on the context it is used +func (o *GetAncestorsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetAncestorsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getAncestorsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getAncestorsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetAncestorsOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getAncestorsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getAncestorsOK" + "." + "pagination") } return err } diff --git a/client/client/organizations/get_events_parameters.go b/client/client/organizations/get_events_parameters.go index f6171b5b..f77b4af0 100644 --- a/client/client/organizations/get_events_parameters.go +++ b/client/client/organizations/get_events_parameters.go @@ -13,78 +13,86 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetEventsParams creates a new GetEventsParams object -// with the default values initialized. +// NewGetEventsParams creates a new GetEventsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetEventsParams() *GetEventsParams { - var () return &GetEventsParams{ - timeout: cr.DefaultTimeout, } } // NewGetEventsParamsWithTimeout creates a new GetEventsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetEventsParamsWithTimeout(timeout time.Duration) *GetEventsParams { - var () return &GetEventsParams{ - timeout: timeout, } } // NewGetEventsParamsWithContext creates a new GetEventsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetEventsParamsWithContext(ctx context.Context) *GetEventsParams { - var () return &GetEventsParams{ - Context: ctx, } } // NewGetEventsParamsWithHTTPClient creates a new GetEventsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetEventsParamsWithHTTPClient(client *http.Client) *GetEventsParams { - var () return &GetEventsParams{ HTTPClient: client, } } -/*GetEventsParams contains all the parameters to send to the API endpoint -for the get events operation typically these are written to a http.Request +/* +GetEventsParams contains all the parameters to send to the API endpoint + + for the get events operation. + + Typically these are written to a http.Request. */ type GetEventsParams struct { - /*Begin - The unix timestamp in milliseconds, which indicate the start of the time range. + /* Begin. + The unix timestamp in milliseconds, which indicate the start of the time range. + + Format: uint64 */ Begin *uint64 - /*End - The unix timestamp in milliseconds, which indicate the end of the time range. + /* End. + + The unix timestamp in milliseconds, which indicate the end of the time range. + + Format: uint64 */ End *uint64 - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*Severity - Specify the severities of the events to be requested. The returned events must have one of the specified severities. + /* Severity. + + Specify the severities of the events to be requested. The returned events must have one of the specified severities. */ Severity []string - /*Type - Specify the types of the events to be requested. The returned events must have one of the specified types. + /* Type. + + Specify the types of the events to be requested. The returned events must have one of the specified types. */ Type []string @@ -93,6 +101,21 @@ type GetEventsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get events params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetEventsParams) WithDefaults() *GetEventsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get events params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetEventsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get events params func (o *GetEventsParams) WithTimeout(timeout time.Duration) *GetEventsParams { o.SetTimeout(timeout) @@ -193,32 +216,34 @@ func (o *GetEventsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg // query param begin var qrBegin uint64 + if o.Begin != nil { qrBegin = *o.Begin } qBegin := swag.FormatUint64(qrBegin) if qBegin != "" { + if err := r.SetQueryParam("begin", qBegin); err != nil { return err } } - } if o.End != nil { // query param end var qrEnd uint64 + if o.End != nil { qrEnd = *o.End } qEnd := swag.FormatUint64(qrEnd) if qEnd != "" { + if err := r.SetQueryParam("end", qEnd); err != nil { return err } } - } // path param organization_canonical @@ -226,20 +251,26 @@ func (o *GetEventsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg return err } - valuesSeverity := o.Severity + if o.Severity != nil { - joinedSeverity := swag.JoinByFormat(valuesSeverity, "multi") - // query array param severity - if err := r.SetQueryParam("severity", joinedSeverity...); err != nil { - return err + // binding items for severity + joinedSeverity := o.bindParamSeverity(reg) + + // query array param severity + if err := r.SetQueryParam("severity", joinedSeverity...); err != nil { + return err + } } - valuesType := o.Type + if o.Type != nil { - joinedType := swag.JoinByFormat(valuesType, "multi") - // query array param type - if err := r.SetQueryParam("type", joinedType...); err != nil { - return err + // binding items for type + joinedType := o.bindParamType(reg) + + // query array param type + if err := r.SetQueryParam("type", joinedType...); err != nil { + return err + } } if len(res) > 0 { @@ -247,3 +278,37 @@ func (o *GetEventsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg } return nil } + +// bindParamGetEvents binds the parameter severity +func (o *GetEventsParams) bindParamSeverity(formats strfmt.Registry) []string { + severityIR := o.Severity + + var severityIC []string + for _, severityIIR := range severityIR { // explode []string + + severityIIV := severityIIR // string as string + severityIC = append(severityIC, severityIIV) + } + + // items.CollectionFormat: "multi" + severityIS := swag.JoinByFormat(severityIC, "multi") + + return severityIS +} + +// bindParamGetEvents binds the parameter type +func (o *GetEventsParams) bindParamType(formats strfmt.Registry) []string { + typeIR := o.Type + + var typeIC []string + for _, typeIIR := range typeIR { // explode []string + + typeIIV := typeIIR // string as string + typeIC = append(typeIC, typeIIV) + } + + // items.CollectionFormat: "multi" + typeIS := swag.JoinByFormat(typeIC, "multi") + + return typeIS +} diff --git a/client/client/organizations/get_events_responses.go b/client/client/organizations/get_events_responses.go index 4889ff57..5803a539 100644 --- a/client/client/organizations/get_events_responses.go +++ b/client/client/organizations/get_events_responses.go @@ -6,18 +6,19 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetEventsReader is a Reader for the GetEvents structure. @@ -69,7 +70,8 @@ func NewGetEventsOK() *GetEventsOK { return &GetEventsOK{} } -/*GetEventsOK handles this case with default header values. +/* +GetEventsOK describes a response with status code 200, with default header values. The list of events which fulfills the query parameters filter */ @@ -77,8 +79,44 @@ type GetEventsOK struct { Payload *GetEventsOKBody } +// IsSuccess returns true when this get events o k response has a 2xx status code +func (o *GetEventsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get events o k response has a 3xx status code +func (o *GetEventsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get events o k response has a 4xx status code +func (o *GetEventsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get events o k response has a 5xx status code +func (o *GetEventsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get events o k response a status code equal to that given +func (o *GetEventsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get events o k response +func (o *GetEventsOK) Code() int { + return 200 +} + func (o *GetEventsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsOK %s", 200, payload) +} + +func (o *GetEventsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsOK %s", 200, payload) } func (o *GetEventsOK) GetPayload() *GetEventsOKBody { @@ -102,20 +140,60 @@ func NewGetEventsForbidden() *GetEventsForbidden { return &GetEventsForbidden{} } -/*GetEventsForbidden handles this case with default header values. +/* +GetEventsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetEventsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get events forbidden response has a 2xx status code +func (o *GetEventsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get events forbidden response has a 3xx status code +func (o *GetEventsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get events forbidden response has a 4xx status code +func (o *GetEventsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get events forbidden response has a 5xx status code +func (o *GetEventsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get events forbidden response a status code equal to that given +func (o *GetEventsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get events forbidden response +func (o *GetEventsForbidden) Code() int { + return 403 +} + func (o *GetEventsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsForbidden %s", 403, payload) +} + +func (o *GetEventsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsForbidden %s", 403, payload) } func (o *GetEventsForbidden) GetPayload() *models.ErrorPayload { @@ -124,12 +202,16 @@ func (o *GetEventsForbidden) GetPayload() *models.ErrorPayload { func (o *GetEventsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -146,20 +228,60 @@ func NewGetEventsNotFound() *GetEventsNotFound { return &GetEventsNotFound{} } -/*GetEventsNotFound handles this case with default header values. +/* +GetEventsNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetEventsNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get events not found response has a 2xx status code +func (o *GetEventsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get events not found response has a 3xx status code +func (o *GetEventsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get events not found response has a 4xx status code +func (o *GetEventsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get events not found response has a 5xx status code +func (o *GetEventsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get events not found response a status code equal to that given +func (o *GetEventsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get events not found response +func (o *GetEventsNotFound) Code() int { + return 404 +} + func (o *GetEventsNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsNotFound %s", 404, payload) +} + +func (o *GetEventsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsNotFound %s", 404, payload) } func (o *GetEventsNotFound) GetPayload() *models.ErrorPayload { @@ -168,12 +290,16 @@ func (o *GetEventsNotFound) GetPayload() *models.ErrorPayload { func (o *GetEventsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -190,20 +316,60 @@ func NewGetEventsUnprocessableEntity() *GetEventsUnprocessableEntity { return &GetEventsUnprocessableEntity{} } -/*GetEventsUnprocessableEntity handles this case with default header values. +/* +GetEventsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetEventsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get events unprocessable entity response has a 2xx status code +func (o *GetEventsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get events unprocessable entity response has a 3xx status code +func (o *GetEventsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get events unprocessable entity response has a 4xx status code +func (o *GetEventsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get events unprocessable entity response has a 5xx status code +func (o *GetEventsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get events unprocessable entity response a status code equal to that given +func (o *GetEventsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get events unprocessable entity response +func (o *GetEventsUnprocessableEntity) Code() int { + return 422 +} + func (o *GetEventsUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsUnprocessableEntity %s", 422, payload) +} + +func (o *GetEventsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEventsUnprocessableEntity %s", 422, payload) } func (o *GetEventsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -212,12 +378,16 @@ func (o *GetEventsUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetEventsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -236,27 +406,61 @@ func NewGetEventsDefault(code int) *GetEventsDefault { } } -/*GetEventsDefault handles this case with default header values. +/* +GetEventsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetEventsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get events default response has a 2xx status code +func (o *GetEventsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get events default response has a 3xx status code +func (o *GetEventsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get events default response has a 4xx status code +func (o *GetEventsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get events default response has a 5xx status code +func (o *GetEventsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get events default response a status code equal to that given +func (o *GetEventsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get events default response func (o *GetEventsDefault) Code() int { return o._statusCode } func (o *GetEventsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEvents default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEvents default %s", o._statusCode, payload) +} + +func (o *GetEventsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events][%d] getEvents default %s", o._statusCode, payload) } func (o *GetEventsDefault) GetPayload() *models.ErrorPayload { @@ -265,12 +469,16 @@ func (o *GetEventsDefault) GetPayload() *models.ErrorPayload { func (o *GetEventsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -282,7 +490,8 @@ func (o *GetEventsDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*GetEventsOKBody The list of log lines +/* +GetEventsOKBody The list of log lines swagger:model GetEventsOKBody */ type GetEventsOKBody struct { @@ -321,6 +530,47 @@ func (o *GetEventsOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getEventsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getEventsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this get events o k body based on the context it is used +func (o *GetEventsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetEventsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getEventsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getEventsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } diff --git a/client/client/organizations/get_events_tags_parameters.go b/client/client/organizations/get_events_tags_parameters.go index 5a09fd74..eb9faf23 100644 --- a/client/client/organizations/get_events_tags_parameters.go +++ b/client/client/organizations/get_events_tags_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetEventsTagsParams creates a new GetEventsTagsParams object -// with the default values initialized. +// NewGetEventsTagsParams creates a new GetEventsTagsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetEventsTagsParams() *GetEventsTagsParams { - var () return &GetEventsTagsParams{ - timeout: cr.DefaultTimeout, } } // NewGetEventsTagsParamsWithTimeout creates a new GetEventsTagsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetEventsTagsParamsWithTimeout(timeout time.Duration) *GetEventsTagsParams { - var () return &GetEventsTagsParams{ - timeout: timeout, } } // NewGetEventsTagsParamsWithContext creates a new GetEventsTagsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetEventsTagsParamsWithContext(ctx context.Context) *GetEventsTagsParams { - var () return &GetEventsTagsParams{ - Context: ctx, } } // NewGetEventsTagsParamsWithHTTPClient creates a new GetEventsTagsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetEventsTagsParamsWithHTTPClient(client *http.Client) *GetEventsTagsParams { - var () return &GetEventsTagsParams{ HTTPClient: client, } } -/*GetEventsTagsParams contains all the parameters to send to the API endpoint -for the get events tags operation typically these are written to a http.Request +/* +GetEventsTagsParams contains all the parameters to send to the API endpoint + + for the get events tags operation. + + Typically these are written to a http.Request. */ type GetEventsTagsParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string @@ -72,6 +72,21 @@ type GetEventsTagsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get events tags params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetEventsTagsParams) WithDefaults() *GetEventsTagsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get events tags params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetEventsTagsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get events tags params func (o *GetEventsTagsParams) WithTimeout(timeout time.Duration) *GetEventsTagsParams { o.SetTimeout(timeout) diff --git a/client/client/organizations/get_events_tags_responses.go b/client/client/organizations/get_events_tags_responses.go index 62225105..3117f601 100644 --- a/client/client/organizations/get_events_tags_responses.go +++ b/client/client/organizations/get_events_tags_responses.go @@ -6,17 +6,17 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetEventsTagsReader is a Reader for the GetEventsTags structure. @@ -62,7 +62,8 @@ func NewGetEventsTagsOK() *GetEventsTagsOK { return &GetEventsTagsOK{} } -/*GetEventsTagsOK handles this case with default header values. +/* +GetEventsTagsOK describes a response with status code 200, with default header values. The list of tags and set of values for all the events of the organization. */ @@ -70,8 +71,44 @@ type GetEventsTagsOK struct { Payload *GetEventsTagsOKBody } +// IsSuccess returns true when this get events tags o k response has a 2xx status code +func (o *GetEventsTagsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get events tags o k response has a 3xx status code +func (o *GetEventsTagsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get events tags o k response has a 4xx status code +func (o *GetEventsTagsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get events tags o k response has a 5xx status code +func (o *GetEventsTagsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get events tags o k response a status code equal to that given +func (o *GetEventsTagsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get events tags o k response +func (o *GetEventsTagsOK) Code() int { + return 200 +} + func (o *GetEventsTagsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsOK %s", 200, payload) +} + +func (o *GetEventsTagsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsOK %s", 200, payload) } func (o *GetEventsTagsOK) GetPayload() *GetEventsTagsOKBody { @@ -95,20 +132,60 @@ func NewGetEventsTagsForbidden() *GetEventsTagsForbidden { return &GetEventsTagsForbidden{} } -/*GetEventsTagsForbidden handles this case with default header values. +/* +GetEventsTagsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetEventsTagsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get events tags forbidden response has a 2xx status code +func (o *GetEventsTagsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get events tags forbidden response has a 3xx status code +func (o *GetEventsTagsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get events tags forbidden response has a 4xx status code +func (o *GetEventsTagsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get events tags forbidden response has a 5xx status code +func (o *GetEventsTagsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get events tags forbidden response a status code equal to that given +func (o *GetEventsTagsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get events tags forbidden response +func (o *GetEventsTagsForbidden) Code() int { + return 403 +} + func (o *GetEventsTagsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsForbidden %s", 403, payload) +} + +func (o *GetEventsTagsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsForbidden %s", 403, payload) } func (o *GetEventsTagsForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +194,16 @@ func (o *GetEventsTagsForbidden) GetPayload() *models.ErrorPayload { func (o *GetEventsTagsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +220,60 @@ func NewGetEventsTagsUnprocessableEntity() *GetEventsTagsUnprocessableEntity { return &GetEventsTagsUnprocessableEntity{} } -/*GetEventsTagsUnprocessableEntity handles this case with default header values. +/* +GetEventsTagsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetEventsTagsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get events tags unprocessable entity response has a 2xx status code +func (o *GetEventsTagsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get events tags unprocessable entity response has a 3xx status code +func (o *GetEventsTagsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get events tags unprocessable entity response has a 4xx status code +func (o *GetEventsTagsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get events tags unprocessable entity response has a 5xx status code +func (o *GetEventsTagsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get events tags unprocessable entity response a status code equal to that given +func (o *GetEventsTagsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get events tags unprocessable entity response +func (o *GetEventsTagsUnprocessableEntity) Code() int { + return 422 +} + func (o *GetEventsTagsUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsUnprocessableEntity %s", 422, payload) +} + +func (o *GetEventsTagsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTagsUnprocessableEntity %s", 422, payload) } func (o *GetEventsTagsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +282,16 @@ func (o *GetEventsTagsUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetEventsTagsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +310,61 @@ func NewGetEventsTagsDefault(code int) *GetEventsTagsDefault { } } -/*GetEventsTagsDefault handles this case with default header values. +/* +GetEventsTagsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetEventsTagsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get events tags default response has a 2xx status code +func (o *GetEventsTagsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get events tags default response has a 3xx status code +func (o *GetEventsTagsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get events tags default response has a 4xx status code +func (o *GetEventsTagsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get events tags default response has a 5xx status code +func (o *GetEventsTagsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get events tags default response a status code equal to that given +func (o *GetEventsTagsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get events tags default response func (o *GetEventsTagsDefault) Code() int { return o._statusCode } func (o *GetEventsTagsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTags default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTags default %s", o._statusCode, payload) +} + +func (o *GetEventsTagsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/events/tags][%d] getEventsTags default %s", o._statusCode, payload) } func (o *GetEventsTagsDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +373,16 @@ func (o *GetEventsTagsDefault) GetPayload() *models.ErrorPayload { func (o *GetEventsTagsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +394,8 @@ func (o *GetEventsTagsDefault) readResponse(response runtime.ClientResponse, con return nil } -/*GetEventsTagsOKBody The list of tags with associated set of values +/* +GetEventsTagsOKBody The list of tags with associated set of values swagger:model GetEventsTagsOKBody */ type GetEventsTagsOKBody struct { @@ -257,13 +421,18 @@ func (o *GetEventsTagsOKBody) Validate(formats strfmt.Registry) error { func (o *GetEventsTagsOKBody) validateData(formats strfmt.Registry) error { - if err := validate.Required("getEventsTagsOK"+"."+"data", "body", o.Data); err != nil { - return err + if o.Data == nil { + return errors.Required("getEventsTagsOK"+"."+"data", "body", nil) } return nil } +// ContextValidate validates this get events tags o k body based on context it is used +func (o *GetEventsTagsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *GetEventsTagsOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/organizations/get_org_parameters.go b/client/client/organizations/get_org_parameters.go index c117ba2c..923688f7 100644 --- a/client/client/organizations/get_org_parameters.go +++ b/client/client/organizations/get_org_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetOrgParams creates a new GetOrgParams object -// with the default values initialized. +// NewGetOrgParams creates a new GetOrgParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetOrgParams() *GetOrgParams { - var () return &GetOrgParams{ - timeout: cr.DefaultTimeout, } } // NewGetOrgParamsWithTimeout creates a new GetOrgParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetOrgParamsWithTimeout(timeout time.Duration) *GetOrgParams { - var () return &GetOrgParams{ - timeout: timeout, } } // NewGetOrgParamsWithContext creates a new GetOrgParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetOrgParamsWithContext(ctx context.Context) *GetOrgParams { - var () return &GetOrgParams{ - Context: ctx, } } // NewGetOrgParamsWithHTTPClient creates a new GetOrgParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetOrgParamsWithHTTPClient(client *http.Client) *GetOrgParams { - var () return &GetOrgParams{ HTTPClient: client, } } -/*GetOrgParams contains all the parameters to send to the API endpoint -for the get org operation typically these are written to a http.Request +/* +GetOrgParams contains all the parameters to send to the API endpoint + + for the get org operation. + + Typically these are written to a http.Request. */ type GetOrgParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string @@ -72,6 +72,21 @@ type GetOrgParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgParams) WithDefaults() *GetOrgParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get org params func (o *GetOrgParams) WithTimeout(timeout time.Duration) *GetOrgParams { o.SetTimeout(timeout) diff --git a/client/client/organizations/get_org_responses.go b/client/client/organizations/get_org_responses.go index ee30ab29..f0d3bb36 100644 --- a/client/client/organizations/get_org_responses.go +++ b/client/client/organizations/get_org_responses.go @@ -6,17 +6,18 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetOrgReader is a Reader for the GetOrg structure. @@ -62,7 +63,8 @@ func NewGetOrgOK() *GetOrgOK { return &GetOrgOK{} } -/*GetOrgOK handles this case with default header values. +/* +GetOrgOK describes a response with status code 200, with default header values. The information of the organization which has the specified ID. */ @@ -70,8 +72,44 @@ type GetOrgOK struct { Payload *GetOrgOKBody } +// IsSuccess returns true when this get org o k response has a 2xx status code +func (o *GetOrgOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get org o k response has a 3xx status code +func (o *GetOrgOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org o k response has a 4xx status code +func (o *GetOrgOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get org o k response has a 5xx status code +func (o *GetOrgOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get org o k response a status code equal to that given +func (o *GetOrgOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get org o k response +func (o *GetOrgOK) Code() int { + return 200 +} + func (o *GetOrgOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgOK %s", 200, payload) +} + +func (o *GetOrgOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgOK %s", 200, payload) } func (o *GetOrgOK) GetPayload() *GetOrgOKBody { @@ -95,20 +133,60 @@ func NewGetOrgForbidden() *GetOrgForbidden { return &GetOrgForbidden{} } -/*GetOrgForbidden handles this case with default header values. +/* +GetOrgForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetOrgForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org forbidden response has a 2xx status code +func (o *GetOrgForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get org forbidden response has a 3xx status code +func (o *GetOrgForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org forbidden response has a 4xx status code +func (o *GetOrgForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get org forbidden response has a 5xx status code +func (o *GetOrgForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get org forbidden response a status code equal to that given +func (o *GetOrgForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get org forbidden response +func (o *GetOrgForbidden) Code() int { + return 403 +} + func (o *GetOrgForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgForbidden %s", 403, payload) +} + +func (o *GetOrgForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgForbidden %s", 403, payload) } func (o *GetOrgForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetOrgForbidden) GetPayload() *models.ErrorPayload { func (o *GetOrgForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetOrgNotFound() *GetOrgNotFound { return &GetOrgNotFound{} } -/*GetOrgNotFound handles this case with default header values. +/* +GetOrgNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetOrgNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org not found response has a 2xx status code +func (o *GetOrgNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get org not found response has a 3xx status code +func (o *GetOrgNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get org not found response has a 4xx status code +func (o *GetOrgNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get org not found response has a 5xx status code +func (o *GetOrgNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get org not found response a status code equal to that given +func (o *GetOrgNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get org not found response +func (o *GetOrgNotFound) Code() int { + return 404 +} + func (o *GetOrgNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgNotFound %s", 404, payload) +} + +func (o *GetOrgNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrgNotFound %s", 404, payload) } func (o *GetOrgNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetOrgNotFound) GetPayload() *models.ErrorPayload { func (o *GetOrgNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetOrgDefault(code int) *GetOrgDefault { } } -/*GetOrgDefault handles this case with default header values. +/* +GetOrgDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetOrgDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get org default response has a 2xx status code +func (o *GetOrgDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get org default response has a 3xx status code +func (o *GetOrgDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get org default response has a 4xx status code +func (o *GetOrgDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get org default response has a 5xx status code +func (o *GetOrgDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get org default response a status code equal to that given +func (o *GetOrgDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get org default response func (o *GetOrgDefault) Code() int { return o._statusCode } func (o *GetOrgDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrg default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrg default %s", o._statusCode, payload) +} + +func (o *GetOrgDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}][%d] getOrg default %s", o._statusCode, payload) } func (o *GetOrgDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetOrgDefault) GetPayload() *models.ErrorPayload { func (o *GetOrgDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetOrgDefault) readResponse(response runtime.ClientResponse, consumer r return nil } -/*GetOrgOKBody get org o k body +/* +GetOrgOKBody get org o k body swagger:model GetOrgOKBody */ type GetOrgOKBody struct { @@ -265,6 +430,39 @@ func (o *GetOrgOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getOrgOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get org o k body based on the context it is used +func (o *GetOrgOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetOrgOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getOrgOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgOK" + "." + "data") } return err } diff --git a/client/client/organizations/get_orgs_parameters.go b/client/client/organizations/get_orgs_parameters.go index 9774fa00..72178403 100644 --- a/client/client/organizations/get_orgs_parameters.go +++ b/client/client/organizations/get_orgs_parameters.go @@ -13,99 +13,91 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewGetOrgsParams creates a new GetOrgsParams object -// with the default values initialized. +// NewGetOrgsParams creates a new GetOrgsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetOrgsParams() *GetOrgsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetOrgsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: cr.DefaultTimeout, } } // NewGetOrgsParamsWithTimeout creates a new GetOrgsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetOrgsParamsWithTimeout(timeout time.Duration) *GetOrgsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetOrgsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - timeout: timeout, } } // NewGetOrgsParamsWithContext creates a new GetOrgsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetOrgsParamsWithContext(ctx context.Context) *GetOrgsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetOrgsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - Context: ctx, } } // NewGetOrgsParamsWithHTTPClient creates a new GetOrgsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetOrgsParamsWithHTTPClient(client *http.Client) *GetOrgsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - ) return &GetOrgsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, HTTPClient: client, } } -/*GetOrgsParams contains all the parameters to send to the API endpoint -for the get orgs operation typically these are written to a http.Request +/* +GetOrgsParams contains all the parameters to send to the API endpoint + + for the get orgs operation. + + Typically these are written to a http.Request. */ type GetOrgsParams struct { - /*OrderBy - Allows to order the list of items. Example usage: field_name:asc + /* OrderBy. + Allows to order the list of items. Example usage: field_name:asc */ OrderBy *string - /*OrganizationCreatedAt - Search by organization's creation date + /* OrganizationCreatedAt. + + Search by organization's creation date + + Format: uint64 */ OrganizationCreatedAt *uint64 - /*OrganizationName - Search by the organization's name + /* OrganizationName. + + Search by the organization's name */ OrganizationName *string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 @@ -114,6 +106,35 @@ type GetOrgsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get orgs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgsParams) WithDefaults() *GetOrgsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get orgs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOrgsParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + ) + + val := GetOrgsParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the get orgs params func (o *GetOrgsParams) WithTimeout(timeout time.Duration) *GetOrgsParams { o.SetTimeout(timeout) @@ -214,80 +235,85 @@ func (o *GetOrgsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regis // query param order_by var qrOrderBy string + if o.OrderBy != nil { qrOrderBy = *o.OrderBy } qOrderBy := qrOrderBy if qOrderBy != "" { + if err := r.SetQueryParam("order_by", qOrderBy); err != nil { return err } } - } if o.OrganizationCreatedAt != nil { // query param organization_created_at var qrOrganizationCreatedAt uint64 + if o.OrganizationCreatedAt != nil { qrOrganizationCreatedAt = *o.OrganizationCreatedAt } qOrganizationCreatedAt := swag.FormatUint64(qrOrganizationCreatedAt) if qOrganizationCreatedAt != "" { + if err := r.SetQueryParam("organization_created_at", qOrganizationCreatedAt); err != nil { return err } } - } if o.OrganizationName != nil { // query param organization_name var qrOrganizationName string + if o.OrganizationName != nil { qrOrganizationName = *o.OrganizationName } qOrganizationName := qrOrganizationName if qOrganizationName != "" { + if err := r.SetQueryParam("organization_name", qOrganizationName); err != nil { return err } } - } if o.PageIndex != nil { // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/organizations/get_orgs_responses.go b/client/client/organizations/get_orgs_responses.go index 610930bd..e12470ab 100644 --- a/client/client/organizations/get_orgs_responses.go +++ b/client/client/organizations/get_orgs_responses.go @@ -6,18 +6,19 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetOrgsReader is a Reader for the GetOrgs structure. @@ -57,7 +58,8 @@ func NewGetOrgsOK() *GetOrgsOK { return &GetOrgsOK{} } -/*GetOrgsOK handles this case with default header values. +/* +GetOrgsOK describes a response with status code 200, with default header values. List of the organizations which authenticated user has access. */ @@ -65,8 +67,44 @@ type GetOrgsOK struct { Payload *GetOrgsOKBody } +// IsSuccess returns true when this get orgs o k response has a 2xx status code +func (o *GetOrgsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get orgs o k response has a 3xx status code +func (o *GetOrgsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get orgs o k response has a 4xx status code +func (o *GetOrgsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get orgs o k response has a 5xx status code +func (o *GetOrgsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get orgs o k response a status code equal to that given +func (o *GetOrgsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get orgs o k response +func (o *GetOrgsOK) Code() int { + return 200 +} + func (o *GetOrgsOK) Error() string { - return fmt.Sprintf("[GET /organizations][%d] getOrgsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations][%d] getOrgsOK %s", 200, payload) +} + +func (o *GetOrgsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations][%d] getOrgsOK %s", 200, payload) } func (o *GetOrgsOK) GetPayload() *GetOrgsOKBody { @@ -90,20 +128,60 @@ func NewGetOrgsUnprocessableEntity() *GetOrgsUnprocessableEntity { return &GetOrgsUnprocessableEntity{} } -/*GetOrgsUnprocessableEntity handles this case with default header values. +/* +GetOrgsUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetOrgsUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get orgs unprocessable entity response has a 2xx status code +func (o *GetOrgsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get orgs unprocessable entity response has a 3xx status code +func (o *GetOrgsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get orgs unprocessable entity response has a 4xx status code +func (o *GetOrgsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get orgs unprocessable entity response has a 5xx status code +func (o *GetOrgsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get orgs unprocessable entity response a status code equal to that given +func (o *GetOrgsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get orgs unprocessable entity response +func (o *GetOrgsUnprocessableEntity) Code() int { + return 422 +} + func (o *GetOrgsUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations][%d] getOrgsUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations][%d] getOrgsUnprocessableEntity %s", 422, payload) +} + +func (o *GetOrgsUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations][%d] getOrgsUnprocessableEntity %s", 422, payload) } func (o *GetOrgsUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -112,12 +190,16 @@ func (o *GetOrgsUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetOrgsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -136,27 +218,61 @@ func NewGetOrgsDefault(code int) *GetOrgsDefault { } } -/*GetOrgsDefault handles this case with default header values. +/* +GetOrgsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetOrgsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get orgs default response has a 2xx status code +func (o *GetOrgsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get orgs default response has a 3xx status code +func (o *GetOrgsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get orgs default response has a 4xx status code +func (o *GetOrgsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get orgs default response has a 5xx status code +func (o *GetOrgsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get orgs default response a status code equal to that given +func (o *GetOrgsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get orgs default response func (o *GetOrgsDefault) Code() int { return o._statusCode } func (o *GetOrgsDefault) Error() string { - return fmt.Sprintf("[GET /organizations][%d] getOrgs default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations][%d] getOrgs default %s", o._statusCode, payload) +} + +func (o *GetOrgsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations][%d] getOrgs default %s", o._statusCode, payload) } func (o *GetOrgsDefault) GetPayload() *models.ErrorPayload { @@ -165,12 +281,16 @@ func (o *GetOrgsDefault) GetPayload() *models.ErrorPayload { func (o *GetOrgsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -182,7 +302,8 @@ func (o *GetOrgsDefault) readResponse(response runtime.ClientResponse, consumer return nil } -/*GetOrgsOKBody get orgs o k body +/* +GetOrgsOKBody get orgs o k body swagger:model GetOrgsOKBody */ type GetOrgsOKBody struct { @@ -229,6 +350,8 @@ func (o *GetOrgsOKBody) validateData(formats strfmt.Registry) error { if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getOrgsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -249,6 +372,68 @@ func (o *GetOrgsOKBody) validatePagination(formats strfmt.Registry) error { if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getOrgsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgsOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get orgs o k body based on the context it is used +func (o *GetOrgsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetOrgsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getOrgsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *GetOrgsOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getOrgsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOrgsOK" + "." + "pagination") } return err } diff --git a/client/client/organizations/get_repo_branches_parameters.go b/client/client/organizations/get_repo_branches_parameters.go index 74ed3db6..fc052a81 100644 --- a/client/client/organizations/get_repo_branches_parameters.go +++ b/client/client/organizations/get_repo_branches_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetRepoBranchesParams creates a new GetRepoBranchesParams object -// with the default values initialized. +// NewGetRepoBranchesParams creates a new GetRepoBranchesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetRepoBranchesParams() *GetRepoBranchesParams { - var () return &GetRepoBranchesParams{ - timeout: cr.DefaultTimeout, } } // NewGetRepoBranchesParamsWithTimeout creates a new GetRepoBranchesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetRepoBranchesParamsWithTimeout(timeout time.Duration) *GetRepoBranchesParams { - var () return &GetRepoBranchesParams{ - timeout: timeout, } } // NewGetRepoBranchesParamsWithContext creates a new GetRepoBranchesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetRepoBranchesParamsWithContext(ctx context.Context) *GetRepoBranchesParams { - var () return &GetRepoBranchesParams{ - Context: ctx, } } // NewGetRepoBranchesParamsWithHTTPClient creates a new GetRepoBranchesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetRepoBranchesParamsWithHTTPClient(client *http.Client) *GetRepoBranchesParams { - var () return &GetRepoBranchesParams{ HTTPClient: client, } } -/*GetRepoBranchesParams contains all the parameters to send to the API endpoint -for the get repo branches operation typically these are written to a http.Request +/* +GetRepoBranchesParams contains all the parameters to send to the API endpoint + + for the get repo branches operation. + + Typically these are written to a http.Request. */ type GetRepoBranchesParams struct { - /*CredentialCanonical - A Credential canonical + /* CredentialCanonical. + A Credential canonical */ CredentialCanonical *string - /*GitURL - Git URL to repository + /* GitURL. + + Git URL to repository */ GitURL string - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -82,6 +84,21 @@ type GetRepoBranchesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get repo branches params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetRepoBranchesParams) WithDefaults() *GetRepoBranchesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get repo branches params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetRepoBranchesParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get repo branches params func (o *GetRepoBranchesParams) WithTimeout(timeout time.Duration) *GetRepoBranchesParams { o.SetTimeout(timeout) @@ -160,22 +177,24 @@ func (o *GetRepoBranchesParams) WriteToRequest(r runtime.ClientRequest, reg strf // query param credential_canonical var qrCredentialCanonical string + if o.CredentialCanonical != nil { qrCredentialCanonical = *o.CredentialCanonical } qCredentialCanonical := qrCredentialCanonical if qCredentialCanonical != "" { + if err := r.SetQueryParam("credential_canonical", qCredentialCanonical); err != nil { return err } } - } // query param git_url qrGitURL := o.GitURL qGitURL := qrGitURL if qGitURL != "" { + if err := r.SetQueryParam("git_url", qGitURL); err != nil { return err } diff --git a/client/client/organizations/get_repo_branches_responses.go b/client/client/organizations/get_repo_branches_responses.go index d00bd387..55b854e5 100644 --- a/client/client/organizations/get_repo_branches_responses.go +++ b/client/client/organizations/get_repo_branches_responses.go @@ -6,17 +6,18 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetRepoBranchesReader is a Reader for the GetRepoBranches structure. @@ -68,7 +69,8 @@ func NewGetRepoBranchesOK() *GetRepoBranchesOK { return &GetRepoBranchesOK{} } -/*GetRepoBranchesOK handles this case with default header values. +/* +GetRepoBranchesOK describes a response with status code 200, with default header values. List of the repository branches */ @@ -76,8 +78,44 @@ type GetRepoBranchesOK struct { Payload *GetRepoBranchesOKBody } +// IsSuccess returns true when this get repo branches o k response has a 2xx status code +func (o *GetRepoBranchesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get repo branches o k response has a 3xx status code +func (o *GetRepoBranchesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get repo branches o k response has a 4xx status code +func (o *GetRepoBranchesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get repo branches o k response has a 5xx status code +func (o *GetRepoBranchesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get repo branches o k response a status code equal to that given +func (o *GetRepoBranchesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get repo branches o k response +func (o *GetRepoBranchesOK) Code() int { + return 200 +} + func (o *GetRepoBranchesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesOK %s", 200, payload) +} + +func (o *GetRepoBranchesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesOK %s", 200, payload) } func (o *GetRepoBranchesOK) GetPayload() *GetRepoBranchesOKBody { @@ -101,20 +139,60 @@ func NewGetRepoBranchesForbidden() *GetRepoBranchesForbidden { return &GetRepoBranchesForbidden{} } -/*GetRepoBranchesForbidden handles this case with default header values. +/* +GetRepoBranchesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetRepoBranchesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get repo branches forbidden response has a 2xx status code +func (o *GetRepoBranchesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get repo branches forbidden response has a 3xx status code +func (o *GetRepoBranchesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get repo branches forbidden response has a 4xx status code +func (o *GetRepoBranchesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get repo branches forbidden response has a 5xx status code +func (o *GetRepoBranchesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get repo branches forbidden response a status code equal to that given +func (o *GetRepoBranchesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get repo branches forbidden response +func (o *GetRepoBranchesForbidden) Code() int { + return 403 +} + func (o *GetRepoBranchesForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesForbidden %s", 403, payload) +} + +func (o *GetRepoBranchesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesForbidden %s", 403, payload) } func (o *GetRepoBranchesForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *GetRepoBranchesForbidden) GetPayload() *models.ErrorPayload { func (o *GetRepoBranchesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewGetRepoBranchesNotFound() *GetRepoBranchesNotFound { return &GetRepoBranchesNotFound{} } -/*GetRepoBranchesNotFound handles this case with default header values. +/* +GetRepoBranchesNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetRepoBranchesNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get repo branches not found response has a 2xx status code +func (o *GetRepoBranchesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get repo branches not found response has a 3xx status code +func (o *GetRepoBranchesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get repo branches not found response has a 4xx status code +func (o *GetRepoBranchesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get repo branches not found response has a 5xx status code +func (o *GetRepoBranchesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get repo branches not found response a status code equal to that given +func (o *GetRepoBranchesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get repo branches not found response +func (o *GetRepoBranchesNotFound) Code() int { + return 404 +} + func (o *GetRepoBranchesNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesNotFound %s", 404, payload) +} + +func (o *GetRepoBranchesNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesNotFound %s", 404, payload) } func (o *GetRepoBranchesNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *GetRepoBranchesNotFound) GetPayload() *models.ErrorPayload { func (o *GetRepoBranchesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewGetRepoBranchesUnprocessableEntity() *GetRepoBranchesUnprocessableEntity return &GetRepoBranchesUnprocessableEntity{} } -/*GetRepoBranchesUnprocessableEntity handles this case with default header values. +/* +GetRepoBranchesUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type GetRepoBranchesUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get repo branches unprocessable entity response has a 2xx status code +func (o *GetRepoBranchesUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get repo branches unprocessable entity response has a 3xx status code +func (o *GetRepoBranchesUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get repo branches unprocessable entity response has a 4xx status code +func (o *GetRepoBranchesUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get repo branches unprocessable entity response has a 5xx status code +func (o *GetRepoBranchesUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get repo branches unprocessable entity response a status code equal to that given +func (o *GetRepoBranchesUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get repo branches unprocessable entity response +func (o *GetRepoBranchesUnprocessableEntity) Code() int { + return 422 +} + func (o *GetRepoBranchesUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesUnprocessableEntity %s", 422, payload) +} + +func (o *GetRepoBranchesUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranchesUnprocessableEntity %s", 422, payload) } func (o *GetRepoBranchesUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *GetRepoBranchesUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *GetRepoBranchesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewGetRepoBranchesDefault(code int) *GetRepoBranchesDefault { } } -/*GetRepoBranchesDefault handles this case with default header values. +/* +GetRepoBranchesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetRepoBranchesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get repo branches default response has a 2xx status code +func (o *GetRepoBranchesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get repo branches default response has a 3xx status code +func (o *GetRepoBranchesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get repo branches default response has a 4xx status code +func (o *GetRepoBranchesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get repo branches default response has a 5xx status code +func (o *GetRepoBranchesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get repo branches default response a status code equal to that given +func (o *GetRepoBranchesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get repo branches default response func (o *GetRepoBranchesDefault) Code() int { return o._statusCode } func (o *GetRepoBranchesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranches default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranches default %s", o._statusCode, payload) +} + +func (o *GetRepoBranchesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/branches][%d] getRepoBranches default %s", o._statusCode, payload) } func (o *GetRepoBranchesDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *GetRepoBranchesDefault) GetPayload() *models.ErrorPayload { func (o *GetRepoBranchesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *GetRepoBranchesDefault) readResponse(response runtime.ClientResponse, c return nil } -/*GetRepoBranchesOKBody get repo branches o k body +/* +GetRepoBranchesOKBody get repo branches o k body swagger:model GetRepoBranchesOKBody */ type GetRepoBranchesOKBody struct { @@ -314,6 +523,11 @@ func (o *GetRepoBranchesOKBody) validateData(formats strfmt.Registry) error { return nil } +// ContextValidate validates this get repo branches o k body based on context it is used +func (o *GetRepoBranchesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *GetRepoBranchesOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/organizations/get_summary_parameters.go b/client/client/organizations/get_summary_parameters.go index 02a19389..76cf4c67 100644 --- a/client/client/organizations/get_summary_parameters.go +++ b/client/client/organizations/get_summary_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetSummaryParams creates a new GetSummaryParams object -// with the default values initialized. +// NewGetSummaryParams creates a new GetSummaryParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetSummaryParams() *GetSummaryParams { - var () return &GetSummaryParams{ - timeout: cr.DefaultTimeout, } } // NewGetSummaryParamsWithTimeout creates a new GetSummaryParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetSummaryParamsWithTimeout(timeout time.Duration) *GetSummaryParams { - var () return &GetSummaryParams{ - timeout: timeout, } } // NewGetSummaryParamsWithContext creates a new GetSummaryParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetSummaryParamsWithContext(ctx context.Context) *GetSummaryParams { - var () return &GetSummaryParams{ - Context: ctx, } } // NewGetSummaryParamsWithHTTPClient creates a new GetSummaryParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetSummaryParamsWithHTTPClient(client *http.Client) *GetSummaryParams { - var () return &GetSummaryParams{ HTTPClient: client, } } -/*GetSummaryParams contains all the parameters to send to the API endpoint -for the get summary operation typically these are written to a http.Request +/* +GetSummaryParams contains all the parameters to send to the API endpoint + + for the get summary operation. + + Typically these are written to a http.Request. */ type GetSummaryParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string @@ -72,6 +72,21 @@ type GetSummaryParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get summary params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetSummaryParams) WithDefaults() *GetSummaryParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get summary params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetSummaryParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get summary params func (o *GetSummaryParams) WithTimeout(timeout time.Duration) *GetSummaryParams { o.SetTimeout(timeout) diff --git a/client/client/organizations/get_summary_responses.go b/client/client/organizations/get_summary_responses.go index f16ebe87..0f720a84 100644 --- a/client/client/organizations/get_summary_responses.go +++ b/client/client/organizations/get_summary_responses.go @@ -6,17 +6,18 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetSummaryReader is a Reader for the GetSummary structure. @@ -45,9 +46,8 @@ func (o *GetSummaryReader) ReadResponse(response runtime.ClientResponse, consume return nil, err } return nil, result - default: - return nil, runtime.NewAPIError("unknown error", response, response.Code()) + return nil, runtime.NewAPIError("[GET /organizations/{organization_canonical}/summary] getSummary", response, response.Code()) } } @@ -56,7 +56,8 @@ func NewGetSummaryOK() *GetSummaryOK { return &GetSummaryOK{} } -/*GetSummaryOK handles this case with default header values. +/* +GetSummaryOK describes a response with status code 200, with default header values. The summary object */ @@ -64,8 +65,44 @@ type GetSummaryOK struct { Payload *GetSummaryOKBody } +// IsSuccess returns true when this get summary o k response has a 2xx status code +func (o *GetSummaryOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get summary o k response has a 3xx status code +func (o *GetSummaryOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get summary o k response has a 4xx status code +func (o *GetSummaryOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get summary o k response has a 5xx status code +func (o *GetSummaryOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get summary o k response a status code equal to that given +func (o *GetSummaryOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get summary o k response +func (o *GetSummaryOK) Code() int { + return 200 +} + func (o *GetSummaryOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryOK %s", 200, payload) +} + +func (o *GetSummaryOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryOK %s", 200, payload) } func (o *GetSummaryOK) GetPayload() *GetSummaryOKBody { @@ -89,20 +126,60 @@ func NewGetSummaryForbidden() *GetSummaryForbidden { return &GetSummaryForbidden{} } -/*GetSummaryForbidden handles this case with default header values. +/* +GetSummaryForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetSummaryForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get summary forbidden response has a 2xx status code +func (o *GetSummaryForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get summary forbidden response has a 3xx status code +func (o *GetSummaryForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get summary forbidden response has a 4xx status code +func (o *GetSummaryForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get summary forbidden response has a 5xx status code +func (o *GetSummaryForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get summary forbidden response a status code equal to that given +func (o *GetSummaryForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get summary forbidden response +func (o *GetSummaryForbidden) Code() int { + return 403 +} + func (o *GetSummaryForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryForbidden %s", 403, payload) +} + +func (o *GetSummaryForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryForbidden %s", 403, payload) } func (o *GetSummaryForbidden) GetPayload() *models.ErrorPayload { @@ -111,12 +188,16 @@ func (o *GetSummaryForbidden) GetPayload() *models.ErrorPayload { func (o *GetSummaryForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -133,20 +214,60 @@ func NewGetSummaryNotFound() *GetSummaryNotFound { return &GetSummaryNotFound{} } -/*GetSummaryNotFound handles this case with default header values. +/* +GetSummaryNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetSummaryNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get summary not found response has a 2xx status code +func (o *GetSummaryNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get summary not found response has a 3xx status code +func (o *GetSummaryNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get summary not found response has a 4xx status code +func (o *GetSummaryNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get summary not found response has a 5xx status code +func (o *GetSummaryNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get summary not found response a status code equal to that given +func (o *GetSummaryNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get summary not found response +func (o *GetSummaryNotFound) Code() int { + return 404 +} + func (o *GetSummaryNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryNotFound %s", 404, payload) +} + +func (o *GetSummaryNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/summary][%d] getSummaryNotFound %s", 404, payload) } func (o *GetSummaryNotFound) GetPayload() *models.ErrorPayload { @@ -155,12 +276,16 @@ func (o *GetSummaryNotFound) GetPayload() *models.ErrorPayload { func (o *GetSummaryNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,7 +297,8 @@ func (o *GetSummaryNotFound) readResponse(response runtime.ClientResponse, consu return nil } -/*GetSummaryOKBody get summary o k body +/* +GetSummaryOKBody get summary o k body swagger:model GetSummaryOKBody */ type GetSummaryOKBody struct { @@ -206,6 +332,39 @@ func (o *GetSummaryOKBody) validateSummary(formats strfmt.Registry) error { if err := o.Summary.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getSummaryOK" + "." + "summary") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getSummaryOK" + "." + "summary") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get summary o k body based on the context it is used +func (o *GetSummaryOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateSummary(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetSummaryOKBody) contextValidateSummary(ctx context.Context, formats strfmt.Registry) error { + + if o.Summary != nil { + + if err := o.Summary.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getSummaryOK" + "." + "summary") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getSummaryOK" + "." + "summary") } return err } diff --git a/client/client/organizations/organizations_client.go b/client/client/organizations/organizations_client.go index 0f7e28d7..8dbdfce3 100644 --- a/client/client/organizations/organizations_client.go +++ b/client/client/organizations/organizations_client.go @@ -9,15 +9,40 @@ import ( "fmt" "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new organizations API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new organizations API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new organizations API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for organizations API */ @@ -26,16 +51,96 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CanDo(params *CanDoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CanDoOK, error) + + CreateOrg(params *CreateOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgOK, error) + + DeleteOrg(params *DeleteOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteOrgNoContent, error) + + GetAncestors(params *GetAncestorsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAncestorsOK, error) + + GetEvents(params *GetEventsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEventsOK, error) + + GetEventsTags(params *GetEventsTagsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEventsTagsOK, error) + + GetOrg(params *GetOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgOK, error) + + GetOrgs(params *GetOrgsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgsOK, error) + + GetRepoBranches(params *GetRepoBranchesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoBranchesOK, error) + + GetSummary(params *GetSummaryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetSummaryOK, error) + + SendEvent(params *SendEventParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SendEventOK, error) + + UpdateOrg(params *UpdateOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOrgOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CanDo Checks if the JWT can do the action */ -func (a *Client) CanDo(params *CanDoParams, authInfo runtime.ClientAuthInfoWriter) (*CanDoOK, error) { +func (a *Client) CanDo(params *CanDoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CanDoOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCanDoParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "canDo", Method: "POST", PathPattern: "/organizations/{organization_canonical}/can_do", @@ -47,7 +152,12 @@ func (a *Client) CanDo(params *CanDoParams, authInfo runtime.ClientAuthInfoWrite AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -63,13 +173,12 @@ func (a *Client) CanDo(params *CanDoParams, authInfo runtime.ClientAuthInfoWrite /* CreateOrg Create a new organization, making the authenticated user the owner of it. */ -func (a *Client) CreateOrg(params *CreateOrgParams, authInfo runtime.ClientAuthInfoWriter) (*CreateOrgOK, error) { +func (a *Client) CreateOrg(params *CreateOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateOrgParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createOrg", Method: "POST", PathPattern: "/organizations", @@ -81,7 +190,12 @@ func (a *Client) CreateOrg(params *CreateOrgParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -97,13 +211,12 @@ func (a *Client) CreateOrg(params *CreateOrgParams, authInfo runtime.ClientAuthI /* DeleteOrg Delete the organization. */ -func (a *Client) DeleteOrg(params *DeleteOrgParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteOrgNoContent, error) { +func (a *Client) DeleteOrg(params *DeleteOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteOrgNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteOrgParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteOrg", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}", @@ -115,7 +228,12 @@ func (a *Client) DeleteOrg(params *DeleteOrgParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -131,13 +249,12 @@ func (a *Client) DeleteOrg(params *DeleteOrgParams, authInfo runtime.ClientAuthI /* GetAncestors Get all the ancestors between the Organization and the User with the shortest path. */ -func (a *Client) GetAncestors(params *GetAncestorsParams, authInfo runtime.ClientAuthInfoWriter) (*GetAncestorsOK, error) { +func (a *Client) GetAncestors(params *GetAncestorsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAncestorsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetAncestorsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getAncestors", Method: "GET", PathPattern: "/organizations/{organization_canonical}/ancestors", @@ -149,7 +266,12 @@ func (a *Client) GetAncestors(params *GetAncestorsParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -163,17 +285,16 @@ func (a *Client) GetAncestors(params *GetAncestorsParams, authInfo runtime.Clien } /* -GetEvents Retrieve the list of events which has been registered on the organization. The events to request can be filtered using Unix timestamps in milliseconds (begin and end timestamps range), the event type and severity; when more than one are applied then they are applied with a logical AND. -- The Unix timestamps must always be specified, the rest of the filters - are not mandatory. + GetEvents Retrieve the list of events which has been registered on the organization. The events to request can be filtered using Unix timestamps in milliseconds (begin and end timestamps range), the event type and severity; when more than one are applied then they are applied with a logical AND. + - The Unix timestamps must always be specified, the rest of the filters + are not mandatory. */ -func (a *Client) GetEvents(params *GetEventsParams, authInfo runtime.ClientAuthInfoWriter) (*GetEventsOK, error) { +func (a *Client) GetEvents(params *GetEventsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEventsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetEventsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getEvents", Method: "GET", PathPattern: "/organizations/{organization_canonical}/events", @@ -185,7 +306,12 @@ func (a *Client) GetEvents(params *GetEventsParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -201,13 +327,12 @@ func (a *Client) GetEvents(params *GetEventsParams, authInfo runtime.ClientAuthI /* GetEventsTags Retrieve the list of tags and set of values for all the events of the organization. */ -func (a *Client) GetEventsTags(params *GetEventsTagsParams, authInfo runtime.ClientAuthInfoWriter) (*GetEventsTagsOK, error) { +func (a *Client) GetEventsTags(params *GetEventsTagsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEventsTagsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetEventsTagsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getEventsTags", Method: "GET", PathPattern: "/organizations/{organization_canonical}/events/tags", @@ -219,7 +344,12 @@ func (a *Client) GetEventsTags(params *GetEventsTagsParams, authInfo runtime.Cli AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -235,13 +365,12 @@ func (a *Client) GetEventsTags(params *GetEventsTagsParams, authInfo runtime.Cli /* GetOrg Get the information of the organization. */ -func (a *Client) GetOrg(params *GetOrgParams, authInfo runtime.ClientAuthInfoWriter) (*GetOrgOK, error) { +func (a *Client) GetOrg(params *GetOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetOrgParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getOrg", Method: "GET", PathPattern: "/organizations/{organization_canonical}", @@ -253,7 +382,12 @@ func (a *Client) GetOrg(params *GetOrgParams, authInfo runtime.ClientAuthInfoWri AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -269,13 +403,12 @@ func (a *Client) GetOrg(params *GetOrgParams, authInfo runtime.ClientAuthInfoWri /* GetOrgs Get the organizations that the authenticated user has access. */ -func (a *Client) GetOrgs(params *GetOrgsParams, authInfo runtime.ClientAuthInfoWriter) (*GetOrgsOK, error) { +func (a *Client) GetOrgs(params *GetOrgsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetOrgsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getOrgs", Method: "GET", PathPattern: "/organizations", @@ -287,7 +420,12 @@ func (a *Client) GetOrgs(params *GetOrgsParams, authInfo runtime.ClientAuthInfoW AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -301,17 +439,16 @@ func (a *Client) GetOrgs(params *GetOrgsParams, authInfo runtime.ClientAuthInfoW } /* -GetRepoBranches Return all the branches of repository. If the repository is empty then an -empty list will be returned. + GetRepoBranches Return all the branches of repository. If the repository is empty then an +empty list will be returned. */ -func (a *Client) GetRepoBranches(params *GetRepoBranchesParams, authInfo runtime.ClientAuthInfoWriter) (*GetRepoBranchesOK, error) { +func (a *Client) GetRepoBranches(params *GetRepoBranchesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoBranchesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetRepoBranchesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getRepoBranches", Method: "GET", PathPattern: "/organizations/{organization_canonical}/branches", @@ -323,7 +460,12 @@ func (a *Client) GetRepoBranches(params *GetRepoBranchesParams, authInfo runtime AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -339,13 +481,12 @@ func (a *Client) GetRepoBranches(params *GetRepoBranchesParams, authInfo runtime /* GetSummary Get the summary of the organization */ -func (a *Client) GetSummary(params *GetSummaryParams, authInfo runtime.ClientAuthInfoWriter) (*GetSummaryOK, error) { +func (a *Client) GetSummary(params *GetSummaryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetSummaryOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetSummaryParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getSummary", Method: "GET", PathPattern: "/organizations/{organization_canonical}/summary", @@ -357,7 +498,12 @@ func (a *Client) GetSummary(params *GetSummaryParams, authInfo runtime.ClientAut AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -374,13 +520,12 @@ func (a *Client) GetSummary(params *GetSummaryParams, authInfo runtime.ClientAut /* SendEvent Send a event on the organization to be registered. */ -func (a *Client) SendEvent(params *SendEventParams, authInfo runtime.ClientAuthInfoWriter) (*SendEventOK, error) { +func (a *Client) SendEvent(params *SendEventParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SendEventOK, error) { // TODO: Validate the params before sending if params == nil { params = NewSendEventParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "sendEvent", Method: "POST", PathPattern: "/organizations/{organization_canonical}/events", @@ -392,7 +537,12 @@ func (a *Client) SendEvent(params *SendEventParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -409,13 +559,12 @@ func (a *Client) SendEvent(params *SendEventParams, authInfo runtime.ClientAuthI /* UpdateOrg Update the information of the organization. */ -func (a *Client) UpdateOrg(params *UpdateOrgParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateOrgOK, error) { +func (a *Client) UpdateOrg(params *UpdateOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOrgOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateOrgParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateOrg", Method: "PUT", PathPattern: "/organizations/{organization_canonical}", @@ -427,7 +576,12 @@ func (a *Client) UpdateOrg(params *UpdateOrgParams, authInfo runtime.ClientAuthI AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/organizations/send_event_parameters.go b/client/client/organizations/send_event_parameters.go index a1b46f9d..df92c048 100644 --- a/client/client/organizations/send_event_parameters.go +++ b/client/client/organizations/send_event_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewSendEventParams creates a new SendEventParams object -// with the default values initialized. +// NewSendEventParams creates a new SendEventParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewSendEventParams() *SendEventParams { - var () return &SendEventParams{ - timeout: cr.DefaultTimeout, } } // NewSendEventParamsWithTimeout creates a new SendEventParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewSendEventParamsWithTimeout(timeout time.Duration) *SendEventParams { - var () return &SendEventParams{ - timeout: timeout, } } // NewSendEventParamsWithContext creates a new SendEventParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewSendEventParamsWithContext(ctx context.Context) *SendEventParams { - var () return &SendEventParams{ - Context: ctx, } } // NewSendEventParamsWithHTTPClient creates a new SendEventParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewSendEventParamsWithHTTPClient(client *http.Client) *SendEventParams { - var () return &SendEventParams{ HTTPClient: client, } } -/*SendEventParams contains all the parameters to send to the API endpoint -for the send event operation typically these are written to a http.Request +/* +SendEventParams contains all the parameters to send to the API endpoint + + for the send event operation. + + Typically these are written to a http.Request. */ type SendEventParams struct { - /*Body - The information associated with the event to register. + /* Body. + The information associated with the event to register. */ Body *models.NewEvent - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type SendEventParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the send event params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SendEventParams) WithDefaults() *SendEventParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the send event params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SendEventParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the send event params func (o *SendEventParams) WithTimeout(timeout time.Duration) *SendEventParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *SendEventParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organizations/send_event_responses.go b/client/client/organizations/send_event_responses.go index 123c3966..5a97e65f 100644 --- a/client/client/organizations/send_event_responses.go +++ b/client/client/organizations/send_event_responses.go @@ -6,17 +6,18 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // SendEventReader is a Reader for the SendEvent structure. @@ -51,9 +52,8 @@ func (o *SendEventReader) ReadResponse(response runtime.ClientResponse, consumer return nil, err } return nil, result - default: - return nil, runtime.NewAPIError("unknown error", response, response.Code()) + return nil, runtime.NewAPIError("[POST /organizations/{organization_canonical}/events] sendEvent", response, response.Code()) } } @@ -62,7 +62,8 @@ func NewSendEventOK() *SendEventOK { return &SendEventOK{} } -/*SendEventOK handles this case with default header values. +/* +SendEventOK describes a response with status code 200, with default header values. Event has been registered */ @@ -70,8 +71,44 @@ type SendEventOK struct { Payload *SendEventOKBody } +// IsSuccess returns true when this send event o k response has a 2xx status code +func (o *SendEventOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this send event o k response has a 3xx status code +func (o *SendEventOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this send event o k response has a 4xx status code +func (o *SendEventOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this send event o k response has a 5xx status code +func (o *SendEventOK) IsServerError() bool { + return false +} + +// IsCode returns true when this send event o k response a status code equal to that given +func (o *SendEventOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the send event o k response +func (o *SendEventOK) Code() int { + return 200 +} + func (o *SendEventOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventOK %s", 200, payload) +} + +func (o *SendEventOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventOK %s", 200, payload) } func (o *SendEventOK) GetPayload() *SendEventOKBody { @@ -95,20 +132,60 @@ func NewSendEventForbidden() *SendEventForbidden { return &SendEventForbidden{} } -/*SendEventForbidden handles this case with default header values. +/* +SendEventForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type SendEventForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this send event forbidden response has a 2xx status code +func (o *SendEventForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this send event forbidden response has a 3xx status code +func (o *SendEventForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this send event forbidden response has a 4xx status code +func (o *SendEventForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this send event forbidden response has a 5xx status code +func (o *SendEventForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this send event forbidden response a status code equal to that given +func (o *SendEventForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the send event forbidden response +func (o *SendEventForbidden) Code() int { + return 403 +} + func (o *SendEventForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventForbidden %s", 403, payload) +} + +func (o *SendEventForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventForbidden %s", 403, payload) } func (o *SendEventForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +194,16 @@ func (o *SendEventForbidden) GetPayload() *models.ErrorPayload { func (o *SendEventForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +220,60 @@ func NewSendEventNotFound() *SendEventNotFound { return &SendEventNotFound{} } -/*SendEventNotFound handles this case with default header values. +/* +SendEventNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type SendEventNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this send event not found response has a 2xx status code +func (o *SendEventNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this send event not found response has a 3xx status code +func (o *SendEventNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this send event not found response has a 4xx status code +func (o *SendEventNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this send event not found response has a 5xx status code +func (o *SendEventNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this send event not found response a status code equal to that given +func (o *SendEventNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the send event not found response +func (o *SendEventNotFound) Code() int { + return 404 +} + func (o *SendEventNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventNotFound %s", 404, payload) +} + +func (o *SendEventNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventNotFound %s", 404, payload) } func (o *SendEventNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +282,16 @@ func (o *SendEventNotFound) GetPayload() *models.ErrorPayload { func (o *SendEventNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -183,20 +308,60 @@ func NewSendEventUnprocessableEntity() *SendEventUnprocessableEntity { return &SendEventUnprocessableEntity{} } -/*SendEventUnprocessableEntity handles this case with default header values. +/* +SendEventUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type SendEventUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this send event unprocessable entity response has a 2xx status code +func (o *SendEventUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this send event unprocessable entity response has a 3xx status code +func (o *SendEventUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this send event unprocessable entity response has a 4xx status code +func (o *SendEventUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this send event unprocessable entity response has a 5xx status code +func (o *SendEventUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this send event unprocessable entity response a status code equal to that given +func (o *SendEventUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the send event unprocessable entity response +func (o *SendEventUnprocessableEntity) Code() int { + return 422 +} + func (o *SendEventUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventUnprocessableEntity %s", 422, payload) +} + +func (o *SendEventUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/events][%d] sendEventUnprocessableEntity %s", 422, payload) } func (o *SendEventUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -205,12 +370,16 @@ func (o *SendEventUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *SendEventUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -222,7 +391,8 @@ func (o *SendEventUnprocessableEntity) readResponse(response runtime.ClientRespo return nil } -/*SendEventOKBody The newly created event +/* +SendEventOKBody The newly created event swagger:model SendEventOKBody */ type SendEventOKBody struct { @@ -256,6 +426,39 @@ func (o *SendEventOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("sendEventOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sendEventOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this send event o k body based on the context it is used +func (o *SendEventOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *SendEventOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sendEventOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sendEventOK" + "." + "data") } return err } diff --git a/client/client/organizations/update_org_parameters.go b/client/client/organizations/update_org_parameters.go index e1f2b69f..a3cdf98e 100644 --- a/client/client/organizations/update_org_parameters.go +++ b/client/client/organizations/update_org_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateOrgParams creates a new UpdateOrgParams object -// with the default values initialized. +// NewUpdateOrgParams creates a new UpdateOrgParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateOrgParams() *UpdateOrgParams { - var () return &UpdateOrgParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateOrgParamsWithTimeout creates a new UpdateOrgParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateOrgParamsWithTimeout(timeout time.Duration) *UpdateOrgParams { - var () return &UpdateOrgParams{ - timeout: timeout, } } // NewUpdateOrgParamsWithContext creates a new UpdateOrgParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateOrgParamsWithContext(ctx context.Context) *UpdateOrgParams { - var () return &UpdateOrgParams{ - Context: ctx, } } // NewUpdateOrgParamsWithHTTPClient creates a new UpdateOrgParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateOrgParamsWithHTTPClient(client *http.Client) *UpdateOrgParams { - var () return &UpdateOrgParams{ HTTPClient: client, } } -/*UpdateOrgParams contains all the parameters to send to the API endpoint -for the update org operation typically these are written to a http.Request +/* +UpdateOrgParams contains all the parameters to send to the API endpoint + + for the update org operation. + + Typically these are written to a http.Request. */ type UpdateOrgParams struct { - /*Body - The information of the organization to update. + /* Body. + The information of the organization to update. */ Body *models.UpdateOrganization - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type UpdateOrgParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateOrgParams) WithDefaults() *UpdateOrgParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update org params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateOrgParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update org params func (o *UpdateOrgParams) WithTimeout(timeout time.Duration) *UpdateOrgParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *UpdateOrgParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/organizations/update_org_responses.go b/client/client/organizations/update_org_responses.go index f0fd34a1..e0660da5 100644 --- a/client/client/organizations/update_org_responses.go +++ b/client/client/organizations/update_org_responses.go @@ -6,17 +6,18 @@ package organizations // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateOrgReader is a Reader for the UpdateOrg structure. @@ -74,7 +75,8 @@ func NewUpdateOrgOK() *UpdateOrgOK { return &UpdateOrgOK{} } -/*UpdateOrgOK handles this case with default header values. +/* +UpdateOrgOK describes a response with status code 200, with default header values. Organization updated. The body contains information of the updated organization. */ @@ -82,8 +84,44 @@ type UpdateOrgOK struct { Payload *UpdateOrgOKBody } +// IsSuccess returns true when this update org o k response has a 2xx status code +func (o *UpdateOrgOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update org o k response has a 3xx status code +func (o *UpdateOrgOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org o k response has a 4xx status code +func (o *UpdateOrgOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update org o k response has a 5xx status code +func (o *UpdateOrgOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update org o k response a status code equal to that given +func (o *UpdateOrgOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update org o k response +func (o *UpdateOrgOK) Code() int { + return 200 +} + func (o *UpdateOrgOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgOK %s", 200, payload) +} + +func (o *UpdateOrgOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgOK %s", 200, payload) } func (o *UpdateOrgOK) GetPayload() *UpdateOrgOKBody { @@ -107,20 +145,60 @@ func NewUpdateOrgForbidden() *UpdateOrgForbidden { return &UpdateOrgForbidden{} } -/*UpdateOrgForbidden handles this case with default header values. +/* +UpdateOrgForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateOrgForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update org forbidden response has a 2xx status code +func (o *UpdateOrgForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update org forbidden response has a 3xx status code +func (o *UpdateOrgForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org forbidden response has a 4xx status code +func (o *UpdateOrgForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update org forbidden response has a 5xx status code +func (o *UpdateOrgForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update org forbidden response a status code equal to that given +func (o *UpdateOrgForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update org forbidden response +func (o *UpdateOrgForbidden) Code() int { + return 403 +} + func (o *UpdateOrgForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgForbidden %s", 403, payload) +} + +func (o *UpdateOrgForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgForbidden %s", 403, payload) } func (o *UpdateOrgForbidden) GetPayload() *models.ErrorPayload { @@ -129,12 +207,16 @@ func (o *UpdateOrgForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateOrgForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -151,20 +233,60 @@ func NewUpdateOrgNotFound() *UpdateOrgNotFound { return &UpdateOrgNotFound{} } -/*UpdateOrgNotFound handles this case with default header values. +/* +UpdateOrgNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateOrgNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update org not found response has a 2xx status code +func (o *UpdateOrgNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update org not found response has a 3xx status code +func (o *UpdateOrgNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org not found response has a 4xx status code +func (o *UpdateOrgNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update org not found response has a 5xx status code +func (o *UpdateOrgNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update org not found response a status code equal to that given +func (o *UpdateOrgNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update org not found response +func (o *UpdateOrgNotFound) Code() int { + return 404 +} + func (o *UpdateOrgNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgNotFound %s", 404, payload) +} + +func (o *UpdateOrgNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgNotFound %s", 404, payload) } func (o *UpdateOrgNotFound) GetPayload() *models.ErrorPayload { @@ -173,12 +295,16 @@ func (o *UpdateOrgNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateOrgNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -195,15 +321,50 @@ func NewUpdateOrgLengthRequired() *UpdateOrgLengthRequired { return &UpdateOrgLengthRequired{} } -/*UpdateOrgLengthRequired handles this case with default header values. +/* +UpdateOrgLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateOrgLengthRequired struct { } +// IsSuccess returns true when this update org length required response has a 2xx status code +func (o *UpdateOrgLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update org length required response has a 3xx status code +func (o *UpdateOrgLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org length required response has a 4xx status code +func (o *UpdateOrgLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update org length required response has a 5xx status code +func (o *UpdateOrgLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update org length required response a status code equal to that given +func (o *UpdateOrgLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update org length required response +func (o *UpdateOrgLengthRequired) Code() int { + return 411 +} + func (o *UpdateOrgLengthRequired) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgLengthRequired ", 411) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgLengthRequired", 411) +} + +func (o *UpdateOrgLengthRequired) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgLengthRequired", 411) } func (o *UpdateOrgLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -216,20 +377,60 @@ func NewUpdateOrgUnprocessableEntity() *UpdateOrgUnprocessableEntity { return &UpdateOrgUnprocessableEntity{} } -/*UpdateOrgUnprocessableEntity handles this case with default header values. +/* +UpdateOrgUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateOrgUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update org unprocessable entity response has a 2xx status code +func (o *UpdateOrgUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update org unprocessable entity response has a 3xx status code +func (o *UpdateOrgUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update org unprocessable entity response has a 4xx status code +func (o *UpdateOrgUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update org unprocessable entity response has a 5xx status code +func (o *UpdateOrgUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update org unprocessable entity response a status code equal to that given +func (o *UpdateOrgUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update org unprocessable entity response +func (o *UpdateOrgUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateOrgUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateOrgUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrgUnprocessableEntity %s", 422, payload) } func (o *UpdateOrgUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -238,12 +439,16 @@ func (o *UpdateOrgUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *UpdateOrgUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -262,27 +467,61 @@ func NewUpdateOrgDefault(code int) *UpdateOrgDefault { } } -/*UpdateOrgDefault handles this case with default header values. +/* +UpdateOrgDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateOrgDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update org default response has a 2xx status code +func (o *UpdateOrgDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update org default response has a 3xx status code +func (o *UpdateOrgDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update org default response has a 4xx status code +func (o *UpdateOrgDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update org default response has a 5xx status code +func (o *UpdateOrgDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update org default response a status code equal to that given +func (o *UpdateOrgDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update org default response func (o *UpdateOrgDefault) Code() int { return o._statusCode } func (o *UpdateOrgDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrg default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrg default %s", o._statusCode, payload) +} + +func (o *UpdateOrgDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}][%d] updateOrg default %s", o._statusCode, payload) } func (o *UpdateOrgDefault) GetPayload() *models.ErrorPayload { @@ -291,12 +530,16 @@ func (o *UpdateOrgDefault) GetPayload() *models.ErrorPayload { func (o *UpdateOrgDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -308,7 +551,8 @@ func (o *UpdateOrgDefault) readResponse(response runtime.ClientResponse, consume return nil } -/*UpdateOrgOKBody update org o k body +/* +UpdateOrgOKBody update org o k body swagger:model UpdateOrgOKBody */ type UpdateOrgOKBody struct { @@ -342,6 +586,39 @@ func (o *UpdateOrgOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateOrgOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateOrgOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update org o k body based on the context it is used +func (o *UpdateOrgOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateOrgOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateOrgOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateOrgOK" + "." + "data") } return err } diff --git a/client/client/service_catalogs/create_service_catalog_from_template_parameters.go b/client/client/service_catalogs/create_service_catalog_from_template_parameters.go index 77d58a80..0301fe67 100644 --- a/client/client/service_catalogs/create_service_catalog_from_template_parameters.go +++ b/client/client/service_catalogs/create_service_catalog_from_template_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateServiceCatalogFromTemplateParams creates a new CreateServiceCatalogFromTemplateParams object -// with the default values initialized. +// NewCreateServiceCatalogFromTemplateParams creates a new CreateServiceCatalogFromTemplateParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateServiceCatalogFromTemplateParams() *CreateServiceCatalogFromTemplateParams { - var () return &CreateServiceCatalogFromTemplateParams{ - timeout: cr.DefaultTimeout, } } // NewCreateServiceCatalogFromTemplateParamsWithTimeout creates a new CreateServiceCatalogFromTemplateParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateServiceCatalogFromTemplateParamsWithTimeout(timeout time.Duration) *CreateServiceCatalogFromTemplateParams { - var () return &CreateServiceCatalogFromTemplateParams{ - timeout: timeout, } } // NewCreateServiceCatalogFromTemplateParamsWithContext creates a new CreateServiceCatalogFromTemplateParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateServiceCatalogFromTemplateParamsWithContext(ctx context.Context) *CreateServiceCatalogFromTemplateParams { - var () return &CreateServiceCatalogFromTemplateParams{ - Context: ctx, } } // NewCreateServiceCatalogFromTemplateParamsWithHTTPClient creates a new CreateServiceCatalogFromTemplateParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateServiceCatalogFromTemplateParamsWithHTTPClient(client *http.Client) *CreateServiceCatalogFromTemplateParams { - var () return &CreateServiceCatalogFromTemplateParams{ HTTPClient: client, } } -/*CreateServiceCatalogFromTemplateParams contains all the parameters to send to the API endpoint -for the create service catalog from template operation typically these are written to a http.Request +/* +CreateServiceCatalogFromTemplateParams contains all the parameters to send to the API endpoint + + for the create service catalog from template operation. + + Typically these are written to a http.Request. */ type CreateServiceCatalogFromTemplateParams struct { - /*Body - The information of the ServiceCatalog. + /* Body. + The information of the ServiceCatalog. */ Body *models.NewServiceCatalogFromTemplate - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -84,6 +86,21 @@ type CreateServiceCatalogFromTemplateParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create service catalog from template params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateServiceCatalogFromTemplateParams) WithDefaults() *CreateServiceCatalogFromTemplateParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create service catalog from template params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateServiceCatalogFromTemplateParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create service catalog from template params func (o *CreateServiceCatalogFromTemplateParams) WithTimeout(timeout time.Duration) *CreateServiceCatalogFromTemplateParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *CreateServiceCatalogFromTemplateParams) WriteToRequest(r runtime.Client return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/service_catalogs/create_service_catalog_from_template_responses.go b/client/client/service_catalogs/create_service_catalog_from_template_responses.go index 399bc997..618b4b5d 100644 --- a/client/client/service_catalogs/create_service_catalog_from_template_responses.go +++ b/client/client/service_catalogs/create_service_catalog_from_template_responses.go @@ -6,17 +6,18 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateServiceCatalogFromTemplateReader is a Reader for the CreateServiceCatalogFromTemplate structure. @@ -68,7 +69,8 @@ func NewCreateServiceCatalogFromTemplateOK() *CreateServiceCatalogFromTemplateOK return &CreateServiceCatalogFromTemplateOK{} } -/*CreateServiceCatalogFromTemplateOK handles this case with default header values. +/* +CreateServiceCatalogFromTemplateOK describes a response with status code 200, with default header values. The information of the service catalog. */ @@ -76,8 +78,44 @@ type CreateServiceCatalogFromTemplateOK struct { Payload *CreateServiceCatalogFromTemplateOKBody } +// IsSuccess returns true when this create service catalog from template o k response has a 2xx status code +func (o *CreateServiceCatalogFromTemplateOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create service catalog from template o k response has a 3xx status code +func (o *CreateServiceCatalogFromTemplateOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog from template o k response has a 4xx status code +func (o *CreateServiceCatalogFromTemplateOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create service catalog from template o k response has a 5xx status code +func (o *CreateServiceCatalogFromTemplateOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog from template o k response a status code equal to that given +func (o *CreateServiceCatalogFromTemplateOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create service catalog from template o k response +func (o *CreateServiceCatalogFromTemplateOK) Code() int { + return 200 +} + func (o *CreateServiceCatalogFromTemplateOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateOK %s", 200, payload) +} + +func (o *CreateServiceCatalogFromTemplateOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateOK %s", 200, payload) } func (o *CreateServiceCatalogFromTemplateOK) GetPayload() *CreateServiceCatalogFromTemplateOKBody { @@ -101,20 +139,60 @@ func NewCreateServiceCatalogFromTemplateForbidden() *CreateServiceCatalogFromTem return &CreateServiceCatalogFromTemplateForbidden{} } -/*CreateServiceCatalogFromTemplateForbidden handles this case with default header values. +/* +CreateServiceCatalogFromTemplateForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateServiceCatalogFromTemplateForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog from template forbidden response has a 2xx status code +func (o *CreateServiceCatalogFromTemplateForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog from template forbidden response has a 3xx status code +func (o *CreateServiceCatalogFromTemplateForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog from template forbidden response has a 4xx status code +func (o *CreateServiceCatalogFromTemplateForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog from template forbidden response has a 5xx status code +func (o *CreateServiceCatalogFromTemplateForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog from template forbidden response a status code equal to that given +func (o *CreateServiceCatalogFromTemplateForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create service catalog from template forbidden response +func (o *CreateServiceCatalogFromTemplateForbidden) Code() int { + return 403 +} + func (o *CreateServiceCatalogFromTemplateForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateForbidden %s", 403, payload) +} + +func (o *CreateServiceCatalogFromTemplateForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateForbidden %s", 403, payload) } func (o *CreateServiceCatalogFromTemplateForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *CreateServiceCatalogFromTemplateForbidden) GetPayload() *models.ErrorPa func (o *CreateServiceCatalogFromTemplateForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewCreateServiceCatalogFromTemplateNotFound() *CreateServiceCatalogFromTemp return &CreateServiceCatalogFromTemplateNotFound{} } -/*CreateServiceCatalogFromTemplateNotFound handles this case with default header values. +/* +CreateServiceCatalogFromTemplateNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateServiceCatalogFromTemplateNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog from template not found response has a 2xx status code +func (o *CreateServiceCatalogFromTemplateNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog from template not found response has a 3xx status code +func (o *CreateServiceCatalogFromTemplateNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog from template not found response has a 4xx status code +func (o *CreateServiceCatalogFromTemplateNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog from template not found response has a 5xx status code +func (o *CreateServiceCatalogFromTemplateNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog from template not found response a status code equal to that given +func (o *CreateServiceCatalogFromTemplateNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create service catalog from template not found response +func (o *CreateServiceCatalogFromTemplateNotFound) Code() int { + return 404 +} + func (o *CreateServiceCatalogFromTemplateNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateNotFound %s", 404, payload) +} + +func (o *CreateServiceCatalogFromTemplateNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateNotFound %s", 404, payload) } func (o *CreateServiceCatalogFromTemplateNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *CreateServiceCatalogFromTemplateNotFound) GetPayload() *models.ErrorPay func (o *CreateServiceCatalogFromTemplateNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewCreateServiceCatalogFromTemplateUnprocessableEntity() *CreateServiceCata return &CreateServiceCatalogFromTemplateUnprocessableEntity{} } -/*CreateServiceCatalogFromTemplateUnprocessableEntity handles this case with default header values. +/* +CreateServiceCatalogFromTemplateUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateServiceCatalogFromTemplateUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog from template unprocessable entity response has a 2xx status code +func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog from template unprocessable entity response has a 3xx status code +func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog from template unprocessable entity response has a 4xx status code +func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog from template unprocessable entity response has a 5xx status code +func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog from template unprocessable entity response a status code equal to that given +func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create service catalog from template unprocessable entity response +func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateUnprocessableEntity %s", 422, payload) +} + +func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplateUnprocessableEntity %s", 422, payload) } func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) GetPayload() *mode func (o *CreateServiceCatalogFromTemplateUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewCreateServiceCatalogFromTemplateDefault(code int) *CreateServiceCatalogF } } -/*CreateServiceCatalogFromTemplateDefault handles this case with default header values. +/* +CreateServiceCatalogFromTemplateDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateServiceCatalogFromTemplateDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog from template default response has a 2xx status code +func (o *CreateServiceCatalogFromTemplateDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create service catalog from template default response has a 3xx status code +func (o *CreateServiceCatalogFromTemplateDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create service catalog from template default response has a 4xx status code +func (o *CreateServiceCatalogFromTemplateDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create service catalog from template default response has a 5xx status code +func (o *CreateServiceCatalogFromTemplateDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create service catalog from template default response a status code equal to that given +func (o *CreateServiceCatalogFromTemplateDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create service catalog from template default response func (o *CreateServiceCatalogFromTemplateDefault) Code() int { return o._statusCode } func (o *CreateServiceCatalogFromTemplateDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplate default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplate default %s", o._statusCode, payload) +} + +func (o *CreateServiceCatalogFromTemplateDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template][%d] createServiceCatalogFromTemplate default %s", o._statusCode, payload) } func (o *CreateServiceCatalogFromTemplateDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *CreateServiceCatalogFromTemplateDefault) GetPayload() *models.ErrorPayl func (o *CreateServiceCatalogFromTemplateDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *CreateServiceCatalogFromTemplateDefault) readResponse(response runtime. return nil } -/*CreateServiceCatalogFromTemplateOKBody create service catalog from template o k body +/* +CreateServiceCatalogFromTemplateOKBody create service catalog from template o k body swagger:model CreateServiceCatalogFromTemplateOKBody */ type CreateServiceCatalogFromTemplateOKBody struct { @@ -315,6 +524,39 @@ func (o *CreateServiceCatalogFromTemplateOKBody) validateData(formats strfmt.Reg if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createServiceCatalogFromTemplateOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createServiceCatalogFromTemplateOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create service catalog from template o k body based on the context it is used +func (o *CreateServiceCatalogFromTemplateOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateServiceCatalogFromTemplateOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createServiceCatalogFromTemplateOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createServiceCatalogFromTemplateOK" + "." + "data") } return err } diff --git a/client/client/service_catalogs/create_service_catalog_parameters.go b/client/client/service_catalogs/create_service_catalog_parameters.go index 499c0890..19708da4 100644 --- a/client/client/service_catalogs/create_service_catalog_parameters.go +++ b/client/client/service_catalogs/create_service_catalog_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateServiceCatalogParams creates a new CreateServiceCatalogParams object -// with the default values initialized. +// NewCreateServiceCatalogParams creates a new CreateServiceCatalogParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateServiceCatalogParams() *CreateServiceCatalogParams { - var () return &CreateServiceCatalogParams{ - timeout: cr.DefaultTimeout, } } // NewCreateServiceCatalogParamsWithTimeout creates a new CreateServiceCatalogParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateServiceCatalogParamsWithTimeout(timeout time.Duration) *CreateServiceCatalogParams { - var () return &CreateServiceCatalogParams{ - timeout: timeout, } } // NewCreateServiceCatalogParamsWithContext creates a new CreateServiceCatalogParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateServiceCatalogParamsWithContext(ctx context.Context) *CreateServiceCatalogParams { - var () return &CreateServiceCatalogParams{ - Context: ctx, } } // NewCreateServiceCatalogParamsWithHTTPClient creates a new CreateServiceCatalogParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateServiceCatalogParamsWithHTTPClient(client *http.Client) *CreateServiceCatalogParams { - var () return &CreateServiceCatalogParams{ HTTPClient: client, } } -/*CreateServiceCatalogParams contains all the parameters to send to the API endpoint -for the create service catalog operation typically these are written to a http.Request +/* +CreateServiceCatalogParams contains all the parameters to send to the API endpoint + + for the create service catalog operation. + + Typically these are written to a http.Request. */ type CreateServiceCatalogParams struct { - /*Body - The information of the ServiceCatalog. + /* Body. + The information of the ServiceCatalog. */ Body *models.NewServiceCatalog - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string @@ -79,6 +80,21 @@ type CreateServiceCatalogParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create service catalog params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateServiceCatalogParams) WithDefaults() *CreateServiceCatalogParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create service catalog params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateServiceCatalogParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create service catalog params func (o *CreateServiceCatalogParams) WithTimeout(timeout time.Duration) *CreateServiceCatalogParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CreateServiceCatalogParams) WriteToRequest(r runtime.ClientRequest, reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/service_catalogs/create_service_catalog_responses.go b/client/client/service_catalogs/create_service_catalog_responses.go index 2700c12c..58ade58a 100644 --- a/client/client/service_catalogs/create_service_catalog_responses.go +++ b/client/client/service_catalogs/create_service_catalog_responses.go @@ -6,17 +6,18 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateServiceCatalogReader is a Reader for the CreateServiceCatalog structure. @@ -68,7 +69,8 @@ func NewCreateServiceCatalogOK() *CreateServiceCatalogOK { return &CreateServiceCatalogOK{} } -/*CreateServiceCatalogOK handles this case with default header values. +/* +CreateServiceCatalogOK describes a response with status code 200, with default header values. The information of the service catalog. */ @@ -76,8 +78,44 @@ type CreateServiceCatalogOK struct { Payload *CreateServiceCatalogOKBody } +// IsSuccess returns true when this create service catalog o k response has a 2xx status code +func (o *CreateServiceCatalogOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create service catalog o k response has a 3xx status code +func (o *CreateServiceCatalogOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog o k response has a 4xx status code +func (o *CreateServiceCatalogOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create service catalog o k response has a 5xx status code +func (o *CreateServiceCatalogOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog o k response a status code equal to that given +func (o *CreateServiceCatalogOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create service catalog o k response +func (o *CreateServiceCatalogOK) Code() int { + return 200 +} + func (o *CreateServiceCatalogOK) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogOK %s", 200, payload) +} + +func (o *CreateServiceCatalogOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogOK %s", 200, payload) } func (o *CreateServiceCatalogOK) GetPayload() *CreateServiceCatalogOKBody { @@ -101,20 +139,60 @@ func NewCreateServiceCatalogForbidden() *CreateServiceCatalogForbidden { return &CreateServiceCatalogForbidden{} } -/*CreateServiceCatalogForbidden handles this case with default header values. +/* +CreateServiceCatalogForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type CreateServiceCatalogForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog forbidden response has a 2xx status code +func (o *CreateServiceCatalogForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog forbidden response has a 3xx status code +func (o *CreateServiceCatalogForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog forbidden response has a 4xx status code +func (o *CreateServiceCatalogForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog forbidden response has a 5xx status code +func (o *CreateServiceCatalogForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog forbidden response a status code equal to that given +func (o *CreateServiceCatalogForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create service catalog forbidden response +func (o *CreateServiceCatalogForbidden) Code() int { + return 403 +} + func (o *CreateServiceCatalogForbidden) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogForbidden %s", 403, payload) +} + +func (o *CreateServiceCatalogForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogForbidden %s", 403, payload) } func (o *CreateServiceCatalogForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *CreateServiceCatalogForbidden) GetPayload() *models.ErrorPayload { func (o *CreateServiceCatalogForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewCreateServiceCatalogNotFound() *CreateServiceCatalogNotFound { return &CreateServiceCatalogNotFound{} } -/*CreateServiceCatalogNotFound handles this case with default header values. +/* +CreateServiceCatalogNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type CreateServiceCatalogNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog not found response has a 2xx status code +func (o *CreateServiceCatalogNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog not found response has a 3xx status code +func (o *CreateServiceCatalogNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog not found response has a 4xx status code +func (o *CreateServiceCatalogNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog not found response has a 5xx status code +func (o *CreateServiceCatalogNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog not found response a status code equal to that given +func (o *CreateServiceCatalogNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the create service catalog not found response +func (o *CreateServiceCatalogNotFound) Code() int { + return 404 +} + func (o *CreateServiceCatalogNotFound) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogNotFound %s", 404, payload) +} + +func (o *CreateServiceCatalogNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogNotFound %s", 404, payload) } func (o *CreateServiceCatalogNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *CreateServiceCatalogNotFound) GetPayload() *models.ErrorPayload { func (o *CreateServiceCatalogNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewCreateServiceCatalogUnprocessableEntity() *CreateServiceCatalogUnprocess return &CreateServiceCatalogUnprocessableEntity{} } -/*CreateServiceCatalogUnprocessableEntity handles this case with default header values. +/* +CreateServiceCatalogUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type CreateServiceCatalogUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog unprocessable entity response has a 2xx status code +func (o *CreateServiceCatalogUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create service catalog unprocessable entity response has a 3xx status code +func (o *CreateServiceCatalogUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create service catalog unprocessable entity response has a 4xx status code +func (o *CreateServiceCatalogUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create service catalog unprocessable entity response has a 5xx status code +func (o *CreateServiceCatalogUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create service catalog unprocessable entity response a status code equal to that given +func (o *CreateServiceCatalogUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create service catalog unprocessable entity response +func (o *CreateServiceCatalogUnprocessableEntity) Code() int { + return 422 +} + func (o *CreateServiceCatalogUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogUnprocessableEntity %s", 422, payload) +} + +func (o *CreateServiceCatalogUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalogUnprocessableEntity %s", 422, payload) } func (o *CreateServiceCatalogUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *CreateServiceCatalogUnprocessableEntity) GetPayload() *models.ErrorPayl func (o *CreateServiceCatalogUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewCreateServiceCatalogDefault(code int) *CreateServiceCatalogDefault { } } -/*CreateServiceCatalogDefault handles this case with default header values. +/* +CreateServiceCatalogDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateServiceCatalogDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create service catalog default response has a 2xx status code +func (o *CreateServiceCatalogDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create service catalog default response has a 3xx status code +func (o *CreateServiceCatalogDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create service catalog default response has a 4xx status code +func (o *CreateServiceCatalogDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create service catalog default response has a 5xx status code +func (o *CreateServiceCatalogDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create service catalog default response a status code equal to that given +func (o *CreateServiceCatalogDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create service catalog default response func (o *CreateServiceCatalogDefault) Code() int { return o._statusCode } func (o *CreateServiceCatalogDefault) Error() string { - return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalog default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalog default %s", o._statusCode, payload) +} + +func (o *CreateServiceCatalogDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /organizations/{organization_canonical}/service_catalogs][%d] createServiceCatalog default %s", o._statusCode, payload) } func (o *CreateServiceCatalogDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *CreateServiceCatalogDefault) GetPayload() *models.ErrorPayload { func (o *CreateServiceCatalogDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *CreateServiceCatalogDefault) readResponse(response runtime.ClientRespon return nil } -/*CreateServiceCatalogOKBody create service catalog o k body +/* +CreateServiceCatalogOKBody create service catalog o k body swagger:model CreateServiceCatalogOKBody */ type CreateServiceCatalogOKBody struct { @@ -315,6 +524,39 @@ func (o *CreateServiceCatalogOKBody) validateData(formats strfmt.Registry) error if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createServiceCatalogOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createServiceCatalogOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create service catalog o k body based on the context it is used +func (o *CreateServiceCatalogOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateServiceCatalogOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createServiceCatalogOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createServiceCatalogOK" + "." + "data") } return err } diff --git a/client/client/service_catalogs/delete_service_catalog_parameters.go b/client/client/service_catalogs/delete_service_catalog_parameters.go index d534caa7..730c657f 100644 --- a/client/client/service_catalogs/delete_service_catalog_parameters.go +++ b/client/client/service_catalogs/delete_service_catalog_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteServiceCatalogParams creates a new DeleteServiceCatalogParams object -// with the default values initialized. +// NewDeleteServiceCatalogParams creates a new DeleteServiceCatalogParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteServiceCatalogParams() *DeleteServiceCatalogParams { - var () return &DeleteServiceCatalogParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteServiceCatalogParamsWithTimeout creates a new DeleteServiceCatalogParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteServiceCatalogParamsWithTimeout(timeout time.Duration) *DeleteServiceCatalogParams { - var () return &DeleteServiceCatalogParams{ - timeout: timeout, } } // NewDeleteServiceCatalogParamsWithContext creates a new DeleteServiceCatalogParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteServiceCatalogParamsWithContext(ctx context.Context) *DeleteServiceCatalogParams { - var () return &DeleteServiceCatalogParams{ - Context: ctx, } } // NewDeleteServiceCatalogParamsWithHTTPClient creates a new DeleteServiceCatalogParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteServiceCatalogParamsWithHTTPClient(client *http.Client) *DeleteServiceCatalogParams { - var () return &DeleteServiceCatalogParams{ HTTPClient: client, } } -/*DeleteServiceCatalogParams contains all the parameters to send to the API endpoint -for the delete service catalog operation typically these are written to a http.Request +/* +DeleteServiceCatalogParams contains all the parameters to send to the API endpoint + + for the delete service catalog operation. + + Typically these are written to a http.Request. */ type DeleteServiceCatalogParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -77,6 +78,21 @@ type DeleteServiceCatalogParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete service catalog params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteServiceCatalogParams) WithDefaults() *DeleteServiceCatalogParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete service catalog params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteServiceCatalogParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete service catalog params func (o *DeleteServiceCatalogParams) WithTimeout(timeout time.Duration) *DeleteServiceCatalogParams { o.SetTimeout(timeout) diff --git a/client/client/service_catalogs/delete_service_catalog_responses.go b/client/client/service_catalogs/delete_service_catalog_responses.go index 3b75ef60..0c3d4cb7 100644 --- a/client/client/service_catalogs/delete_service_catalog_responses.go +++ b/client/client/service_catalogs/delete_service_catalog_responses.go @@ -6,16 +6,16 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteServiceCatalogReader is a Reader for the DeleteServiceCatalog structure. @@ -50,9 +50,8 @@ func (o *DeleteServiceCatalogReader) ReadResponse(response runtime.ClientRespons return nil, err } return nil, result - default: - return nil, runtime.NewAPIError("unknown error", response, response.Code()) + return nil, runtime.NewAPIError("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}] deleteServiceCatalog", response, response.Code()) } } @@ -61,15 +60,50 @@ func NewDeleteServiceCatalogNoContent() *DeleteServiceCatalogNoContent { return &DeleteServiceCatalogNoContent{} } -/*DeleteServiceCatalogNoContent handles this case with default header values. +/* +DeleteServiceCatalogNoContent describes a response with status code 204, with default header values. Service Catalog has been deleted. */ type DeleteServiceCatalogNoContent struct { } +// IsSuccess returns true when this delete service catalog no content response has a 2xx status code +func (o *DeleteServiceCatalogNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete service catalog no content response has a 3xx status code +func (o *DeleteServiceCatalogNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete service catalog no content response has a 4xx status code +func (o *DeleteServiceCatalogNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete service catalog no content response has a 5xx status code +func (o *DeleteServiceCatalogNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete service catalog no content response a status code equal to that given +func (o *DeleteServiceCatalogNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete service catalog no content response +func (o *DeleteServiceCatalogNoContent) Code() int { + return 204 +} + func (o *DeleteServiceCatalogNoContent) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogNoContent ", 204) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogNoContent", 204) +} + +func (o *DeleteServiceCatalogNoContent) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogNoContent", 204) } func (o *DeleteServiceCatalogNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +116,60 @@ func NewDeleteServiceCatalogForbidden() *DeleteServiceCatalogForbidden { return &DeleteServiceCatalogForbidden{} } -/*DeleteServiceCatalogForbidden handles this case with default header values. +/* +DeleteServiceCatalogForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteServiceCatalogForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete service catalog forbidden response has a 2xx status code +func (o *DeleteServiceCatalogForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete service catalog forbidden response has a 3xx status code +func (o *DeleteServiceCatalogForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete service catalog forbidden response has a 4xx status code +func (o *DeleteServiceCatalogForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete service catalog forbidden response has a 5xx status code +func (o *DeleteServiceCatalogForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete service catalog forbidden response a status code equal to that given +func (o *DeleteServiceCatalogForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete service catalog forbidden response +func (o *DeleteServiceCatalogForbidden) Code() int { + return 403 +} + func (o *DeleteServiceCatalogForbidden) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogForbidden %s", 403, payload) +} + +func (o *DeleteServiceCatalogForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogForbidden %s", 403, payload) } func (o *DeleteServiceCatalogForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +178,16 @@ func (o *DeleteServiceCatalogForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteServiceCatalogForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +204,60 @@ func NewDeleteServiceCatalogNotFound() *DeleteServiceCatalogNotFound { return &DeleteServiceCatalogNotFound{} } -/*DeleteServiceCatalogNotFound handles this case with default header values. +/* +DeleteServiceCatalogNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type DeleteServiceCatalogNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete service catalog not found response has a 2xx status code +func (o *DeleteServiceCatalogNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete service catalog not found response has a 3xx status code +func (o *DeleteServiceCatalogNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete service catalog not found response has a 4xx status code +func (o *DeleteServiceCatalogNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete service catalog not found response has a 5xx status code +func (o *DeleteServiceCatalogNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete service catalog not found response a status code equal to that given +func (o *DeleteServiceCatalogNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete service catalog not found response +func (o *DeleteServiceCatalogNotFound) Code() int { + return 404 +} + func (o *DeleteServiceCatalogNotFound) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogNotFound %s", 404, payload) +} + +func (o *DeleteServiceCatalogNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogNotFound %s", 404, payload) } func (o *DeleteServiceCatalogNotFound) GetPayload() *models.ErrorPayload { @@ -148,12 +266,16 @@ func (o *DeleteServiceCatalogNotFound) GetPayload() *models.ErrorPayload { func (o *DeleteServiceCatalogNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -170,15 +292,50 @@ func NewDeleteServiceCatalogConflict() *DeleteServiceCatalogConflict { return &DeleteServiceCatalogConflict{} } -/*DeleteServiceCatalogConflict handles this case with default header values. +/* +DeleteServiceCatalogConflict describes a response with status code 409, with default header values. Service Catalog deletion has internal conflict */ type DeleteServiceCatalogConflict struct { } +// IsSuccess returns true when this delete service catalog conflict response has a 2xx status code +func (o *DeleteServiceCatalogConflict) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete service catalog conflict response has a 3xx status code +func (o *DeleteServiceCatalogConflict) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete service catalog conflict response has a 4xx status code +func (o *DeleteServiceCatalogConflict) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete service catalog conflict response has a 5xx status code +func (o *DeleteServiceCatalogConflict) IsServerError() bool { + return false +} + +// IsCode returns true when this delete service catalog conflict response a status code equal to that given +func (o *DeleteServiceCatalogConflict) IsCode(code int) bool { + return code == 409 +} + +// Code gets the status code for the delete service catalog conflict response +func (o *DeleteServiceCatalogConflict) Code() int { + return 409 +} + func (o *DeleteServiceCatalogConflict) Error() string { - return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogConflict ", 409) + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogConflict", 409) +} + +func (o *DeleteServiceCatalogConflict) String() string { + return fmt.Sprintf("[DELETE /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] deleteServiceCatalogConflict", 409) } func (o *DeleteServiceCatalogConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { diff --git a/client/client/service_catalogs/get_service_catalog_config_parameters.go b/client/client/service_catalogs/get_service_catalog_config_parameters.go index 3f44e0a9..8fad5712 100644 --- a/client/client/service_catalogs/get_service_catalog_config_parameters.go +++ b/client/client/service_catalogs/get_service_catalog_config_parameters.go @@ -13,77 +13,81 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetServiceCatalogConfigParams creates a new GetServiceCatalogConfigParams object -// with the default values initialized. +// NewGetServiceCatalogConfigParams creates a new GetServiceCatalogConfigParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetServiceCatalogConfigParams() *GetServiceCatalogConfigParams { - var () return &GetServiceCatalogConfigParams{ - timeout: cr.DefaultTimeout, } } // NewGetServiceCatalogConfigParamsWithTimeout creates a new GetServiceCatalogConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetServiceCatalogConfigParamsWithTimeout(timeout time.Duration) *GetServiceCatalogConfigParams { - var () return &GetServiceCatalogConfigParams{ - timeout: timeout, } } // NewGetServiceCatalogConfigParamsWithContext creates a new GetServiceCatalogConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetServiceCatalogConfigParamsWithContext(ctx context.Context) *GetServiceCatalogConfigParams { - var () return &GetServiceCatalogConfigParams{ - Context: ctx, } } // NewGetServiceCatalogConfigParamsWithHTTPClient creates a new GetServiceCatalogConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetServiceCatalogConfigParamsWithHTTPClient(client *http.Client) *GetServiceCatalogConfigParams { - var () return &GetServiceCatalogConfigParams{ HTTPClient: client, } } -/*GetServiceCatalogConfigParams contains all the parameters to send to the API endpoint -for the get service catalog config operation typically these are written to a http.Request +/* +GetServiceCatalogConfigParams contains all the parameters to send to the API endpoint + + for the get service catalog config operation. + + Typically these are written to a http.Request. */ type GetServiceCatalogConfigParams struct { - /*Environment - The environment canonical to use a query filter + /* EnvironmentCanonical. + A list of environments' canonical to filter from */ - Environment *string - /*OrganizationCanonical - A canonical of an organization. + EnvironmentCanonical *string + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*Project - A canonical of a project used for filtering. + /* ProjectCanonical. + + A list of projects' canonical to filter from */ - Project *string - /*ServiceCatalogRef - A Service Catalog name + ProjectCanonical *string + + /* ServiceCatalogRef. + A Service Catalog name */ ServiceCatalogRef string - /*UseCase - A use case of a stack to be selectd from the stack config + /* UseCase. + + A use case of a stack to be selectd from the stack config */ UseCase *string @@ -92,6 +96,21 @@ type GetServiceCatalogConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get service catalog config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogConfigParams) WithDefaults() *GetServiceCatalogConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get service catalog config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get service catalog config params func (o *GetServiceCatalogConfigParams) WithTimeout(timeout time.Duration) *GetServiceCatalogConfigParams { o.SetTimeout(timeout) @@ -125,15 +144,15 @@ func (o *GetServiceCatalogConfigParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } -// WithEnvironment adds the environment to the get service catalog config params -func (o *GetServiceCatalogConfigParams) WithEnvironment(environment *string) *GetServiceCatalogConfigParams { - o.SetEnvironment(environment) +// WithEnvironmentCanonical adds the environmentCanonical to the get service catalog config params +func (o *GetServiceCatalogConfigParams) WithEnvironmentCanonical(environmentCanonical *string) *GetServiceCatalogConfigParams { + o.SetEnvironmentCanonical(environmentCanonical) return o } -// SetEnvironment adds the environment to the get service catalog config params -func (o *GetServiceCatalogConfigParams) SetEnvironment(environment *string) { - o.Environment = environment +// SetEnvironmentCanonical adds the environmentCanonical to the get service catalog config params +func (o *GetServiceCatalogConfigParams) SetEnvironmentCanonical(environmentCanonical *string) { + o.EnvironmentCanonical = environmentCanonical } // WithOrganizationCanonical adds the organizationCanonical to the get service catalog config params @@ -147,15 +166,15 @@ func (o *GetServiceCatalogConfigParams) SetOrganizationCanonical(organizationCan o.OrganizationCanonical = organizationCanonical } -// WithProject adds the project to the get service catalog config params -func (o *GetServiceCatalogConfigParams) WithProject(project *string) *GetServiceCatalogConfigParams { - o.SetProject(project) +// WithProjectCanonical adds the projectCanonical to the get service catalog config params +func (o *GetServiceCatalogConfigParams) WithProjectCanonical(projectCanonical *string) *GetServiceCatalogConfigParams { + o.SetProjectCanonical(projectCanonical) return o } -// SetProject adds the project to the get service catalog config params -func (o *GetServiceCatalogConfigParams) SetProject(project *string) { - o.Project = project +// SetProjectCanonical adds the projectCanonical to the get service catalog config params +func (o *GetServiceCatalogConfigParams) SetProjectCanonical(projectCanonical *string) { + o.ProjectCanonical = projectCanonical } // WithServiceCatalogRef adds the serviceCatalogRef to the get service catalog config params @@ -188,20 +207,21 @@ func (o *GetServiceCatalogConfigParams) WriteToRequest(r runtime.ClientRequest, } var res []error - if o.Environment != nil { + if o.EnvironmentCanonical != nil { - // query param environment - var qrEnvironment string - if o.Environment != nil { - qrEnvironment = *o.Environment + // query param environment_canonical + var qrEnvironmentCanonical string + + if o.EnvironmentCanonical != nil { + qrEnvironmentCanonical = *o.EnvironmentCanonical } - qEnvironment := qrEnvironment - if qEnvironment != "" { - if err := r.SetQueryParam("environment", qEnvironment); err != nil { + qEnvironmentCanonical := qrEnvironmentCanonical + if qEnvironmentCanonical != "" { + + if err := r.SetQueryParam("environment_canonical", qEnvironmentCanonical); err != nil { return err } } - } // path param organization_canonical @@ -209,20 +229,21 @@ func (o *GetServiceCatalogConfigParams) WriteToRequest(r runtime.ClientRequest, return err } - if o.Project != nil { + if o.ProjectCanonical != nil { - // query param project - var qrProject string - if o.Project != nil { - qrProject = *o.Project + // query param project_canonical + var qrProjectCanonical string + + if o.ProjectCanonical != nil { + qrProjectCanonical = *o.ProjectCanonical } - qProject := qrProject - if qProject != "" { - if err := r.SetQueryParam("project", qProject); err != nil { + qProjectCanonical := qrProjectCanonical + if qProjectCanonical != "" { + + if err := r.SetQueryParam("project_canonical", qProjectCanonical); err != nil { return err } } - } // path param service_catalog_ref @@ -234,16 +255,17 @@ func (o *GetServiceCatalogConfigParams) WriteToRequest(r runtime.ClientRequest, // query param use_case var qrUseCase string + if o.UseCase != nil { qrUseCase = *o.UseCase } qUseCase := qrUseCase if qUseCase != "" { + if err := r.SetQueryParam("use_case", qUseCase); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/service_catalogs/get_service_catalog_config_responses.go b/client/client/service_catalogs/get_service_catalog_config_responses.go index 245f6f1f..4db8dda3 100644 --- a/client/client/service_catalogs/get_service_catalog_config_responses.go +++ b/client/client/service_catalogs/get_service_catalog_config_responses.go @@ -6,17 +6,17 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetServiceCatalogConfigReader is a Reader for the GetServiceCatalogConfig structure. @@ -62,7 +62,8 @@ func NewGetServiceCatalogConfigOK() *GetServiceCatalogConfigOK { return &GetServiceCatalogConfigOK{} } -/*GetServiceCatalogConfigOK handles this case with default header values. +/* +GetServiceCatalogConfigOK describes a response with status code 200, with default header values. The config of the service catalog. */ @@ -70,8 +71,44 @@ type GetServiceCatalogConfigOK struct { Payload *GetServiceCatalogConfigOKBody } +// IsSuccess returns true when this get service catalog config o k response has a 2xx status code +func (o *GetServiceCatalogConfigOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get service catalog config o k response has a 3xx status code +func (o *GetServiceCatalogConfigOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog config o k response has a 4xx status code +func (o *GetServiceCatalogConfigOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service catalog config o k response has a 5xx status code +func (o *GetServiceCatalogConfigOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog config o k response a status code equal to that given +func (o *GetServiceCatalogConfigOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get service catalog config o k response +func (o *GetServiceCatalogConfigOK) Code() int { + return 200 +} + func (o *GetServiceCatalogConfigOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigOK %s", 200, payload) +} + +func (o *GetServiceCatalogConfigOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigOK %s", 200, payload) } func (o *GetServiceCatalogConfigOK) GetPayload() *GetServiceCatalogConfigOKBody { @@ -95,20 +132,60 @@ func NewGetServiceCatalogConfigForbidden() *GetServiceCatalogConfigForbidden { return &GetServiceCatalogConfigForbidden{} } -/*GetServiceCatalogConfigForbidden handles this case with default header values. +/* +GetServiceCatalogConfigForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetServiceCatalogConfigForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog config forbidden response has a 2xx status code +func (o *GetServiceCatalogConfigForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog config forbidden response has a 3xx status code +func (o *GetServiceCatalogConfigForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog config forbidden response has a 4xx status code +func (o *GetServiceCatalogConfigForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog config forbidden response has a 5xx status code +func (o *GetServiceCatalogConfigForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog config forbidden response a status code equal to that given +func (o *GetServiceCatalogConfigForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get service catalog config forbidden response +func (o *GetServiceCatalogConfigForbidden) Code() int { + return 403 +} + func (o *GetServiceCatalogConfigForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigForbidden %s", 403, payload) +} + +func (o *GetServiceCatalogConfigForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigForbidden %s", 403, payload) } func (o *GetServiceCatalogConfigForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +194,16 @@ func (o *GetServiceCatalogConfigForbidden) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogConfigForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +220,60 @@ func NewGetServiceCatalogConfigNotFound() *GetServiceCatalogConfigNotFound { return &GetServiceCatalogConfigNotFound{} } -/*GetServiceCatalogConfigNotFound handles this case with default header values. +/* +GetServiceCatalogConfigNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetServiceCatalogConfigNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog config not found response has a 2xx status code +func (o *GetServiceCatalogConfigNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog config not found response has a 3xx status code +func (o *GetServiceCatalogConfigNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog config not found response has a 4xx status code +func (o *GetServiceCatalogConfigNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog config not found response has a 5xx status code +func (o *GetServiceCatalogConfigNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog config not found response a status code equal to that given +func (o *GetServiceCatalogConfigNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get service catalog config not found response +func (o *GetServiceCatalogConfigNotFound) Code() int { + return 404 +} + func (o *GetServiceCatalogConfigNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigNotFound %s", 404, payload) +} + +func (o *GetServiceCatalogConfigNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfigNotFound %s", 404, payload) } func (o *GetServiceCatalogConfigNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +282,16 @@ func (o *GetServiceCatalogConfigNotFound) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogConfigNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +310,61 @@ func NewGetServiceCatalogConfigDefault(code int) *GetServiceCatalogConfigDefault } } -/*GetServiceCatalogConfigDefault handles this case with default header values. +/* +GetServiceCatalogConfigDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetServiceCatalogConfigDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog config default response has a 2xx status code +func (o *GetServiceCatalogConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get service catalog config default response has a 3xx status code +func (o *GetServiceCatalogConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get service catalog config default response has a 4xx status code +func (o *GetServiceCatalogConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get service catalog config default response has a 5xx status code +func (o *GetServiceCatalogConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get service catalog config default response a status code equal to that given +func (o *GetServiceCatalogConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get service catalog config default response func (o *GetServiceCatalogConfigDefault) Code() int { return o._statusCode } func (o *GetServiceCatalogConfigDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfig default %s", o._statusCode, payload) +} + +func (o *GetServiceCatalogConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config][%d] getServiceCatalogConfig default %s", o._statusCode, payload) } func (o *GetServiceCatalogConfigDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +373,16 @@ func (o *GetServiceCatalogConfigDefault) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogConfigDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +394,8 @@ func (o *GetServiceCatalogConfigDefault) readResponse(response runtime.ClientRes return nil } -/*GetServiceCatalogConfigOKBody get service catalog config o k body +/* +GetServiceCatalogConfigOKBody get service catalog config o k body swagger:model GetServiceCatalogConfigOKBody */ type GetServiceCatalogConfigOKBody struct { @@ -257,13 +421,18 @@ func (o *GetServiceCatalogConfigOKBody) Validate(formats strfmt.Registry) error func (o *GetServiceCatalogConfigOKBody) validateData(formats strfmt.Registry) error { - if err := validate.Required("getServiceCatalogConfigOK"+"."+"data", "body", o.Data); err != nil { - return err + if o.Data == nil { + return errors.Required("getServiceCatalogConfigOK"+"."+"data", "body", nil) } return nil } +// ContextValidate validates this get service catalog config o k body based on context it is used +func (o *GetServiceCatalogConfigOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *GetServiceCatalogConfigOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/service_catalogs/get_service_catalog_parameters.go b/client/client/service_catalogs/get_service_catalog_parameters.go index 6fa973ef..5a3069e4 100644 --- a/client/client/service_catalogs/get_service_catalog_parameters.go +++ b/client/client/service_catalogs/get_service_catalog_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetServiceCatalogParams creates a new GetServiceCatalogParams object -// with the default values initialized. +// NewGetServiceCatalogParams creates a new GetServiceCatalogParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetServiceCatalogParams() *GetServiceCatalogParams { - var () return &GetServiceCatalogParams{ - timeout: cr.DefaultTimeout, } } // NewGetServiceCatalogParamsWithTimeout creates a new GetServiceCatalogParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetServiceCatalogParamsWithTimeout(timeout time.Duration) *GetServiceCatalogParams { - var () return &GetServiceCatalogParams{ - timeout: timeout, } } // NewGetServiceCatalogParamsWithContext creates a new GetServiceCatalogParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetServiceCatalogParamsWithContext(ctx context.Context) *GetServiceCatalogParams { - var () return &GetServiceCatalogParams{ - Context: ctx, } } // NewGetServiceCatalogParamsWithHTTPClient creates a new GetServiceCatalogParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetServiceCatalogParamsWithHTTPClient(client *http.Client) *GetServiceCatalogParams { - var () return &GetServiceCatalogParams{ HTTPClient: client, } } -/*GetServiceCatalogParams contains all the parameters to send to the API endpoint -for the get service catalog operation typically these are written to a http.Request +/* +GetServiceCatalogParams contains all the parameters to send to the API endpoint + + for the get service catalog operation. + + Typically these are written to a http.Request. */ type GetServiceCatalogParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -77,6 +78,21 @@ type GetServiceCatalogParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get service catalog params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogParams) WithDefaults() *GetServiceCatalogParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get service catalog params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get service catalog params func (o *GetServiceCatalogParams) WithTimeout(timeout time.Duration) *GetServiceCatalogParams { o.SetTimeout(timeout) diff --git a/client/client/service_catalogs/get_service_catalog_responses.go b/client/client/service_catalogs/get_service_catalog_responses.go index 6d7c77e7..f255813c 100644 --- a/client/client/service_catalogs/get_service_catalog_responses.go +++ b/client/client/service_catalogs/get_service_catalog_responses.go @@ -6,17 +6,18 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetServiceCatalogReader is a Reader for the GetServiceCatalog structure. @@ -62,7 +63,8 @@ func NewGetServiceCatalogOK() *GetServiceCatalogOK { return &GetServiceCatalogOK{} } -/*GetServiceCatalogOK handles this case with default header values. +/* +GetServiceCatalogOK describes a response with status code 200, with default header values. The information of the service catalog. */ @@ -70,8 +72,44 @@ type GetServiceCatalogOK struct { Payload *GetServiceCatalogOKBody } +// IsSuccess returns true when this get service catalog o k response has a 2xx status code +func (o *GetServiceCatalogOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get service catalog o k response has a 3xx status code +func (o *GetServiceCatalogOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog o k response has a 4xx status code +func (o *GetServiceCatalogOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service catalog o k response has a 5xx status code +func (o *GetServiceCatalogOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog o k response a status code equal to that given +func (o *GetServiceCatalogOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get service catalog o k response +func (o *GetServiceCatalogOK) Code() int { + return 200 +} + func (o *GetServiceCatalogOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogOK %s", 200, payload) +} + +func (o *GetServiceCatalogOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogOK %s", 200, payload) } func (o *GetServiceCatalogOK) GetPayload() *GetServiceCatalogOKBody { @@ -95,20 +133,60 @@ func NewGetServiceCatalogForbidden() *GetServiceCatalogForbidden { return &GetServiceCatalogForbidden{} } -/*GetServiceCatalogForbidden handles this case with default header values. +/* +GetServiceCatalogForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetServiceCatalogForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog forbidden response has a 2xx status code +func (o *GetServiceCatalogForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog forbidden response has a 3xx status code +func (o *GetServiceCatalogForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog forbidden response has a 4xx status code +func (o *GetServiceCatalogForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog forbidden response has a 5xx status code +func (o *GetServiceCatalogForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog forbidden response a status code equal to that given +func (o *GetServiceCatalogForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get service catalog forbidden response +func (o *GetServiceCatalogForbidden) Code() int { + return 403 +} + func (o *GetServiceCatalogForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogForbidden %s", 403, payload) +} + +func (o *GetServiceCatalogForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogForbidden %s", 403, payload) } func (o *GetServiceCatalogForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetServiceCatalogForbidden) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetServiceCatalogNotFound() *GetServiceCatalogNotFound { return &GetServiceCatalogNotFound{} } -/*GetServiceCatalogNotFound handles this case with default header values. +/* +GetServiceCatalogNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetServiceCatalogNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog not found response has a 2xx status code +func (o *GetServiceCatalogNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog not found response has a 3xx status code +func (o *GetServiceCatalogNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog not found response has a 4xx status code +func (o *GetServiceCatalogNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog not found response has a 5xx status code +func (o *GetServiceCatalogNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog not found response a status code equal to that given +func (o *GetServiceCatalogNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get service catalog not found response +func (o *GetServiceCatalogNotFound) Code() int { + return 404 +} + func (o *GetServiceCatalogNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogNotFound %s", 404, payload) +} + +func (o *GetServiceCatalogNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalogNotFound %s", 404, payload) } func (o *GetServiceCatalogNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetServiceCatalogNotFound) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetServiceCatalogDefault(code int) *GetServiceCatalogDefault { } } -/*GetServiceCatalogDefault handles this case with default header values. +/* +GetServiceCatalogDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetServiceCatalogDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog default response has a 2xx status code +func (o *GetServiceCatalogDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get service catalog default response has a 3xx status code +func (o *GetServiceCatalogDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get service catalog default response has a 4xx status code +func (o *GetServiceCatalogDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get service catalog default response has a 5xx status code +func (o *GetServiceCatalogDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get service catalog default response a status code equal to that given +func (o *GetServiceCatalogDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get service catalog default response func (o *GetServiceCatalogDefault) Code() int { return o._statusCode } func (o *GetServiceCatalogDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalog default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalog default %s", o._statusCode, payload) +} + +func (o *GetServiceCatalogDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] getServiceCatalog default %s", o._statusCode, payload) } func (o *GetServiceCatalogDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetServiceCatalogDefault) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetServiceCatalogDefault) readResponse(response runtime.ClientResponse, return nil } -/*GetServiceCatalogOKBody get service catalog o k body +/* +GetServiceCatalogOKBody get service catalog o k body swagger:model GetServiceCatalogOKBody */ type GetServiceCatalogOKBody struct { @@ -265,6 +430,39 @@ func (o *GetServiceCatalogOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getServiceCatalogOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get service catalog o k body based on the context it is used +func (o *GetServiceCatalogOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetServiceCatalogOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getServiceCatalogOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogOK" + "." + "data") } return err } diff --git a/client/client/service_catalogs/get_service_catalog_terraform_diagram_parameters.go b/client/client/service_catalogs/get_service_catalog_terraform_diagram_parameters.go index bc3b2015..b12f8645 100644 --- a/client/client/service_catalogs/get_service_catalog_terraform_diagram_parameters.go +++ b/client/client/service_catalogs/get_service_catalog_terraform_diagram_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetServiceCatalogTerraformDiagramParams creates a new GetServiceCatalogTerraformDiagramParams object -// with the default values initialized. +// NewGetServiceCatalogTerraformDiagramParams creates a new GetServiceCatalogTerraformDiagramParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetServiceCatalogTerraformDiagramParams() *GetServiceCatalogTerraformDiagramParams { - var () return &GetServiceCatalogTerraformDiagramParams{ - timeout: cr.DefaultTimeout, } } // NewGetServiceCatalogTerraformDiagramParamsWithTimeout creates a new GetServiceCatalogTerraformDiagramParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetServiceCatalogTerraformDiagramParamsWithTimeout(timeout time.Duration) *GetServiceCatalogTerraformDiagramParams { - var () return &GetServiceCatalogTerraformDiagramParams{ - timeout: timeout, } } // NewGetServiceCatalogTerraformDiagramParamsWithContext creates a new GetServiceCatalogTerraformDiagramParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetServiceCatalogTerraformDiagramParamsWithContext(ctx context.Context) *GetServiceCatalogTerraformDiagramParams { - var () return &GetServiceCatalogTerraformDiagramParams{ - Context: ctx, } } // NewGetServiceCatalogTerraformDiagramParamsWithHTTPClient creates a new GetServiceCatalogTerraformDiagramParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetServiceCatalogTerraformDiagramParamsWithHTTPClient(client *http.Client) *GetServiceCatalogTerraformDiagramParams { - var () return &GetServiceCatalogTerraformDiagramParams{ HTTPClient: client, } } -/*GetServiceCatalogTerraformDiagramParams contains all the parameters to send to the API endpoint -for the get service catalog terraform diagram operation typically these are written to a http.Request +/* +GetServiceCatalogTerraformDiagramParams contains all the parameters to send to the API endpoint + + for the get service catalog terraform diagram operation. + + Typically these are written to a http.Request. */ type GetServiceCatalogTerraformDiagramParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -77,6 +78,21 @@ type GetServiceCatalogTerraformDiagramParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get service catalog terraform diagram params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogTerraformDiagramParams) WithDefaults() *GetServiceCatalogTerraformDiagramParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get service catalog terraform diagram params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogTerraformDiagramParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get service catalog terraform diagram params func (o *GetServiceCatalogTerraformDiagramParams) WithTimeout(timeout time.Duration) *GetServiceCatalogTerraformDiagramParams { o.SetTimeout(timeout) diff --git a/client/client/service_catalogs/get_service_catalog_terraform_diagram_responses.go b/client/client/service_catalogs/get_service_catalog_terraform_diagram_responses.go index 7d9374f3..004ceab4 100644 --- a/client/client/service_catalogs/get_service_catalog_terraform_diagram_responses.go +++ b/client/client/service_catalogs/get_service_catalog_terraform_diagram_responses.go @@ -6,17 +6,18 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetServiceCatalogTerraformDiagramReader is a Reader for the GetServiceCatalogTerraformDiagram structure. @@ -62,7 +63,8 @@ func NewGetServiceCatalogTerraformDiagramOK() *GetServiceCatalogTerraformDiagram return &GetServiceCatalogTerraformDiagramOK{} } -/*GetServiceCatalogTerraformDiagramOK handles this case with default header values. +/* +GetServiceCatalogTerraformDiagramOK describes a response with status code 200, with default header values. The information of Terraform Diagram */ @@ -70,8 +72,44 @@ type GetServiceCatalogTerraformDiagramOK struct { Payload *GetServiceCatalogTerraformDiagramOKBody } +// IsSuccess returns true when this get service catalog terraform diagram o k response has a 2xx status code +func (o *GetServiceCatalogTerraformDiagramOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get service catalog terraform diagram o k response has a 3xx status code +func (o *GetServiceCatalogTerraformDiagramOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform diagram o k response has a 4xx status code +func (o *GetServiceCatalogTerraformDiagramOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service catalog terraform diagram o k response has a 5xx status code +func (o *GetServiceCatalogTerraformDiagramOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform diagram o k response a status code equal to that given +func (o *GetServiceCatalogTerraformDiagramOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get service catalog terraform diagram o k response +func (o *GetServiceCatalogTerraformDiagramOK) Code() int { + return 200 +} + func (o *GetServiceCatalogTerraformDiagramOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramOK %s", 200, payload) +} + +func (o *GetServiceCatalogTerraformDiagramOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramOK %s", 200, payload) } func (o *GetServiceCatalogTerraformDiagramOK) GetPayload() *GetServiceCatalogTerraformDiagramOKBody { @@ -95,20 +133,60 @@ func NewGetServiceCatalogTerraformDiagramForbidden() *GetServiceCatalogTerraform return &GetServiceCatalogTerraformDiagramForbidden{} } -/*GetServiceCatalogTerraformDiagramForbidden handles this case with default header values. +/* +GetServiceCatalogTerraformDiagramForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetServiceCatalogTerraformDiagramForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform diagram forbidden response has a 2xx status code +func (o *GetServiceCatalogTerraformDiagramForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog terraform diagram forbidden response has a 3xx status code +func (o *GetServiceCatalogTerraformDiagramForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform diagram forbidden response has a 4xx status code +func (o *GetServiceCatalogTerraformDiagramForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog terraform diagram forbidden response has a 5xx status code +func (o *GetServiceCatalogTerraformDiagramForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform diagram forbidden response a status code equal to that given +func (o *GetServiceCatalogTerraformDiagramForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get service catalog terraform diagram forbidden response +func (o *GetServiceCatalogTerraformDiagramForbidden) Code() int { + return 403 +} + func (o *GetServiceCatalogTerraformDiagramForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramForbidden %s", 403, payload) +} + +func (o *GetServiceCatalogTerraformDiagramForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramForbidden %s", 403, payload) } func (o *GetServiceCatalogTerraformDiagramForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetServiceCatalogTerraformDiagramForbidden) GetPayload() *models.ErrorP func (o *GetServiceCatalogTerraformDiagramForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetServiceCatalogTerraformDiagramNotFound() *GetServiceCatalogTerraformD return &GetServiceCatalogTerraformDiagramNotFound{} } -/*GetServiceCatalogTerraformDiagramNotFound handles this case with default header values. +/* +GetServiceCatalogTerraformDiagramNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetServiceCatalogTerraformDiagramNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform diagram not found response has a 2xx status code +func (o *GetServiceCatalogTerraformDiagramNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog terraform diagram not found response has a 3xx status code +func (o *GetServiceCatalogTerraformDiagramNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform diagram not found response has a 4xx status code +func (o *GetServiceCatalogTerraformDiagramNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog terraform diagram not found response has a 5xx status code +func (o *GetServiceCatalogTerraformDiagramNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform diagram not found response a status code equal to that given +func (o *GetServiceCatalogTerraformDiagramNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get service catalog terraform diagram not found response +func (o *GetServiceCatalogTerraformDiagramNotFound) Code() int { + return 404 +} + func (o *GetServiceCatalogTerraformDiagramNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramNotFound %s", 404, payload) +} + +func (o *GetServiceCatalogTerraformDiagramNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagramNotFound %s", 404, payload) } func (o *GetServiceCatalogTerraformDiagramNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetServiceCatalogTerraformDiagramNotFound) GetPayload() *models.ErrorPa func (o *GetServiceCatalogTerraformDiagramNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetServiceCatalogTerraformDiagramDefault(code int) *GetServiceCatalogTer } } -/*GetServiceCatalogTerraformDiagramDefault handles this case with default header values. +/* +GetServiceCatalogTerraformDiagramDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetServiceCatalogTerraformDiagramDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform diagram default response has a 2xx status code +func (o *GetServiceCatalogTerraformDiagramDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get service catalog terraform diagram default response has a 3xx status code +func (o *GetServiceCatalogTerraformDiagramDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get service catalog terraform diagram default response has a 4xx status code +func (o *GetServiceCatalogTerraformDiagramDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get service catalog terraform diagram default response has a 5xx status code +func (o *GetServiceCatalogTerraformDiagramDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get service catalog terraform diagram default response a status code equal to that given +func (o *GetServiceCatalogTerraformDiagramDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get service catalog terraform diagram default response func (o *GetServiceCatalogTerraformDiagramDefault) Code() int { return o._statusCode } func (o *GetServiceCatalogTerraformDiagramDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagram default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagram default %s", o._statusCode, payload) +} + +func (o *GetServiceCatalogTerraformDiagramDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] getServiceCatalogTerraformDiagram default %s", o._statusCode, payload) } func (o *GetServiceCatalogTerraformDiagramDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetServiceCatalogTerraformDiagramDefault) GetPayload() *models.ErrorPay func (o *GetServiceCatalogTerraformDiagramDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetServiceCatalogTerraformDiagramDefault) readResponse(response runtime return nil } -/*GetServiceCatalogTerraformDiagramOKBody get service catalog terraform diagram o k body +/* +GetServiceCatalogTerraformDiagramOKBody get service catalog terraform diagram o k body swagger:model GetServiceCatalogTerraformDiagramOKBody */ type GetServiceCatalogTerraformDiagramOKBody struct { @@ -272,12 +437,11 @@ func (o *GetServiceCatalogTerraformDiagramOKBody) Validate(formats strfmt.Regist } func (o *GetServiceCatalogTerraformDiagramOKBody) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(o.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("getServiceCatalogTerraformDiagramOK"+"."+"created_at", "body", int64(*o.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("getServiceCatalogTerraformDiagramOK"+"."+"created_at", "body", *o.CreatedAt, 0, false); err != nil { return err } @@ -286,26 +450,30 @@ func (o *GetServiceCatalogTerraformDiagramOKBody) validateCreatedAt(formats strf func (o *GetServiceCatalogTerraformDiagramOKBody) validateData(formats strfmt.Registry) error { - if err := validate.Required("getServiceCatalogTerraformDiagramOK"+"."+"data", "body", o.Data); err != nil { - return err + if o.Data == nil { + return errors.Required("getServiceCatalogTerraformDiagramOK"+"."+"data", "body", nil) } return nil } func (o *GetServiceCatalogTerraformDiagramOKBody) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(o.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("getServiceCatalogTerraformDiagramOK"+"."+"updated_at", "body", int64(*o.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("getServiceCatalogTerraformDiagramOK"+"."+"updated_at", "body", *o.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validates this get service catalog terraform diagram o k body based on context it is used +func (o *GetServiceCatalogTerraformDiagramOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (o *GetServiceCatalogTerraformDiagramOKBody) MarshalBinary() ([]byte, error) { if o == nil { diff --git a/client/client/service_catalogs/get_service_catalog_terraform_image_parameters.go b/client/client/service_catalogs/get_service_catalog_terraform_image_parameters.go index 56ad59ce..8c8178b2 100644 --- a/client/client/service_catalogs/get_service_catalog_terraform_image_parameters.go +++ b/client/client/service_catalogs/get_service_catalog_terraform_image_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetServiceCatalogTerraformImageParams creates a new GetServiceCatalogTerraformImageParams object -// with the default values initialized. +// NewGetServiceCatalogTerraformImageParams creates a new GetServiceCatalogTerraformImageParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetServiceCatalogTerraformImageParams() *GetServiceCatalogTerraformImageParams { - var () return &GetServiceCatalogTerraformImageParams{ - timeout: cr.DefaultTimeout, } } // NewGetServiceCatalogTerraformImageParamsWithTimeout creates a new GetServiceCatalogTerraformImageParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetServiceCatalogTerraformImageParamsWithTimeout(timeout time.Duration) *GetServiceCatalogTerraformImageParams { - var () return &GetServiceCatalogTerraformImageParams{ - timeout: timeout, } } // NewGetServiceCatalogTerraformImageParamsWithContext creates a new GetServiceCatalogTerraformImageParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetServiceCatalogTerraformImageParamsWithContext(ctx context.Context) *GetServiceCatalogTerraformImageParams { - var () return &GetServiceCatalogTerraformImageParams{ - Context: ctx, } } // NewGetServiceCatalogTerraformImageParamsWithHTTPClient creates a new GetServiceCatalogTerraformImageParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetServiceCatalogTerraformImageParamsWithHTTPClient(client *http.Client) *GetServiceCatalogTerraformImageParams { - var () return &GetServiceCatalogTerraformImageParams{ HTTPClient: client, } } -/*GetServiceCatalogTerraformImageParams contains all the parameters to send to the API endpoint -for the get service catalog terraform image operation typically these are written to a http.Request +/* +GetServiceCatalogTerraformImageParams contains all the parameters to send to the API endpoint + + for the get service catalog terraform image operation. + + Typically these are written to a http.Request. */ type GetServiceCatalogTerraformImageParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -77,6 +78,21 @@ type GetServiceCatalogTerraformImageParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get service catalog terraform image params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogTerraformImageParams) WithDefaults() *GetServiceCatalogTerraformImageParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get service catalog terraform image params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogTerraformImageParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get service catalog terraform image params func (o *GetServiceCatalogTerraformImageParams) WithTimeout(timeout time.Duration) *GetServiceCatalogTerraformImageParams { o.SetTimeout(timeout) diff --git a/client/client/service_catalogs/get_service_catalog_terraform_image_responses.go b/client/client/service_catalogs/get_service_catalog_terraform_image_responses.go index df005f52..690a1126 100644 --- a/client/client/service_catalogs/get_service_catalog_terraform_image_responses.go +++ b/client/client/service_catalogs/get_service_catalog_terraform_image_responses.go @@ -6,17 +6,18 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetServiceCatalogTerraformImageReader is a Reader for the GetServiceCatalogTerraformImage structure. @@ -62,7 +63,8 @@ func NewGetServiceCatalogTerraformImageOK() *GetServiceCatalogTerraformImageOK { return &GetServiceCatalogTerraformImageOK{} } -/*GetServiceCatalogTerraformImageOK handles this case with default header values. +/* +GetServiceCatalogTerraformImageOK describes a response with status code 200, with default header values. The SC TF Image */ @@ -70,8 +72,44 @@ type GetServiceCatalogTerraformImageOK struct { Payload *GetServiceCatalogTerraformImageOKBody } +// IsSuccess returns true when this get service catalog terraform image o k response has a 2xx status code +func (o *GetServiceCatalogTerraformImageOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get service catalog terraform image o k response has a 3xx status code +func (o *GetServiceCatalogTerraformImageOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform image o k response has a 4xx status code +func (o *GetServiceCatalogTerraformImageOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service catalog terraform image o k response has a 5xx status code +func (o *GetServiceCatalogTerraformImageOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform image o k response a status code equal to that given +func (o *GetServiceCatalogTerraformImageOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get service catalog terraform image o k response +func (o *GetServiceCatalogTerraformImageOK) Code() int { + return 200 +} + func (o *GetServiceCatalogTerraformImageOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageOK %s", 200, payload) +} + +func (o *GetServiceCatalogTerraformImageOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageOK %s", 200, payload) } func (o *GetServiceCatalogTerraformImageOK) GetPayload() *GetServiceCatalogTerraformImageOKBody { @@ -95,20 +133,60 @@ func NewGetServiceCatalogTerraformImageForbidden() *GetServiceCatalogTerraformIm return &GetServiceCatalogTerraformImageForbidden{} } -/*GetServiceCatalogTerraformImageForbidden handles this case with default header values. +/* +GetServiceCatalogTerraformImageForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetServiceCatalogTerraformImageForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform image forbidden response has a 2xx status code +func (o *GetServiceCatalogTerraformImageForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog terraform image forbidden response has a 3xx status code +func (o *GetServiceCatalogTerraformImageForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform image forbidden response has a 4xx status code +func (o *GetServiceCatalogTerraformImageForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog terraform image forbidden response has a 5xx status code +func (o *GetServiceCatalogTerraformImageForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform image forbidden response a status code equal to that given +func (o *GetServiceCatalogTerraformImageForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get service catalog terraform image forbidden response +func (o *GetServiceCatalogTerraformImageForbidden) Code() int { + return 403 +} + func (o *GetServiceCatalogTerraformImageForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageForbidden %s", 403, payload) +} + +func (o *GetServiceCatalogTerraformImageForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageForbidden %s", 403, payload) } func (o *GetServiceCatalogTerraformImageForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetServiceCatalogTerraformImageForbidden) GetPayload() *models.ErrorPay func (o *GetServiceCatalogTerraformImageForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetServiceCatalogTerraformImageNotFound() *GetServiceCatalogTerraformIma return &GetServiceCatalogTerraformImageNotFound{} } -/*GetServiceCatalogTerraformImageNotFound handles this case with default header values. +/* +GetServiceCatalogTerraformImageNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetServiceCatalogTerraformImageNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform image not found response has a 2xx status code +func (o *GetServiceCatalogTerraformImageNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog terraform image not found response has a 3xx status code +func (o *GetServiceCatalogTerraformImageNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform image not found response has a 4xx status code +func (o *GetServiceCatalogTerraformImageNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog terraform image not found response has a 5xx status code +func (o *GetServiceCatalogTerraformImageNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform image not found response a status code equal to that given +func (o *GetServiceCatalogTerraformImageNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get service catalog terraform image not found response +func (o *GetServiceCatalogTerraformImageNotFound) Code() int { + return 404 +} + func (o *GetServiceCatalogTerraformImageNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageNotFound %s", 404, payload) +} + +func (o *GetServiceCatalogTerraformImageNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImageNotFound %s", 404, payload) } func (o *GetServiceCatalogTerraformImageNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetServiceCatalogTerraformImageNotFound) GetPayload() *models.ErrorPayl func (o *GetServiceCatalogTerraformImageNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetServiceCatalogTerraformImageDefault(code int) *GetServiceCatalogTerra } } -/*GetServiceCatalogTerraformImageDefault handles this case with default header values. +/* +GetServiceCatalogTerraformImageDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetServiceCatalogTerraformImageDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform image default response has a 2xx status code +func (o *GetServiceCatalogTerraformImageDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get service catalog terraform image default response has a 3xx status code +func (o *GetServiceCatalogTerraformImageDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get service catalog terraform image default response has a 4xx status code +func (o *GetServiceCatalogTerraformImageDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get service catalog terraform image default response has a 5xx status code +func (o *GetServiceCatalogTerraformImageDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get service catalog terraform image default response a status code equal to that given +func (o *GetServiceCatalogTerraformImageDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get service catalog terraform image default response func (o *GetServiceCatalogTerraformImageDefault) Code() int { return o._statusCode } func (o *GetServiceCatalogTerraformImageDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImage default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImage default %s", o._statusCode, payload) +} + +func (o *GetServiceCatalogTerraformImageDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] getServiceCatalogTerraformImage default %s", o._statusCode, payload) } func (o *GetServiceCatalogTerraformImageDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetServiceCatalogTerraformImageDefault) GetPayload() *models.ErrorPaylo func (o *GetServiceCatalogTerraformImageDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetServiceCatalogTerraformImageDefault) readResponse(response runtime.C return nil } -/*GetServiceCatalogTerraformImageOKBody get service catalog terraform image o k body +/* +GetServiceCatalogTerraformImageOKBody get service catalog terraform image o k body swagger:model GetServiceCatalogTerraformImageOKBody */ type GetServiceCatalogTerraformImageOKBody struct { @@ -265,6 +430,39 @@ func (o *GetServiceCatalogTerraformImageOKBody) validateData(formats strfmt.Regi if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getServiceCatalogTerraformImageOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogTerraformImageOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get service catalog terraform image o k body based on the context it is used +func (o *GetServiceCatalogTerraformImageOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetServiceCatalogTerraformImageOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getServiceCatalogTerraformImageOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogTerraformImageOK" + "." + "data") } return err } diff --git a/client/client/service_catalogs/get_service_catalog_terraform_parameters.go b/client/client/service_catalogs/get_service_catalog_terraform_parameters.go index 9998d016..652cb9a4 100644 --- a/client/client/service_catalogs/get_service_catalog_terraform_parameters.go +++ b/client/client/service_catalogs/get_service_catalog_terraform_parameters.go @@ -13,67 +13,69 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetServiceCatalogTerraformParams creates a new GetServiceCatalogTerraformParams object -// with the default values initialized. +// NewGetServiceCatalogTerraformParams creates a new GetServiceCatalogTerraformParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetServiceCatalogTerraformParams() *GetServiceCatalogTerraformParams { - var () return &GetServiceCatalogTerraformParams{ - timeout: cr.DefaultTimeout, } } // NewGetServiceCatalogTerraformParamsWithTimeout creates a new GetServiceCatalogTerraformParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetServiceCatalogTerraformParamsWithTimeout(timeout time.Duration) *GetServiceCatalogTerraformParams { - var () return &GetServiceCatalogTerraformParams{ - timeout: timeout, } } // NewGetServiceCatalogTerraformParamsWithContext creates a new GetServiceCatalogTerraformParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetServiceCatalogTerraformParamsWithContext(ctx context.Context) *GetServiceCatalogTerraformParams { - var () return &GetServiceCatalogTerraformParams{ - Context: ctx, } } // NewGetServiceCatalogTerraformParamsWithHTTPClient creates a new GetServiceCatalogTerraformParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetServiceCatalogTerraformParamsWithHTTPClient(client *http.Client) *GetServiceCatalogTerraformParams { - var () return &GetServiceCatalogTerraformParams{ HTTPClient: client, } } -/*GetServiceCatalogTerraformParams contains all the parameters to send to the API endpoint -for the get service catalog terraform operation typically these are written to a http.Request +/* +GetServiceCatalogTerraformParams contains all the parameters to send to the API endpoint + + for the get service catalog terraform operation. + + Typically these are written to a http.Request. */ type GetServiceCatalogTerraformParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string - /*UseCaseCanonical - A use case canonical + /* UseCaseCanonical. + + A use case canonical */ UseCaseCanonical string @@ -82,6 +84,21 @@ type GetServiceCatalogTerraformParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get service catalog terraform params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogTerraformParams) WithDefaults() *GetServiceCatalogTerraformParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get service catalog terraform params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetServiceCatalogTerraformParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get service catalog terraform params func (o *GetServiceCatalogTerraformParams) WithTimeout(timeout time.Duration) *GetServiceCatalogTerraformParams { o.SetTimeout(timeout) diff --git a/client/client/service_catalogs/get_service_catalog_terraform_responses.go b/client/client/service_catalogs/get_service_catalog_terraform_responses.go index a903b62c..04415c58 100644 --- a/client/client/service_catalogs/get_service_catalog_terraform_responses.go +++ b/client/client/service_catalogs/get_service_catalog_terraform_responses.go @@ -6,17 +6,18 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetServiceCatalogTerraformReader is a Reader for the GetServiceCatalogTerraform structure. @@ -62,7 +63,8 @@ func NewGetServiceCatalogTerraformOK() *GetServiceCatalogTerraformOK { return &GetServiceCatalogTerraformOK{} } -/*GetServiceCatalogTerraformOK handles this case with default header values. +/* +GetServiceCatalogTerraformOK describes a response with status code 200, with default header values. The information of Terraform */ @@ -70,8 +72,44 @@ type GetServiceCatalogTerraformOK struct { Payload *GetServiceCatalogTerraformOKBody } +// IsSuccess returns true when this get service catalog terraform o k response has a 2xx status code +func (o *GetServiceCatalogTerraformOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get service catalog terraform o k response has a 3xx status code +func (o *GetServiceCatalogTerraformOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform o k response has a 4xx status code +func (o *GetServiceCatalogTerraformOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get service catalog terraform o k response has a 5xx status code +func (o *GetServiceCatalogTerraformOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform o k response a status code equal to that given +func (o *GetServiceCatalogTerraformOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get service catalog terraform o k response +func (o *GetServiceCatalogTerraformOK) Code() int { + return 200 +} + func (o *GetServiceCatalogTerraformOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformOK %s", 200, payload) +} + +func (o *GetServiceCatalogTerraformOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformOK %s", 200, payload) } func (o *GetServiceCatalogTerraformOK) GetPayload() *GetServiceCatalogTerraformOKBody { @@ -95,20 +133,60 @@ func NewGetServiceCatalogTerraformForbidden() *GetServiceCatalogTerraformForbidd return &GetServiceCatalogTerraformForbidden{} } -/*GetServiceCatalogTerraformForbidden handles this case with default header values. +/* +GetServiceCatalogTerraformForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type GetServiceCatalogTerraformForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform forbidden response has a 2xx status code +func (o *GetServiceCatalogTerraformForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog terraform forbidden response has a 3xx status code +func (o *GetServiceCatalogTerraformForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform forbidden response has a 4xx status code +func (o *GetServiceCatalogTerraformForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog terraform forbidden response has a 5xx status code +func (o *GetServiceCatalogTerraformForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform forbidden response a status code equal to that given +func (o *GetServiceCatalogTerraformForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get service catalog terraform forbidden response +func (o *GetServiceCatalogTerraformForbidden) Code() int { + return 403 +} + func (o *GetServiceCatalogTerraformForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformForbidden %s", 403, payload) +} + +func (o *GetServiceCatalogTerraformForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformForbidden %s", 403, payload) } func (o *GetServiceCatalogTerraformForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *GetServiceCatalogTerraformForbidden) GetPayload() *models.ErrorPayload func (o *GetServiceCatalogTerraformForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewGetServiceCatalogTerraformNotFound() *GetServiceCatalogTerraformNotFound return &GetServiceCatalogTerraformNotFound{} } -/*GetServiceCatalogTerraformNotFound handles this case with default header values. +/* +GetServiceCatalogTerraformNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type GetServiceCatalogTerraformNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform not found response has a 2xx status code +func (o *GetServiceCatalogTerraformNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get service catalog terraform not found response has a 3xx status code +func (o *GetServiceCatalogTerraformNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get service catalog terraform not found response has a 4xx status code +func (o *GetServiceCatalogTerraformNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get service catalog terraform not found response has a 5xx status code +func (o *GetServiceCatalogTerraformNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get service catalog terraform not found response a status code equal to that given +func (o *GetServiceCatalogTerraformNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get service catalog terraform not found response +func (o *GetServiceCatalogTerraformNotFound) Code() int { + return 404 +} + func (o *GetServiceCatalogTerraformNotFound) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformNotFound %s", 404, payload) +} + +func (o *GetServiceCatalogTerraformNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraformNotFound %s", 404, payload) } func (o *GetServiceCatalogTerraformNotFound) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *GetServiceCatalogTerraformNotFound) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogTerraformNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewGetServiceCatalogTerraformDefault(code int) *GetServiceCatalogTerraformD } } -/*GetServiceCatalogTerraformDefault handles this case with default header values. +/* +GetServiceCatalogTerraformDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetServiceCatalogTerraformDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get service catalog terraform default response has a 2xx status code +func (o *GetServiceCatalogTerraformDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get service catalog terraform default response has a 3xx status code +func (o *GetServiceCatalogTerraformDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get service catalog terraform default response has a 4xx status code +func (o *GetServiceCatalogTerraformDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get service catalog terraform default response has a 5xx status code +func (o *GetServiceCatalogTerraformDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get service catalog terraform default response a status code equal to that given +func (o *GetServiceCatalogTerraformDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get service catalog terraform default response func (o *GetServiceCatalogTerraformDefault) Code() int { return o._statusCode } func (o *GetServiceCatalogTerraformDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraform default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraform default %s", o._statusCode, payload) +} + +func (o *GetServiceCatalogTerraformDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] getServiceCatalogTerraform default %s", o._statusCode, payload) } func (o *GetServiceCatalogTerraformDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *GetServiceCatalogTerraformDefault) GetPayload() *models.ErrorPayload { func (o *GetServiceCatalogTerraformDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *GetServiceCatalogTerraformDefault) readResponse(response runtime.Client return nil } -/*GetServiceCatalogTerraformOKBody get service catalog terraform o k body +/* +GetServiceCatalogTerraformOKBody get service catalog terraform o k body swagger:model GetServiceCatalogTerraformOKBody */ type GetServiceCatalogTerraformOKBody struct { @@ -265,6 +430,39 @@ func (o *GetServiceCatalogTerraformOKBody) validateData(formats strfmt.Registry) if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getServiceCatalogTerraformOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogTerraformOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get service catalog terraform o k body based on the context it is used +func (o *GetServiceCatalogTerraformOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetServiceCatalogTerraformOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getServiceCatalogTerraformOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getServiceCatalogTerraformOK" + "." + "data") } return err } diff --git a/client/client/service_catalogs/list_service_catalogs_parameters.go b/client/client/service_catalogs/list_service_catalogs_parameters.go index 6a87986b..bf06ab18 100644 --- a/client/client/service_catalogs/list_service_catalogs_parameters.go +++ b/client/client/service_catalogs/list_service_catalogs_parameters.go @@ -13,118 +13,102 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) -// NewListServiceCatalogsParams creates a new ListServiceCatalogsParams object -// with the default values initialized. +// NewListServiceCatalogsParams creates a new ListServiceCatalogsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewListServiceCatalogsParams() *ListServiceCatalogsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - serviceCatalogTemplateDefault = bool(false) - ) return &ListServiceCatalogsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - ServiceCatalogTemplate: &serviceCatalogTemplateDefault, - timeout: cr.DefaultTimeout, } } // NewListServiceCatalogsParamsWithTimeout creates a new ListServiceCatalogsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewListServiceCatalogsParamsWithTimeout(timeout time.Duration) *ListServiceCatalogsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - serviceCatalogTemplateDefault = bool(false) - ) return &ListServiceCatalogsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - ServiceCatalogTemplate: &serviceCatalogTemplateDefault, - timeout: timeout, } } // NewListServiceCatalogsParamsWithContext creates a new ListServiceCatalogsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewListServiceCatalogsParamsWithContext(ctx context.Context) *ListServiceCatalogsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - serviceCatalogTemplateDefault = bool(false) - ) return &ListServiceCatalogsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - ServiceCatalogTemplate: &serviceCatalogTemplateDefault, - Context: ctx, } } // NewListServiceCatalogsParamsWithHTTPClient creates a new ListServiceCatalogsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewListServiceCatalogsParamsWithHTTPClient(client *http.Client) *ListServiceCatalogsParams { - var ( - pageIndexDefault = uint32(1) - pageSizeDefault = uint32(1000) - serviceCatalogTemplateDefault = bool(false) - ) return &ListServiceCatalogsParams{ - PageIndex: &pageIndexDefault, - PageSize: &pageSizeDefault, - ServiceCatalogTemplate: &serviceCatalogTemplateDefault, - HTTPClient: client, + HTTPClient: client, } } -/*ListServiceCatalogsParams contains all the parameters to send to the API endpoint -for the list service catalogs operation typically these are written to a http.Request +/* +ListServiceCatalogsParams contains all the parameters to send to the API endpoint + + for the list service catalogs operation. + + Typically these are written to a http.Request. */ type ListServiceCatalogsParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*PageIndex - The page number to request. The first page is 1. + /* PageIndex. + + The page number to request. The first page is 1. + + Format: uint32 + Default: 1 */ PageIndex *uint32 - /*PageSize - The number of items at most which the response can have. + /* PageSize. + + The number of items at most which the response can have. + + Format: uint32 + Default: 1000 */ PageSize *uint32 - /*ServiceCatalogOwn - Filters the Service Catalogs to only show the ones owned by the User Organization + /* ServiceCatalogOwn. + + Filters the Service Catalogs to only show the ones owned by the User Organization */ ServiceCatalogOwn *bool - /*ServiceCatalogStatus - The status of the catalog service used for filtering. + /* ServiceCatalogStatus. + + The status of the catalog service used for filtering. */ ServiceCatalogStatus *string - /*ServiceCatalogTemplate - Filters the Service Catalogs to only show the ones that are templates + /* ServiceCatalogTemplate. + + Filters the Service Catalogs to only show the ones that are templates */ ServiceCatalogTemplate *bool - /*ServiceCatalogTrusted - Filters the Service Catalogs to only show the ones that are from trusted source (Cycloid) + /* ServiceCatalogTrusted. + + Filters the Service Catalogs to only show the ones that are from trusted source (Cycloid) */ ServiceCatalogTrusted *bool @@ -134,6 +118,38 @@ type ListServiceCatalogsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the list service catalogs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListServiceCatalogsParams) WithDefaults() *ListServiceCatalogsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list service catalogs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListServiceCatalogsParams) SetDefaults() { + var ( + pageIndexDefault = uint32(1) + + pageSizeDefault = uint32(1000) + + serviceCatalogTemplateDefault = bool(false) + ) + + val := ListServiceCatalogsParams{ + PageIndex: &pageIndexDefault, + PageSize: &pageSizeDefault, + ServiceCatalogTemplate: &serviceCatalogTemplateDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + // WithTimeout adds the timeout to the list service catalogs params func (o *ListServiceCatalogsParams) WithTimeout(timeout time.Duration) *ListServiceCatalogsParams { o.SetTimeout(timeout) @@ -261,96 +277,102 @@ func (o *ListServiceCatalogsParams) WriteToRequest(r runtime.ClientRequest, reg // query param page_index var qrPageIndex uint32 + if o.PageIndex != nil { qrPageIndex = *o.PageIndex } qPageIndex := swag.FormatUint32(qrPageIndex) if qPageIndex != "" { + if err := r.SetQueryParam("page_index", qPageIndex); err != nil { return err } } - } if o.PageSize != nil { // query param page_size var qrPageSize uint32 + if o.PageSize != nil { qrPageSize = *o.PageSize } qPageSize := swag.FormatUint32(qrPageSize) if qPageSize != "" { + if err := r.SetQueryParam("page_size", qPageSize); err != nil { return err } } - } if o.ServiceCatalogOwn != nil { // query param service_catalog_own var qrServiceCatalogOwn bool + if o.ServiceCatalogOwn != nil { qrServiceCatalogOwn = *o.ServiceCatalogOwn } qServiceCatalogOwn := swag.FormatBool(qrServiceCatalogOwn) if qServiceCatalogOwn != "" { + if err := r.SetQueryParam("service_catalog_own", qServiceCatalogOwn); err != nil { return err } } - } if o.ServiceCatalogStatus != nil { // query param service_catalog_status var qrServiceCatalogStatus string + if o.ServiceCatalogStatus != nil { qrServiceCatalogStatus = *o.ServiceCatalogStatus } qServiceCatalogStatus := qrServiceCatalogStatus if qServiceCatalogStatus != "" { + if err := r.SetQueryParam("service_catalog_status", qServiceCatalogStatus); err != nil { return err } } - } if o.ServiceCatalogTemplate != nil { // query param service_catalog_template var qrServiceCatalogTemplate bool + if o.ServiceCatalogTemplate != nil { qrServiceCatalogTemplate = *o.ServiceCatalogTemplate } qServiceCatalogTemplate := swag.FormatBool(qrServiceCatalogTemplate) if qServiceCatalogTemplate != "" { + if err := r.SetQueryParam("service_catalog_template", qServiceCatalogTemplate); err != nil { return err } } - } if o.ServiceCatalogTrusted != nil { // query param service_catalog_trusted var qrServiceCatalogTrusted bool + if o.ServiceCatalogTrusted != nil { qrServiceCatalogTrusted = *o.ServiceCatalogTrusted } qServiceCatalogTrusted := swag.FormatBool(qrServiceCatalogTrusted) if qServiceCatalogTrusted != "" { + if err := r.SetQueryParam("service_catalog_trusted", qServiceCatalogTrusted); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/service_catalogs/list_service_catalogs_responses.go b/client/client/service_catalogs/list_service_catalogs_responses.go index 1ad23bf6..9e15d5fc 100644 --- a/client/client/service_catalogs/list_service_catalogs_responses.go +++ b/client/client/service_catalogs/list_service_catalogs_responses.go @@ -6,18 +6,19 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ListServiceCatalogsReader is a Reader for the ListServiceCatalogs structure. @@ -57,7 +58,8 @@ func NewListServiceCatalogsOK() *ListServiceCatalogsOK { return &ListServiceCatalogsOK{} } -/*ListServiceCatalogsOK handles this case with default header values. +/* +ListServiceCatalogsOK describes a response with status code 200, with default header values. List of the service catalogs. */ @@ -65,8 +67,44 @@ type ListServiceCatalogsOK struct { Payload *ListServiceCatalogsOKBody } +// IsSuccess returns true when this list service catalogs o k response has a 2xx status code +func (o *ListServiceCatalogsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list service catalogs o k response has a 3xx status code +func (o *ListServiceCatalogsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list service catalogs o k response has a 4xx status code +func (o *ListServiceCatalogsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list service catalogs o k response has a 5xx status code +func (o *ListServiceCatalogsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list service catalogs o k response a status code equal to that given +func (o *ListServiceCatalogsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list service catalogs o k response +func (o *ListServiceCatalogsOK) Code() int { + return 200 +} + func (o *ListServiceCatalogsOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogsOK %s", 200, payload) +} + +func (o *ListServiceCatalogsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogsOK %s", 200, payload) } func (o *ListServiceCatalogsOK) GetPayload() *ListServiceCatalogsOKBody { @@ -90,20 +128,60 @@ func NewListServiceCatalogsForbidden() *ListServiceCatalogsForbidden { return &ListServiceCatalogsForbidden{} } -/*ListServiceCatalogsForbidden handles this case with default header values. +/* +ListServiceCatalogsForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ListServiceCatalogsForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this list service catalogs forbidden response has a 2xx status code +func (o *ListServiceCatalogsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list service catalogs forbidden response has a 3xx status code +func (o *ListServiceCatalogsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list service catalogs forbidden response has a 4xx status code +func (o *ListServiceCatalogsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this list service catalogs forbidden response has a 5xx status code +func (o *ListServiceCatalogsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this list service catalogs forbidden response a status code equal to that given +func (o *ListServiceCatalogsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the list service catalogs forbidden response +func (o *ListServiceCatalogsForbidden) Code() int { + return 403 +} + func (o *ListServiceCatalogsForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogsForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogsForbidden %s", 403, payload) +} + +func (o *ListServiceCatalogsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogsForbidden %s", 403, payload) } func (o *ListServiceCatalogsForbidden) GetPayload() *models.ErrorPayload { @@ -112,12 +190,16 @@ func (o *ListServiceCatalogsForbidden) GetPayload() *models.ErrorPayload { func (o *ListServiceCatalogsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -136,27 +218,61 @@ func NewListServiceCatalogsDefault(code int) *ListServiceCatalogsDefault { } } -/*ListServiceCatalogsDefault handles this case with default header values. +/* +ListServiceCatalogsDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ListServiceCatalogsDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this list service catalogs default response has a 2xx status code +func (o *ListServiceCatalogsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list service catalogs default response has a 3xx status code +func (o *ListServiceCatalogsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list service catalogs default response has a 4xx status code +func (o *ListServiceCatalogsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list service catalogs default response has a 5xx status code +func (o *ListServiceCatalogsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list service catalogs default response a status code equal to that given +func (o *ListServiceCatalogsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the list service catalogs default response func (o *ListServiceCatalogsDefault) Code() int { return o._statusCode } func (o *ListServiceCatalogsDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogs default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogs default %s", o._statusCode, payload) +} + +func (o *ListServiceCatalogsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs][%d] listServiceCatalogs default %s", o._statusCode, payload) } func (o *ListServiceCatalogsDefault) GetPayload() *models.ErrorPayload { @@ -165,12 +281,16 @@ func (o *ListServiceCatalogsDefault) GetPayload() *models.ErrorPayload { func (o *ListServiceCatalogsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -182,7 +302,8 @@ func (o *ListServiceCatalogsDefault) readResponse(response runtime.ClientRespons return nil } -/*ListServiceCatalogsOKBody list service catalogs o k body +/* +ListServiceCatalogsOKBody list service catalogs o k body swagger:model ListServiceCatalogsOKBody */ type ListServiceCatalogsOKBody struct { @@ -229,6 +350,8 @@ func (o *ListServiceCatalogsOKBody) validateData(formats strfmt.Registry) error if err := o.Data[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("listServiceCatalogsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listServiceCatalogsOK" + "." + "data" + "." + strconv.Itoa(i)) } return err } @@ -249,6 +372,68 @@ func (o *ListServiceCatalogsOKBody) validatePagination(formats strfmt.Registry) if err := o.Pagination.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("listServiceCatalogsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listServiceCatalogsOK" + "." + "pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this list service catalogs o k body based on the context it is used +func (o *ListServiceCatalogsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := o.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListServiceCatalogsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.Data); i++ { + + if o.Data[i] != nil { + + if swag.IsZero(o.Data[i]) { // not required + return nil + } + + if err := o.Data[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listServiceCatalogsOK" + "." + "data" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listServiceCatalogsOK" + "." + "data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (o *ListServiceCatalogsOKBody) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if o.Pagination != nil { + + if err := o.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listServiceCatalogsOK" + "." + "pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listServiceCatalogsOK" + "." + "pagination") } return err } diff --git a/client/client/service_catalogs/service_catalogs_client.go b/client/client/service_catalogs/service_catalogs_client.go index a6b6f9fe..dfd70578 100644 --- a/client/client/service_catalogs/service_catalogs_client.go +++ b/client/client/service_catalogs/service_catalogs_client.go @@ -9,15 +9,40 @@ import ( "fmt" "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new service catalogs API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new service catalogs API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new service catalogs API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for service catalogs API */ @@ -26,16 +51,100 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateServiceCatalog(params *CreateServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateServiceCatalogOK, error) + + CreateServiceCatalogFromTemplate(params *CreateServiceCatalogFromTemplateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateServiceCatalogFromTemplateOK, error) + + DeleteServiceCatalog(params *DeleteServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteServiceCatalogNoContent, error) + + GetServiceCatalog(params *GetServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogOK, error) + + GetServiceCatalogConfig(params *GetServiceCatalogConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogConfigOK, error) + + GetServiceCatalogTerraform(params *GetServiceCatalogTerraformParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogTerraformOK, error) + + GetServiceCatalogTerraformDiagram(params *GetServiceCatalogTerraformDiagramParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogTerraformDiagramOK, error) + + GetServiceCatalogTerraformImage(params *GetServiceCatalogTerraformImageParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogTerraformImageOK, error) + + ListServiceCatalogs(params *ListServiceCatalogsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListServiceCatalogsOK, error) + + UpdateServiceCatalog(params *UpdateServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogOK, error) + + UpdateServiceCatalogTerraform(params *UpdateServiceCatalogTerraformParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogTerraformNoContent, error) + + UpdateServiceCatalogTerraformDiagram(params *UpdateServiceCatalogTerraformDiagramParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogTerraformDiagramNoContent, error) + + UpdateServiceCatalogTerraformImage(params *UpdateServiceCatalogTerraformImageParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogTerraformImageNoContent, error) + + ValidateServiceCatalogDependencies(params *ValidateServiceCatalogDependenciesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValidateServiceCatalogDependenciesOK, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateServiceCatalog Create a new Service Catalog */ -func (a *Client) CreateServiceCatalog(params *CreateServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter) (*CreateServiceCatalogOK, error) { +func (a *Client) CreateServiceCatalog(params *CreateServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateServiceCatalogOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateServiceCatalogParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createServiceCatalog", Method: "POST", PathPattern: "/organizations/{organization_canonical}/service_catalogs", @@ -47,7 +156,12 @@ func (a *Client) CreateServiceCatalog(params *CreateServiceCatalogParams, authIn AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -62,15 +176,13 @@ func (a *Client) CreateServiceCatalog(params *CreateServiceCatalogParams, authIn /* CreateServiceCatalogFromTemplate Create a new Service Catalog using the ref and use case passed as template - */ -func (a *Client) CreateServiceCatalogFromTemplate(params *CreateServiceCatalogFromTemplateParams, authInfo runtime.ClientAuthInfoWriter) (*CreateServiceCatalogFromTemplateOK, error) { +func (a *Client) CreateServiceCatalogFromTemplate(params *CreateServiceCatalogFromTemplateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateServiceCatalogFromTemplateOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateServiceCatalogFromTemplateParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createServiceCatalogFromTemplate", Method: "POST", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/template", @@ -82,7 +194,12 @@ func (a *Client) CreateServiceCatalogFromTemplate(params *CreateServiceCatalogFr AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -98,13 +215,12 @@ func (a *Client) CreateServiceCatalogFromTemplate(params *CreateServiceCatalogFr /* DeleteServiceCatalog Delete the service catalog. */ -func (a *Client) DeleteServiceCatalog(params *DeleteServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteServiceCatalogNoContent, error) { +func (a *Client) DeleteServiceCatalog(params *DeleteServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteServiceCatalogNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteServiceCatalogParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteServiceCatalog", Method: "DELETE", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}", @@ -116,7 +232,12 @@ func (a *Client) DeleteServiceCatalog(params *DeleteServiceCatalogParams, authIn AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -133,13 +254,12 @@ func (a *Client) DeleteServiceCatalog(params *DeleteServiceCatalogParams, authIn /* GetServiceCatalog Get the information of the service catalog */ -func (a *Client) GetServiceCatalog(params *GetServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter) (*GetServiceCatalogOK, error) { +func (a *Client) GetServiceCatalog(params *GetServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetServiceCatalogParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getServiceCatalog", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}", @@ -151,7 +271,12 @@ func (a *Client) GetServiceCatalog(params *GetServiceCatalogParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -167,13 +292,12 @@ func (a *Client) GetServiceCatalog(params *GetServiceCatalogParams, authInfo run /* GetServiceCatalogConfig Get the config of the service catalog */ -func (a *Client) GetServiceCatalogConfig(params *GetServiceCatalogConfigParams, authInfo runtime.ClientAuthInfoWriter) (*GetServiceCatalogConfigOK, error) { +func (a *Client) GetServiceCatalogConfig(params *GetServiceCatalogConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogConfigOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetServiceCatalogConfigParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getServiceCatalogConfig", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/config", @@ -185,7 +309,12 @@ func (a *Client) GetServiceCatalogConfig(params *GetServiceCatalogConfigParams, AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -201,13 +330,12 @@ func (a *Client) GetServiceCatalogConfig(params *GetServiceCatalogConfigParams, /* GetServiceCatalogTerraform Get the information of the service catalog Terraform config */ -func (a *Client) GetServiceCatalogTerraform(params *GetServiceCatalogTerraformParams, authInfo runtime.ClientAuthInfoWriter) (*GetServiceCatalogTerraformOK, error) { +func (a *Client) GetServiceCatalogTerraform(params *GetServiceCatalogTerraformParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogTerraformOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetServiceCatalogTerraformParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getServiceCatalogTerraform", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform", @@ -219,7 +347,12 @@ func (a *Client) GetServiceCatalogTerraform(params *GetServiceCatalogTerraformPa AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -235,13 +368,12 @@ func (a *Client) GetServiceCatalogTerraform(params *GetServiceCatalogTerraformPa /* GetServiceCatalogTerraformDiagram Get the information of the service catalog Terraform diagram */ -func (a *Client) GetServiceCatalogTerraformDiagram(params *GetServiceCatalogTerraformDiagramParams, authInfo runtime.ClientAuthInfoWriter) (*GetServiceCatalogTerraformDiagramOK, error) { +func (a *Client) GetServiceCatalogTerraformDiagram(params *GetServiceCatalogTerraformDiagramParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogTerraformDiagramOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetServiceCatalogTerraformDiagramParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getServiceCatalogTerraformDiagram", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram", @@ -253,7 +385,12 @@ func (a *Client) GetServiceCatalogTerraformDiagram(params *GetServiceCatalogTerr AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -269,13 +406,12 @@ func (a *Client) GetServiceCatalogTerraformDiagram(params *GetServiceCatalogTerr /* GetServiceCatalogTerraformImage Get the SC TF Image */ -func (a *Client) GetServiceCatalogTerraformImage(params *GetServiceCatalogTerraformImageParams, authInfo runtime.ClientAuthInfoWriter) (*GetServiceCatalogTerraformImageOK, error) { +func (a *Client) GetServiceCatalogTerraformImage(params *GetServiceCatalogTerraformImageParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetServiceCatalogTerraformImageOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetServiceCatalogTerraformImageParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getServiceCatalogTerraformImage", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image", @@ -287,7 +423,12 @@ func (a *Client) GetServiceCatalogTerraformImage(params *GetServiceCatalogTerraf AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -303,13 +444,12 @@ func (a *Client) GetServiceCatalogTerraformImage(params *GetServiceCatalogTerraf /* ListServiceCatalogs Return all the service catalogs */ -func (a *Client) ListServiceCatalogs(params *ListServiceCatalogsParams, authInfo runtime.ClientAuthInfoWriter) (*ListServiceCatalogsOK, error) { +func (a *Client) ListServiceCatalogs(params *ListServiceCatalogsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListServiceCatalogsOK, error) { // TODO: Validate the params before sending if params == nil { params = NewListServiceCatalogsParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "listServiceCatalogs", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalogs", @@ -321,7 +461,12 @@ func (a *Client) ListServiceCatalogs(params *ListServiceCatalogsParams, authInfo AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -337,13 +482,12 @@ func (a *Client) ListServiceCatalogs(params *ListServiceCatalogsParams, authInfo /* UpdateServiceCatalog Update the information of the service catalog */ -func (a *Client) UpdateServiceCatalog(params *UpdateServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateServiceCatalogOK, error) { +func (a *Client) UpdateServiceCatalog(params *UpdateServiceCatalogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateServiceCatalogParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateServiceCatalog", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}", @@ -355,7 +499,12 @@ func (a *Client) UpdateServiceCatalog(params *UpdateServiceCatalogParams, authIn AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -371,13 +520,12 @@ func (a *Client) UpdateServiceCatalog(params *UpdateServiceCatalogParams, authIn /* UpdateServiceCatalogTerraform Update/Create the information of the service catalog Terraform config */ -func (a *Client) UpdateServiceCatalogTerraform(params *UpdateServiceCatalogTerraformParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateServiceCatalogTerraformNoContent, error) { +func (a *Client) UpdateServiceCatalogTerraform(params *UpdateServiceCatalogTerraformParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogTerraformNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateServiceCatalogTerraformParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateServiceCatalogTerraform", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform", @@ -389,7 +537,12 @@ func (a *Client) UpdateServiceCatalogTerraform(params *UpdateServiceCatalogTerra AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -405,13 +558,12 @@ func (a *Client) UpdateServiceCatalogTerraform(params *UpdateServiceCatalogTerra /* UpdateServiceCatalogTerraformDiagram Update/Create the information of the service catalog Terraform diagram */ -func (a *Client) UpdateServiceCatalogTerraformDiagram(params *UpdateServiceCatalogTerraformDiagramParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateServiceCatalogTerraformDiagramNoContent, error) { +func (a *Client) UpdateServiceCatalogTerraformDiagram(params *UpdateServiceCatalogTerraformDiagramParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogTerraformDiagramNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateServiceCatalogTerraformDiagramParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateServiceCatalogTerraformDiagram", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram", @@ -423,7 +575,12 @@ func (a *Client) UpdateServiceCatalogTerraformDiagram(params *UpdateServiceCatal AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -439,13 +596,12 @@ func (a *Client) UpdateServiceCatalogTerraformDiagram(params *UpdateServiceCatal /* UpdateServiceCatalogTerraformImage Update/Create the Image for the SC TF Image */ -func (a *Client) UpdateServiceCatalogTerraformImage(params *UpdateServiceCatalogTerraformImageParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateServiceCatalogTerraformImageNoContent, error) { +func (a *Client) UpdateServiceCatalogTerraformImage(params *UpdateServiceCatalogTerraformImageParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateServiceCatalogTerraformImageNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateServiceCatalogTerraformImageParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateServiceCatalogTerraformImage", Method: "PUT", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image", @@ -457,7 +613,12 @@ func (a *Client) UpdateServiceCatalogTerraformImage(params *UpdateServiceCatalog AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -473,13 +634,12 @@ func (a *Client) UpdateServiceCatalogTerraformImage(params *UpdateServiceCatalog /* ValidateServiceCatalogDependencies Validates the dependencies of a Service Catalog */ -func (a *Client) ValidateServiceCatalogDependencies(params *ValidateServiceCatalogDependenciesParams, authInfo runtime.ClientAuthInfoWriter) (*ValidateServiceCatalogDependenciesOK, error) { +func (a *Client) ValidateServiceCatalogDependencies(params *ValidateServiceCatalogDependenciesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ValidateServiceCatalogDependenciesOK, error) { // TODO: Validate the params before sending if params == nil { params = NewValidateServiceCatalogDependenciesParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "validateServiceCatalogDependencies", Method: "GET", PathPattern: "/organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate", @@ -491,7 +651,12 @@ func (a *Client) ValidateServiceCatalogDependencies(params *ValidateServiceCatal AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/client/service_catalogs/update_service_catalog_parameters.go b/client/client/service_catalogs/update_service_catalog_parameters.go index 3860e529..c8e5c0fd 100644 --- a/client/client/service_catalogs/update_service_catalog_parameters.go +++ b/client/client/service_catalogs/update_service_catalog_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateServiceCatalogParams creates a new UpdateServiceCatalogParams object -// with the default values initialized. +// NewUpdateServiceCatalogParams creates a new UpdateServiceCatalogParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateServiceCatalogParams() *UpdateServiceCatalogParams { - var () return &UpdateServiceCatalogParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateServiceCatalogParamsWithTimeout creates a new UpdateServiceCatalogParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateServiceCatalogParamsWithTimeout(timeout time.Duration) *UpdateServiceCatalogParams { - var () return &UpdateServiceCatalogParams{ - timeout: timeout, } } // NewUpdateServiceCatalogParamsWithContext creates a new UpdateServiceCatalogParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateServiceCatalogParamsWithContext(ctx context.Context) *UpdateServiceCatalogParams { - var () return &UpdateServiceCatalogParams{ - Context: ctx, } } // NewUpdateServiceCatalogParamsWithHTTPClient creates a new UpdateServiceCatalogParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateServiceCatalogParamsWithHTTPClient(client *http.Client) *UpdateServiceCatalogParams { - var () return &UpdateServiceCatalogParams{ HTTPClient: client, } } -/*UpdateServiceCatalogParams contains all the parameters to send to the API endpoint -for the update service catalog operation typically these are written to a http.Request +/* +UpdateServiceCatalogParams contains all the parameters to send to the API endpoint + + for the update service catalog operation. + + Typically these are written to a http.Request. */ type UpdateServiceCatalogParams struct { - /*Body - The information of the ServiceCatalog Terraform. + /* Body. + The information of the ServiceCatalog Terraform. */ Body *models.NewServiceCatalog - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -84,6 +86,21 @@ type UpdateServiceCatalogParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update service catalog params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogParams) WithDefaults() *UpdateServiceCatalogParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update service catalog params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update service catalog params func (o *UpdateServiceCatalogParams) WithTimeout(timeout time.Duration) *UpdateServiceCatalogParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateServiceCatalogParams) WriteToRequest(r runtime.ClientRequest, reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/service_catalogs/update_service_catalog_responses.go b/client/client/service_catalogs/update_service_catalog_responses.go index 16421a0d..964e28ac 100644 --- a/client/client/service_catalogs/update_service_catalog_responses.go +++ b/client/client/service_catalogs/update_service_catalog_responses.go @@ -6,17 +6,18 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateServiceCatalogReader is a Reader for the UpdateServiceCatalog structure. @@ -68,7 +69,8 @@ func NewUpdateServiceCatalogOK() *UpdateServiceCatalogOK { return &UpdateServiceCatalogOK{} } -/*UpdateServiceCatalogOK handles this case with default header values. +/* +UpdateServiceCatalogOK describes a response with status code 200, with default header values. Updated the Service Catalog */ @@ -76,8 +78,44 @@ type UpdateServiceCatalogOK struct { Payload *UpdateServiceCatalogOKBody } +// IsSuccess returns true when this update service catalog o k response has a 2xx status code +func (o *UpdateServiceCatalogOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update service catalog o k response has a 3xx status code +func (o *UpdateServiceCatalogOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog o k response has a 4xx status code +func (o *UpdateServiceCatalogOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update service catalog o k response has a 5xx status code +func (o *UpdateServiceCatalogOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog o k response a status code equal to that given +func (o *UpdateServiceCatalogOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update service catalog o k response +func (o *UpdateServiceCatalogOK) Code() int { + return 200 +} + func (o *UpdateServiceCatalogOK) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogOK %s", 200, payload) +} + +func (o *UpdateServiceCatalogOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogOK %s", 200, payload) } func (o *UpdateServiceCatalogOK) GetPayload() *UpdateServiceCatalogOKBody { @@ -101,20 +139,60 @@ func NewUpdateServiceCatalogForbidden() *UpdateServiceCatalogForbidden { return &UpdateServiceCatalogForbidden{} } -/*UpdateServiceCatalogForbidden handles this case with default header values. +/* +UpdateServiceCatalogForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateServiceCatalogForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog forbidden response has a 2xx status code +func (o *UpdateServiceCatalogForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog forbidden response has a 3xx status code +func (o *UpdateServiceCatalogForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog forbidden response has a 4xx status code +func (o *UpdateServiceCatalogForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog forbidden response has a 5xx status code +func (o *UpdateServiceCatalogForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog forbidden response a status code equal to that given +func (o *UpdateServiceCatalogForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update service catalog forbidden response +func (o *UpdateServiceCatalogForbidden) Code() int { + return 403 +} + func (o *UpdateServiceCatalogForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogForbidden %s", 403, payload) +} + +func (o *UpdateServiceCatalogForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogForbidden %s", 403, payload) } func (o *UpdateServiceCatalogForbidden) GetPayload() *models.ErrorPayload { @@ -123,12 +201,16 @@ func (o *UpdateServiceCatalogForbidden) GetPayload() *models.ErrorPayload { func (o *UpdateServiceCatalogForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -145,20 +227,60 @@ func NewUpdateServiceCatalogNotFound() *UpdateServiceCatalogNotFound { return &UpdateServiceCatalogNotFound{} } -/*UpdateServiceCatalogNotFound handles this case with default header values. +/* +UpdateServiceCatalogNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateServiceCatalogNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog not found response has a 2xx status code +func (o *UpdateServiceCatalogNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog not found response has a 3xx status code +func (o *UpdateServiceCatalogNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog not found response has a 4xx status code +func (o *UpdateServiceCatalogNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog not found response has a 5xx status code +func (o *UpdateServiceCatalogNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog not found response a status code equal to that given +func (o *UpdateServiceCatalogNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update service catalog not found response +func (o *UpdateServiceCatalogNotFound) Code() int { + return 404 +} + func (o *UpdateServiceCatalogNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogNotFound %s", 404, payload) +} + +func (o *UpdateServiceCatalogNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogNotFound %s", 404, payload) } func (o *UpdateServiceCatalogNotFound) GetPayload() *models.ErrorPayload { @@ -167,12 +289,16 @@ func (o *UpdateServiceCatalogNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateServiceCatalogNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -189,20 +315,60 @@ func NewUpdateServiceCatalogUnprocessableEntity() *UpdateServiceCatalogUnprocess return &UpdateServiceCatalogUnprocessableEntity{} } -/*UpdateServiceCatalogUnprocessableEntity handles this case with default header values. +/* +UpdateServiceCatalogUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateServiceCatalogUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog unprocessable entity response has a 2xx status code +func (o *UpdateServiceCatalogUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog unprocessable entity response has a 3xx status code +func (o *UpdateServiceCatalogUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog unprocessable entity response has a 4xx status code +func (o *UpdateServiceCatalogUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog unprocessable entity response has a 5xx status code +func (o *UpdateServiceCatalogUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog unprocessable entity response a status code equal to that given +func (o *UpdateServiceCatalogUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update service catalog unprocessable entity response +func (o *UpdateServiceCatalogUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateServiceCatalogUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateServiceCatalogUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalogUnprocessableEntity %s", 422, payload) } func (o *UpdateServiceCatalogUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -211,12 +377,16 @@ func (o *UpdateServiceCatalogUnprocessableEntity) GetPayload() *models.ErrorPayl func (o *UpdateServiceCatalogUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -235,27 +405,61 @@ func NewUpdateServiceCatalogDefault(code int) *UpdateServiceCatalogDefault { } } -/*UpdateServiceCatalogDefault handles this case with default header values. +/* +UpdateServiceCatalogDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateServiceCatalogDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog default response has a 2xx status code +func (o *UpdateServiceCatalogDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update service catalog default response has a 3xx status code +func (o *UpdateServiceCatalogDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update service catalog default response has a 4xx status code +func (o *UpdateServiceCatalogDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update service catalog default response has a 5xx status code +func (o *UpdateServiceCatalogDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update service catalog default response a status code equal to that given +func (o *UpdateServiceCatalogDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update service catalog default response func (o *UpdateServiceCatalogDefault) Code() int { return o._statusCode } func (o *UpdateServiceCatalogDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalog default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalog default %s", o._statusCode, payload) +} + +func (o *UpdateServiceCatalogDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}][%d] updateServiceCatalog default %s", o._statusCode, payload) } func (o *UpdateServiceCatalogDefault) GetPayload() *models.ErrorPayload { @@ -264,12 +468,16 @@ func (o *UpdateServiceCatalogDefault) GetPayload() *models.ErrorPayload { func (o *UpdateServiceCatalogDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -281,7 +489,8 @@ func (o *UpdateServiceCatalogDefault) readResponse(response runtime.ClientRespon return nil } -/*UpdateServiceCatalogOKBody update service catalog o k body +/* +UpdateServiceCatalogOKBody update service catalog o k body swagger:model UpdateServiceCatalogOKBody */ type UpdateServiceCatalogOKBody struct { @@ -315,6 +524,39 @@ func (o *UpdateServiceCatalogOKBody) validateData(formats strfmt.Registry) error if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateServiceCatalogOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateServiceCatalogOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update service catalog o k body based on the context it is used +func (o *UpdateServiceCatalogOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateServiceCatalogOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateServiceCatalogOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateServiceCatalogOK" + "." + "data") } return err } diff --git a/client/client/service_catalogs/update_service_catalog_terraform_diagram_parameters.go b/client/client/service_catalogs/update_service_catalog_terraform_diagram_parameters.go index 398a803e..e269d887 100644 --- a/client/client/service_catalogs/update_service_catalog_terraform_diagram_parameters.go +++ b/client/client/service_catalogs/update_service_catalog_terraform_diagram_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateServiceCatalogTerraformDiagramParams creates a new UpdateServiceCatalogTerraformDiagramParams object -// with the default values initialized. +// NewUpdateServiceCatalogTerraformDiagramParams creates a new UpdateServiceCatalogTerraformDiagramParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateServiceCatalogTerraformDiagramParams() *UpdateServiceCatalogTerraformDiagramParams { - var () return &UpdateServiceCatalogTerraformDiagramParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateServiceCatalogTerraformDiagramParamsWithTimeout creates a new UpdateServiceCatalogTerraformDiagramParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateServiceCatalogTerraformDiagramParamsWithTimeout(timeout time.Duration) *UpdateServiceCatalogTerraformDiagramParams { - var () return &UpdateServiceCatalogTerraformDiagramParams{ - timeout: timeout, } } // NewUpdateServiceCatalogTerraformDiagramParamsWithContext creates a new UpdateServiceCatalogTerraformDiagramParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateServiceCatalogTerraformDiagramParamsWithContext(ctx context.Context) *UpdateServiceCatalogTerraformDiagramParams { - var () return &UpdateServiceCatalogTerraformDiagramParams{ - Context: ctx, } } // NewUpdateServiceCatalogTerraformDiagramParamsWithHTTPClient creates a new UpdateServiceCatalogTerraformDiagramParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateServiceCatalogTerraformDiagramParamsWithHTTPClient(client *http.Client) *UpdateServiceCatalogTerraformDiagramParams { - var () return &UpdateServiceCatalogTerraformDiagramParams{ HTTPClient: client, } } -/*UpdateServiceCatalogTerraformDiagramParams contains all the parameters to send to the API endpoint -for the update service catalog terraform diagram operation typically these are written to a http.Request +/* +UpdateServiceCatalogTerraformDiagramParams contains all the parameters to send to the API endpoint + + for the update service catalog terraform diagram operation. + + Typically these are written to a http.Request. */ type UpdateServiceCatalogTerraformDiagramParams struct { - /*Body - The information of the ServiceCatalog Terraform Diagram + /* Body. + The information of the ServiceCatalog Terraform Diagram */ Body models.TerraformJSONDiagram - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -84,6 +86,21 @@ type UpdateServiceCatalogTerraformDiagramParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update service catalog terraform diagram params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogTerraformDiagramParams) WithDefaults() *UpdateServiceCatalogTerraformDiagramParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update service catalog terraform diagram params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogTerraformDiagramParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update service catalog terraform diagram params func (o *UpdateServiceCatalogTerraformDiagramParams) WithTimeout(timeout time.Duration) *UpdateServiceCatalogTerraformDiagramParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateServiceCatalogTerraformDiagramParams) WriteToRequest(r runtime.Cl return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/service_catalogs/update_service_catalog_terraform_diagram_responses.go b/client/client/service_catalogs/update_service_catalog_terraform_diagram_responses.go index d945e688..8ebb623d 100644 --- a/client/client/service_catalogs/update_service_catalog_terraform_diagram_responses.go +++ b/client/client/service_catalogs/update_service_catalog_terraform_diagram_responses.go @@ -6,16 +6,16 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateServiceCatalogTerraformDiagramReader is a Reader for the UpdateServiceCatalogTerraformDiagram structure. @@ -67,15 +67,50 @@ func NewUpdateServiceCatalogTerraformDiagramNoContent() *UpdateServiceCatalogTer return &UpdateServiceCatalogTerraformDiagramNoContent{} } -/*UpdateServiceCatalogTerraformDiagramNoContent handles this case with default header values. +/* +UpdateServiceCatalogTerraformDiagramNoContent describes a response with status code 204, with default header values. Configuration has been updated */ type UpdateServiceCatalogTerraformDiagramNoContent struct { } +// IsSuccess returns true when this update service catalog terraform diagram no content response has a 2xx status code +func (o *UpdateServiceCatalogTerraformDiagramNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update service catalog terraform diagram no content response has a 3xx status code +func (o *UpdateServiceCatalogTerraformDiagramNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform diagram no content response has a 4xx status code +func (o *UpdateServiceCatalogTerraformDiagramNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this update service catalog terraform diagram no content response has a 5xx status code +func (o *UpdateServiceCatalogTerraformDiagramNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform diagram no content response a status code equal to that given +func (o *UpdateServiceCatalogTerraformDiagramNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the update service catalog terraform diagram no content response +func (o *UpdateServiceCatalogTerraformDiagramNoContent) Code() int { + return 204 +} + func (o *UpdateServiceCatalogTerraformDiagramNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramNoContent", 204) +} + +func (o *UpdateServiceCatalogTerraformDiagramNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramNoContent", 204) } func (o *UpdateServiceCatalogTerraformDiagramNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -88,20 +123,60 @@ func NewUpdateServiceCatalogTerraformDiagramForbidden() *UpdateServiceCatalogTer return &UpdateServiceCatalogTerraformDiagramForbidden{} } -/*UpdateServiceCatalogTerraformDiagramForbidden handles this case with default header values. +/* +UpdateServiceCatalogTerraformDiagramForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateServiceCatalogTerraformDiagramForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform diagram forbidden response has a 2xx status code +func (o *UpdateServiceCatalogTerraformDiagramForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog terraform diagram forbidden response has a 3xx status code +func (o *UpdateServiceCatalogTerraformDiagramForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform diagram forbidden response has a 4xx status code +func (o *UpdateServiceCatalogTerraformDiagramForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog terraform diagram forbidden response has a 5xx status code +func (o *UpdateServiceCatalogTerraformDiagramForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform diagram forbidden response a status code equal to that given +func (o *UpdateServiceCatalogTerraformDiagramForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update service catalog terraform diagram forbidden response +func (o *UpdateServiceCatalogTerraformDiagramForbidden) Code() int { + return 403 +} + func (o *UpdateServiceCatalogTerraformDiagramForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramForbidden %s", 403, payload) +} + +func (o *UpdateServiceCatalogTerraformDiagramForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramForbidden %s", 403, payload) } func (o *UpdateServiceCatalogTerraformDiagramForbidden) GetPayload() *models.ErrorPayload { @@ -110,12 +185,16 @@ func (o *UpdateServiceCatalogTerraformDiagramForbidden) GetPayload() *models.Err func (o *UpdateServiceCatalogTerraformDiagramForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -132,20 +211,60 @@ func NewUpdateServiceCatalogTerraformDiagramNotFound() *UpdateServiceCatalogTerr return &UpdateServiceCatalogTerraformDiagramNotFound{} } -/*UpdateServiceCatalogTerraformDiagramNotFound handles this case with default header values. +/* +UpdateServiceCatalogTerraformDiagramNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateServiceCatalogTerraformDiagramNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform diagram not found response has a 2xx status code +func (o *UpdateServiceCatalogTerraformDiagramNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog terraform diagram not found response has a 3xx status code +func (o *UpdateServiceCatalogTerraformDiagramNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform diagram not found response has a 4xx status code +func (o *UpdateServiceCatalogTerraformDiagramNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog terraform diagram not found response has a 5xx status code +func (o *UpdateServiceCatalogTerraformDiagramNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform diagram not found response a status code equal to that given +func (o *UpdateServiceCatalogTerraformDiagramNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update service catalog terraform diagram not found response +func (o *UpdateServiceCatalogTerraformDiagramNotFound) Code() int { + return 404 +} + func (o *UpdateServiceCatalogTerraformDiagramNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramNotFound %s", 404, payload) +} + +func (o *UpdateServiceCatalogTerraformDiagramNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramNotFound %s", 404, payload) } func (o *UpdateServiceCatalogTerraformDiagramNotFound) GetPayload() *models.ErrorPayload { @@ -154,12 +273,16 @@ func (o *UpdateServiceCatalogTerraformDiagramNotFound) GetPayload() *models.Erro func (o *UpdateServiceCatalogTerraformDiagramNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -176,20 +299,60 @@ func NewUpdateServiceCatalogTerraformDiagramUnprocessableEntity() *UpdateService return &UpdateServiceCatalogTerraformDiagramUnprocessableEntity{} } -/*UpdateServiceCatalogTerraformDiagramUnprocessableEntity handles this case with default header values. +/* +UpdateServiceCatalogTerraformDiagramUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateServiceCatalogTerraformDiagramUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform diagram unprocessable entity response has a 2xx status code +func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog terraform diagram unprocessable entity response has a 3xx status code +func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform diagram unprocessable entity response has a 4xx status code +func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog terraform diagram unprocessable entity response has a 5xx status code +func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform diagram unprocessable entity response a status code equal to that given +func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update service catalog terraform diagram unprocessable entity response +func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagramUnprocessableEntity %s", 422, payload) } func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -198,12 +361,16 @@ func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) GetPayload() * func (o *UpdateServiceCatalogTerraformDiagramUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -222,27 +389,61 @@ func NewUpdateServiceCatalogTerraformDiagramDefault(code int) *UpdateServiceCata } } -/*UpdateServiceCatalogTerraformDiagramDefault handles this case with default header values. +/* +UpdateServiceCatalogTerraformDiagramDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateServiceCatalogTerraformDiagramDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform diagram default response has a 2xx status code +func (o *UpdateServiceCatalogTerraformDiagramDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update service catalog terraform diagram default response has a 3xx status code +func (o *UpdateServiceCatalogTerraformDiagramDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update service catalog terraform diagram default response has a 4xx status code +func (o *UpdateServiceCatalogTerraformDiagramDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update service catalog terraform diagram default response has a 5xx status code +func (o *UpdateServiceCatalogTerraformDiagramDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update service catalog terraform diagram default response a status code equal to that given +func (o *UpdateServiceCatalogTerraformDiagramDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update service catalog terraform diagram default response func (o *UpdateServiceCatalogTerraformDiagramDefault) Code() int { return o._statusCode } func (o *UpdateServiceCatalogTerraformDiagramDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagram default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagram default %s", o._statusCode, payload) +} + +func (o *UpdateServiceCatalogTerraformDiagramDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram][%d] updateServiceCatalogTerraformDiagram default %s", o._statusCode, payload) } func (o *UpdateServiceCatalogTerraformDiagramDefault) GetPayload() *models.ErrorPayload { @@ -251,12 +452,16 @@ func (o *UpdateServiceCatalogTerraformDiagramDefault) GetPayload() *models.Error func (o *UpdateServiceCatalogTerraformDiagramDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/service_catalogs/update_service_catalog_terraform_image_parameters.go b/client/client/service_catalogs/update_service_catalog_terraform_image_parameters.go index 0b449b2f..b30e5dd6 100644 --- a/client/client/service_catalogs/update_service_catalog_terraform_image_parameters.go +++ b/client/client/service_catalogs/update_service_catalog_terraform_image_parameters.go @@ -13,69 +13,71 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateServiceCatalogTerraformImageParams creates a new UpdateServiceCatalogTerraformImageParams object -// with the default values initialized. +// NewUpdateServiceCatalogTerraformImageParams creates a new UpdateServiceCatalogTerraformImageParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateServiceCatalogTerraformImageParams() *UpdateServiceCatalogTerraformImageParams { - var () return &UpdateServiceCatalogTerraformImageParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateServiceCatalogTerraformImageParamsWithTimeout creates a new UpdateServiceCatalogTerraformImageParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateServiceCatalogTerraformImageParamsWithTimeout(timeout time.Duration) *UpdateServiceCatalogTerraformImageParams { - var () return &UpdateServiceCatalogTerraformImageParams{ - timeout: timeout, } } // NewUpdateServiceCatalogTerraformImageParamsWithContext creates a new UpdateServiceCatalogTerraformImageParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateServiceCatalogTerraformImageParamsWithContext(ctx context.Context) *UpdateServiceCatalogTerraformImageParams { - var () return &UpdateServiceCatalogTerraformImageParams{ - Context: ctx, } } // NewUpdateServiceCatalogTerraformImageParamsWithHTTPClient creates a new UpdateServiceCatalogTerraformImageParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateServiceCatalogTerraformImageParamsWithHTTPClient(client *http.Client) *UpdateServiceCatalogTerraformImageParams { - var () return &UpdateServiceCatalogTerraformImageParams{ HTTPClient: client, } } -/*UpdateServiceCatalogTerraformImageParams contains all the parameters to send to the API endpoint -for the update service catalog terraform image operation typically these are written to a http.Request +/* +UpdateServiceCatalogTerraformImageParams contains all the parameters to send to the API endpoint + + for the update service catalog terraform image operation. + + Typically these are written to a http.Request. */ type UpdateServiceCatalogTerraformImageParams struct { - /*Body - The information of the ServiceCatalog Terraform Diagram + /* Body. + The information of the ServiceCatalog Terraform Diagram */ Body *models.TerraformImage - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -84,6 +86,21 @@ type UpdateServiceCatalogTerraformImageParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update service catalog terraform image params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogTerraformImageParams) WithDefaults() *UpdateServiceCatalogTerraformImageParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update service catalog terraform image params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogTerraformImageParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update service catalog terraform image params func (o *UpdateServiceCatalogTerraformImageParams) WithTimeout(timeout time.Duration) *UpdateServiceCatalogTerraformImageParams { o.SetTimeout(timeout) @@ -157,7 +174,6 @@ func (o *UpdateServiceCatalogTerraformImageParams) WriteToRequest(r runtime.Clie return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/service_catalogs/update_service_catalog_terraform_image_responses.go b/client/client/service_catalogs/update_service_catalog_terraform_image_responses.go index a0db96b8..f0dd3c7e 100644 --- a/client/client/service_catalogs/update_service_catalog_terraform_image_responses.go +++ b/client/client/service_catalogs/update_service_catalog_terraform_image_responses.go @@ -6,16 +6,16 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateServiceCatalogTerraformImageReader is a Reader for the UpdateServiceCatalogTerraformImage structure. @@ -61,15 +61,50 @@ func NewUpdateServiceCatalogTerraformImageNoContent() *UpdateServiceCatalogTerra return &UpdateServiceCatalogTerraformImageNoContent{} } -/*UpdateServiceCatalogTerraformImageNoContent handles this case with default header values. +/* +UpdateServiceCatalogTerraformImageNoContent describes a response with status code 204, with default header values. Configuration has been updated */ type UpdateServiceCatalogTerraformImageNoContent struct { } +// IsSuccess returns true when this update service catalog terraform image no content response has a 2xx status code +func (o *UpdateServiceCatalogTerraformImageNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update service catalog terraform image no content response has a 3xx status code +func (o *UpdateServiceCatalogTerraformImageNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform image no content response has a 4xx status code +func (o *UpdateServiceCatalogTerraformImageNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this update service catalog terraform image no content response has a 5xx status code +func (o *UpdateServiceCatalogTerraformImageNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform image no content response a status code equal to that given +func (o *UpdateServiceCatalogTerraformImageNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the update service catalog terraform image no content response +func (o *UpdateServiceCatalogTerraformImageNoContent) Code() int { + return 204 +} + func (o *UpdateServiceCatalogTerraformImageNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageNoContent", 204) +} + +func (o *UpdateServiceCatalogTerraformImageNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageNoContent", 204) } func (o *UpdateServiceCatalogTerraformImageNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewUpdateServiceCatalogTerraformImageForbidden() *UpdateServiceCatalogTerra return &UpdateServiceCatalogTerraformImageForbidden{} } -/*UpdateServiceCatalogTerraformImageForbidden handles this case with default header values. +/* +UpdateServiceCatalogTerraformImageForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateServiceCatalogTerraformImageForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform image forbidden response has a 2xx status code +func (o *UpdateServiceCatalogTerraformImageForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog terraform image forbidden response has a 3xx status code +func (o *UpdateServiceCatalogTerraformImageForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform image forbidden response has a 4xx status code +func (o *UpdateServiceCatalogTerraformImageForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog terraform image forbidden response has a 5xx status code +func (o *UpdateServiceCatalogTerraformImageForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform image forbidden response a status code equal to that given +func (o *UpdateServiceCatalogTerraformImageForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update service catalog terraform image forbidden response +func (o *UpdateServiceCatalogTerraformImageForbidden) Code() int { + return 403 +} + func (o *UpdateServiceCatalogTerraformImageForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageForbidden %s", 403, payload) +} + +func (o *UpdateServiceCatalogTerraformImageForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageForbidden %s", 403, payload) } func (o *UpdateServiceCatalogTerraformImageForbidden) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *UpdateServiceCatalogTerraformImageForbidden) GetPayload() *models.Error func (o *UpdateServiceCatalogTerraformImageForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewUpdateServiceCatalogTerraformImageUnprocessableEntity() *UpdateServiceCa return &UpdateServiceCatalogTerraformImageUnprocessableEntity{} } -/*UpdateServiceCatalogTerraformImageUnprocessableEntity handles this case with default header values. +/* +UpdateServiceCatalogTerraformImageUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateServiceCatalogTerraformImageUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform image unprocessable entity response has a 2xx status code +func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog terraform image unprocessable entity response has a 3xx status code +func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform image unprocessable entity response has a 4xx status code +func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog terraform image unprocessable entity response has a 5xx status code +func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform image unprocessable entity response a status code equal to that given +func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update service catalog terraform image unprocessable entity response +func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImageUnprocessableEntity %s", 422, payload) } func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) GetPayload() *mo func (o *UpdateServiceCatalogTerraformImageUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewUpdateServiceCatalogTerraformImageDefault(code int) *UpdateServiceCatalo } } -/*UpdateServiceCatalogTerraformImageDefault handles this case with default header values. +/* +UpdateServiceCatalogTerraformImageDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateServiceCatalogTerraformImageDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform image default response has a 2xx status code +func (o *UpdateServiceCatalogTerraformImageDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update service catalog terraform image default response has a 3xx status code +func (o *UpdateServiceCatalogTerraformImageDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update service catalog terraform image default response has a 4xx status code +func (o *UpdateServiceCatalogTerraformImageDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update service catalog terraform image default response has a 5xx status code +func (o *UpdateServiceCatalogTerraformImageDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update service catalog terraform image default response a status code equal to that given +func (o *UpdateServiceCatalogTerraformImageDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update service catalog terraform image default response func (o *UpdateServiceCatalogTerraformImageDefault) Code() int { return o._statusCode } func (o *UpdateServiceCatalogTerraformImageDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImage default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImage default %s", o._statusCode, payload) +} + +func (o *UpdateServiceCatalogTerraformImageDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/terraform/diagram/image][%d] updateServiceCatalogTerraformImage default %s", o._statusCode, payload) } func (o *UpdateServiceCatalogTerraformImageDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *UpdateServiceCatalogTerraformImageDefault) GetPayload() *models.ErrorPa func (o *UpdateServiceCatalogTerraformImageDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/service_catalogs/update_service_catalog_terraform_parameters.go b/client/client/service_catalogs/update_service_catalog_terraform_parameters.go index 68e9b3d4..e8fe59ea 100644 --- a/client/client/service_catalogs/update_service_catalog_terraform_parameters.go +++ b/client/client/service_catalogs/update_service_catalog_terraform_parameters.go @@ -13,74 +13,77 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateServiceCatalogTerraformParams creates a new UpdateServiceCatalogTerraformParams object -// with the default values initialized. +// NewUpdateServiceCatalogTerraformParams creates a new UpdateServiceCatalogTerraformParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateServiceCatalogTerraformParams() *UpdateServiceCatalogTerraformParams { - var () return &UpdateServiceCatalogTerraformParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateServiceCatalogTerraformParamsWithTimeout creates a new UpdateServiceCatalogTerraformParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateServiceCatalogTerraformParamsWithTimeout(timeout time.Duration) *UpdateServiceCatalogTerraformParams { - var () return &UpdateServiceCatalogTerraformParams{ - timeout: timeout, } } // NewUpdateServiceCatalogTerraformParamsWithContext creates a new UpdateServiceCatalogTerraformParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateServiceCatalogTerraformParamsWithContext(ctx context.Context) *UpdateServiceCatalogTerraformParams { - var () return &UpdateServiceCatalogTerraformParams{ - Context: ctx, } } // NewUpdateServiceCatalogTerraformParamsWithHTTPClient creates a new UpdateServiceCatalogTerraformParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateServiceCatalogTerraformParamsWithHTTPClient(client *http.Client) *UpdateServiceCatalogTerraformParams { - var () return &UpdateServiceCatalogTerraformParams{ HTTPClient: client, } } -/*UpdateServiceCatalogTerraformParams contains all the parameters to send to the API endpoint -for the update service catalog terraform operation typically these are written to a http.Request +/* +UpdateServiceCatalogTerraformParams contains all the parameters to send to the API endpoint + + for the update service catalog terraform operation. + + Typically these are written to a http.Request. */ type UpdateServiceCatalogTerraformParams struct { - /*Body - The information of the ServiceCatalog Terraform. + /* Body. + The information of the ServiceCatalog Terraform. */ Body *models.TerraformJSONConfig - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string - /*UseCaseCanonical - A use case canonical + /* UseCaseCanonical. + + A use case canonical */ UseCaseCanonical string @@ -89,6 +92,21 @@ type UpdateServiceCatalogTerraformParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update service catalog terraform params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogTerraformParams) WithDefaults() *UpdateServiceCatalogTerraformParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update service catalog terraform params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceCatalogTerraformParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update service catalog terraform params func (o *UpdateServiceCatalogTerraformParams) WithTimeout(timeout time.Duration) *UpdateServiceCatalogTerraformParams { o.SetTimeout(timeout) @@ -173,7 +191,6 @@ func (o *UpdateServiceCatalogTerraformParams) WriteToRequest(r runtime.ClientReq return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/service_catalogs/update_service_catalog_terraform_responses.go b/client/client/service_catalogs/update_service_catalog_terraform_responses.go index 70ced481..9e58229c 100644 --- a/client/client/service_catalogs/update_service_catalog_terraform_responses.go +++ b/client/client/service_catalogs/update_service_catalog_terraform_responses.go @@ -6,16 +6,16 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateServiceCatalogTerraformReader is a Reader for the UpdateServiceCatalogTerraform structure. @@ -67,15 +67,50 @@ func NewUpdateServiceCatalogTerraformNoContent() *UpdateServiceCatalogTerraformN return &UpdateServiceCatalogTerraformNoContent{} } -/*UpdateServiceCatalogTerraformNoContent handles this case with default header values. +/* +UpdateServiceCatalogTerraformNoContent describes a response with status code 204, with default header values. Configuration has been updated */ type UpdateServiceCatalogTerraformNoContent struct { } +// IsSuccess returns true when this update service catalog terraform no content response has a 2xx status code +func (o *UpdateServiceCatalogTerraformNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update service catalog terraform no content response has a 3xx status code +func (o *UpdateServiceCatalogTerraformNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform no content response has a 4xx status code +func (o *UpdateServiceCatalogTerraformNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this update service catalog terraform no content response has a 5xx status code +func (o *UpdateServiceCatalogTerraformNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform no content response a status code equal to that given +func (o *UpdateServiceCatalogTerraformNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the update service catalog terraform no content response +func (o *UpdateServiceCatalogTerraformNoContent) Code() int { + return 204 +} + func (o *UpdateServiceCatalogTerraformNoContent) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformNoContent ", 204) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformNoContent", 204) +} + +func (o *UpdateServiceCatalogTerraformNoContent) String() string { + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformNoContent", 204) } func (o *UpdateServiceCatalogTerraformNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -88,20 +123,60 @@ func NewUpdateServiceCatalogTerraformForbidden() *UpdateServiceCatalogTerraformF return &UpdateServiceCatalogTerraformForbidden{} } -/*UpdateServiceCatalogTerraformForbidden handles this case with default header values. +/* +UpdateServiceCatalogTerraformForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type UpdateServiceCatalogTerraformForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform forbidden response has a 2xx status code +func (o *UpdateServiceCatalogTerraformForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog terraform forbidden response has a 3xx status code +func (o *UpdateServiceCatalogTerraformForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform forbidden response has a 4xx status code +func (o *UpdateServiceCatalogTerraformForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog terraform forbidden response has a 5xx status code +func (o *UpdateServiceCatalogTerraformForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform forbidden response a status code equal to that given +func (o *UpdateServiceCatalogTerraformForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update service catalog terraform forbidden response +func (o *UpdateServiceCatalogTerraformForbidden) Code() int { + return 403 +} + func (o *UpdateServiceCatalogTerraformForbidden) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformForbidden %s", 403, payload) +} + +func (o *UpdateServiceCatalogTerraformForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformForbidden %s", 403, payload) } func (o *UpdateServiceCatalogTerraformForbidden) GetPayload() *models.ErrorPayload { @@ -110,12 +185,16 @@ func (o *UpdateServiceCatalogTerraformForbidden) GetPayload() *models.ErrorPaylo func (o *UpdateServiceCatalogTerraformForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -132,20 +211,60 @@ func NewUpdateServiceCatalogTerraformNotFound() *UpdateServiceCatalogTerraformNo return &UpdateServiceCatalogTerraformNotFound{} } -/*UpdateServiceCatalogTerraformNotFound handles this case with default header values. +/* +UpdateServiceCatalogTerraformNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateServiceCatalogTerraformNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform not found response has a 2xx status code +func (o *UpdateServiceCatalogTerraformNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog terraform not found response has a 3xx status code +func (o *UpdateServiceCatalogTerraformNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform not found response has a 4xx status code +func (o *UpdateServiceCatalogTerraformNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog terraform not found response has a 5xx status code +func (o *UpdateServiceCatalogTerraformNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform not found response a status code equal to that given +func (o *UpdateServiceCatalogTerraformNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update service catalog terraform not found response +func (o *UpdateServiceCatalogTerraformNotFound) Code() int { + return 404 +} + func (o *UpdateServiceCatalogTerraformNotFound) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformNotFound %s", 404, payload) +} + +func (o *UpdateServiceCatalogTerraformNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformNotFound %s", 404, payload) } func (o *UpdateServiceCatalogTerraformNotFound) GetPayload() *models.ErrorPayload { @@ -154,12 +273,16 @@ func (o *UpdateServiceCatalogTerraformNotFound) GetPayload() *models.ErrorPayloa func (o *UpdateServiceCatalogTerraformNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -176,20 +299,60 @@ func NewUpdateServiceCatalogTerraformUnprocessableEntity() *UpdateServiceCatalog return &UpdateServiceCatalogTerraformUnprocessableEntity{} } -/*UpdateServiceCatalogTerraformUnprocessableEntity handles this case with default header values. +/* +UpdateServiceCatalogTerraformUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateServiceCatalogTerraformUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform unprocessable entity response has a 2xx status code +func (o *UpdateServiceCatalogTerraformUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update service catalog terraform unprocessable entity response has a 3xx status code +func (o *UpdateServiceCatalogTerraformUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update service catalog terraform unprocessable entity response has a 4xx status code +func (o *UpdateServiceCatalogTerraformUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update service catalog terraform unprocessable entity response has a 5xx status code +func (o *UpdateServiceCatalogTerraformUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update service catalog terraform unprocessable entity response a status code equal to that given +func (o *UpdateServiceCatalogTerraformUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update service catalog terraform unprocessable entity response +func (o *UpdateServiceCatalogTerraformUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateServiceCatalogTerraformUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateServiceCatalogTerraformUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraformUnprocessableEntity %s", 422, payload) } func (o *UpdateServiceCatalogTerraformUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -198,12 +361,16 @@ func (o *UpdateServiceCatalogTerraformUnprocessableEntity) GetPayload() *models. func (o *UpdateServiceCatalogTerraformUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -222,27 +389,61 @@ func NewUpdateServiceCatalogTerraformDefault(code int) *UpdateServiceCatalogTerr } } -/*UpdateServiceCatalogTerraformDefault handles this case with default header values. +/* +UpdateServiceCatalogTerraformDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateServiceCatalogTerraformDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update service catalog terraform default response has a 2xx status code +func (o *UpdateServiceCatalogTerraformDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update service catalog terraform default response has a 3xx status code +func (o *UpdateServiceCatalogTerraformDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update service catalog terraform default response has a 4xx status code +func (o *UpdateServiceCatalogTerraformDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update service catalog terraform default response has a 5xx status code +func (o *UpdateServiceCatalogTerraformDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update service catalog terraform default response a status code equal to that given +func (o *UpdateServiceCatalogTerraformDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update service catalog terraform default response func (o *UpdateServiceCatalogTerraformDefault) Code() int { return o._statusCode } func (o *UpdateServiceCatalogTerraformDefault) Error() string { - return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraform default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraform default %s", o._statusCode, payload) +} + +func (o *UpdateServiceCatalogTerraformDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/{use_case_canonical}/terraform][%d] updateServiceCatalogTerraform default %s", o._statusCode, payload) } func (o *UpdateServiceCatalogTerraformDefault) GetPayload() *models.ErrorPayload { @@ -251,12 +452,16 @@ func (o *UpdateServiceCatalogTerraformDefault) GetPayload() *models.ErrorPayload func (o *UpdateServiceCatalogTerraformDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/service_catalogs/validate_service_catalog_dependencies_parameters.go b/client/client/service_catalogs/validate_service_catalog_dependencies_parameters.go index 7f2dcddb..8fb67b56 100644 --- a/client/client/service_catalogs/validate_service_catalog_dependencies_parameters.go +++ b/client/client/service_catalogs/validate_service_catalog_dependencies_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewValidateServiceCatalogDependenciesParams creates a new ValidateServiceCatalogDependenciesParams object -// with the default values initialized. +// NewValidateServiceCatalogDependenciesParams creates a new ValidateServiceCatalogDependenciesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewValidateServiceCatalogDependenciesParams() *ValidateServiceCatalogDependenciesParams { - var () return &ValidateServiceCatalogDependenciesParams{ - timeout: cr.DefaultTimeout, } } // NewValidateServiceCatalogDependenciesParamsWithTimeout creates a new ValidateServiceCatalogDependenciesParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewValidateServiceCatalogDependenciesParamsWithTimeout(timeout time.Duration) *ValidateServiceCatalogDependenciesParams { - var () return &ValidateServiceCatalogDependenciesParams{ - timeout: timeout, } } // NewValidateServiceCatalogDependenciesParamsWithContext creates a new ValidateServiceCatalogDependenciesParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewValidateServiceCatalogDependenciesParamsWithContext(ctx context.Context) *ValidateServiceCatalogDependenciesParams { - var () return &ValidateServiceCatalogDependenciesParams{ - Context: ctx, } } // NewValidateServiceCatalogDependenciesParamsWithHTTPClient creates a new ValidateServiceCatalogDependenciesParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewValidateServiceCatalogDependenciesParamsWithHTTPClient(client *http.Client) *ValidateServiceCatalogDependenciesParams { - var () return &ValidateServiceCatalogDependenciesParams{ HTTPClient: client, } } -/*ValidateServiceCatalogDependenciesParams contains all the parameters to send to the API endpoint -for the validate service catalog dependencies operation typically these are written to a http.Request +/* +ValidateServiceCatalogDependenciesParams contains all the parameters to send to the API endpoint + + for the validate service catalog dependencies operation. + + Typically these are written to a http.Request. */ type ValidateServiceCatalogDependenciesParams struct { - /*OrganizationCanonical - A canonical of an organization. + /* OrganizationCanonical. + A canonical of an organization. */ OrganizationCanonical string - /*ServiceCatalogRef - A Service Catalog name + /* ServiceCatalogRef. + + A Service Catalog name */ ServiceCatalogRef string @@ -77,6 +78,21 @@ type ValidateServiceCatalogDependenciesParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the validate service catalog dependencies params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValidateServiceCatalogDependenciesParams) WithDefaults() *ValidateServiceCatalogDependenciesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the validate service catalog dependencies params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ValidateServiceCatalogDependenciesParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the validate service catalog dependencies params func (o *ValidateServiceCatalogDependenciesParams) WithTimeout(timeout time.Duration) *ValidateServiceCatalogDependenciesParams { o.SetTimeout(timeout) diff --git a/client/client/service_catalogs/validate_service_catalog_dependencies_responses.go b/client/client/service_catalogs/validate_service_catalog_dependencies_responses.go index c0a160c5..65819a7c 100644 --- a/client/client/service_catalogs/validate_service_catalog_dependencies_responses.go +++ b/client/client/service_catalogs/validate_service_catalog_dependencies_responses.go @@ -6,17 +6,18 @@ package service_catalogs // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // ValidateServiceCatalogDependenciesReader is a Reader for the ValidateServiceCatalogDependencies structure. @@ -62,7 +63,8 @@ func NewValidateServiceCatalogDependenciesOK() *ValidateServiceCatalogDependenci return &ValidateServiceCatalogDependenciesOK{} } -/*ValidateServiceCatalogDependenciesOK handles this case with default header values. +/* +ValidateServiceCatalogDependenciesOK describes a response with status code 200, with default header values. The result of the service catalog's dependencies validation */ @@ -70,8 +72,44 @@ type ValidateServiceCatalogDependenciesOK struct { Payload *ValidateServiceCatalogDependenciesOKBody } +// IsSuccess returns true when this validate service catalog dependencies o k response has a 2xx status code +func (o *ValidateServiceCatalogDependenciesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this validate service catalog dependencies o k response has a 3xx status code +func (o *ValidateServiceCatalogDependenciesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate service catalog dependencies o k response has a 4xx status code +func (o *ValidateServiceCatalogDependenciesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this validate service catalog dependencies o k response has a 5xx status code +func (o *ValidateServiceCatalogDependenciesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this validate service catalog dependencies o k response a status code equal to that given +func (o *ValidateServiceCatalogDependenciesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the validate service catalog dependencies o k response +func (o *ValidateServiceCatalogDependenciesOK) Code() int { + return 200 +} + func (o *ValidateServiceCatalogDependenciesOK) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesOK %s", 200, payload) +} + +func (o *ValidateServiceCatalogDependenciesOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesOK %s", 200, payload) } func (o *ValidateServiceCatalogDependenciesOK) GetPayload() *ValidateServiceCatalogDependenciesOKBody { @@ -95,20 +133,60 @@ func NewValidateServiceCatalogDependenciesForbidden() *ValidateServiceCatalogDep return &ValidateServiceCatalogDependenciesForbidden{} } -/*ValidateServiceCatalogDependenciesForbidden handles this case with default header values. +/* +ValidateServiceCatalogDependenciesForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type ValidateServiceCatalogDependenciesForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate service catalog dependencies forbidden response has a 2xx status code +func (o *ValidateServiceCatalogDependenciesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate service catalog dependencies forbidden response has a 3xx status code +func (o *ValidateServiceCatalogDependenciesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate service catalog dependencies forbidden response has a 4xx status code +func (o *ValidateServiceCatalogDependenciesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate service catalog dependencies forbidden response has a 5xx status code +func (o *ValidateServiceCatalogDependenciesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this validate service catalog dependencies forbidden response a status code equal to that given +func (o *ValidateServiceCatalogDependenciesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the validate service catalog dependencies forbidden response +func (o *ValidateServiceCatalogDependenciesForbidden) Code() int { + return 403 +} + func (o *ValidateServiceCatalogDependenciesForbidden) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesForbidden %s", 403, payload) +} + +func (o *ValidateServiceCatalogDependenciesForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesForbidden %s", 403, payload) } func (o *ValidateServiceCatalogDependenciesForbidden) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *ValidateServiceCatalogDependenciesForbidden) GetPayload() *models.Error func (o *ValidateServiceCatalogDependenciesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewValidateServiceCatalogDependenciesUnprocessableEntity() *ValidateService return &ValidateServiceCatalogDependenciesUnprocessableEntity{} } -/*ValidateServiceCatalogDependenciesUnprocessableEntity handles this case with default header values. +/* +ValidateServiceCatalogDependenciesUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type ValidateServiceCatalogDependenciesUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate service catalog dependencies unprocessable entity response has a 2xx status code +func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this validate service catalog dependencies unprocessable entity response has a 3xx status code +func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this validate service catalog dependencies unprocessable entity response has a 4xx status code +func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this validate service catalog dependencies unprocessable entity response has a 5xx status code +func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this validate service catalog dependencies unprocessable entity response a status code equal to that given +func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the validate service catalog dependencies unprocessable entity response +func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) Code() int { + return 422 +} + func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesUnprocessableEntity %s", 422, payload) +} + +func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependenciesUnprocessableEntity %s", 422, payload) } func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) GetPayload() *mo func (o *ValidateServiceCatalogDependenciesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewValidateServiceCatalogDependenciesDefault(code int) *ValidateServiceCata } } -/*ValidateServiceCatalogDependenciesDefault handles this case with default header values. +/* +ValidateServiceCatalogDependenciesDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type ValidateServiceCatalogDependenciesDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this validate service catalog dependencies default response has a 2xx status code +func (o *ValidateServiceCatalogDependenciesDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this validate service catalog dependencies default response has a 3xx status code +func (o *ValidateServiceCatalogDependenciesDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this validate service catalog dependencies default response has a 4xx status code +func (o *ValidateServiceCatalogDependenciesDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this validate service catalog dependencies default response has a 5xx status code +func (o *ValidateServiceCatalogDependenciesDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this validate service catalog dependencies default response a status code equal to that given +func (o *ValidateServiceCatalogDependenciesDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the validate service catalog dependencies default response func (o *ValidateServiceCatalogDependenciesDefault) Code() int { return o._statusCode } func (o *ValidateServiceCatalogDependenciesDefault) Error() string { - return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependencies default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependencies default %s", o._statusCode, payload) +} + +func (o *ValidateServiceCatalogDependenciesDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /organizations/{organization_canonical}/service_catalogs/{service_catalog_ref}/dependencies/validate][%d] validateServiceCatalogDependencies default %s", o._statusCode, payload) } func (o *ValidateServiceCatalogDependenciesDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *ValidateServiceCatalogDependenciesDefault) GetPayload() *models.ErrorPa func (o *ValidateServiceCatalogDependenciesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *ValidateServiceCatalogDependenciesDefault) readResponse(response runtim return nil } -/*ValidateServiceCatalogDependenciesOKBody validate service catalog dependencies o k body +/* +ValidateServiceCatalogDependenciesOKBody validate service catalog dependencies o k body swagger:model ValidateServiceCatalogDependenciesOKBody */ type ValidateServiceCatalogDependenciesOKBody struct { @@ -265,6 +430,39 @@ func (o *ValidateServiceCatalogDependenciesOKBody) validateData(formats strfmt.R if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("validateServiceCatalogDependenciesOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("validateServiceCatalogDependenciesOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this validate service catalog dependencies o k body based on the context it is used +func (o *ValidateServiceCatalogDependenciesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ValidateServiceCatalogDependenciesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("validateServiceCatalogDependenciesOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("validateServiceCatalogDependenciesOK" + "." + "data") } return err } diff --git a/client/client/user/create_o_auth_user_parameters.go b/client/client/user/create_o_auth_user_parameters.go index 35bc9fd6..19a85f51 100644 --- a/client/client/user/create_o_auth_user_parameters.go +++ b/client/client/user/create_o_auth_user_parameters.go @@ -13,64 +13,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewCreateOAuthUserParams creates a new CreateOAuthUserParams object -// with the default values initialized. +// NewCreateOAuthUserParams creates a new CreateOAuthUserParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewCreateOAuthUserParams() *CreateOAuthUserParams { - var () return &CreateOAuthUserParams{ - timeout: cr.DefaultTimeout, } } // NewCreateOAuthUserParamsWithTimeout creates a new CreateOAuthUserParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateOAuthUserParamsWithTimeout(timeout time.Duration) *CreateOAuthUserParams { - var () return &CreateOAuthUserParams{ - timeout: timeout, } } // NewCreateOAuthUserParamsWithContext creates a new CreateOAuthUserParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateOAuthUserParamsWithContext(ctx context.Context) *CreateOAuthUserParams { - var () return &CreateOAuthUserParams{ - Context: ctx, } } // NewCreateOAuthUserParamsWithHTTPClient creates a new CreateOAuthUserParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateOAuthUserParamsWithHTTPClient(client *http.Client) *CreateOAuthUserParams { - var () return &CreateOAuthUserParams{ HTTPClient: client, } } -/*CreateOAuthUserParams contains all the parameters to send to the API endpoint -for the create o auth user operation typically these are written to a http.Request +/* +CreateOAuthUserParams contains all the parameters to send to the API endpoint + + for the create o auth user operation. + + Typically these are written to a http.Request. */ type CreateOAuthUserParams struct { - /*Body - The user content + /* Body. + The user content */ Body *models.NewOAuthUser - /*SocialType - The OAuth Social type + /* SocialType. + + The OAuth Social type */ SocialType string @@ -79,6 +80,21 @@ type CreateOAuthUserParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create o auth user params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateOAuthUserParams) WithDefaults() *CreateOAuthUserParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create o auth user params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateOAuthUserParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create o auth user params func (o *CreateOAuthUserParams) WithTimeout(timeout time.Duration) *CreateOAuthUserParams { o.SetTimeout(timeout) @@ -141,7 +157,6 @@ func (o *CreateOAuthUserParams) WriteToRequest(r runtime.ClientRequest, reg strf return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/create_o_auth_user_responses.go b/client/client/user/create_o_auth_user_responses.go index 59f2c0b8..47340cfc 100644 --- a/client/client/user/create_o_auth_user_responses.go +++ b/client/client/user/create_o_auth_user_responses.go @@ -6,17 +6,18 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // CreateOAuthUserReader is a Reader for the CreateOAuthUser structure. @@ -56,7 +57,8 @@ func NewCreateOAuthUserOK() *CreateOAuthUserOK { return &CreateOAuthUserOK{} } -/*CreateOAuthUserOK handles this case with default header values. +/* +CreateOAuthUserOK describes a response with status code 200, with default header values. Create a user from the OAuth 'social_type' */ @@ -64,8 +66,44 @@ type CreateOAuthUserOK struct { Payload *CreateOAuthUserOKBody } +// IsSuccess returns true when this create o auth user o k response has a 2xx status code +func (o *CreateOAuthUserOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create o auth user o k response has a 3xx status code +func (o *CreateOAuthUserOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create o auth user o k response has a 4xx status code +func (o *CreateOAuthUserOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create o auth user o k response has a 5xx status code +func (o *CreateOAuthUserOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create o auth user o k response a status code equal to that given +func (o *CreateOAuthUserOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create o auth user o k response +func (o *CreateOAuthUserOK) Code() int { + return 200 +} + func (o *CreateOAuthUserOK) Error() string { - return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUserOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUserOK %s", 200, payload) +} + +func (o *CreateOAuthUserOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUserOK %s", 200, payload) } func (o *CreateOAuthUserOK) GetPayload() *CreateOAuthUserOKBody { @@ -89,20 +127,60 @@ func NewCreateOAuthUserUnauthorized() *CreateOAuthUserUnauthorized { return &CreateOAuthUserUnauthorized{} } -/*CreateOAuthUserUnauthorized handles this case with default header values. +/* +CreateOAuthUserUnauthorized describes a response with status code 401, with default header values. The user cannot be authenticated with the credentials which she/he has used. */ type CreateOAuthUserUnauthorized struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create o auth user unauthorized response has a 2xx status code +func (o *CreateOAuthUserUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create o auth user unauthorized response has a 3xx status code +func (o *CreateOAuthUserUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create o auth user unauthorized response has a 4xx status code +func (o *CreateOAuthUserUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this create o auth user unauthorized response has a 5xx status code +func (o *CreateOAuthUserUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this create o auth user unauthorized response a status code equal to that given +func (o *CreateOAuthUserUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the create o auth user unauthorized response +func (o *CreateOAuthUserUnauthorized) Code() int { + return 401 +} + func (o *CreateOAuthUserUnauthorized) Error() string { - return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUserUnauthorized %+v", 401, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUserUnauthorized %s", 401, payload) +} + +func (o *CreateOAuthUserUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUserUnauthorized %s", 401, payload) } func (o *CreateOAuthUserUnauthorized) GetPayload() *models.ErrorPayload { @@ -111,12 +189,16 @@ func (o *CreateOAuthUserUnauthorized) GetPayload() *models.ErrorPayload { func (o *CreateOAuthUserUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -135,27 +217,61 @@ func NewCreateOAuthUserDefault(code int) *CreateOAuthUserDefault { } } -/*CreateOAuthUserDefault handles this case with default header values. +/* +CreateOAuthUserDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type CreateOAuthUserDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this create o auth user default response has a 2xx status code +func (o *CreateOAuthUserDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create o auth user default response has a 3xx status code +func (o *CreateOAuthUserDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create o auth user default response has a 4xx status code +func (o *CreateOAuthUserDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create o auth user default response has a 5xx status code +func (o *CreateOAuthUserDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create o auth user default response a status code equal to that given +func (o *CreateOAuthUserDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create o auth user default response func (o *CreateOAuthUserDefault) Code() int { return o._statusCode } func (o *CreateOAuthUserDefault) Error() string { - return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUser default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUser default %s", o._statusCode, payload) +} + +func (o *CreateOAuthUserDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/{social_type}/oauth][%d] createOAuthUser default %s", o._statusCode, payload) } func (o *CreateOAuthUserDefault) GetPayload() *models.ErrorPayload { @@ -164,12 +280,16 @@ func (o *CreateOAuthUserDefault) GetPayload() *models.ErrorPayload { func (o *CreateOAuthUserDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -181,7 +301,8 @@ func (o *CreateOAuthUserDefault) readResponse(response runtime.ClientResponse, c return nil } -/*CreateOAuthUserOKBody create o auth user o k body +/* +CreateOAuthUserOKBody create o auth user o k body swagger:model CreateOAuthUserOKBody */ type CreateOAuthUserOKBody struct { @@ -215,6 +336,39 @@ func (o *CreateOAuthUserOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("createOAuthUserOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createOAuthUserOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create o auth user o k body based on the context it is used +func (o *CreateOAuthUserOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *CreateOAuthUserOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createOAuthUserOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createOAuthUserOK" + "." + "data") } return err } diff --git a/client/client/user/delete_user_account_parameters.go b/client/client/user/delete_user_account_parameters.go index be51a7b7..c82a85df 100644 --- a/client/client/user/delete_user_account_parameters.go +++ b/client/client/user/delete_user_account_parameters.go @@ -13,51 +13,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDeleteUserAccountParams creates a new DeleteUserAccountParams object -// with the default values initialized. +// NewDeleteUserAccountParams creates a new DeleteUserAccountParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewDeleteUserAccountParams() *DeleteUserAccountParams { - return &DeleteUserAccountParams{ - timeout: cr.DefaultTimeout, } } // NewDeleteUserAccountParamsWithTimeout creates a new DeleteUserAccountParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDeleteUserAccountParamsWithTimeout(timeout time.Duration) *DeleteUserAccountParams { - return &DeleteUserAccountParams{ - timeout: timeout, } } // NewDeleteUserAccountParamsWithContext creates a new DeleteUserAccountParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDeleteUserAccountParamsWithContext(ctx context.Context) *DeleteUserAccountParams { - return &DeleteUserAccountParams{ - Context: ctx, } } // NewDeleteUserAccountParamsWithHTTPClient creates a new DeleteUserAccountParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDeleteUserAccountParamsWithHTTPClient(client *http.Client) *DeleteUserAccountParams { - return &DeleteUserAccountParams{ HTTPClient: client, } } -/*DeleteUserAccountParams contains all the parameters to send to the API endpoint -for the delete user account operation typically these are written to a http.Request +/* +DeleteUserAccountParams contains all the parameters to send to the API endpoint + + for the delete user account operation. + + Typically these are written to a http.Request. */ type DeleteUserAccountParams struct { timeout time.Duration @@ -65,6 +65,21 @@ type DeleteUserAccountParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the delete user account params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteUserAccountParams) WithDefaults() *DeleteUserAccountParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete user account params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteUserAccountParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the delete user account params func (o *DeleteUserAccountParams) WithTimeout(timeout time.Duration) *DeleteUserAccountParams { o.SetTimeout(timeout) diff --git a/client/client/user/delete_user_account_responses.go b/client/client/user/delete_user_account_responses.go index 9e84d8d6..d66d0705 100644 --- a/client/client/user/delete_user_account_responses.go +++ b/client/client/user/delete_user_account_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // DeleteUserAccountReader is a Reader for the DeleteUserAccount structure. @@ -55,15 +55,50 @@ func NewDeleteUserAccountNoContent() *DeleteUserAccountNoContent { return &DeleteUserAccountNoContent{} } -/*DeleteUserAccountNoContent handles this case with default header values. +/* +DeleteUserAccountNoContent describes a response with status code 204, with default header values. User account has been deleted. */ type DeleteUserAccountNoContent struct { } +// IsSuccess returns true when this delete user account no content response has a 2xx status code +func (o *DeleteUserAccountNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete user account no content response has a 3xx status code +func (o *DeleteUserAccountNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete user account no content response has a 4xx status code +func (o *DeleteUserAccountNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete user account no content response has a 5xx status code +func (o *DeleteUserAccountNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this delete user account no content response a status code equal to that given +func (o *DeleteUserAccountNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the delete user account no content response +func (o *DeleteUserAccountNoContent) Code() int { + return 204 +} + func (o *DeleteUserAccountNoContent) Error() string { - return fmt.Sprintf("[DELETE /user][%d] deleteUserAccountNoContent ", 204) + return fmt.Sprintf("[DELETE /user][%d] deleteUserAccountNoContent", 204) +} + +func (o *DeleteUserAccountNoContent) String() string { + return fmt.Sprintf("[DELETE /user][%d] deleteUserAccountNoContent", 204) } func (o *DeleteUserAccountNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -76,20 +111,60 @@ func NewDeleteUserAccountForbidden() *DeleteUserAccountForbidden { return &DeleteUserAccountForbidden{} } -/*DeleteUserAccountForbidden handles this case with default header values. +/* +DeleteUserAccountForbidden describes a response with status code 403, with default header values. The authenticated user cannot perform the operation because, it doesn't have permissions for such operation. */ type DeleteUserAccountForbidden struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete user account forbidden response has a 2xx status code +func (o *DeleteUserAccountForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete user account forbidden response has a 3xx status code +func (o *DeleteUserAccountForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete user account forbidden response has a 4xx status code +func (o *DeleteUserAccountForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete user account forbidden response has a 5xx status code +func (o *DeleteUserAccountForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete user account forbidden response a status code equal to that given +func (o *DeleteUserAccountForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete user account forbidden response +func (o *DeleteUserAccountForbidden) Code() int { + return 403 +} + func (o *DeleteUserAccountForbidden) Error() string { - return fmt.Sprintf("[DELETE /user][%d] deleteUserAccountForbidden %+v", 403, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /user][%d] deleteUserAccountForbidden %s", 403, payload) +} + +func (o *DeleteUserAccountForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /user][%d] deleteUserAccountForbidden %s", 403, payload) } func (o *DeleteUserAccountForbidden) GetPayload() *models.ErrorPayload { @@ -98,12 +173,16 @@ func (o *DeleteUserAccountForbidden) GetPayload() *models.ErrorPayload { func (o *DeleteUserAccountForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -122,27 +201,61 @@ func NewDeleteUserAccountDefault(code int) *DeleteUserAccountDefault { } } -/*DeleteUserAccountDefault handles this case with default header values. +/* +DeleteUserAccountDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type DeleteUserAccountDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this delete user account default response has a 2xx status code +func (o *DeleteUserAccountDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this delete user account default response has a 3xx status code +func (o *DeleteUserAccountDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this delete user account default response has a 4xx status code +func (o *DeleteUserAccountDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this delete user account default response has a 5xx status code +func (o *DeleteUserAccountDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this delete user account default response a status code equal to that given +func (o *DeleteUserAccountDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the delete user account default response func (o *DeleteUserAccountDefault) Code() int { return o._statusCode } func (o *DeleteUserAccountDefault) Error() string { - return fmt.Sprintf("[DELETE /user][%d] deleteUserAccount default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /user][%d] deleteUserAccount default %s", o._statusCode, payload) +} + +func (o *DeleteUserAccountDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /user][%d] deleteUserAccount default %s", o._statusCode, payload) } func (o *DeleteUserAccountDefault) GetPayload() *models.ErrorPayload { @@ -151,12 +264,16 @@ func (o *DeleteUserAccountDefault) GetPayload() *models.ErrorPayload { func (o *DeleteUserAccountDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/email_authentication_verification_parameters.go b/client/client/user/email_authentication_verification_parameters.go index 8e86f615..86f12c8a 100644 --- a/client/client/user/email_authentication_verification_parameters.go +++ b/client/client/user/email_authentication_verification_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewEmailAuthenticationVerificationParams creates a new EmailAuthenticationVerificationParams object -// with the default values initialized. +// NewEmailAuthenticationVerificationParams creates a new EmailAuthenticationVerificationParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewEmailAuthenticationVerificationParams() *EmailAuthenticationVerificationParams { - var () return &EmailAuthenticationVerificationParams{ - timeout: cr.DefaultTimeout, } } // NewEmailAuthenticationVerificationParamsWithTimeout creates a new EmailAuthenticationVerificationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewEmailAuthenticationVerificationParamsWithTimeout(timeout time.Duration) *EmailAuthenticationVerificationParams { - var () return &EmailAuthenticationVerificationParams{ - timeout: timeout, } } // NewEmailAuthenticationVerificationParamsWithContext creates a new EmailAuthenticationVerificationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewEmailAuthenticationVerificationParamsWithContext(ctx context.Context) *EmailAuthenticationVerificationParams { - var () return &EmailAuthenticationVerificationParams{ - Context: ctx, } } // NewEmailAuthenticationVerificationParamsWithHTTPClient creates a new EmailAuthenticationVerificationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewEmailAuthenticationVerificationParamsWithHTTPClient(client *http.Client) *EmailAuthenticationVerificationParams { - var () return &EmailAuthenticationVerificationParams{ HTTPClient: client, } } -/*EmailAuthenticationVerificationParams contains all the parameters to send to the API endpoint -for the email authentication verification operation typically these are written to a http.Request +/* +EmailAuthenticationVerificationParams contains all the parameters to send to the API endpoint + + for the email authentication verification operation. + + Typically these are written to a http.Request. */ type EmailAuthenticationVerificationParams struct { - /*AuthenticationToken - A token for authenticating login vie email + /* AuthenticationToken. + A token for authenticating login vie email */ AuthenticationToken string @@ -72,6 +72,21 @@ type EmailAuthenticationVerificationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the email authentication verification params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *EmailAuthenticationVerificationParams) WithDefaults() *EmailAuthenticationVerificationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the email authentication verification params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *EmailAuthenticationVerificationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the email authentication verification params func (o *EmailAuthenticationVerificationParams) WithTimeout(timeout time.Duration) *EmailAuthenticationVerificationParams { o.SetTimeout(timeout) diff --git a/client/client/user/email_authentication_verification_responses.go b/client/client/user/email_authentication_verification_responses.go index 755fdc8b..4a8d0f58 100644 --- a/client/client/user/email_authentication_verification_responses.go +++ b/client/client/user/email_authentication_verification_responses.go @@ -6,17 +6,18 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // EmailAuthenticationVerificationReader is a Reader for the EmailAuthenticationVerification structure. @@ -62,7 +63,8 @@ func NewEmailAuthenticationVerificationOK() *EmailAuthenticationVerificationOK { return &EmailAuthenticationVerificationOK{} } -/*EmailAuthenticationVerificationOK handles this case with default header values. +/* +EmailAuthenticationVerificationOK describes a response with status code 200, with default header values. The token which represents the session of the user. */ @@ -70,8 +72,44 @@ type EmailAuthenticationVerificationOK struct { Payload *EmailAuthenticationVerificationOKBody } +// IsSuccess returns true when this email authentication verification o k response has a 2xx status code +func (o *EmailAuthenticationVerificationOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this email authentication verification o k response has a 3xx status code +func (o *EmailAuthenticationVerificationOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this email authentication verification o k response has a 4xx status code +func (o *EmailAuthenticationVerificationOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this email authentication verification o k response has a 5xx status code +func (o *EmailAuthenticationVerificationOK) IsServerError() bool { + return false +} + +// IsCode returns true when this email authentication verification o k response a status code equal to that given +func (o *EmailAuthenticationVerificationOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the email authentication verification o k response +func (o *EmailAuthenticationVerificationOK) Code() int { + return 200 +} + func (o *EmailAuthenticationVerificationOK) Error() string { - return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationOK %s", 200, payload) +} + +func (o *EmailAuthenticationVerificationOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationOK %s", 200, payload) } func (o *EmailAuthenticationVerificationOK) GetPayload() *EmailAuthenticationVerificationOKBody { @@ -95,20 +133,60 @@ func NewEmailAuthenticationVerificationUnauthorized() *EmailAuthenticationVerifi return &EmailAuthenticationVerificationUnauthorized{} } -/*EmailAuthenticationVerificationUnauthorized handles this case with default header values. +/* +EmailAuthenticationVerificationUnauthorized describes a response with status code 401, with default header values. The user cannot be authenticated with the credentials which she/he has used. */ type EmailAuthenticationVerificationUnauthorized struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this email authentication verification unauthorized response has a 2xx status code +func (o *EmailAuthenticationVerificationUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this email authentication verification unauthorized response has a 3xx status code +func (o *EmailAuthenticationVerificationUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this email authentication verification unauthorized response has a 4xx status code +func (o *EmailAuthenticationVerificationUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this email authentication verification unauthorized response has a 5xx status code +func (o *EmailAuthenticationVerificationUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this email authentication verification unauthorized response a status code equal to that given +func (o *EmailAuthenticationVerificationUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the email authentication verification unauthorized response +func (o *EmailAuthenticationVerificationUnauthorized) Code() int { + return 401 +} + func (o *EmailAuthenticationVerificationUnauthorized) Error() string { - return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationUnauthorized %+v", 401, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationUnauthorized %s", 401, payload) +} + +func (o *EmailAuthenticationVerificationUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationUnauthorized %s", 401, payload) } func (o *EmailAuthenticationVerificationUnauthorized) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *EmailAuthenticationVerificationUnauthorized) GetPayload() *models.Error func (o *EmailAuthenticationVerificationUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewEmailAuthenticationVerificationUnprocessableEntity() *EmailAuthenticatio return &EmailAuthenticationVerificationUnprocessableEntity{} } -/*EmailAuthenticationVerificationUnprocessableEntity handles this case with default header values. +/* +EmailAuthenticationVerificationUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type EmailAuthenticationVerificationUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this email authentication verification unprocessable entity response has a 2xx status code +func (o *EmailAuthenticationVerificationUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this email authentication verification unprocessable entity response has a 3xx status code +func (o *EmailAuthenticationVerificationUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this email authentication verification unprocessable entity response has a 4xx status code +func (o *EmailAuthenticationVerificationUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this email authentication verification unprocessable entity response has a 5xx status code +func (o *EmailAuthenticationVerificationUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this email authentication verification unprocessable entity response a status code equal to that given +func (o *EmailAuthenticationVerificationUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the email authentication verification unprocessable entity response +func (o *EmailAuthenticationVerificationUnprocessableEntity) Code() int { + return 422 +} + func (o *EmailAuthenticationVerificationUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationUnprocessableEntity %s", 422, payload) +} + +func (o *EmailAuthenticationVerificationUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerificationUnprocessableEntity %s", 422, payload) } func (o *EmailAuthenticationVerificationUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *EmailAuthenticationVerificationUnprocessableEntity) GetPayload() *model func (o *EmailAuthenticationVerificationUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewEmailAuthenticationVerificationDefault(code int) *EmailAuthenticationVer } } -/*EmailAuthenticationVerificationDefault handles this case with default header values. +/* +EmailAuthenticationVerificationDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type EmailAuthenticationVerificationDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this email authentication verification default response has a 2xx status code +func (o *EmailAuthenticationVerificationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this email authentication verification default response has a 3xx status code +func (o *EmailAuthenticationVerificationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this email authentication verification default response has a 4xx status code +func (o *EmailAuthenticationVerificationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this email authentication verification default response has a 5xx status code +func (o *EmailAuthenticationVerificationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this email authentication verification default response a status code equal to that given +func (o *EmailAuthenticationVerificationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the email authentication verification default response func (o *EmailAuthenticationVerificationDefault) Code() int { return o._statusCode } func (o *EmailAuthenticationVerificationDefault) Error() string { - return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerification default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerification default %s", o._statusCode, payload) +} + +func (o *EmailAuthenticationVerificationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/authentication/{authentication_token}][%d] emailAuthenticationVerification default %s", o._statusCode, payload) } func (o *EmailAuthenticationVerificationDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *EmailAuthenticationVerificationDefault) GetPayload() *models.ErrorPaylo func (o *EmailAuthenticationVerificationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *EmailAuthenticationVerificationDefault) readResponse(response runtime.C return nil } -/*EmailAuthenticationVerificationOKBody email authentication verification o k body +/* +EmailAuthenticationVerificationOKBody email authentication verification o k body swagger:model EmailAuthenticationVerificationOKBody */ type EmailAuthenticationVerificationOKBody struct { @@ -265,6 +430,39 @@ func (o *EmailAuthenticationVerificationOKBody) validateData(formats strfmt.Regi if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("emailAuthenticationVerificationOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("emailAuthenticationVerificationOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this email authentication verification o k body based on the context it is used +func (o *EmailAuthenticationVerificationOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *EmailAuthenticationVerificationOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("emailAuthenticationVerificationOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("emailAuthenticationVerificationOK" + "." + "data") } return err } diff --git a/client/client/user/email_verification_parameters.go b/client/client/user/email_verification_parameters.go index 5b90f7c2..a389e599 100644 --- a/client/client/user/email_verification_parameters.go +++ b/client/client/user/email_verification_parameters.go @@ -13,57 +13,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewEmailVerificationParams creates a new EmailVerificationParams object -// with the default values initialized. +// NewEmailVerificationParams creates a new EmailVerificationParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewEmailVerificationParams() *EmailVerificationParams { - var () return &EmailVerificationParams{ - timeout: cr.DefaultTimeout, } } // NewEmailVerificationParamsWithTimeout creates a new EmailVerificationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewEmailVerificationParamsWithTimeout(timeout time.Duration) *EmailVerificationParams { - var () return &EmailVerificationParams{ - timeout: timeout, } } // NewEmailVerificationParamsWithContext creates a new EmailVerificationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewEmailVerificationParamsWithContext(ctx context.Context) *EmailVerificationParams { - var () return &EmailVerificationParams{ - Context: ctx, } } // NewEmailVerificationParamsWithHTTPClient creates a new EmailVerificationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewEmailVerificationParamsWithHTTPClient(client *http.Client) *EmailVerificationParams { - var () return &EmailVerificationParams{ HTTPClient: client, } } -/*EmailVerificationParams contains all the parameters to send to the API endpoint -for the email verification operation typically these are written to a http.Request +/* +EmailVerificationParams contains all the parameters to send to the API endpoint + + for the email verification operation. + + Typically these are written to a http.Request. */ type EmailVerificationParams struct { - /*VerificationToken - A token for verifying emails, invitations, etc. + /* VerificationToken. + A token for verifying emails, invitations, etc. */ VerificationToken string @@ -72,6 +72,21 @@ type EmailVerificationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the email verification params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *EmailVerificationParams) WithDefaults() *EmailVerificationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the email verification params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *EmailVerificationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the email verification params func (o *EmailVerificationParams) WithTimeout(timeout time.Duration) *EmailVerificationParams { o.SetTimeout(timeout) diff --git a/client/client/user/email_verification_resend_parameters.go b/client/client/user/email_verification_resend_parameters.go index 484633fa..dd7aa247 100644 --- a/client/client/user/email_verification_resend_parameters.go +++ b/client/client/user/email_verification_resend_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewEmailVerificationResendParams creates a new EmailVerificationResendParams object -// with the default values initialized. +// NewEmailVerificationResendParams creates a new EmailVerificationResendParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewEmailVerificationResendParams() *EmailVerificationResendParams { - var () return &EmailVerificationResendParams{ - timeout: cr.DefaultTimeout, } } // NewEmailVerificationResendParamsWithTimeout creates a new EmailVerificationResendParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewEmailVerificationResendParamsWithTimeout(timeout time.Duration) *EmailVerificationResendParams { - var () return &EmailVerificationResendParams{ - timeout: timeout, } } // NewEmailVerificationResendParamsWithContext creates a new EmailVerificationResendParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewEmailVerificationResendParamsWithContext(ctx context.Context) *EmailVerificationResendParams { - var () return &EmailVerificationResendParams{ - Context: ctx, } } // NewEmailVerificationResendParamsWithHTTPClient creates a new EmailVerificationResendParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewEmailVerificationResendParamsWithHTTPClient(client *http.Client) *EmailVerificationResendParams { - var () return &EmailVerificationResendParams{ HTTPClient: client, } } -/*EmailVerificationResendParams contains all the parameters to send to the API endpoint -for the email verification resend operation typically these are written to a http.Request +/* +EmailVerificationResendParams contains all the parameters to send to the API endpoint + + for the email verification resend operation. + + Typically these are written to a http.Request. */ type EmailVerificationResendParams struct { - /*Body - The email address to re-send the verification email. This endpoint doesn't return any error status code if the email doesn't exist nor it's already verified for avoiding that an attacker could find registered users email address. + /* Body. + The email address to re-send the verification email. This endpoint doesn't return any error status code if the email doesn't exist nor it's already verified for avoiding that an attacker could find registered users email address. */ Body *models.UserEmail @@ -74,6 +74,21 @@ type EmailVerificationResendParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the email verification resend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *EmailVerificationResendParams) WithDefaults() *EmailVerificationResendParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the email verification resend params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *EmailVerificationResendParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the email verification resend params func (o *EmailVerificationResendParams) WithTimeout(timeout time.Duration) *EmailVerificationResendParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *EmailVerificationResendParams) WriteToRequest(r runtime.ClientRequest, return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/email_verification_resend_responses.go b/client/client/user/email_verification_resend_responses.go index 09a2171d..066801ee 100644 --- a/client/client/user/email_verification_resend_responses.go +++ b/client/client/user/email_verification_resend_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // EmailVerificationResendReader is a Reader for the EmailVerificationResend structure. @@ -55,15 +55,50 @@ func NewEmailVerificationResendNoContent() *EmailVerificationResendNoContent { return &EmailVerificationResendNoContent{} } -/*EmailVerificationResendNoContent handles this case with default header values. +/* +EmailVerificationResendNoContent describes a response with status code 204, with default header values. The email verification has been re-sent. */ type EmailVerificationResendNoContent struct { } +// IsSuccess returns true when this email verification resend no content response has a 2xx status code +func (o *EmailVerificationResendNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this email verification resend no content response has a 3xx status code +func (o *EmailVerificationResendNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this email verification resend no content response has a 4xx status code +func (o *EmailVerificationResendNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this email verification resend no content response has a 5xx status code +func (o *EmailVerificationResendNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this email verification resend no content response a status code equal to that given +func (o *EmailVerificationResendNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the email verification resend no content response +func (o *EmailVerificationResendNoContent) Code() int { + return 204 +} + func (o *EmailVerificationResendNoContent) Error() string { - return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResendNoContent ", 204) + return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResendNoContent", 204) +} + +func (o *EmailVerificationResendNoContent) String() string { + return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResendNoContent", 204) } func (o *EmailVerificationResendNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -76,20 +111,60 @@ func NewEmailVerificationResendUnprocessableEntity() *EmailVerificationResendUnp return &EmailVerificationResendUnprocessableEntity{} } -/*EmailVerificationResendUnprocessableEntity handles this case with default header values. +/* +EmailVerificationResendUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type EmailVerificationResendUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this email verification resend unprocessable entity response has a 2xx status code +func (o *EmailVerificationResendUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this email verification resend unprocessable entity response has a 3xx status code +func (o *EmailVerificationResendUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this email verification resend unprocessable entity response has a 4xx status code +func (o *EmailVerificationResendUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this email verification resend unprocessable entity response has a 5xx status code +func (o *EmailVerificationResendUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this email verification resend unprocessable entity response a status code equal to that given +func (o *EmailVerificationResendUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the email verification resend unprocessable entity response +func (o *EmailVerificationResendUnprocessableEntity) Code() int { + return 422 +} + func (o *EmailVerificationResendUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResendUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResendUnprocessableEntity %s", 422, payload) +} + +func (o *EmailVerificationResendUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResendUnprocessableEntity %s", 422, payload) } func (o *EmailVerificationResendUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -98,12 +173,16 @@ func (o *EmailVerificationResendUnprocessableEntity) GetPayload() *models.ErrorP func (o *EmailVerificationResendUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -122,27 +201,61 @@ func NewEmailVerificationResendDefault(code int) *EmailVerificationResendDefault } } -/*EmailVerificationResendDefault handles this case with default header values. +/* +EmailVerificationResendDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type EmailVerificationResendDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this email verification resend default response has a 2xx status code +func (o *EmailVerificationResendDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this email verification resend default response has a 3xx status code +func (o *EmailVerificationResendDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this email verification resend default response has a 4xx status code +func (o *EmailVerificationResendDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this email verification resend default response has a 5xx status code +func (o *EmailVerificationResendDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this email verification resend default response a status code equal to that given +func (o *EmailVerificationResendDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the email verification resend default response func (o *EmailVerificationResendDefault) Code() int { return o._statusCode } func (o *EmailVerificationResendDefault) Error() string { - return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResend default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResend default %s", o._statusCode, payload) +} + +func (o *EmailVerificationResendDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/email/verification][%d] emailVerificationResend default %s", o._statusCode, payload) } func (o *EmailVerificationResendDefault) GetPayload() *models.ErrorPayload { @@ -151,12 +264,16 @@ func (o *EmailVerificationResendDefault) GetPayload() *models.ErrorPayload { func (o *EmailVerificationResendDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/email_verification_responses.go b/client/client/user/email_verification_responses.go index 0da53e49..3575c656 100644 --- a/client/client/user/email_verification_responses.go +++ b/client/client/user/email_verification_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // EmailVerificationReader is a Reader for the EmailVerification structure. @@ -61,15 +61,50 @@ func NewEmailVerificationNoContent() *EmailVerificationNoContent { return &EmailVerificationNoContent{} } -/*EmailVerificationNoContent handles this case with default header values. +/* +EmailVerificationNoContent describes a response with status code 204, with default header values. Email address has been verified. */ type EmailVerificationNoContent struct { } +// IsSuccess returns true when this email verification no content response has a 2xx status code +func (o *EmailVerificationNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this email verification no content response has a 3xx status code +func (o *EmailVerificationNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this email verification no content response has a 4xx status code +func (o *EmailVerificationNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this email verification no content response has a 5xx status code +func (o *EmailVerificationNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this email verification no content response a status code equal to that given +func (o *EmailVerificationNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the email verification no content response +func (o *EmailVerificationNoContent) Code() int { + return 204 +} + func (o *EmailVerificationNoContent) Error() string { - return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationNoContent ", 204) + return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationNoContent", 204) +} + +func (o *EmailVerificationNoContent) String() string { + return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationNoContent", 204) } func (o *EmailVerificationNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewEmailVerificationNotFound() *EmailVerificationNotFound { return &EmailVerificationNotFound{} } -/*EmailVerificationNotFound handles this case with default header values. +/* +EmailVerificationNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type EmailVerificationNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this email verification not found response has a 2xx status code +func (o *EmailVerificationNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this email verification not found response has a 3xx status code +func (o *EmailVerificationNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this email verification not found response has a 4xx status code +func (o *EmailVerificationNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this email verification not found response has a 5xx status code +func (o *EmailVerificationNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this email verification not found response a status code equal to that given +func (o *EmailVerificationNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the email verification not found response +func (o *EmailVerificationNotFound) Code() int { + return 404 +} + func (o *EmailVerificationNotFound) Error() string { - return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationNotFound %s", 404, payload) +} + +func (o *EmailVerificationNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationNotFound %s", 404, payload) } func (o *EmailVerificationNotFound) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *EmailVerificationNotFound) GetPayload() *models.ErrorPayload { func (o *EmailVerificationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewEmailVerificationUnprocessableEntity() *EmailVerificationUnprocessableEn return &EmailVerificationUnprocessableEntity{} } -/*EmailVerificationUnprocessableEntity handles this case with default header values. +/* +EmailVerificationUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type EmailVerificationUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this email verification unprocessable entity response has a 2xx status code +func (o *EmailVerificationUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this email verification unprocessable entity response has a 3xx status code +func (o *EmailVerificationUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this email verification unprocessable entity response has a 4xx status code +func (o *EmailVerificationUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this email verification unprocessable entity response has a 5xx status code +func (o *EmailVerificationUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this email verification unprocessable entity response a status code equal to that given +func (o *EmailVerificationUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the email verification unprocessable entity response +func (o *EmailVerificationUnprocessableEntity) Code() int { + return 422 +} + func (o *EmailVerificationUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationUnprocessableEntity %s", 422, payload) +} + +func (o *EmailVerificationUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerificationUnprocessableEntity %s", 422, payload) } func (o *EmailVerificationUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *EmailVerificationUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *EmailVerificationUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewEmailVerificationDefault(code int) *EmailVerificationDefault { } } -/*EmailVerificationDefault handles this case with default header values. +/* +EmailVerificationDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type EmailVerificationDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this email verification default response has a 2xx status code +func (o *EmailVerificationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this email verification default response has a 3xx status code +func (o *EmailVerificationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this email verification default response has a 4xx status code +func (o *EmailVerificationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this email verification default response has a 5xx status code +func (o *EmailVerificationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this email verification default response a status code equal to that given +func (o *EmailVerificationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the email verification default response func (o *EmailVerificationDefault) Code() int { return o._statusCode } func (o *EmailVerificationDefault) Error() string { - return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerification default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerification default %s", o._statusCode, payload) +} + +func (o *EmailVerificationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/email/verification/{verification_token}][%d] emailVerification default %s", o._statusCode, payload) } func (o *EmailVerificationDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *EmailVerificationDefault) GetPayload() *models.ErrorPayload { func (o *EmailVerificationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/get_o_auth_user_parameters.go b/client/client/user/get_o_auth_user_parameters.go index f0763a08..ee247a7b 100644 --- a/client/client/user/get_o_auth_user_parameters.go +++ b/client/client/user/get_o_auth_user_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetOAuthUserParams creates a new GetOAuthUserParams object -// with the default values initialized. +// NewGetOAuthUserParams creates a new GetOAuthUserParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetOAuthUserParams() *GetOAuthUserParams { - var () return &GetOAuthUserParams{ - timeout: cr.DefaultTimeout, } } // NewGetOAuthUserParamsWithTimeout creates a new GetOAuthUserParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetOAuthUserParamsWithTimeout(timeout time.Duration) *GetOAuthUserParams { - var () return &GetOAuthUserParams{ - timeout: timeout, } } // NewGetOAuthUserParamsWithContext creates a new GetOAuthUserParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetOAuthUserParamsWithContext(ctx context.Context) *GetOAuthUserParams { - var () return &GetOAuthUserParams{ - Context: ctx, } } // NewGetOAuthUserParamsWithHTTPClient creates a new GetOAuthUserParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetOAuthUserParamsWithHTTPClient(client *http.Client) *GetOAuthUserParams { - var () return &GetOAuthUserParams{ HTTPClient: client, } } -/*GetOAuthUserParams contains all the parameters to send to the API endpoint -for the get o auth user operation typically these are written to a http.Request +/* +GetOAuthUserParams contains all the parameters to send to the API endpoint + + for the get o auth user operation. + + Typically these are written to a http.Request. */ type GetOAuthUserParams struct { - /*OauthCode - The OAuth code returned form the Social Provider + /* OauthCode. + The OAuth code returned form the Social Provider */ OauthCode string - /*SocialType - The OAuth Social type + /* SocialType. + + The OAuth Social type */ SocialType string @@ -77,6 +78,21 @@ type GetOAuthUserParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get o auth user params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOAuthUserParams) WithDefaults() *GetOAuthUserParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get o auth user params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetOAuthUserParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get o auth user params func (o *GetOAuthUserParams) WithTimeout(timeout time.Duration) *GetOAuthUserParams { o.SetTimeout(timeout) @@ -144,6 +160,7 @@ func (o *GetOAuthUserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. qrOauthCode := o.OauthCode qOauthCode := qrOauthCode if qOauthCode != "" { + if err := r.SetQueryParam("oauth_code", qOauthCode); err != nil { return err } diff --git a/client/client/user/get_o_auth_user_responses.go b/client/client/user/get_o_auth_user_responses.go index 9db4222c..08a1ef2b 100644 --- a/client/client/user/get_o_auth_user_responses.go +++ b/client/client/user/get_o_auth_user_responses.go @@ -6,17 +6,18 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetOAuthUserReader is a Reader for the GetOAuthUser structure. @@ -56,7 +57,8 @@ func NewGetOAuthUserOK() *GetOAuthUserOK { return &GetOAuthUserOK{} } -/*GetOAuthUserOK handles this case with default header values. +/* +GetOAuthUserOK describes a response with status code 200, with default header values. Used to know if a user from the platform exists on that 'social_type'. */ @@ -64,8 +66,44 @@ type GetOAuthUserOK struct { Payload *GetOAuthUserOKBody } +// IsSuccess returns true when this get o auth user o k response has a 2xx status code +func (o *GetOAuthUserOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get o auth user o k response has a 3xx status code +func (o *GetOAuthUserOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get o auth user o k response has a 4xx status code +func (o *GetOAuthUserOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get o auth user o k response has a 5xx status code +func (o *GetOAuthUserOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get o auth user o k response a status code equal to that given +func (o *GetOAuthUserOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get o auth user o k response +func (o *GetOAuthUserOK) Code() int { + return 200 +} + func (o *GetOAuthUserOK) Error() string { - return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUserOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUserOK %s", 200, payload) +} + +func (o *GetOAuthUserOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUserOK %s", 200, payload) } func (o *GetOAuthUserOK) GetPayload() *GetOAuthUserOKBody { @@ -89,20 +127,60 @@ func NewGetOAuthUserUnauthorized() *GetOAuthUserUnauthorized { return &GetOAuthUserUnauthorized{} } -/*GetOAuthUserUnauthorized handles this case with default header values. +/* +GetOAuthUserUnauthorized describes a response with status code 401, with default header values. The user cannot be authenticated with the credentials which she/he has used. */ type GetOAuthUserUnauthorized struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get o auth user unauthorized response has a 2xx status code +func (o *GetOAuthUserUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get o auth user unauthorized response has a 3xx status code +func (o *GetOAuthUserUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get o auth user unauthorized response has a 4xx status code +func (o *GetOAuthUserUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get o auth user unauthorized response has a 5xx status code +func (o *GetOAuthUserUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get o auth user unauthorized response a status code equal to that given +func (o *GetOAuthUserUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get o auth user unauthorized response +func (o *GetOAuthUserUnauthorized) Code() int { + return 401 +} + func (o *GetOAuthUserUnauthorized) Error() string { - return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUserUnauthorized %+v", 401, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUserUnauthorized %s", 401, payload) +} + +func (o *GetOAuthUserUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUserUnauthorized %s", 401, payload) } func (o *GetOAuthUserUnauthorized) GetPayload() *models.ErrorPayload { @@ -111,12 +189,16 @@ func (o *GetOAuthUserUnauthorized) GetPayload() *models.ErrorPayload { func (o *GetOAuthUserUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -135,27 +217,61 @@ func NewGetOAuthUserDefault(code int) *GetOAuthUserDefault { } } -/*GetOAuthUserDefault handles this case with default header values. +/* +GetOAuthUserDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetOAuthUserDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get o auth user default response has a 2xx status code +func (o *GetOAuthUserDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get o auth user default response has a 3xx status code +func (o *GetOAuthUserDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get o auth user default response has a 4xx status code +func (o *GetOAuthUserDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get o auth user default response has a 5xx status code +func (o *GetOAuthUserDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get o auth user default response a status code equal to that given +func (o *GetOAuthUserDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get o auth user default response func (o *GetOAuthUserDefault) Code() int { return o._statusCode } func (o *GetOAuthUserDefault) Error() string { - return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUser default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUser default %s", o._statusCode, payload) +} + +func (o *GetOAuthUserDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/{social_type}/oauth][%d] getOAuthUser default %s", o._statusCode, payload) } func (o *GetOAuthUserDefault) GetPayload() *models.ErrorPayload { @@ -164,12 +280,16 @@ func (o *GetOAuthUserDefault) GetPayload() *models.ErrorPayload { func (o *GetOAuthUserDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -181,7 +301,8 @@ func (o *GetOAuthUserDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*GetOAuthUserOKBody get o auth user o k body +/* +GetOAuthUserOKBody get o auth user o k body swagger:model GetOAuthUserOKBody */ type GetOAuthUserOKBody struct { @@ -215,6 +336,39 @@ func (o *GetOAuthUserOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getOAuthUserOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOAuthUserOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get o auth user o k body based on the context it is used +func (o *GetOAuthUserOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetOAuthUserOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getOAuthUserOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getOAuthUserOK" + "." + "data") } return err } diff --git a/client/client/user/get_user_account_parameters.go b/client/client/user/get_user_account_parameters.go index a5459fc8..331ca1fb 100644 --- a/client/client/user/get_user_account_parameters.go +++ b/client/client/user/get_user_account_parameters.go @@ -13,51 +13,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetUserAccountParams creates a new GetUserAccountParams object -// with the default values initialized. +// NewGetUserAccountParams creates a new GetUserAccountParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewGetUserAccountParams() *GetUserAccountParams { - return &GetUserAccountParams{ - timeout: cr.DefaultTimeout, } } // NewGetUserAccountParamsWithTimeout creates a new GetUserAccountParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetUserAccountParamsWithTimeout(timeout time.Duration) *GetUserAccountParams { - return &GetUserAccountParams{ - timeout: timeout, } } // NewGetUserAccountParamsWithContext creates a new GetUserAccountParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetUserAccountParamsWithContext(ctx context.Context) *GetUserAccountParams { - return &GetUserAccountParams{ - Context: ctx, } } // NewGetUserAccountParamsWithHTTPClient creates a new GetUserAccountParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetUserAccountParamsWithHTTPClient(client *http.Client) *GetUserAccountParams { - return &GetUserAccountParams{ HTTPClient: client, } } -/*GetUserAccountParams contains all the parameters to send to the API endpoint -for the get user account operation typically these are written to a http.Request +/* +GetUserAccountParams contains all the parameters to send to the API endpoint + + for the get user account operation. + + Typically these are written to a http.Request. */ type GetUserAccountParams struct { timeout time.Duration @@ -65,6 +65,21 @@ type GetUserAccountParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get user account params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetUserAccountParams) WithDefaults() *GetUserAccountParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get user account params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetUserAccountParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get user account params func (o *GetUserAccountParams) WithTimeout(timeout time.Duration) *GetUserAccountParams { o.SetTimeout(timeout) diff --git a/client/client/user/get_user_account_responses.go b/client/client/user/get_user_account_responses.go index 99e547bf..b7a9a4f9 100644 --- a/client/client/user/get_user_account_responses.go +++ b/client/client/user/get_user_account_responses.go @@ -6,17 +6,18 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // GetUserAccountReader is a Reader for the GetUserAccount structure. @@ -50,7 +51,8 @@ func NewGetUserAccountOK() *GetUserAccountOK { return &GetUserAccountOK{} } -/*GetUserAccountOK handles this case with default header values. +/* +GetUserAccountOK describes a response with status code 200, with default header values. The user account information. */ @@ -58,8 +60,44 @@ type GetUserAccountOK struct { Payload *GetUserAccountOKBody } +// IsSuccess returns true when this get user account o k response has a 2xx status code +func (o *GetUserAccountOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get user account o k response has a 3xx status code +func (o *GetUserAccountOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get user account o k response has a 4xx status code +func (o *GetUserAccountOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get user account o k response has a 5xx status code +func (o *GetUserAccountOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get user account o k response a status code equal to that given +func (o *GetUserAccountOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get user account o k response +func (o *GetUserAccountOK) Code() int { + return 200 +} + func (o *GetUserAccountOK) Error() string { - return fmt.Sprintf("[GET /user][%d] getUserAccountOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user][%d] getUserAccountOK %s", 200, payload) +} + +func (o *GetUserAccountOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user][%d] getUserAccountOK %s", 200, payload) } func (o *GetUserAccountOK) GetPayload() *GetUserAccountOKBody { @@ -85,27 +123,61 @@ func NewGetUserAccountDefault(code int) *GetUserAccountDefault { } } -/*GetUserAccountDefault handles this case with default header values. +/* +GetUserAccountDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type GetUserAccountDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this get user account default response has a 2xx status code +func (o *GetUserAccountDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get user account default response has a 3xx status code +func (o *GetUserAccountDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get user account default response has a 4xx status code +func (o *GetUserAccountDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get user account default response has a 5xx status code +func (o *GetUserAccountDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get user account default response a status code equal to that given +func (o *GetUserAccountDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get user account default response func (o *GetUserAccountDefault) Code() int { return o._statusCode } func (o *GetUserAccountDefault) Error() string { - return fmt.Sprintf("[GET /user][%d] getUserAccount default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user][%d] getUserAccount default %s", o._statusCode, payload) +} + +func (o *GetUserAccountDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user][%d] getUserAccount default %s", o._statusCode, payload) } func (o *GetUserAccountDefault) GetPayload() *models.ErrorPayload { @@ -114,12 +186,16 @@ func (o *GetUserAccountDefault) GetPayload() *models.ErrorPayload { func (o *GetUserAccountDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -131,7 +207,8 @@ func (o *GetUserAccountDefault) readResponse(response runtime.ClientResponse, co return nil } -/*GetUserAccountOKBody get user account o k body +/* +GetUserAccountOKBody get user account o k body swagger:model GetUserAccountOKBody */ type GetUserAccountOKBody struct { @@ -165,6 +242,39 @@ func (o *GetUserAccountOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getUserAccountOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getUserAccountOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this get user account o k body based on the context it is used +func (o *GetUserAccountOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetUserAccountOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getUserAccountOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getUserAccountOK" + "." + "data") } return err } diff --git a/client/client/user/handle_a_w_s_marketplace_user_entitlement_parameters.go b/client/client/user/handle_a_w_s_marketplace_user_entitlement_parameters.go index f8fc3285..d32cf0eb 100644 --- a/client/client/user/handle_a_w_s_marketplace_user_entitlement_parameters.go +++ b/client/client/user/handle_a_w_s_marketplace_user_entitlement_parameters.go @@ -13,51 +13,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewHandleAWSMarketplaceUserEntitlementParams creates a new HandleAWSMarketplaceUserEntitlementParams object -// with the default values initialized. +// NewHandleAWSMarketplaceUserEntitlementParams creates a new HandleAWSMarketplaceUserEntitlementParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewHandleAWSMarketplaceUserEntitlementParams() *HandleAWSMarketplaceUserEntitlementParams { - return &HandleAWSMarketplaceUserEntitlementParams{ - timeout: cr.DefaultTimeout, } } // NewHandleAWSMarketplaceUserEntitlementParamsWithTimeout creates a new HandleAWSMarketplaceUserEntitlementParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewHandleAWSMarketplaceUserEntitlementParamsWithTimeout(timeout time.Duration) *HandleAWSMarketplaceUserEntitlementParams { - return &HandleAWSMarketplaceUserEntitlementParams{ - timeout: timeout, } } // NewHandleAWSMarketplaceUserEntitlementParamsWithContext creates a new HandleAWSMarketplaceUserEntitlementParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewHandleAWSMarketplaceUserEntitlementParamsWithContext(ctx context.Context) *HandleAWSMarketplaceUserEntitlementParams { - return &HandleAWSMarketplaceUserEntitlementParams{ - Context: ctx, } } // NewHandleAWSMarketplaceUserEntitlementParamsWithHTTPClient creates a new HandleAWSMarketplaceUserEntitlementParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewHandleAWSMarketplaceUserEntitlementParamsWithHTTPClient(client *http.Client) *HandleAWSMarketplaceUserEntitlementParams { - return &HandleAWSMarketplaceUserEntitlementParams{ HTTPClient: client, } } -/*HandleAWSMarketplaceUserEntitlementParams contains all the parameters to send to the API endpoint -for the handle a w s marketplace user entitlement operation typically these are written to a http.Request +/* +HandleAWSMarketplaceUserEntitlementParams contains all the parameters to send to the API endpoint + + for the handle a w s marketplace user entitlement operation. + + Typically these are written to a http.Request. */ type HandleAWSMarketplaceUserEntitlementParams struct { timeout time.Duration @@ -65,6 +65,21 @@ type HandleAWSMarketplaceUserEntitlementParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the handle a w s marketplace user entitlement params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *HandleAWSMarketplaceUserEntitlementParams) WithDefaults() *HandleAWSMarketplaceUserEntitlementParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the handle a w s marketplace user entitlement params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *HandleAWSMarketplaceUserEntitlementParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the handle a w s marketplace user entitlement params func (o *HandleAWSMarketplaceUserEntitlementParams) WithTimeout(timeout time.Duration) *HandleAWSMarketplaceUserEntitlementParams { o.SetTimeout(timeout) diff --git a/client/client/user/handle_a_w_s_marketplace_user_entitlement_responses.go b/client/client/user/handle_a_w_s_marketplace_user_entitlement_responses.go index 08945f0f..99b9df28 100644 --- a/client/client/user/handle_a_w_s_marketplace_user_entitlement_responses.go +++ b/client/client/user/handle_a_w_s_marketplace_user_entitlement_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // HandleAWSMarketplaceUserEntitlementReader is a Reader for the HandleAWSMarketplaceUserEntitlement structure. @@ -49,7 +49,8 @@ func NewHandleAWSMarketplaceUserEntitlementMovedPermanently() *HandleAWSMarketpl return &HandleAWSMarketplaceUserEntitlementMovedPermanently{} } -/*HandleAWSMarketplaceUserEntitlementMovedPermanently handles this case with default header values. +/* +HandleAWSMarketplaceUserEntitlementMovedPermanently describes a response with status code 301, with default header values. The user is redirected based on his account state. */ @@ -57,14 +58,52 @@ type HandleAWSMarketplaceUserEntitlementMovedPermanently struct { Location string } +// IsSuccess returns true when this handle a w s marketplace user entitlement moved permanently response has a 2xx status code +func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this handle a w s marketplace user entitlement moved permanently response has a 3xx status code +func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) IsRedirect() bool { + return true +} + +// IsClientError returns true when this handle a w s marketplace user entitlement moved permanently response has a 4xx status code +func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) IsClientError() bool { + return false +} + +// IsServerError returns true when this handle a w s marketplace user entitlement moved permanently response has a 5xx status code +func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) IsServerError() bool { + return false +} + +// IsCode returns true when this handle a w s marketplace user entitlement moved permanently response a status code equal to that given +func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) IsCode(code int) bool { + return code == 301 +} + +// Code gets the status code for the handle a w s marketplace user entitlement moved permanently response +func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) Code() int { + return 301 +} + func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) Error() string { - return fmt.Sprintf("[POST /user/aws_marketplace/entitlement][%d] handleAWSMarketplaceUserEntitlementMovedPermanently ", 301) + return fmt.Sprintf("[POST /user/aws_marketplace/entitlement][%d] handleAWSMarketplaceUserEntitlementMovedPermanently", 301) +} + +func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) String() string { + return fmt.Sprintf("[POST /user/aws_marketplace/entitlement][%d] handleAWSMarketplaceUserEntitlementMovedPermanently", 301) } func (o *HandleAWSMarketplaceUserEntitlementMovedPermanently) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Location - o.Location = response.GetHeader("Location") + // hydrates response header Location + hdrLocation := response.GetHeader("Location") + + if hdrLocation != "" { + o.Location = hdrLocation + } return nil } @@ -76,27 +115,61 @@ func NewHandleAWSMarketplaceUserEntitlementDefault(code int) *HandleAWSMarketpla } } -/*HandleAWSMarketplaceUserEntitlementDefault handles this case with default header values. +/* +HandleAWSMarketplaceUserEntitlementDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type HandleAWSMarketplaceUserEntitlementDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this handle a w s marketplace user entitlement default response has a 2xx status code +func (o *HandleAWSMarketplaceUserEntitlementDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this handle a w s marketplace user entitlement default response has a 3xx status code +func (o *HandleAWSMarketplaceUserEntitlementDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this handle a w s marketplace user entitlement default response has a 4xx status code +func (o *HandleAWSMarketplaceUserEntitlementDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this handle a w s marketplace user entitlement default response has a 5xx status code +func (o *HandleAWSMarketplaceUserEntitlementDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this handle a w s marketplace user entitlement default response a status code equal to that given +func (o *HandleAWSMarketplaceUserEntitlementDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the handle a w s marketplace user entitlement default response func (o *HandleAWSMarketplaceUserEntitlementDefault) Code() int { return o._statusCode } func (o *HandleAWSMarketplaceUserEntitlementDefault) Error() string { - return fmt.Sprintf("[POST /user/aws_marketplace/entitlement][%d] handleAWSMarketplaceUserEntitlement default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/aws_marketplace/entitlement][%d] handleAWSMarketplaceUserEntitlement default %s", o._statusCode, payload) +} + +func (o *HandleAWSMarketplaceUserEntitlementDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/aws_marketplace/entitlement][%d] handleAWSMarketplaceUserEntitlement default %s", o._statusCode, payload) } func (o *HandleAWSMarketplaceUserEntitlementDefault) GetPayload() *models.ErrorPayload { @@ -105,12 +178,16 @@ func (o *HandleAWSMarketplaceUserEntitlementDefault) GetPayload() *models.ErrorP func (o *HandleAWSMarketplaceUserEntitlementDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/login_parameters.go b/client/client/user/login_parameters.go index afbb8c71..89d07684 100644 --- a/client/client/user/login_parameters.go +++ b/client/client/user/login_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewLoginParams creates a new LoginParams object -// with the default values initialized. +// NewLoginParams creates a new LoginParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewLoginParams() *LoginParams { - var () return &LoginParams{ - timeout: cr.DefaultTimeout, } } // NewLoginParamsWithTimeout creates a new LoginParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewLoginParamsWithTimeout(timeout time.Duration) *LoginParams { - var () return &LoginParams{ - timeout: timeout, } } // NewLoginParamsWithContext creates a new LoginParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewLoginParamsWithContext(ctx context.Context) *LoginParams { - var () return &LoginParams{ - Context: ctx, } } // NewLoginParamsWithHTTPClient creates a new LoginParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewLoginParamsWithHTTPClient(client *http.Client) *LoginParams { - var () return &LoginParams{ HTTPClient: client, } } -/*LoginParams contains all the parameters to send to the API endpoint -for the login operation typically these are written to a http.Request +/* +LoginParams contains all the parameters to send to the API endpoint + + for the login operation. + + Typically these are written to a http.Request. */ type LoginParams struct { - /*Body - The user content + /* Body. + The user content */ Body *models.UserLogin @@ -74,6 +74,21 @@ type LoginParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the login params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *LoginParams) WithDefaults() *LoginParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the login params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *LoginParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the login params func (o *LoginParams) WithTimeout(timeout time.Duration) *LoginParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *LoginParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registr return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/login_responses.go b/client/client/user/login_responses.go index 9df6fe2e..533efa58 100644 --- a/client/client/user/login_responses.go +++ b/client/client/user/login_responses.go @@ -6,17 +6,18 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // LoginReader is a Reader for the Login structure. @@ -62,7 +63,8 @@ func NewLoginOK() *LoginOK { return &LoginOK{} } -/*LoginOK handles this case with default header values. +/* +LoginOK describes a response with status code 200, with default header values. The token which represents the session of the user. */ @@ -70,8 +72,44 @@ type LoginOK struct { Payload *LoginOKBody } +// IsSuccess returns true when this login o k response has a 2xx status code +func (o *LoginOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this login o k response has a 3xx status code +func (o *LoginOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this login o k response has a 4xx status code +func (o *LoginOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this login o k response has a 5xx status code +func (o *LoginOK) IsServerError() bool { + return false +} + +// IsCode returns true when this login o k response a status code equal to that given +func (o *LoginOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the login o k response +func (o *LoginOK) Code() int { + return 200 +} + func (o *LoginOK) Error() string { - return fmt.Sprintf("[POST /user/login][%d] loginOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/login][%d] loginOK %s", 200, payload) +} + +func (o *LoginOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/login][%d] loginOK %s", 200, payload) } func (o *LoginOK) GetPayload() *LoginOKBody { @@ -95,20 +133,60 @@ func NewLoginUnauthorized() *LoginUnauthorized { return &LoginUnauthorized{} } -/*LoginUnauthorized handles this case with default header values. +/* +LoginUnauthorized describes a response with status code 401, with default header values. The user cannot be authenticated with the credentials which she/he has used. */ type LoginUnauthorized struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this login unauthorized response has a 2xx status code +func (o *LoginUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this login unauthorized response has a 3xx status code +func (o *LoginUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this login unauthorized response has a 4xx status code +func (o *LoginUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this login unauthorized response has a 5xx status code +func (o *LoginUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this login unauthorized response a status code equal to that given +func (o *LoginUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the login unauthorized response +func (o *LoginUnauthorized) Code() int { + return 401 +} + func (o *LoginUnauthorized) Error() string { - return fmt.Sprintf("[POST /user/login][%d] loginUnauthorized %+v", 401, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/login][%d] loginUnauthorized %s", 401, payload) +} + +func (o *LoginUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/login][%d] loginUnauthorized %s", 401, payload) } func (o *LoginUnauthorized) GetPayload() *models.ErrorPayload { @@ -117,12 +195,16 @@ func (o *LoginUnauthorized) GetPayload() *models.ErrorPayload { func (o *LoginUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -139,20 +221,60 @@ func NewLoginUnprocessableEntity() *LoginUnprocessableEntity { return &LoginUnprocessableEntity{} } -/*LoginUnprocessableEntity handles this case with default header values. +/* +LoginUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type LoginUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this login unprocessable entity response has a 2xx status code +func (o *LoginUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this login unprocessable entity response has a 3xx status code +func (o *LoginUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this login unprocessable entity response has a 4xx status code +func (o *LoginUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this login unprocessable entity response has a 5xx status code +func (o *LoginUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this login unprocessable entity response a status code equal to that given +func (o *LoginUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the login unprocessable entity response +func (o *LoginUnprocessableEntity) Code() int { + return 422 +} + func (o *LoginUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /user/login][%d] loginUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/login][%d] loginUnprocessableEntity %s", 422, payload) +} + +func (o *LoginUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/login][%d] loginUnprocessableEntity %s", 422, payload) } func (o *LoginUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -161,12 +283,16 @@ func (o *LoginUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *LoginUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -185,27 +311,61 @@ func NewLoginDefault(code int) *LoginDefault { } } -/*LoginDefault handles this case with default header values. +/* +LoginDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type LoginDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this login default response has a 2xx status code +func (o *LoginDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this login default response has a 3xx status code +func (o *LoginDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this login default response has a 4xx status code +func (o *LoginDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this login default response has a 5xx status code +func (o *LoginDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this login default response a status code equal to that given +func (o *LoginDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the login default response func (o *LoginDefault) Code() int { return o._statusCode } func (o *LoginDefault) Error() string { - return fmt.Sprintf("[POST /user/login][%d] login default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/login][%d] login default %s", o._statusCode, payload) +} + +func (o *LoginDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/login][%d] login default %s", o._statusCode, payload) } func (o *LoginDefault) GetPayload() *models.ErrorPayload { @@ -214,12 +374,16 @@ func (o *LoginDefault) GetPayload() *models.ErrorPayload { func (o *LoginDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -231,7 +395,8 @@ func (o *LoginDefault) readResponse(response runtime.ClientResponse, consumer ru return nil } -/*LoginOKBody login o k body +/* +LoginOKBody login o k body swagger:model LoginOKBody */ type LoginOKBody struct { @@ -265,6 +430,39 @@ func (o *LoginOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("loginOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("loginOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this login o k body based on the context it is used +func (o *LoginOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *LoginOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("loginOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("loginOK" + "." + "data") } return err } diff --git a/client/client/user/password_reset_req_parameters.go b/client/client/user/password_reset_req_parameters.go index 418ee4ae..b5ab04d6 100644 --- a/client/client/user/password_reset_req_parameters.go +++ b/client/client/user/password_reset_req_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewPasswordResetReqParams creates a new PasswordResetReqParams object -// with the default values initialized. +// NewPasswordResetReqParams creates a new PasswordResetReqParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewPasswordResetReqParams() *PasswordResetReqParams { - var () return &PasswordResetReqParams{ - timeout: cr.DefaultTimeout, } } // NewPasswordResetReqParamsWithTimeout creates a new PasswordResetReqParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPasswordResetReqParamsWithTimeout(timeout time.Duration) *PasswordResetReqParams { - var () return &PasswordResetReqParams{ - timeout: timeout, } } // NewPasswordResetReqParamsWithContext creates a new PasswordResetReqParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPasswordResetReqParamsWithContext(ctx context.Context) *PasswordResetReqParams { - var () return &PasswordResetReqParams{ - Context: ctx, } } // NewPasswordResetReqParamsWithHTTPClient creates a new PasswordResetReqParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPasswordResetReqParamsWithHTTPClient(client *http.Client) *PasswordResetReqParams { - var () return &PasswordResetReqParams{ HTTPClient: client, } } -/*PasswordResetReqParams contains all the parameters to send to the API endpoint -for the password reset req operation typically these are written to a http.Request +/* +PasswordResetReqParams contains all the parameters to send to the API endpoint + + for the password reset req operation. + + Typically these are written to a http.Request. */ type PasswordResetReqParams struct { - /*Body - The reset password payload + /* Body. + The reset password payload */ Body *models.UserPasswordResetReq @@ -74,6 +74,21 @@ type PasswordResetReqParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the password reset req params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PasswordResetReqParams) WithDefaults() *PasswordResetReqParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the password reset req params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PasswordResetReqParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the password reset req params func (o *PasswordResetReqParams) WithTimeout(timeout time.Duration) *PasswordResetReqParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *PasswordResetReqParams) WriteToRequest(r runtime.ClientRequest, reg str return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/password_reset_req_responses.go b/client/client/user/password_reset_req_responses.go index 1f9c28b1..ad205cb1 100644 --- a/client/client/user/password_reset_req_responses.go +++ b/client/client/user/password_reset_req_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // PasswordResetReqReader is a Reader for the PasswordResetReq structure. @@ -55,15 +55,50 @@ func NewPasswordResetReqNoContent() *PasswordResetReqNoContent { return &PasswordResetReqNoContent{} } -/*PasswordResetReqNoContent handles this case with default header values. +/* +PasswordResetReqNoContent describes a response with status code 204, with default header values. The password has been changed. */ type PasswordResetReqNoContent struct { } +// IsSuccess returns true when this password reset req no content response has a 2xx status code +func (o *PasswordResetReqNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this password reset req no content response has a 3xx status code +func (o *PasswordResetReqNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this password reset req no content response has a 4xx status code +func (o *PasswordResetReqNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this password reset req no content response has a 5xx status code +func (o *PasswordResetReqNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this password reset req no content response a status code equal to that given +func (o *PasswordResetReqNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the password reset req no content response +func (o *PasswordResetReqNoContent) Code() int { + return 204 +} + func (o *PasswordResetReqNoContent) Error() string { - return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReqNoContent ", 204) + return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReqNoContent", 204) +} + +func (o *PasswordResetReqNoContent) String() string { + return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReqNoContent", 204) } func (o *PasswordResetReqNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -76,20 +111,60 @@ func NewPasswordResetReqUnprocessableEntity() *PasswordResetReqUnprocessableEnti return &PasswordResetReqUnprocessableEntity{} } -/*PasswordResetReqUnprocessableEntity handles this case with default header values. +/* +PasswordResetReqUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type PasswordResetReqUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this password reset req unprocessable entity response has a 2xx status code +func (o *PasswordResetReqUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this password reset req unprocessable entity response has a 3xx status code +func (o *PasswordResetReqUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this password reset req unprocessable entity response has a 4xx status code +func (o *PasswordResetReqUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this password reset req unprocessable entity response has a 5xx status code +func (o *PasswordResetReqUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this password reset req unprocessable entity response a status code equal to that given +func (o *PasswordResetReqUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the password reset req unprocessable entity response +func (o *PasswordResetReqUnprocessableEntity) Code() int { + return 422 +} + func (o *PasswordResetReqUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReqUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReqUnprocessableEntity %s", 422, payload) +} + +func (o *PasswordResetReqUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReqUnprocessableEntity %s", 422, payload) } func (o *PasswordResetReqUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -98,12 +173,16 @@ func (o *PasswordResetReqUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *PasswordResetReqUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -122,27 +201,61 @@ func NewPasswordResetReqDefault(code int) *PasswordResetReqDefault { } } -/*PasswordResetReqDefault handles this case with default header values. +/* +PasswordResetReqDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type PasswordResetReqDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this password reset req default response has a 2xx status code +func (o *PasswordResetReqDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this password reset req default response has a 3xx status code +func (o *PasswordResetReqDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this password reset req default response has a 4xx status code +func (o *PasswordResetReqDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this password reset req default response has a 5xx status code +func (o *PasswordResetReqDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this password reset req default response a status code equal to that given +func (o *PasswordResetReqDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the password reset req default response func (o *PasswordResetReqDefault) Code() int { return o._statusCode } func (o *PasswordResetReqDefault) Error() string { - return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReq default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReq default %s", o._statusCode, payload) +} + +func (o *PasswordResetReqDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/reset_password][%d] passwordResetReq default %s", o._statusCode, payload) } func (o *PasswordResetReqDefault) GetPayload() *models.ErrorPayload { @@ -151,12 +264,16 @@ func (o *PasswordResetReqDefault) GetPayload() *models.ErrorPayload { func (o *PasswordResetReqDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/password_reset_update_parameters.go b/client/client/user/password_reset_update_parameters.go index c06eaee0..702eac7b 100644 --- a/client/client/user/password_reset_update_parameters.go +++ b/client/client/user/password_reset_update_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewPasswordResetUpdateParams creates a new PasswordResetUpdateParams object -// with the default values initialized. +// NewPasswordResetUpdateParams creates a new PasswordResetUpdateParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewPasswordResetUpdateParams() *PasswordResetUpdateParams { - var () return &PasswordResetUpdateParams{ - timeout: cr.DefaultTimeout, } } // NewPasswordResetUpdateParamsWithTimeout creates a new PasswordResetUpdateParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPasswordResetUpdateParamsWithTimeout(timeout time.Duration) *PasswordResetUpdateParams { - var () return &PasswordResetUpdateParams{ - timeout: timeout, } } // NewPasswordResetUpdateParamsWithContext creates a new PasswordResetUpdateParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPasswordResetUpdateParamsWithContext(ctx context.Context) *PasswordResetUpdateParams { - var () return &PasswordResetUpdateParams{ - Context: ctx, } } // NewPasswordResetUpdateParamsWithHTTPClient creates a new PasswordResetUpdateParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPasswordResetUpdateParamsWithHTTPClient(client *http.Client) *PasswordResetUpdateParams { - var () return &PasswordResetUpdateParams{ HTTPClient: client, } } -/*PasswordResetUpdateParams contains all the parameters to send to the API endpoint -for the password reset update operation typically these are written to a http.Request +/* +PasswordResetUpdateParams contains all the parameters to send to the API endpoint + + for the password reset update operation. + + Typically these are written to a http.Request. */ type PasswordResetUpdateParams struct { - /*Body - The reset password payload + /* Body. + The reset password payload */ Body *models.UserPasswordResetUpdate @@ -74,6 +74,21 @@ type PasswordResetUpdateParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the password reset update params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PasswordResetUpdateParams) WithDefaults() *PasswordResetUpdateParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the password reset update params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PasswordResetUpdateParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the password reset update params func (o *PasswordResetUpdateParams) WithTimeout(timeout time.Duration) *PasswordResetUpdateParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *PasswordResetUpdateParams) WriteToRequest(r runtime.ClientRequest, reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/password_reset_update_responses.go b/client/client/user/password_reset_update_responses.go index f6059c62..a0c99848 100644 --- a/client/client/user/password_reset_update_responses.go +++ b/client/client/user/password_reset_update_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // PasswordResetUpdateReader is a Reader for the PasswordResetUpdate structure. @@ -61,15 +61,50 @@ func NewPasswordResetUpdateNoContent() *PasswordResetUpdateNoContent { return &PasswordResetUpdateNoContent{} } -/*PasswordResetUpdateNoContent handles this case with default header values. +/* +PasswordResetUpdateNoContent describes a response with status code 204, with default header values. The password has been changed. */ type PasswordResetUpdateNoContent struct { } +// IsSuccess returns true when this password reset update no content response has a 2xx status code +func (o *PasswordResetUpdateNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this password reset update no content response has a 3xx status code +func (o *PasswordResetUpdateNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this password reset update no content response has a 4xx status code +func (o *PasswordResetUpdateNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this password reset update no content response has a 5xx status code +func (o *PasswordResetUpdateNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this password reset update no content response a status code equal to that given +func (o *PasswordResetUpdateNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the password reset update no content response +func (o *PasswordResetUpdateNoContent) Code() int { + return 204 +} + func (o *PasswordResetUpdateNoContent) Error() string { - return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateNoContent ", 204) + return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateNoContent", 204) +} + +func (o *PasswordResetUpdateNoContent) String() string { + return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateNoContent", 204) } func (o *PasswordResetUpdateNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewPasswordResetUpdateNotFound() *PasswordResetUpdateNotFound { return &PasswordResetUpdateNotFound{} } -/*PasswordResetUpdateNotFound handles this case with default header values. +/* +PasswordResetUpdateNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type PasswordResetUpdateNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this password reset update not found response has a 2xx status code +func (o *PasswordResetUpdateNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this password reset update not found response has a 3xx status code +func (o *PasswordResetUpdateNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this password reset update not found response has a 4xx status code +func (o *PasswordResetUpdateNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this password reset update not found response has a 5xx status code +func (o *PasswordResetUpdateNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this password reset update not found response a status code equal to that given +func (o *PasswordResetUpdateNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the password reset update not found response +func (o *PasswordResetUpdateNotFound) Code() int { + return 404 +} + func (o *PasswordResetUpdateNotFound) Error() string { - return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateNotFound %s", 404, payload) +} + +func (o *PasswordResetUpdateNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateNotFound %s", 404, payload) } func (o *PasswordResetUpdateNotFound) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *PasswordResetUpdateNotFound) GetPayload() *models.ErrorPayload { func (o *PasswordResetUpdateNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewPasswordResetUpdateUnprocessableEntity() *PasswordResetUpdateUnprocessab return &PasswordResetUpdateUnprocessableEntity{} } -/*PasswordResetUpdateUnprocessableEntity handles this case with default header values. +/* +PasswordResetUpdateUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type PasswordResetUpdateUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this password reset update unprocessable entity response has a 2xx status code +func (o *PasswordResetUpdateUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this password reset update unprocessable entity response has a 3xx status code +func (o *PasswordResetUpdateUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this password reset update unprocessable entity response has a 4xx status code +func (o *PasswordResetUpdateUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this password reset update unprocessable entity response has a 5xx status code +func (o *PasswordResetUpdateUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this password reset update unprocessable entity response a status code equal to that given +func (o *PasswordResetUpdateUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the password reset update unprocessable entity response +func (o *PasswordResetUpdateUnprocessableEntity) Code() int { + return 422 +} + func (o *PasswordResetUpdateUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateUnprocessableEntity %s", 422, payload) +} + +func (o *PasswordResetUpdateUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdateUnprocessableEntity %s", 422, payload) } func (o *PasswordResetUpdateUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *PasswordResetUpdateUnprocessableEntity) GetPayload() *models.ErrorPaylo func (o *PasswordResetUpdateUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewPasswordResetUpdateDefault(code int) *PasswordResetUpdateDefault { } } -/*PasswordResetUpdateDefault handles this case with default header values. +/* +PasswordResetUpdateDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type PasswordResetUpdateDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this password reset update default response has a 2xx status code +func (o *PasswordResetUpdateDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this password reset update default response has a 3xx status code +func (o *PasswordResetUpdateDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this password reset update default response has a 4xx status code +func (o *PasswordResetUpdateDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this password reset update default response has a 5xx status code +func (o *PasswordResetUpdateDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this password reset update default response a status code equal to that given +func (o *PasswordResetUpdateDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the password reset update default response func (o *PasswordResetUpdateDefault) Code() int { return o._statusCode } func (o *PasswordResetUpdateDefault) Error() string { - return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdate default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdate default %s", o._statusCode, payload) +} + +func (o *PasswordResetUpdateDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/reset_password][%d] passwordResetUpdate default %s", o._statusCode, payload) } func (o *PasswordResetUpdateDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *PasswordResetUpdateDefault) GetPayload() *models.ErrorPayload { func (o *PasswordResetUpdateDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/refresh_token_parameters.go b/client/client/user/refresh_token_parameters.go index 902b0024..e83053d8 100644 --- a/client/client/user/refresh_token_parameters.go +++ b/client/client/user/refresh_token_parameters.go @@ -13,62 +13,63 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewRefreshTokenParams creates a new RefreshTokenParams object -// with the default values initialized. +// NewRefreshTokenParams creates a new RefreshTokenParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewRefreshTokenParams() *RefreshTokenParams { - var () return &RefreshTokenParams{ - timeout: cr.DefaultTimeout, } } // NewRefreshTokenParamsWithTimeout creates a new RefreshTokenParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewRefreshTokenParamsWithTimeout(timeout time.Duration) *RefreshTokenParams { - var () return &RefreshTokenParams{ - timeout: timeout, } } // NewRefreshTokenParamsWithContext creates a new RefreshTokenParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewRefreshTokenParamsWithContext(ctx context.Context) *RefreshTokenParams { - var () return &RefreshTokenParams{ - Context: ctx, } } // NewRefreshTokenParamsWithHTTPClient creates a new RefreshTokenParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewRefreshTokenParamsWithHTTPClient(client *http.Client) *RefreshTokenParams { - var () return &RefreshTokenParams{ HTTPClient: client, } } -/*RefreshTokenParams contains all the parameters to send to the API endpoint -for the refresh token operation typically these are written to a http.Request +/* +RefreshTokenParams contains all the parameters to send to the API endpoint + + for the refresh token operation. + + Typically these are written to a http.Request. */ type RefreshTokenParams struct { - /*ChildCanonical - A canonical of a child organization used for filtering. + /* ChildCanonical. + A canonical of a child organization used for filtering. */ ChildCanonical *string - /*OrganizationCanonical - A canonical of a organization used for filtering. + /* OrganizationCanonical. + + A canonical of a organization used for filtering. */ OrganizationCanonical *string @@ -77,6 +78,21 @@ type RefreshTokenParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the refresh token params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RefreshTokenParams) WithDefaults() *RefreshTokenParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the refresh token params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RefreshTokenParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the refresh token params func (o *RefreshTokenParams) WithTimeout(timeout time.Duration) *RefreshTokenParams { o.SetTimeout(timeout) @@ -144,32 +160,34 @@ func (o *RefreshTokenParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. // query param child_canonical var qrChildCanonical string + if o.ChildCanonical != nil { qrChildCanonical = *o.ChildCanonical } qChildCanonical := qrChildCanonical if qChildCanonical != "" { + if err := r.SetQueryParam("child_canonical", qChildCanonical); err != nil { return err } } - } if o.OrganizationCanonical != nil { // query param organization_canonical var qrOrganizationCanonical string + if o.OrganizationCanonical != nil { qrOrganizationCanonical = *o.OrganizationCanonical } qOrganizationCanonical := qrOrganizationCanonical if qOrganizationCanonical != "" { + if err := r.SetQueryParam("organization_canonical", qOrganizationCanonical); err != nil { return err } } - } if len(res) > 0 { diff --git a/client/client/user/refresh_token_responses.go b/client/client/user/refresh_token_responses.go index da4880f5..8b029c21 100644 --- a/client/client/user/refresh_token_responses.go +++ b/client/client/user/refresh_token_responses.go @@ -6,17 +6,18 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // RefreshTokenReader is a Reader for the RefreshToken structure. @@ -56,7 +57,8 @@ func NewRefreshTokenOK() *RefreshTokenOK { return &RefreshTokenOK{} } -/*RefreshTokenOK handles this case with default header values. +/* +RefreshTokenOK describes a response with status code 200, with default header values. The token which represents the session of the user. */ @@ -64,8 +66,44 @@ type RefreshTokenOK struct { Payload *RefreshTokenOKBody } +// IsSuccess returns true when this refresh token o k response has a 2xx status code +func (o *RefreshTokenOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this refresh token o k response has a 3xx status code +func (o *RefreshTokenOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this refresh token o k response has a 4xx status code +func (o *RefreshTokenOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this refresh token o k response has a 5xx status code +func (o *RefreshTokenOK) IsServerError() bool { + return false +} + +// IsCode returns true when this refresh token o k response a status code equal to that given +func (o *RefreshTokenOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the refresh token o k response +func (o *RefreshTokenOK) Code() int { + return 200 +} + func (o *RefreshTokenOK) Error() string { - return fmt.Sprintf("[GET /user/refresh_token][%d] refreshTokenOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/refresh_token][%d] refreshTokenOK %s", 200, payload) +} + +func (o *RefreshTokenOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/refresh_token][%d] refreshTokenOK %s", 200, payload) } func (o *RefreshTokenOK) GetPayload() *RefreshTokenOKBody { @@ -89,20 +127,60 @@ func NewRefreshTokenUnauthorized() *RefreshTokenUnauthorized { return &RefreshTokenUnauthorized{} } -/*RefreshTokenUnauthorized handles this case with default header values. +/* +RefreshTokenUnauthorized describes a response with status code 401, with default header values. The user cannot be authenticated with the credentials which she/he has used. */ type RefreshTokenUnauthorized struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this refresh token unauthorized response has a 2xx status code +func (o *RefreshTokenUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this refresh token unauthorized response has a 3xx status code +func (o *RefreshTokenUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this refresh token unauthorized response has a 4xx status code +func (o *RefreshTokenUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this refresh token unauthorized response has a 5xx status code +func (o *RefreshTokenUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this refresh token unauthorized response a status code equal to that given +func (o *RefreshTokenUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the refresh token unauthorized response +func (o *RefreshTokenUnauthorized) Code() int { + return 401 +} + func (o *RefreshTokenUnauthorized) Error() string { - return fmt.Sprintf("[GET /user/refresh_token][%d] refreshTokenUnauthorized %+v", 401, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/refresh_token][%d] refreshTokenUnauthorized %s", 401, payload) +} + +func (o *RefreshTokenUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/refresh_token][%d] refreshTokenUnauthorized %s", 401, payload) } func (o *RefreshTokenUnauthorized) GetPayload() *models.ErrorPayload { @@ -111,12 +189,16 @@ func (o *RefreshTokenUnauthorized) GetPayload() *models.ErrorPayload { func (o *RefreshTokenUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -135,27 +217,61 @@ func NewRefreshTokenDefault(code int) *RefreshTokenDefault { } } -/*RefreshTokenDefault handles this case with default header values. +/* +RefreshTokenDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type RefreshTokenDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this refresh token default response has a 2xx status code +func (o *RefreshTokenDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this refresh token default response has a 3xx status code +func (o *RefreshTokenDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this refresh token default response has a 4xx status code +func (o *RefreshTokenDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this refresh token default response has a 5xx status code +func (o *RefreshTokenDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this refresh token default response a status code equal to that given +func (o *RefreshTokenDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the refresh token default response func (o *RefreshTokenDefault) Code() int { return o._statusCode } func (o *RefreshTokenDefault) Error() string { - return fmt.Sprintf("[GET /user/refresh_token][%d] refreshToken default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/refresh_token][%d] refreshToken default %s", o._statusCode, payload) +} + +func (o *RefreshTokenDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /user/refresh_token][%d] refreshToken default %s", o._statusCode, payload) } func (o *RefreshTokenDefault) GetPayload() *models.ErrorPayload { @@ -164,12 +280,16 @@ func (o *RefreshTokenDefault) GetPayload() *models.ErrorPayload { func (o *RefreshTokenDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -181,7 +301,8 @@ func (o *RefreshTokenDefault) readResponse(response runtime.ClientResponse, cons return nil } -/*RefreshTokenOKBody refresh token o k body +/* +RefreshTokenOKBody refresh token o k body swagger:model RefreshTokenOKBody */ type RefreshTokenOKBody struct { @@ -215,6 +336,39 @@ func (o *RefreshTokenOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("refreshTokenOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("refreshTokenOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this refresh token o k body based on the context it is used +func (o *RefreshTokenOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *RefreshTokenOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("refreshTokenOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("refreshTokenOK" + "." + "data") } return err } diff --git a/client/client/user/sign_up_a_w_s_marketplace_parameters.go b/client/client/user/sign_up_a_w_s_marketplace_parameters.go index 92df5572..f29a05f7 100644 --- a/client/client/user/sign_up_a_w_s_marketplace_parameters.go +++ b/client/client/user/sign_up_a_w_s_marketplace_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewSignUpAWSMarketplaceParams creates a new SignUpAWSMarketplaceParams object -// with the default values initialized. +// NewSignUpAWSMarketplaceParams creates a new SignUpAWSMarketplaceParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewSignUpAWSMarketplaceParams() *SignUpAWSMarketplaceParams { - var () return &SignUpAWSMarketplaceParams{ - timeout: cr.DefaultTimeout, } } // NewSignUpAWSMarketplaceParamsWithTimeout creates a new SignUpAWSMarketplaceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewSignUpAWSMarketplaceParamsWithTimeout(timeout time.Duration) *SignUpAWSMarketplaceParams { - var () return &SignUpAWSMarketplaceParams{ - timeout: timeout, } } // NewSignUpAWSMarketplaceParamsWithContext creates a new SignUpAWSMarketplaceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewSignUpAWSMarketplaceParamsWithContext(ctx context.Context) *SignUpAWSMarketplaceParams { - var () return &SignUpAWSMarketplaceParams{ - Context: ctx, } } // NewSignUpAWSMarketplaceParamsWithHTTPClient creates a new SignUpAWSMarketplaceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewSignUpAWSMarketplaceParamsWithHTTPClient(client *http.Client) *SignUpAWSMarketplaceParams { - var () return &SignUpAWSMarketplaceParams{ HTTPClient: client, } } -/*SignUpAWSMarketplaceParams contains all the parameters to send to the API endpoint -for the sign up a w s marketplace operation typically these are written to a http.Request +/* +SignUpAWSMarketplaceParams contains all the parameters to send to the API endpoint + + for the sign up a w s marketplace operation. + + Typically these are written to a http.Request. */ type SignUpAWSMarketplaceParams struct { - /*Body - The user content + /* Body. + The user content */ Body *models.NewAWSMarketplaceUserAccount @@ -74,6 +74,21 @@ type SignUpAWSMarketplaceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the sign up a w s marketplace params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SignUpAWSMarketplaceParams) WithDefaults() *SignUpAWSMarketplaceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the sign up a w s marketplace params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SignUpAWSMarketplaceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the sign up a w s marketplace params func (o *SignUpAWSMarketplaceParams) WithTimeout(timeout time.Duration) *SignUpAWSMarketplaceParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *SignUpAWSMarketplaceParams) WriteToRequest(r runtime.ClientRequest, reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/sign_up_a_w_s_marketplace_responses.go b/client/client/user/sign_up_a_w_s_marketplace_responses.go index 5859183a..1b4b895b 100644 --- a/client/client/user/sign_up_a_w_s_marketplace_responses.go +++ b/client/client/user/sign_up_a_w_s_marketplace_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // SignUpAWSMarketplaceReader is a Reader for the SignUpAWSMarketplace structure. @@ -61,15 +61,50 @@ func NewSignUpAWSMarketplaceNoContent() *SignUpAWSMarketplaceNoContent { return &SignUpAWSMarketplaceNoContent{} } -/*SignUpAWSMarketplaceNoContent handles this case with default header values. +/* +SignUpAWSMarketplaceNoContent describes a response with status code 204, with default header values. Account created. The account MUST be verified through the link sent to the email address. */ type SignUpAWSMarketplaceNoContent struct { } +// IsSuccess returns true when this sign up a w s marketplace no content response has a 2xx status code +func (o *SignUpAWSMarketplaceNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this sign up a w s marketplace no content response has a 3xx status code +func (o *SignUpAWSMarketplaceNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this sign up a w s marketplace no content response has a 4xx status code +func (o *SignUpAWSMarketplaceNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this sign up a w s marketplace no content response has a 5xx status code +func (o *SignUpAWSMarketplaceNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this sign up a w s marketplace no content response a status code equal to that given +func (o *SignUpAWSMarketplaceNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the sign up a w s marketplace no content response +func (o *SignUpAWSMarketplaceNoContent) Code() int { + return 204 +} + func (o *SignUpAWSMarketplaceNoContent) Error() string { - return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceNoContent ", 204) + return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceNoContent", 204) +} + +func (o *SignUpAWSMarketplaceNoContent) String() string { + return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceNoContent", 204) } func (o *SignUpAWSMarketplaceNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,15 +117,50 @@ func NewSignUpAWSMarketplaceLengthRequired() *SignUpAWSMarketplaceLengthRequired return &SignUpAWSMarketplaceLengthRequired{} } -/*SignUpAWSMarketplaceLengthRequired handles this case with default header values. +/* +SignUpAWSMarketplaceLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type SignUpAWSMarketplaceLengthRequired struct { } +// IsSuccess returns true when this sign up a w s marketplace length required response has a 2xx status code +func (o *SignUpAWSMarketplaceLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this sign up a w s marketplace length required response has a 3xx status code +func (o *SignUpAWSMarketplaceLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this sign up a w s marketplace length required response has a 4xx status code +func (o *SignUpAWSMarketplaceLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this sign up a w s marketplace length required response has a 5xx status code +func (o *SignUpAWSMarketplaceLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this sign up a w s marketplace length required response a status code equal to that given +func (o *SignUpAWSMarketplaceLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the sign up a w s marketplace length required response +func (o *SignUpAWSMarketplaceLengthRequired) Code() int { + return 411 +} + func (o *SignUpAWSMarketplaceLengthRequired) Error() string { - return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceLengthRequired ", 411) + return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceLengthRequired", 411) +} + +func (o *SignUpAWSMarketplaceLengthRequired) String() string { + return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceLengthRequired", 411) } func (o *SignUpAWSMarketplaceLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -103,20 +173,60 @@ func NewSignUpAWSMarketplaceUnprocessableEntity() *SignUpAWSMarketplaceUnprocess return &SignUpAWSMarketplaceUnprocessableEntity{} } -/*SignUpAWSMarketplaceUnprocessableEntity handles this case with default header values. +/* +SignUpAWSMarketplaceUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type SignUpAWSMarketplaceUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this sign up a w s marketplace unprocessable entity response has a 2xx status code +func (o *SignUpAWSMarketplaceUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this sign up a w s marketplace unprocessable entity response has a 3xx status code +func (o *SignUpAWSMarketplaceUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this sign up a w s marketplace unprocessable entity response has a 4xx status code +func (o *SignUpAWSMarketplaceUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this sign up a w s marketplace unprocessable entity response has a 5xx status code +func (o *SignUpAWSMarketplaceUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this sign up a w s marketplace unprocessable entity response a status code equal to that given +func (o *SignUpAWSMarketplaceUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the sign up a w s marketplace unprocessable entity response +func (o *SignUpAWSMarketplaceUnprocessableEntity) Code() int { + return 422 +} + func (o *SignUpAWSMarketplaceUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceUnprocessableEntity %s", 422, payload) +} + +func (o *SignUpAWSMarketplaceUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplaceUnprocessableEntity %s", 422, payload) } func (o *SignUpAWSMarketplaceUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -125,12 +235,16 @@ func (o *SignUpAWSMarketplaceUnprocessableEntity) GetPayload() *models.ErrorPayl func (o *SignUpAWSMarketplaceUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -149,27 +263,61 @@ func NewSignUpAWSMarketplaceDefault(code int) *SignUpAWSMarketplaceDefault { } } -/*SignUpAWSMarketplaceDefault handles this case with default header values. +/* +SignUpAWSMarketplaceDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type SignUpAWSMarketplaceDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this sign up a w s marketplace default response has a 2xx status code +func (o *SignUpAWSMarketplaceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this sign up a w s marketplace default response has a 3xx status code +func (o *SignUpAWSMarketplaceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this sign up a w s marketplace default response has a 4xx status code +func (o *SignUpAWSMarketplaceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this sign up a w s marketplace default response has a 5xx status code +func (o *SignUpAWSMarketplaceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this sign up a w s marketplace default response a status code equal to that given +func (o *SignUpAWSMarketplaceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the sign up a w s marketplace default response func (o *SignUpAWSMarketplaceDefault) Code() int { return o._statusCode } func (o *SignUpAWSMarketplaceDefault) Error() string { - return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplace default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplace default %s", o._statusCode, payload) +} + +func (o *SignUpAWSMarketplaceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user/aws_marketplace][%d] signUpAWSMarketplace default %s", o._statusCode, payload) } func (o *SignUpAWSMarketplaceDefault) GetPayload() *models.ErrorPayload { @@ -178,12 +326,16 @@ func (o *SignUpAWSMarketplaceDefault) GetPayload() *models.ErrorPayload { func (o *SignUpAWSMarketplaceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/sign_up_parameters.go b/client/client/user/sign_up_parameters.go index bfc0344c..5fd53f0d 100644 --- a/client/client/user/sign_up_parameters.go +++ b/client/client/user/sign_up_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewSignUpParams creates a new SignUpParams object -// with the default values initialized. +// NewSignUpParams creates a new SignUpParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewSignUpParams() *SignUpParams { - var () return &SignUpParams{ - timeout: cr.DefaultTimeout, } } // NewSignUpParamsWithTimeout creates a new SignUpParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewSignUpParamsWithTimeout(timeout time.Duration) *SignUpParams { - var () return &SignUpParams{ - timeout: timeout, } } // NewSignUpParamsWithContext creates a new SignUpParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewSignUpParamsWithContext(ctx context.Context) *SignUpParams { - var () return &SignUpParams{ - Context: ctx, } } // NewSignUpParamsWithHTTPClient creates a new SignUpParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewSignUpParamsWithHTTPClient(client *http.Client) *SignUpParams { - var () return &SignUpParams{ HTTPClient: client, } } -/*SignUpParams contains all the parameters to send to the API endpoint -for the sign up operation typically these are written to a http.Request +/* +SignUpParams contains all the parameters to send to the API endpoint + + for the sign up operation. + + Typically these are written to a http.Request. */ type SignUpParams struct { - /*Body - The user content + /* Body. + The user content */ Body *models.NewUserAccount @@ -74,6 +74,21 @@ type SignUpParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the sign up params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SignUpParams) WithDefaults() *SignUpParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the sign up params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SignUpParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the sign up params func (o *SignUpParams) WithTimeout(timeout time.Duration) *SignUpParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *SignUpParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regist return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/sign_up_responses.go b/client/client/user/sign_up_responses.go index 7b919f15..8653747e 100644 --- a/client/client/user/sign_up_responses.go +++ b/client/client/user/sign_up_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // SignUpReader is a Reader for the SignUp structure. @@ -61,15 +61,50 @@ func NewSignUpNoContent() *SignUpNoContent { return &SignUpNoContent{} } -/*SignUpNoContent handles this case with default header values. +/* +SignUpNoContent describes a response with status code 204, with default header values. Account created. The account MUST be verified through the link sent to the email address. */ type SignUpNoContent struct { } +// IsSuccess returns true when this sign up no content response has a 2xx status code +func (o *SignUpNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this sign up no content response has a 3xx status code +func (o *SignUpNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this sign up no content response has a 4xx status code +func (o *SignUpNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this sign up no content response has a 5xx status code +func (o *SignUpNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this sign up no content response a status code equal to that given +func (o *SignUpNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the sign up no content response +func (o *SignUpNoContent) Code() int { + return 204 +} + func (o *SignUpNoContent) Error() string { - return fmt.Sprintf("[POST /user][%d] signUpNoContent ", 204) + return fmt.Sprintf("[POST /user][%d] signUpNoContent", 204) +} + +func (o *SignUpNoContent) String() string { + return fmt.Sprintf("[POST /user][%d] signUpNoContent", 204) } func (o *SignUpNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,15 +117,50 @@ func NewSignUpLengthRequired() *SignUpLengthRequired { return &SignUpLengthRequired{} } -/*SignUpLengthRequired handles this case with default header values. +/* +SignUpLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type SignUpLengthRequired struct { } +// IsSuccess returns true when this sign up length required response has a 2xx status code +func (o *SignUpLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this sign up length required response has a 3xx status code +func (o *SignUpLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this sign up length required response has a 4xx status code +func (o *SignUpLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this sign up length required response has a 5xx status code +func (o *SignUpLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this sign up length required response a status code equal to that given +func (o *SignUpLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the sign up length required response +func (o *SignUpLengthRequired) Code() int { + return 411 +} + func (o *SignUpLengthRequired) Error() string { - return fmt.Sprintf("[POST /user][%d] signUpLengthRequired ", 411) + return fmt.Sprintf("[POST /user][%d] signUpLengthRequired", 411) +} + +func (o *SignUpLengthRequired) String() string { + return fmt.Sprintf("[POST /user][%d] signUpLengthRequired", 411) } func (o *SignUpLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -103,20 +173,60 @@ func NewSignUpUnprocessableEntity() *SignUpUnprocessableEntity { return &SignUpUnprocessableEntity{} } -/*SignUpUnprocessableEntity handles this case with default header values. +/* +SignUpUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type SignUpUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this sign up unprocessable entity response has a 2xx status code +func (o *SignUpUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this sign up unprocessable entity response has a 3xx status code +func (o *SignUpUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this sign up unprocessable entity response has a 4xx status code +func (o *SignUpUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this sign up unprocessable entity response has a 5xx status code +func (o *SignUpUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this sign up unprocessable entity response a status code equal to that given +func (o *SignUpUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the sign up unprocessable entity response +func (o *SignUpUnprocessableEntity) Code() int { + return 422 +} + func (o *SignUpUnprocessableEntity) Error() string { - return fmt.Sprintf("[POST /user][%d] signUpUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user][%d] signUpUnprocessableEntity %s", 422, payload) +} + +func (o *SignUpUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user][%d] signUpUnprocessableEntity %s", 422, payload) } func (o *SignUpUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -125,12 +235,16 @@ func (o *SignUpUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *SignUpUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -149,27 +263,61 @@ func NewSignUpDefault(code int) *SignUpDefault { } } -/*SignUpDefault handles this case with default header values. +/* +SignUpDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type SignUpDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this sign up default response has a 2xx status code +func (o *SignUpDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this sign up default response has a 3xx status code +func (o *SignUpDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this sign up default response has a 4xx status code +func (o *SignUpDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this sign up default response has a 5xx status code +func (o *SignUpDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this sign up default response a status code equal to that given +func (o *SignUpDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the sign up default response func (o *SignUpDefault) Code() int { return o._statusCode } func (o *SignUpDefault) Error() string { - return fmt.Sprintf("[POST /user][%d] signUp default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user][%d] signUp default %s", o._statusCode, payload) +} + +func (o *SignUpDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /user][%d] signUp default %s", o._statusCode, payload) } func (o *SignUpDefault) GetPayload() *models.ErrorPayload { @@ -178,12 +326,16 @@ func (o *SignUpDefault) GetPayload() *models.ErrorPayload { func (o *SignUpDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/update_user_account_parameters.go b/client/client/user/update_user_account_parameters.go index 12ac7b70..05cca170 100644 --- a/client/client/user/update_user_account_parameters.go +++ b/client/client/user/update_user_account_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateUserAccountParams creates a new UpdateUserAccountParams object -// with the default values initialized. +// NewUpdateUserAccountParams creates a new UpdateUserAccountParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateUserAccountParams() *UpdateUserAccountParams { - var () return &UpdateUserAccountParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateUserAccountParamsWithTimeout creates a new UpdateUserAccountParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateUserAccountParamsWithTimeout(timeout time.Duration) *UpdateUserAccountParams { - var () return &UpdateUserAccountParams{ - timeout: timeout, } } // NewUpdateUserAccountParamsWithContext creates a new UpdateUserAccountParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateUserAccountParamsWithContext(ctx context.Context) *UpdateUserAccountParams { - var () return &UpdateUserAccountParams{ - Context: ctx, } } // NewUpdateUserAccountParamsWithHTTPClient creates a new UpdateUserAccountParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateUserAccountParamsWithHTTPClient(client *http.Client) *UpdateUserAccountParams { - var () return &UpdateUserAccountParams{ HTTPClient: client, } } -/*UpdateUserAccountParams contains all the parameters to send to the API endpoint -for the update user account operation typically these are written to a http.Request +/* +UpdateUserAccountParams contains all the parameters to send to the API endpoint + + for the update user account operation. + + Typically these are written to a http.Request. */ type UpdateUserAccountParams struct { - /*Body - The user content + /* Body. + The user content */ Body *models.UpdateUserAccount @@ -74,6 +74,21 @@ type UpdateUserAccountParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update user account params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateUserAccountParams) WithDefaults() *UpdateUserAccountParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update user account params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateUserAccountParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update user account params func (o *UpdateUserAccountParams) WithTimeout(timeout time.Duration) *UpdateUserAccountParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *UpdateUserAccountParams) WriteToRequest(r runtime.ClientRequest, reg st return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/update_user_account_responses.go b/client/client/user/update_user_account_responses.go index 948f7e45..fe1ddfa7 100644 --- a/client/client/user/update_user_account_responses.go +++ b/client/client/user/update_user_account_responses.go @@ -6,17 +6,18 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateUserAccountReader is a Reader for the UpdateUserAccount structure. @@ -74,7 +75,8 @@ func NewUpdateUserAccountOK() *UpdateUserAccountOK { return &UpdateUserAccountOK{} } -/*UpdateUserAccountOK handles this case with default header values. +/* +UpdateUserAccountOK describes a response with status code 200, with default header values. The updated user profile information. */ @@ -82,8 +84,44 @@ type UpdateUserAccountOK struct { Payload *UpdateUserAccountOKBody } +// IsSuccess returns true when this update user account o k response has a 2xx status code +func (o *UpdateUserAccountOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update user account o k response has a 3xx status code +func (o *UpdateUserAccountOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update user account o k response has a 4xx status code +func (o *UpdateUserAccountOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update user account o k response has a 5xx status code +func (o *UpdateUserAccountOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update user account o k response a status code equal to that given +func (o *UpdateUserAccountOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update user account o k response +func (o *UpdateUserAccountOK) Code() int { + return 200 +} + func (o *UpdateUserAccountOK) Error() string { - return fmt.Sprintf("[PUT /user][%d] updateUserAccountOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user][%d] updateUserAccountOK %s", 200, payload) +} + +func (o *UpdateUserAccountOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user][%d] updateUserAccountOK %s", 200, payload) } func (o *UpdateUserAccountOK) GetPayload() *UpdateUserAccountOKBody { @@ -107,15 +145,50 @@ func NewUpdateUserAccountConflict() *UpdateUserAccountConflict { return &UpdateUserAccountConflict{} } -/*UpdateUserAccountConflict handles this case with default header values. +/* +UpdateUserAccountConflict describes a response with status code 409, with default header values. Trying setting an unverified email as the primary */ type UpdateUserAccountConflict struct { } +// IsSuccess returns true when this update user account conflict response has a 2xx status code +func (o *UpdateUserAccountConflict) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update user account conflict response has a 3xx status code +func (o *UpdateUserAccountConflict) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update user account conflict response has a 4xx status code +func (o *UpdateUserAccountConflict) IsClientError() bool { + return true +} + +// IsServerError returns true when this update user account conflict response has a 5xx status code +func (o *UpdateUserAccountConflict) IsServerError() bool { + return false +} + +// IsCode returns true when this update user account conflict response a status code equal to that given +func (o *UpdateUserAccountConflict) IsCode(code int) bool { + return code == 409 +} + +// Code gets the status code for the update user account conflict response +func (o *UpdateUserAccountConflict) Code() int { + return 409 +} + func (o *UpdateUserAccountConflict) Error() string { - return fmt.Sprintf("[PUT /user][%d] updateUserAccountConflict ", 409) + return fmt.Sprintf("[PUT /user][%d] updateUserAccountConflict", 409) +} + +func (o *UpdateUserAccountConflict) String() string { + return fmt.Sprintf("[PUT /user][%d] updateUserAccountConflict", 409) } func (o *UpdateUserAccountConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -128,15 +201,50 @@ func NewUpdateUserAccountLengthRequired() *UpdateUserAccountLengthRequired { return &UpdateUserAccountLengthRequired{} } -/*UpdateUserAccountLengthRequired handles this case with default header values. +/* +UpdateUserAccountLengthRequired describes a response with status code 411, with default header values. The request has a body but it doesn't have a Content-Length header. */ type UpdateUserAccountLengthRequired struct { } +// IsSuccess returns true when this update user account length required response has a 2xx status code +func (o *UpdateUserAccountLengthRequired) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update user account length required response has a 3xx status code +func (o *UpdateUserAccountLengthRequired) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update user account length required response has a 4xx status code +func (o *UpdateUserAccountLengthRequired) IsClientError() bool { + return true +} + +// IsServerError returns true when this update user account length required response has a 5xx status code +func (o *UpdateUserAccountLengthRequired) IsServerError() bool { + return false +} + +// IsCode returns true when this update user account length required response a status code equal to that given +func (o *UpdateUserAccountLengthRequired) IsCode(code int) bool { + return code == 411 +} + +// Code gets the status code for the update user account length required response +func (o *UpdateUserAccountLengthRequired) Code() int { + return 411 +} + func (o *UpdateUserAccountLengthRequired) Error() string { - return fmt.Sprintf("[PUT /user][%d] updateUserAccountLengthRequired ", 411) + return fmt.Sprintf("[PUT /user][%d] updateUserAccountLengthRequired", 411) +} + +func (o *UpdateUserAccountLengthRequired) String() string { + return fmt.Sprintf("[PUT /user][%d] updateUserAccountLengthRequired", 411) } func (o *UpdateUserAccountLengthRequired) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -149,20 +257,60 @@ func NewUpdateUserAccountUnprocessableEntity() *UpdateUserAccountUnprocessableEn return &UpdateUserAccountUnprocessableEntity{} } -/*UpdateUserAccountUnprocessableEntity handles this case with default header values. +/* +UpdateUserAccountUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateUserAccountUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update user account unprocessable entity response has a 2xx status code +func (o *UpdateUserAccountUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update user account unprocessable entity response has a 3xx status code +func (o *UpdateUserAccountUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update user account unprocessable entity response has a 4xx status code +func (o *UpdateUserAccountUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update user account unprocessable entity response has a 5xx status code +func (o *UpdateUserAccountUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update user account unprocessable entity response a status code equal to that given +func (o *UpdateUserAccountUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update user account unprocessable entity response +func (o *UpdateUserAccountUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateUserAccountUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /user][%d] updateUserAccountUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user][%d] updateUserAccountUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateUserAccountUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user][%d] updateUserAccountUnprocessableEntity %s", 422, payload) } func (o *UpdateUserAccountUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -171,12 +319,16 @@ func (o *UpdateUserAccountUnprocessableEntity) GetPayload() *models.ErrorPayload func (o *UpdateUserAccountUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -193,20 +345,60 @@ func NewUpdateUserAccountServiceUnavailable() *UpdateUserAccountServiceUnavailab return &UpdateUserAccountServiceUnavailable{} } -/*UpdateUserAccountServiceUnavailable handles this case with default header values. +/* +UpdateUserAccountServiceUnavailable describes a response with status code 503, with default header values. The operation couldn't be executed or completed and it should retried. */ type UpdateUserAccountServiceUnavailable struct { - /*The number of seconds to wait until retry the request - */ + + /* The number of seconds to wait until retry the request + + Format: uint16 + */ RetryAfter uint16 Payload *models.ErrorPayload } +// IsSuccess returns true when this update user account service unavailable response has a 2xx status code +func (o *UpdateUserAccountServiceUnavailable) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update user account service unavailable response has a 3xx status code +func (o *UpdateUserAccountServiceUnavailable) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update user account service unavailable response has a 4xx status code +func (o *UpdateUserAccountServiceUnavailable) IsClientError() bool { + return false +} + +// IsServerError returns true when this update user account service unavailable response has a 5xx status code +func (o *UpdateUserAccountServiceUnavailable) IsServerError() bool { + return true +} + +// IsCode returns true when this update user account service unavailable response a status code equal to that given +func (o *UpdateUserAccountServiceUnavailable) IsCode(code int) bool { + return code == 503 +} + +// Code gets the status code for the update user account service unavailable response +func (o *UpdateUserAccountServiceUnavailable) Code() int { + return 503 +} + func (o *UpdateUserAccountServiceUnavailable) Error() string { - return fmt.Sprintf("[PUT /user][%d] updateUserAccountServiceUnavailable %+v", 503, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user][%d] updateUserAccountServiceUnavailable %s", 503, payload) +} + +func (o *UpdateUserAccountServiceUnavailable) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user][%d] updateUserAccountServiceUnavailable %s", 503, payload) } func (o *UpdateUserAccountServiceUnavailable) GetPayload() *models.ErrorPayload { @@ -215,12 +407,16 @@ func (o *UpdateUserAccountServiceUnavailable) GetPayload() *models.ErrorPayload func (o *UpdateUserAccountServiceUnavailable) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Retry-After - retryAfter, err := swag.ConvertUint16(response.GetHeader("Retry-After")) - if err != nil { - return errors.InvalidType("Retry-After", "header", "uint16", response.GetHeader("Retry-After")) + // hydrates response header Retry-After + hdrRetryAfter := response.GetHeader("Retry-After") + + if hdrRetryAfter != "" { + valretryAfter, err := swag.ConvertUint16(hdrRetryAfter) + if err != nil { + return errors.InvalidType("Retry-After", "header", "uint16", hdrRetryAfter) + } + o.RetryAfter = valretryAfter } - o.RetryAfter = retryAfter o.Payload = new(models.ErrorPayload) @@ -239,27 +435,61 @@ func NewUpdateUserAccountDefault(code int) *UpdateUserAccountDefault { } } -/*UpdateUserAccountDefault handles this case with default header values. +/* +UpdateUserAccountDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateUserAccountDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update user account default response has a 2xx status code +func (o *UpdateUserAccountDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update user account default response has a 3xx status code +func (o *UpdateUserAccountDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update user account default response has a 4xx status code +func (o *UpdateUserAccountDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update user account default response has a 5xx status code +func (o *UpdateUserAccountDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update user account default response a status code equal to that given +func (o *UpdateUserAccountDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update user account default response func (o *UpdateUserAccountDefault) Code() int { return o._statusCode } func (o *UpdateUserAccountDefault) Error() string { - return fmt.Sprintf("[PUT /user][%d] updateUserAccount default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user][%d] updateUserAccount default %s", o._statusCode, payload) +} + +func (o *UpdateUserAccountDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user][%d] updateUserAccount default %s", o._statusCode, payload) } func (o *UpdateUserAccountDefault) GetPayload() *models.ErrorPayload { @@ -268,12 +498,16 @@ func (o *UpdateUserAccountDefault) GetPayload() *models.ErrorPayload { func (o *UpdateUserAccountDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -285,7 +519,8 @@ func (o *UpdateUserAccountDefault) readResponse(response runtime.ClientResponse, return nil } -/*UpdateUserAccountOKBody update user account o k body +/* +UpdateUserAccountOKBody update user account o k body swagger:model UpdateUserAccountOKBody */ type UpdateUserAccountOKBody struct { @@ -319,6 +554,39 @@ func (o *UpdateUserAccountOKBody) validateData(formats strfmt.Registry) error { if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updateUserAccountOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateUserAccountOK" + "." + "data") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update user account o k body based on the context it is used +func (o *UpdateUserAccountOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UpdateUserAccountOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if o.Data != nil { + + if err := o.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updateUserAccountOK" + "." + "data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updateUserAccountOK" + "." + "data") } return err } diff --git a/client/client/user/update_user_guide_parameters.go b/client/client/user/update_user_guide_parameters.go index b9cb0cc4..65444f42 100644 --- a/client/client/user/update_user_guide_parameters.go +++ b/client/client/user/update_user_guide_parameters.go @@ -13,59 +13,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) -// NewUpdateUserGuideParams creates a new UpdateUserGuideParams object -// with the default values initialized. +// NewUpdateUserGuideParams creates a new UpdateUserGuideParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. func NewUpdateUserGuideParams() *UpdateUserGuideParams { - var () return &UpdateUserGuideParams{ - timeout: cr.DefaultTimeout, } } // NewUpdateUserGuideParamsWithTimeout creates a new UpdateUserGuideParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewUpdateUserGuideParamsWithTimeout(timeout time.Duration) *UpdateUserGuideParams { - var () return &UpdateUserGuideParams{ - timeout: timeout, } } // NewUpdateUserGuideParamsWithContext creates a new UpdateUserGuideParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewUpdateUserGuideParamsWithContext(ctx context.Context) *UpdateUserGuideParams { - var () return &UpdateUserGuideParams{ - Context: ctx, } } // NewUpdateUserGuideParamsWithHTTPClient creates a new UpdateUserGuideParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewUpdateUserGuideParamsWithHTTPClient(client *http.Client) *UpdateUserGuideParams { - var () return &UpdateUserGuideParams{ HTTPClient: client, } } -/*UpdateUserGuideParams contains all the parameters to send to the API endpoint -for the update user guide operation typically these are written to a http.Request +/* +UpdateUserGuideParams contains all the parameters to send to the API endpoint + + for the update user guide operation. + + Typically these are written to a http.Request. */ type UpdateUserGuideParams struct { - /*Body - The guide's progress JSON schema + /* Body. + The guide's progress JSON schema */ Body models.UserGuide @@ -74,6 +74,21 @@ type UpdateUserGuideParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the update user guide params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateUserGuideParams) WithDefaults() *UpdateUserGuideParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update user guide params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateUserGuideParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the update user guide params func (o *UpdateUserGuideParams) WithTimeout(timeout time.Duration) *UpdateUserGuideParams { o.SetTimeout(timeout) @@ -125,7 +140,6 @@ func (o *UpdateUserGuideParams) WriteToRequest(r runtime.ClientRequest, reg strf return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/client/user/update_user_guide_responses.go b/client/client/user/update_user_guide_responses.go index 5caaf5ba..135a3d05 100644 --- a/client/client/user/update_user_guide_responses.go +++ b/client/client/user/update_user_guide_responses.go @@ -6,16 +6,16 @@ package user // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/cycloidio/cycloid-cli/client/models" + "github.com/cycloidio/cycloid-cli/client/models" ) // UpdateUserGuideReader is a Reader for the UpdateUserGuide structure. @@ -61,15 +61,50 @@ func NewUpdateUserGuideNoContent() *UpdateUserGuideNoContent { return &UpdateUserGuideNoContent{} } -/*UpdateUserGuideNoContent handles this case with default header values. +/* +UpdateUserGuideNoContent describes a response with status code 204, with default header values. The guide progress has been updated. */ type UpdateUserGuideNoContent struct { } +// IsSuccess returns true when this update user guide no content response has a 2xx status code +func (o *UpdateUserGuideNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update user guide no content response has a 3xx status code +func (o *UpdateUserGuideNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update user guide no content response has a 4xx status code +func (o *UpdateUserGuideNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this update user guide no content response has a 5xx status code +func (o *UpdateUserGuideNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this update user guide no content response a status code equal to that given +func (o *UpdateUserGuideNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the update user guide no content response +func (o *UpdateUserGuideNoContent) Code() int { + return 204 +} + func (o *UpdateUserGuideNoContent) Error() string { - return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideNoContent ", 204) + return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideNoContent", 204) +} + +func (o *UpdateUserGuideNoContent) String() string { + return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideNoContent", 204) } func (o *UpdateUserGuideNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -82,20 +117,60 @@ func NewUpdateUserGuideNotFound() *UpdateUserGuideNotFound { return &UpdateUserGuideNotFound{} } -/*UpdateUserGuideNotFound handles this case with default header values. +/* +UpdateUserGuideNotFound describes a response with status code 404, with default header values. The response sent when any of the entities present in the path is not found. */ type UpdateUserGuideNotFound struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update user guide not found response has a 2xx status code +func (o *UpdateUserGuideNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update user guide not found response has a 3xx status code +func (o *UpdateUserGuideNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update user guide not found response has a 4xx status code +func (o *UpdateUserGuideNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update user guide not found response has a 5xx status code +func (o *UpdateUserGuideNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update user guide not found response a status code equal to that given +func (o *UpdateUserGuideNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update user guide not found response +func (o *UpdateUserGuideNotFound) Code() int { + return 404 +} + func (o *UpdateUserGuideNotFound) Error() string { - return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideNotFound %s", 404, payload) +} + +func (o *UpdateUserGuideNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideNotFound %s", 404, payload) } func (o *UpdateUserGuideNotFound) GetPayload() *models.ErrorPayload { @@ -104,12 +179,16 @@ func (o *UpdateUserGuideNotFound) GetPayload() *models.ErrorPayload { func (o *UpdateUserGuideNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -126,20 +205,60 @@ func NewUpdateUserGuideUnprocessableEntity() *UpdateUserGuideUnprocessableEntity return &UpdateUserGuideUnprocessableEntity{} } -/*UpdateUserGuideUnprocessableEntity handles this case with default header values. +/* +UpdateUserGuideUnprocessableEntity describes a response with status code 422, with default header values. All the custom errors that are generated from the Cycloid API */ type UpdateUserGuideUnprocessableEntity struct { - /*The length of the response body in octets (8-bit bytes). - */ + + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update user guide unprocessable entity response has a 2xx status code +func (o *UpdateUserGuideUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update user guide unprocessable entity response has a 3xx status code +func (o *UpdateUserGuideUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update user guide unprocessable entity response has a 4xx status code +func (o *UpdateUserGuideUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this update user guide unprocessable entity response has a 5xx status code +func (o *UpdateUserGuideUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this update user guide unprocessable entity response a status code equal to that given +func (o *UpdateUserGuideUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the update user guide unprocessable entity response +func (o *UpdateUserGuideUnprocessableEntity) Code() int { + return 422 +} + func (o *UpdateUserGuideUnprocessableEntity) Error() string { - return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideUnprocessableEntity %s", 422, payload) +} + +func (o *UpdateUserGuideUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuideUnprocessableEntity %s", 422, payload) } func (o *UpdateUserGuideUnprocessableEntity) GetPayload() *models.ErrorPayload { @@ -148,12 +267,16 @@ func (o *UpdateUserGuideUnprocessableEntity) GetPayload() *models.ErrorPayload { func (o *UpdateUserGuideUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) @@ -172,27 +295,61 @@ func NewUpdateUserGuideDefault(code int) *UpdateUserGuideDefault { } } -/*UpdateUserGuideDefault handles this case with default header values. +/* +UpdateUserGuideDefault describes a response with status code -1, with default header values. The response sent when an unexpected error happened, as known as an internal server error. */ type UpdateUserGuideDefault struct { _statusCode int - /*The length of the response body in octets (8-bit bytes). - */ + /* The length of the response body in octets (8-bit bytes). + + Format: uint64 + */ ContentLength uint64 Payload *models.ErrorPayload } +// IsSuccess returns true when this update user guide default response has a 2xx status code +func (o *UpdateUserGuideDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this update user guide default response has a 3xx status code +func (o *UpdateUserGuideDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this update user guide default response has a 4xx status code +func (o *UpdateUserGuideDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this update user guide default response has a 5xx status code +func (o *UpdateUserGuideDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this update user guide default response a status code equal to that given +func (o *UpdateUserGuideDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the update user guide default response func (o *UpdateUserGuideDefault) Code() int { return o._statusCode } func (o *UpdateUserGuideDefault) Error() string { - return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuide default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuide default %s", o._statusCode, payload) +} + +func (o *UpdateUserGuideDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /user/guide][%d] updateUserGuide default %s", o._statusCode, payload) } func (o *UpdateUserGuideDefault) GetPayload() *models.ErrorPayload { @@ -201,12 +358,16 @@ func (o *UpdateUserGuideDefault) GetPayload() *models.ErrorPayload { func (o *UpdateUserGuideDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - // response header Content-Length - contentLength, err := swag.ConvertUint64(response.GetHeader("Content-Length")) - if err != nil { - return errors.InvalidType("Content-Length", "header", "uint64", response.GetHeader("Content-Length")) + // hydrates response header Content-Length + hdrContentLength := response.GetHeader("Content-Length") + + if hdrContentLength != "" { + valcontentLength, err := swag.ConvertUint64(hdrContentLength) + if err != nil { + return errors.InvalidType("Content-Length", "header", "uint64", hdrContentLength) + } + o.ContentLength = valcontentLength } - o.ContentLength = contentLength o.Payload = new(models.ErrorPayload) diff --git a/client/client/user/user_client.go b/client/client/user/user_client.go index a92f2411..5b691a42 100644 --- a/client/client/user/user_client.go +++ b/client/client/user/user_client.go @@ -7,15 +7,40 @@ package user import ( "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" ) // New creates a new user API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } +// New creates a new user API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new user API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + /* Client for user API */ @@ -24,16 +49,104 @@ type Client struct { formats strfmt.Registry } +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// This client is generated with a few options you might find useful for your swagger spec. +// +// Feel free to add you own set of options. + +// WithContentType allows the client to force the Content-Type header +// to negotiate a specific Consumer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithContentType(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{mime} + } +} + +// WithContentTypeApplicationJSON sets the Content-Type header to "application/json". +func WithContentTypeApplicationJSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/json"} +} + +// WithContentTypeApplicationVndCycloidIoV1JSON sets the Content-Type header to "application/vnd.cycloid.io.v1+json". +func WithContentTypeApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// WithContentTypeApplicationxWwwFormUrlencoded sets the Content-Type header to "application/x-www-form-urlencoded". +func WithContentTypeApplicationxWwwFormUrlencoded(r *runtime.ClientOperation) { + r.ConsumesMediaTypes = []string{"application/x-www-form-urlencoded"} +} + +// WithAccept allows the client to force the Accept header +// to negotiate a specific Producer from the server. +// +// You may use this option to set arbitrary extensions to your MIME media type. +func WithAccept(mime string) ClientOption { + return func(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{mime} + } +} + +// WithAcceptApplicationJSON sets the Accept header to "application/json". +func WithAcceptApplicationJSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/json"} +} + +// WithAcceptApplicationVndCycloidIoV1JSON sets the Accept header to "application/vnd.cycloid.io.v1+json". +func WithAcceptApplicationVndCycloidIoV1JSON(r *runtime.ClientOperation) { + r.ProducesMediaTypes = []string{"application/vnd.cycloid.io.v1+json"} +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateOAuthUser(params *CreateOAuthUserParams, opts ...ClientOption) (*CreateOAuthUserOK, error) + + DeleteUserAccount(params *DeleteUserAccountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteUserAccountNoContent, error) + + EmailAuthenticationVerification(params *EmailAuthenticationVerificationParams, opts ...ClientOption) (*EmailAuthenticationVerificationOK, error) + + EmailVerification(params *EmailVerificationParams, opts ...ClientOption) (*EmailVerificationNoContent, error) + + EmailVerificationResend(params *EmailVerificationResendParams, opts ...ClientOption) (*EmailVerificationResendNoContent, error) + + GetOAuthUser(params *GetOAuthUserParams, opts ...ClientOption) (*GetOAuthUserOK, error) + + GetUserAccount(params *GetUserAccountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetUserAccountOK, error) + + HandleAWSMarketplaceUserEntitlement(params *HandleAWSMarketplaceUserEntitlementParams, opts ...ClientOption) error + + Login(params *LoginParams, opts ...ClientOption) (*LoginOK, error) + + PasswordResetReq(params *PasswordResetReqParams, opts ...ClientOption) (*PasswordResetReqNoContent, error) + + PasswordResetUpdate(params *PasswordResetUpdateParams, opts ...ClientOption) (*PasswordResetUpdateNoContent, error) + + RefreshToken(params *RefreshTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RefreshTokenOK, error) + + SignUp(params *SignUpParams, opts ...ClientOption) (*SignUpNoContent, error) + + SignUpAWSMarketplace(params *SignUpAWSMarketplaceParams, opts ...ClientOption) (*SignUpAWSMarketplaceNoContent, error) + + UpdateUserAccount(params *UpdateUserAccountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateUserAccountOK, error) + + UpdateUserGuide(params *UpdateUserGuideParams, opts ...ClientOption) (*UpdateUserGuideNoContent, error) + + SetTransport(transport runtime.ClientTransport) +} + /* CreateOAuthUser Create a user from the OAuth 'social_type' */ -func (a *Client) CreateOAuthUser(params *CreateOAuthUserParams) (*CreateOAuthUserOK, error) { +func (a *Client) CreateOAuthUser(params *CreateOAuthUserParams, opts ...ClientOption) (*CreateOAuthUserOK, error) { // TODO: Validate the params before sending if params == nil { params = NewCreateOAuthUserParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "createOAuthUser", Method: "POST", PathPattern: "/user/{social_type}/oauth", @@ -44,7 +157,12 @@ func (a *Client) CreateOAuthUser(params *CreateOAuthUserParams) (*CreateOAuthUse Reader: &CreateOAuthUserReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -60,13 +178,12 @@ func (a *Client) CreateOAuthUser(params *CreateOAuthUserParams) (*CreateOAuthUse /* DeleteUserAccount The authenticated user delete itself from the system. */ -func (a *Client) DeleteUserAccount(params *DeleteUserAccountParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteUserAccountNoContent, error) { +func (a *Client) DeleteUserAccount(params *DeleteUserAccountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteUserAccountNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewDeleteUserAccountParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "deleteUserAccount", Method: "DELETE", PathPattern: "/user", @@ -78,7 +195,12 @@ func (a *Client) DeleteUserAccount(params *DeleteUserAccountParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -94,13 +216,12 @@ func (a *Client) DeleteUserAccount(params *DeleteUserAccountParams, authInfo run /* EmailAuthenticationVerification Verify that the email address is own by the user. */ -func (a *Client) EmailAuthenticationVerification(params *EmailAuthenticationVerificationParams) (*EmailAuthenticationVerificationOK, error) { +func (a *Client) EmailAuthenticationVerification(params *EmailAuthenticationVerificationParams, opts ...ClientOption) (*EmailAuthenticationVerificationOK, error) { // TODO: Validate the params before sending if params == nil { params = NewEmailAuthenticationVerificationParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "emailAuthenticationVerification", Method: "PUT", PathPattern: "/user/email/authentication/{authentication_token}", @@ -111,7 +232,12 @@ func (a *Client) EmailAuthenticationVerification(params *EmailAuthenticationVeri Reader: &EmailAuthenticationVerificationReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -127,13 +253,12 @@ func (a *Client) EmailAuthenticationVerification(params *EmailAuthenticationVeri /* EmailVerification Verify that the email address is own by the user. */ -func (a *Client) EmailVerification(params *EmailVerificationParams) (*EmailVerificationNoContent, error) { +func (a *Client) EmailVerification(params *EmailVerificationParams, opts ...ClientOption) (*EmailVerificationNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewEmailVerificationParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "emailVerification", Method: "PUT", PathPattern: "/user/email/verification/{verification_token}", @@ -144,7 +269,12 @@ func (a *Client) EmailVerification(params *EmailVerificationParams) (*EmailVerif Reader: &EmailVerificationReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -160,13 +290,12 @@ func (a *Client) EmailVerification(params *EmailVerificationParams) (*EmailVerif /* EmailVerificationResend Re-send the verification user's email to the indicated address. */ -func (a *Client) EmailVerificationResend(params *EmailVerificationResendParams) (*EmailVerificationResendNoContent, error) { +func (a *Client) EmailVerificationResend(params *EmailVerificationResendParams, opts ...ClientOption) (*EmailVerificationResendNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewEmailVerificationResendParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "emailVerificationResend", Method: "POST", PathPattern: "/user/email/verification", @@ -177,7 +306,12 @@ func (a *Client) EmailVerificationResend(params *EmailVerificationResendParams) Reader: &EmailVerificationResendReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -193,13 +327,12 @@ func (a *Client) EmailVerificationResend(params *EmailVerificationResendParams) /* GetOAuthUser Used to know if a user from the platform exists on that 'social_type'. If it exists we'll return the JWT 'token', if it does not we'll return the data of that user on the 'user' so it can be confirmed and created */ -func (a *Client) GetOAuthUser(params *GetOAuthUserParams) (*GetOAuthUserOK, error) { +func (a *Client) GetOAuthUser(params *GetOAuthUserParams, opts ...ClientOption) (*GetOAuthUserOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetOAuthUserParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getOAuthUser", Method: "GET", PathPattern: "/user/{social_type}/oauth", @@ -210,7 +343,12 @@ func (a *Client) GetOAuthUser(params *GetOAuthUserParams) (*GetOAuthUserOK, erro Reader: &GetOAuthUserReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -226,13 +364,12 @@ func (a *Client) GetOAuthUser(params *GetOAuthUserParams) (*GetOAuthUserOK, erro /* GetUserAccount Get the information of the account of the authenticated user. */ -func (a *Client) GetUserAccount(params *GetUserAccountParams, authInfo runtime.ClientAuthInfoWriter) (*GetUserAccountOK, error) { +func (a *Client) GetUserAccount(params *GetUserAccountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetUserAccountOK, error) { // TODO: Validate the params before sending if params == nil { params = NewGetUserAccountParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "getUserAccount", Method: "GET", PathPattern: "/user", @@ -244,7 +381,12 @@ func (a *Client) GetUserAccount(params *GetUserAccountParams, authInfo runtime.C AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -258,18 +400,17 @@ func (a *Client) GetUserAccount(params *GetUserAccountParams, authInfo runtime.C } /* -HandleAWSMarketplaceUserEntitlement This endpoint handles redirections from AWS Marketplace to our system. + HandleAWSMarketplaceUserEntitlement This endpoint handles redirections from AWS Marketplace to our system. + If user doesn't exist, he'll be redirected to registration page. If user exist, he'll be redirected to login page. - */ -func (a *Client) HandleAWSMarketplaceUserEntitlement(params *HandleAWSMarketplaceUserEntitlementParams) error { +func (a *Client) HandleAWSMarketplaceUserEntitlement(params *HandleAWSMarketplaceUserEntitlementParams, opts ...ClientOption) error { // TODO: Validate the params before sending if params == nil { params = NewHandleAWSMarketplaceUserEntitlementParams() } - - _, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "handleAWSMarketplaceUserEntitlement", Method: "POST", PathPattern: "/user/aws_marketplace/entitlement", @@ -280,7 +421,12 @@ func (a *Client) HandleAWSMarketplaceUserEntitlement(params *HandleAWSMarketplac Reader: &HandleAWSMarketplaceUserEntitlementReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + _, err := a.transport.Submit(op) if err != nil { return err } @@ -290,13 +436,12 @@ func (a *Client) HandleAWSMarketplaceUserEntitlement(params *HandleAWSMarketplac /* Login Authenticate a user and return a new JWT token. */ -func (a *Client) Login(params *LoginParams) (*LoginOK, error) { +func (a *Client) Login(params *LoginParams, opts ...ClientOption) (*LoginOK, error) { // TODO: Validate the params before sending if params == nil { params = NewLoginParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "login", Method: "POST", PathPattern: "/user/login", @@ -307,7 +452,12 @@ func (a *Client) Login(params *LoginParams) (*LoginOK, error) { Reader: &LoginReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -323,13 +473,12 @@ func (a *Client) Login(params *LoginParams) (*LoginOK, error) { /* PasswordResetReq Request to reset the password. Due to security reasons, this endpoint doesn't return Not Found (404) when the email doesn't exist or belongs to a user primary email. */ -func (a *Client) PasswordResetReq(params *PasswordResetReqParams) (*PasswordResetReqNoContent, error) { +func (a *Client) PasswordResetReq(params *PasswordResetReqParams, opts ...ClientOption) (*PasswordResetReqNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewPasswordResetReqParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "passwordResetReq", Method: "POST", PathPattern: "/user/reset_password", @@ -340,7 +489,12 @@ func (a *Client) PasswordResetReq(params *PasswordResetReqParams) (*PasswordRese Reader: &PasswordResetReqReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -356,13 +510,12 @@ func (a *Client) PasswordResetReq(params *PasswordResetReqParams) (*PasswordRese /* PasswordResetUpdate Reset the user password when it has been forgotten. Due to security reasons, the endpoint doesn't return a Unprocessable Entity (422) when the token is invalid. 404 Status code is returned if the user has been deleted of the system between the user password request and this request. */ -func (a *Client) PasswordResetUpdate(params *PasswordResetUpdateParams) (*PasswordResetUpdateNoContent, error) { +func (a *Client) PasswordResetUpdate(params *PasswordResetUpdateParams, opts ...ClientOption) (*PasswordResetUpdateNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewPasswordResetUpdateParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "passwordResetUpdate", Method: "PUT", PathPattern: "/user/reset_password", @@ -373,7 +526,12 @@ func (a *Client) PasswordResetUpdate(params *PasswordResetUpdateParams) (*Passwo Reader: &PasswordResetUpdateReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -389,13 +547,12 @@ func (a *Client) PasswordResetUpdate(params *PasswordResetUpdateParams) (*Passwo /* RefreshToken Refresh the user JWT and returns a new one if the previous is valid. The 'organization_canonical_query' has to be of an organization in which the user belongs to, and the 'child_canonical_query' of a child of the 'organization_canonical_query' in any level (could be of a grand child). */ -func (a *Client) RefreshToken(params *RefreshTokenParams, authInfo runtime.ClientAuthInfoWriter) (*RefreshTokenOK, error) { +func (a *Client) RefreshToken(params *RefreshTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RefreshTokenOK, error) { // TODO: Validate the params before sending if params == nil { params = NewRefreshTokenParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "refreshToken", Method: "GET", PathPattern: "/user/refresh_token", @@ -407,7 +564,12 @@ func (a *Client) RefreshToken(params *RefreshTokenParams, authInfo runtime.Clien AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -423,13 +585,12 @@ func (a *Client) RefreshToken(params *RefreshTokenParams, authInfo runtime.Clien /* SignUp Create a new User (sign-up). */ -func (a *Client) SignUp(params *SignUpParams) (*SignUpNoContent, error) { +func (a *Client) SignUp(params *SignUpParams, opts ...ClientOption) (*SignUpNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewSignUpParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "signUp", Method: "POST", PathPattern: "/user", @@ -440,7 +601,12 @@ func (a *Client) SignUp(params *SignUpParams) (*SignUpNoContent, error) { Reader: &SignUpReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -456,13 +622,12 @@ func (a *Client) SignUp(params *SignUpParams) (*SignUpNoContent, error) { /* SignUpAWSMarketplace Create a new AWS Marketplace User. */ -func (a *Client) SignUpAWSMarketplace(params *SignUpAWSMarketplaceParams) (*SignUpAWSMarketplaceNoContent, error) { +func (a *Client) SignUpAWSMarketplace(params *SignUpAWSMarketplaceParams, opts ...ClientOption) (*SignUpAWSMarketplaceNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewSignUpAWSMarketplaceParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "signUpAWSMarketplace", Method: "POST", PathPattern: "/user/aws_marketplace", @@ -473,7 +638,12 @@ func (a *Client) SignUpAWSMarketplace(params *SignUpAWSMarketplaceParams) (*Sign Reader: &SignUpAWSMarketplaceReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -489,13 +659,12 @@ func (a *Client) SignUpAWSMarketplace(params *SignUpAWSMarketplaceParams) (*Sign /* UpdateUserAccount Update the information of the account of the authenticated user. */ -func (a *Client) UpdateUserAccount(params *UpdateUserAccountParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateUserAccountOK, error) { +func (a *Client) UpdateUserAccount(params *UpdateUserAccountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateUserAccountOK, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateUserAccountParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateUserAccount", Method: "PUT", PathPattern: "/user", @@ -507,7 +676,12 @@ func (a *Client) UpdateUserAccount(params *UpdateUserAccountParams, authInfo run AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } @@ -523,13 +697,12 @@ func (a *Client) UpdateUserAccount(params *UpdateUserAccountParams, authInfo run /* UpdateUserGuide Update user's guide progress. */ -func (a *Client) UpdateUserGuide(params *UpdateUserGuideParams) (*UpdateUserGuideNoContent, error) { +func (a *Client) UpdateUserGuide(params *UpdateUserGuideParams, opts ...ClientOption) (*UpdateUserGuideNoContent, error) { // TODO: Validate the params before sending if params == nil { params = NewUpdateUserGuideParams() } - - result, err := a.transport.Submit(&runtime.ClientOperation{ + op := &runtime.ClientOperation{ ID: "updateUserGuide", Method: "PUT", PathPattern: "/user/guide", @@ -540,7 +713,12 @@ func (a *Client) UpdateUserGuide(params *UpdateUserGuideParams) (*UpdateUserGuid Reader: &UpdateUserGuideReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, - }) + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) if err != nil { return nil, err } diff --git a/client/models/a_w_s_cloud_watch_logs.go b/client/models/a_w_s_cloud_watch_logs.go index 6a68fb91..0e0684ea 100644 --- a/client/models/a_w_s_cloud_watch_logs.go +++ b/client/models/a_w_s_cloud_watch_logs.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -35,11 +35,8 @@ func (m *AWSCloudWatchLogs) Engine() string { // SetEngine sets the engine of this subtype func (m *AWSCloudWatchLogs) SetEngine(val string) { - } -// Region gets the region of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *AWSCloudWatchLogs) UnmarshalJSON(raw []byte) error { var data struct { @@ -97,8 +94,7 @@ func (m AWSCloudWatchLogs) MarshalJSON() ([]byte, error) { }{ Region: m.Region, - }, - ) + }) if err != nil { return nil, err } @@ -107,8 +103,7 @@ func (m AWSCloudWatchLogs) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -139,6 +134,16 @@ func (m *AWSCloudWatchLogs) validateRegion(formats strfmt.Registry) error { return nil } +// ContextValidate validate this a w s cloud watch logs based on the context it is used +func (m *AWSCloudWatchLogs) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *AWSCloudWatchLogs) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/a_w_s_infrastructure_resource_bucket.go b/client/models/a_w_s_infrastructure_resource_bucket.go index d772d47f..e1f61c82 100644 --- a/client/models/a_w_s_infrastructure_resource_bucket.go +++ b/client/models/a_w_s_infrastructure_resource_bucket.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceBucket AWS Infrastructure S3 bucket Resource // // This object contains the items described in the S3 bucket data type described in but it also contains its associated tags which are documented in the properties of this object definition. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceBucket type AWSInfrastructureResourceBucket interface{} diff --git a/client/models/a_w_s_infrastructure_resource_d_b_instance.go b/client/models/a_w_s_infrastructure_resource_d_b_instance.go index 5cf25730..3889f81c 100644 --- a/client/models/a_w_s_infrastructure_resource_d_b_instance.go +++ b/client/models/a_w_s_infrastructure_resource_d_b_instance.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceDBInstance AWS Infrastructure RDS DB instance Resource // // This object contains the items described in the RDS DB instance data type described in https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DBInstance.html but it also contains its associated tags which are documented in the properties of this object definition. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceDBInstance type AWSInfrastructureResourceDBInstance interface{} diff --git a/client/models/a_w_s_infrastructure_resource_elasticache_cluster.go b/client/models/a_w_s_infrastructure_resource_elasticache_cluster.go index 40c5e8d7..d59fbcd4 100644 --- a/client/models/a_w_s_infrastructure_resource_elasticache_cluster.go +++ b/client/models/a_w_s_infrastructure_resource_elasticache_cluster.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceElasticacheCluster AWS Infrastructure Elasticache cluster Resource // // This object contains the items described in the ElastiCache cluster data type described in https://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/API_CacheCluster.html but it also contains its associated tags which are documented in the properties of this object definition. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceElasticacheCluster type AWSInfrastructureResourceElasticacheCluster interface{} diff --git a/client/models/a_w_s_infrastructure_resource_image.go b/client/models/a_w_s_infrastructure_resource_image.go index e08ef976..ef4b82d8 100644 --- a/client/models/a_w_s_infrastructure_resource_image.go +++ b/client/models/a_w_s_infrastructure_resource_image.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceImage AWS Infrastructure image Resource // // This object contains the items described in the image data type described in https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Image.html Tags property is set, for guaranteeing that the respond will always have the property of the type array, not allowing null in case that the resource doesn't have any, hence an empty array is used in such case. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceImage type AWSInfrastructureResourceImage interface{} diff --git a/client/models/a_w_s_infrastructure_resource_instance.go b/client/models/a_w_s_infrastructure_resource_instance.go index 48f02a39..ed19c6b6 100644 --- a/client/models/a_w_s_infrastructure_resource_instance.go +++ b/client/models/a_w_s_infrastructure_resource_instance.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceInstance AWS Infrastructure Instance Resource // // This object contains the items described in the instance data type described in https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Instance.html Tags property is set, for guaranteeing that the respond will always have the property of the type array, not allowing null in case that the resource doesn't have any, hence an empty array is used in such case. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceInstance type AWSInfrastructureResourceInstance interface{} diff --git a/client/models/a_w_s_infrastructure_resource_load_balancer_v1.go b/client/models/a_w_s_infrastructure_resource_load_balancer_v1.go index 042266e0..0e483907 100644 --- a/client/models/a_w_s_infrastructure_resource_load_balancer_v1.go +++ b/client/models/a_w_s_infrastructure_resource_load_balancer_v1.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceLoadBalancerV1 AWS Infrastructure load balancer (ELB) Resource // // This object contains the items described in the load balancer (ELB) data type described in https://docs.aws.amazon.com/elasticloadbalancing/2012-06-01/APIReference/API_LoadBalancerDescription.html but it also contains its associated tags which are documented in the properties of this object definition. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceLoadBalancerV1 type AWSInfrastructureResourceLoadBalancerV1 interface{} diff --git a/client/models/a_w_s_infrastructure_resource_load_balancer_v2.go b/client/models/a_w_s_infrastructure_resource_load_balancer_v2.go index 46b8599f..560ca3ff 100644 --- a/client/models/a_w_s_infrastructure_resource_load_balancer_v2.go +++ b/client/models/a_w_s_infrastructure_resource_load_balancer_v2.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceLoadBalancerV2 AWS Infrastructure load balancer (ELB v2 or a.k.a ALB) Resource // // This object contains the items described in the load balancer (ELB v2 or a.k.a ALB) data type described in https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_LoadBalancer.html but it also contains its associated tags which are documented in the properties of this object definition. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceLoadBalancerV2 type AWSInfrastructureResourceLoadBalancerV2 interface{} diff --git a/client/models/a_w_s_infrastructure_resource_security_group.go b/client/models/a_w_s_infrastructure_resource_security_group.go index f21b883b..825374db 100644 --- a/client/models/a_w_s_infrastructure_resource_security_group.go +++ b/client/models/a_w_s_infrastructure_resource_security_group.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceSecurityGroup AWS Infrastructure security group Resource // // This object contains the items described in the security group data type described in https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_SecurityGroup.html Tags property is set, for guaranteeing that the respond will always have the property of the type array, not allowing null in case that the resource doesn't have any, hence an empty array is used in such case. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceSecurityGroup type AWSInfrastructureResourceSecurityGroup interface{} diff --git a/client/models/a_w_s_infrastructure_resource_snapshot.go b/client/models/a_w_s_infrastructure_resource_snapshot.go index 4b599473..b4dca0d4 100644 --- a/client/models/a_w_s_infrastructure_resource_snapshot.go +++ b/client/models/a_w_s_infrastructure_resource_snapshot.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceSnapshot AWS Infrastructure snapshot Resource // // This object contains the items described in the snapshot data type described in https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Snapshot.html Tags property is set, for guaranteeing that the respond will always have the property of the type array, not allowing null in case that the resource doesn't have any, hence an empty array is used in such case. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceSnapshot type AWSInfrastructureResourceSnapshot interface{} diff --git a/client/models/a_w_s_infrastructure_resource_subnet.go b/client/models/a_w_s_infrastructure_resource_subnet.go index 94a22c8e..86eab304 100644 --- a/client/models/a_w_s_infrastructure_resource_subnet.go +++ b/client/models/a_w_s_infrastructure_resource_subnet.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceSubnet AWS Infrastructure subnet Resource // // This object contains the items described in the subnet data type described in https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Subnet.html Tags property is set, for guaranteeing that the respond will always have the property of the type array, not allowing null in case that the resource doesn't have any, hence an empty array is used in such case. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceSubnet type AWSInfrastructureResourceSubnet interface{} diff --git a/client/models/a_w_s_infrastructure_resource_v_p_c.go b/client/models/a_w_s_infrastructure_resource_v_p_c.go index f96de62e..67f32c8e 100644 --- a/client/models/a_w_s_infrastructure_resource_v_p_c.go +++ b/client/models/a_w_s_infrastructure_resource_v_p_c.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceVPC AWS Infrastructure VPC Resource // // This object contains the items described in the VPC data type described in https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Vpc.html Tags property is set, for guaranteeing that the respond will always have the property of the type array, not allowing null in case that the resource doesn't have any, hence an empty array is used in such case. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceVPC type AWSInfrastructureResourceVPC interface{} diff --git a/client/models/a_w_s_infrastructure_resource_volume.go b/client/models/a_w_s_infrastructure_resource_volume.go index 2f343828..c7b2f514 100644 --- a/client/models/a_w_s_infrastructure_resource_volume.go +++ b/client/models/a_w_s_infrastructure_resource_volume.go @@ -8,5 +8,6 @@ package models // AWSInfrastructureResourceVolume AWS Infrastructure volume Resource // // This object contains the items described in the volume data type described in https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Volume.html Tags property is set, for guaranteeing that the respond will always have the property of the type array, not allowing null in case that the resource doesn't have any, hence an empty array is used in such case. This object will contain a property named 'Tags' which is of the type defined by the schema definition '#/definitions/AWSTags' +// // swagger:model AWSInfrastructureResourceVolume type AWSInfrastructureResourceVolume interface{} diff --git a/client/models/a_w_s_infrastructure_resources_aggregation.go b/client/models/a_w_s_infrastructure_resources_aggregation.go index d35ed509..07f5c3c9 100644 --- a/client/models/a_w_s_infrastructure_resources_aggregation.go +++ b/client/models/a_w_s_infrastructure_resources_aggregation.go @@ -6,13 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "encoding/json" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // AWSInfrastructureResourcesAggregation AWS Infrastructure Resources Aggregation +// +// MinProperties: 1 +// MaxProperties: 12 +// // swagger:model AWSInfrastructureResourcesAggregation type AWSInfrastructureResourcesAggregation struct { @@ -51,12 +57,214 @@ type AWSInfrastructureResourcesAggregation struct { // vpcs Vpcs *InfrastructureResourcesAggregationItem `json:"vpcs,omitempty"` + + // a w s infrastructure resources aggregation additional properties + AWSInfrastructureResourcesAggregationAdditionalProperties map[string]interface{} `json:"-"` +} + +// UnmarshalJSON unmarshals this object with additional properties from JSON +func (m *AWSInfrastructureResourcesAggregation) UnmarshalJSON(data []byte) error { + // stage 1, bind the properties + var stage1 struct { + + // buckets + Buckets *InfrastructureResourcesAggregationItem `json:"buckets,omitempty"` + + // cache clusters + CacheClusters *InfrastructureResourcesAggregationItem `json:"cache_clusters,omitempty"` + + // db instances + DbInstances *InfrastructureResourcesAggregationItem `json:"db_instances,omitempty"` + + // images + Images *InfrastructureResourcesAggregationItem `json:"images,omitempty"` + + // instances + Instances *InfrastructureResourcesAggregationItem `json:"instances,omitempty"` + + // load balancers v1 + LoadBalancersV1 *InfrastructureResourcesAggregationItem `json:"load_balancers_v1,omitempty"` + + // load balancers v2 + LoadBalancersV2 *InfrastructureResourcesAggregationItem `json:"load_balancers_v2,omitempty"` + + // security groups + SecurityGroups *InfrastructureResourcesAggregationItem `json:"security_groups,omitempty"` + + // snapshots + Snapshots *InfrastructureResourcesAggregationItem `json:"snapshots,omitempty"` + + // subnets + Subnets *InfrastructureResourcesAggregationItem `json:"subnets,omitempty"` + + // volumes + Volumes *InfrastructureResourcesAggregationItem `json:"volumes,omitempty"` + + // vpcs + Vpcs *InfrastructureResourcesAggregationItem `json:"vpcs,omitempty"` + } + if err := json.Unmarshal(data, &stage1); err != nil { + return err + } + var rcv AWSInfrastructureResourcesAggregation + + rcv.Buckets = stage1.Buckets + rcv.CacheClusters = stage1.CacheClusters + rcv.DbInstances = stage1.DbInstances + rcv.Images = stage1.Images + rcv.Instances = stage1.Instances + rcv.LoadBalancersV1 = stage1.LoadBalancersV1 + rcv.LoadBalancersV2 = stage1.LoadBalancersV2 + rcv.SecurityGroups = stage1.SecurityGroups + rcv.Snapshots = stage1.Snapshots + rcv.Subnets = stage1.Subnets + rcv.Volumes = stage1.Volumes + rcv.Vpcs = stage1.Vpcs + *m = rcv + + // stage 2, remove properties and add to map + stage2 := make(map[string]json.RawMessage) + if err := json.Unmarshal(data, &stage2); err != nil { + return err + } + + delete(stage2, "buckets") + delete(stage2, "cache_clusters") + delete(stage2, "db_instances") + delete(stage2, "images") + delete(stage2, "instances") + delete(stage2, "load_balancers_v1") + delete(stage2, "load_balancers_v2") + delete(stage2, "security_groups") + delete(stage2, "snapshots") + delete(stage2, "subnets") + delete(stage2, "volumes") + delete(stage2, "vpcs") + // stage 3, add additional properties values + if len(stage2) > 0 { + result := make(map[string]interface{}) + for k, v := range stage2 { + var toadd interface{} + if err := json.Unmarshal(v, &toadd); err != nil { + return err + } + result[k] = toadd + } + m.AWSInfrastructureResourcesAggregationAdditionalProperties = result + } + + return nil +} + +// MarshalJSON marshals this object with additional properties into a JSON object +func (m AWSInfrastructureResourcesAggregation) MarshalJSON() ([]byte, error) { + var stage1 struct { + + // buckets + Buckets *InfrastructureResourcesAggregationItem `json:"buckets,omitempty"` + + // cache clusters + CacheClusters *InfrastructureResourcesAggregationItem `json:"cache_clusters,omitempty"` + + // db instances + DbInstances *InfrastructureResourcesAggregationItem `json:"db_instances,omitempty"` + + // images + Images *InfrastructureResourcesAggregationItem `json:"images,omitempty"` + + // instances + Instances *InfrastructureResourcesAggregationItem `json:"instances,omitempty"` + + // load balancers v1 + LoadBalancersV1 *InfrastructureResourcesAggregationItem `json:"load_balancers_v1,omitempty"` + + // load balancers v2 + LoadBalancersV2 *InfrastructureResourcesAggregationItem `json:"load_balancers_v2,omitempty"` + + // security groups + SecurityGroups *InfrastructureResourcesAggregationItem `json:"security_groups,omitempty"` + + // snapshots + Snapshots *InfrastructureResourcesAggregationItem `json:"snapshots,omitempty"` + + // subnets + Subnets *InfrastructureResourcesAggregationItem `json:"subnets,omitempty"` + + // volumes + Volumes *InfrastructureResourcesAggregationItem `json:"volumes,omitempty"` + + // vpcs + Vpcs *InfrastructureResourcesAggregationItem `json:"vpcs,omitempty"` + } + + stage1.Buckets = m.Buckets + stage1.CacheClusters = m.CacheClusters + stage1.DbInstances = m.DbInstances + stage1.Images = m.Images + stage1.Instances = m.Instances + stage1.LoadBalancersV1 = m.LoadBalancersV1 + stage1.LoadBalancersV2 = m.LoadBalancersV2 + stage1.SecurityGroups = m.SecurityGroups + stage1.Snapshots = m.Snapshots + stage1.Subnets = m.Subnets + stage1.Volumes = m.Volumes + stage1.Vpcs = m.Vpcs + + // make JSON object for known properties + props, err := json.Marshal(stage1) + if err != nil { + return nil, err + } + + if len(m.AWSInfrastructureResourcesAggregationAdditionalProperties) == 0 { // no additional properties + return props, nil + } + + // make JSON object for the additional properties + additional, err := json.Marshal(m.AWSInfrastructureResourcesAggregationAdditionalProperties) + if err != nil { + return nil, err + } + + if len(props) < 3 { // "{}": only additional properties + return additional, nil + } + + // concatenate the 2 objects + return swag.ConcatJSON(props, additional), nil } // Validate validates this a w s infrastructure resources aggregation func (m *AWSInfrastructureResourcesAggregation) Validate(formats strfmt.Registry) error { var res []error + // short circuits minProperties > 0 + if m == nil { + return errors.TooFewProperties("", "body", 1) + } + + props := make(map[string]json.RawMessage, 12+10) + j, err := swag.WriteJSON(m) + if err != nil { + return err + } + + if err = swag.ReadJSON(j, &props); err != nil { + return err + } + + nprops := len(props) + + // minProperties: 1 + if nprops < 1 { + return errors.TooFewProperties("", "body", 1) + } + + // maxProperties: 12 + if nprops > 12 { + return errors.TooManyProperties("", "body", 12) + } + if err := m.validateBuckets(formats); err != nil { res = append(res, err) } @@ -112,7 +320,6 @@ func (m *AWSInfrastructureResourcesAggregation) Validate(formats strfmt.Registry } func (m *AWSInfrastructureResourcesAggregation) validateBuckets(formats strfmt.Registry) error { - if swag.IsZero(m.Buckets) { // not required return nil } @@ -121,6 +328,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateBuckets(formats strfmt.R if err := m.Buckets.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("buckets") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("buckets") } return err } @@ -130,7 +339,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateBuckets(formats strfmt.R } func (m *AWSInfrastructureResourcesAggregation) validateCacheClusters(formats strfmt.Registry) error { - if swag.IsZero(m.CacheClusters) { // not required return nil } @@ -139,6 +347,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateCacheClusters(formats st if err := m.CacheClusters.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("cache_clusters") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cache_clusters") } return err } @@ -148,7 +358,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateCacheClusters(formats st } func (m *AWSInfrastructureResourcesAggregation) validateDbInstances(formats strfmt.Registry) error { - if swag.IsZero(m.DbInstances) { // not required return nil } @@ -157,6 +366,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateDbInstances(formats strf if err := m.DbInstances.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("db_instances") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("db_instances") } return err } @@ -166,7 +377,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateDbInstances(formats strf } func (m *AWSInfrastructureResourcesAggregation) validateImages(formats strfmt.Registry) error { - if swag.IsZero(m.Images) { // not required return nil } @@ -175,6 +385,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateImages(formats strfmt.Re if err := m.Images.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("images") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("images") } return err } @@ -184,7 +396,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateImages(formats strfmt.Re } func (m *AWSInfrastructureResourcesAggregation) validateInstances(formats strfmt.Registry) error { - if swag.IsZero(m.Instances) { // not required return nil } @@ -193,6 +404,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateInstances(formats strfmt if err := m.Instances.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("instances") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("instances") } return err } @@ -202,7 +415,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateInstances(formats strfmt } func (m *AWSInfrastructureResourcesAggregation) validateLoadBalancersV1(formats strfmt.Registry) error { - if swag.IsZero(m.LoadBalancersV1) { // not required return nil } @@ -211,6 +423,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateLoadBalancersV1(formats if err := m.LoadBalancersV1.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("load_balancers_v1") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("load_balancers_v1") } return err } @@ -220,7 +434,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateLoadBalancersV1(formats } func (m *AWSInfrastructureResourcesAggregation) validateLoadBalancersV2(formats strfmt.Registry) error { - if swag.IsZero(m.LoadBalancersV2) { // not required return nil } @@ -229,6 +442,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateLoadBalancersV2(formats if err := m.LoadBalancersV2.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("load_balancers_v2") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("load_balancers_v2") } return err } @@ -238,7 +453,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateLoadBalancersV2(formats } func (m *AWSInfrastructureResourcesAggregation) validateSecurityGroups(formats strfmt.Registry) error { - if swag.IsZero(m.SecurityGroups) { // not required return nil } @@ -247,6 +461,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateSecurityGroups(formats s if err := m.SecurityGroups.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("security_groups") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("security_groups") } return err } @@ -256,7 +472,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateSecurityGroups(formats s } func (m *AWSInfrastructureResourcesAggregation) validateSnapshots(formats strfmt.Registry) error { - if swag.IsZero(m.Snapshots) { // not required return nil } @@ -265,6 +480,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateSnapshots(formats strfmt if err := m.Snapshots.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("snapshots") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("snapshots") } return err } @@ -274,7 +491,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateSnapshots(formats strfmt } func (m *AWSInfrastructureResourcesAggregation) validateSubnets(formats strfmt.Registry) error { - if swag.IsZero(m.Subnets) { // not required return nil } @@ -283,6 +499,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateSubnets(formats strfmt.R if err := m.Subnets.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("subnets") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("subnets") } return err } @@ -292,7 +510,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateSubnets(formats strfmt.R } func (m *AWSInfrastructureResourcesAggregation) validateVolumes(formats strfmt.Registry) error { - if swag.IsZero(m.Volumes) { // not required return nil } @@ -301,6 +518,8 @@ func (m *AWSInfrastructureResourcesAggregation) validateVolumes(formats strfmt.R if err := m.Volumes.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("volumes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumes") } return err } @@ -310,7 +529,6 @@ func (m *AWSInfrastructureResourcesAggregation) validateVolumes(formats strfmt.R } func (m *AWSInfrastructureResourcesAggregation) validateVpcs(formats strfmt.Registry) error { - if swag.IsZero(m.Vpcs) { // not required return nil } @@ -319,6 +537,318 @@ func (m *AWSInfrastructureResourcesAggregation) validateVpcs(formats strfmt.Regi if err := m.Vpcs.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("vpcs") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpcs") + } + return err + } + } + + return nil +} + +// ContextValidate validate this a w s infrastructure resources aggregation based on the context it is used +func (m *AWSInfrastructureResourcesAggregation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBuckets(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateCacheClusters(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateDbInstances(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateImages(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateInstances(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateLoadBalancersV1(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateLoadBalancersV2(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSecurityGroups(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSnapshots(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSubnets(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVolumes(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVpcs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateBuckets(ctx context.Context, formats strfmt.Registry) error { + + if m.Buckets != nil { + + if swag.IsZero(m.Buckets) { // not required + return nil + } + + if err := m.Buckets.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("buckets") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("buckets") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateCacheClusters(ctx context.Context, formats strfmt.Registry) error { + + if m.CacheClusters != nil { + + if swag.IsZero(m.CacheClusters) { // not required + return nil + } + + if err := m.CacheClusters.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cache_clusters") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cache_clusters") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateDbInstances(ctx context.Context, formats strfmt.Registry) error { + + if m.DbInstances != nil { + + if swag.IsZero(m.DbInstances) { // not required + return nil + } + + if err := m.DbInstances.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("db_instances") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("db_instances") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateImages(ctx context.Context, formats strfmt.Registry) error { + + if m.Images != nil { + + if swag.IsZero(m.Images) { // not required + return nil + } + + if err := m.Images.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("images") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("images") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateInstances(ctx context.Context, formats strfmt.Registry) error { + + if m.Instances != nil { + + if swag.IsZero(m.Instances) { // not required + return nil + } + + if err := m.Instances.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("instances") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("instances") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateLoadBalancersV1(ctx context.Context, formats strfmt.Registry) error { + + if m.LoadBalancersV1 != nil { + + if swag.IsZero(m.LoadBalancersV1) { // not required + return nil + } + + if err := m.LoadBalancersV1.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("load_balancers_v1") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("load_balancers_v1") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateLoadBalancersV2(ctx context.Context, formats strfmt.Registry) error { + + if m.LoadBalancersV2 != nil { + + if swag.IsZero(m.LoadBalancersV2) { // not required + return nil + } + + if err := m.LoadBalancersV2.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("load_balancers_v2") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("load_balancers_v2") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateSecurityGroups(ctx context.Context, formats strfmt.Registry) error { + + if m.SecurityGroups != nil { + + if swag.IsZero(m.SecurityGroups) { // not required + return nil + } + + if err := m.SecurityGroups.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("security_groups") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("security_groups") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateSnapshots(ctx context.Context, formats strfmt.Registry) error { + + if m.Snapshots != nil { + + if swag.IsZero(m.Snapshots) { // not required + return nil + } + + if err := m.Snapshots.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("snapshots") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("snapshots") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateSubnets(ctx context.Context, formats strfmt.Registry) error { + + if m.Subnets != nil { + + if swag.IsZero(m.Subnets) { // not required + return nil + } + + if err := m.Subnets.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("subnets") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("subnets") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateVolumes(ctx context.Context, formats strfmt.Registry) error { + + if m.Volumes != nil { + + if swag.IsZero(m.Volumes) { // not required + return nil + } + + if err := m.Volumes.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumes") + } + return err + } + } + + return nil +} + +func (m *AWSInfrastructureResourcesAggregation) contextValidateVpcs(ctx context.Context, formats strfmt.Registry) error { + + if m.Vpcs != nil { + + if swag.IsZero(m.Vpcs) { // not required + return nil + } + + if err := m.Vpcs.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpcs") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpcs") } return err } diff --git a/client/models/a_w_s_remote_t_f_state.go b/client/models/a_w_s_remote_t_f_state.go index d38670a9..e1666b1d 100644 --- a/client/models/a_w_s_remote_t_f_state.go +++ b/client/models/a_w_s_remote_t_f_state.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -58,21 +58,8 @@ func (m *AWSRemoteTFState) Engine() string { // SetEngine sets the engine of this subtype func (m *AWSRemoteTFState) SetEngine(val string) { - } -// Bucket gets the bucket of this subtype - -// Endpoint gets the endpoint of this subtype - -// Key gets the key of this subtype - -// Region gets the region of this subtype - -// S3ForcePathStyle gets the s3 force path style of this subtype - -// SkipVerifySsl gets the skip verify ssl of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *AWSRemoteTFState) UnmarshalJSON(raw []byte) error { var data struct { @@ -133,15 +120,10 @@ func (m *AWSRemoteTFState) UnmarshalJSON(raw []byte) error { } result.Bucket = data.Bucket - result.Endpoint = data.Endpoint - result.Key = data.Key - result.Region = data.Region - result.S3ForcePathStyle = data.S3ForcePathStyle - result.SkipVerifySsl = data.SkipVerifySsl *m = result @@ -194,8 +176,7 @@ func (m AWSRemoteTFState) MarshalJSON() ([]byte, error) { S3ForcePathStyle: m.S3ForcePathStyle, SkipVerifySsl: m.SkipVerifySsl, - }, - ) + }) if err != nil { return nil, err } @@ -204,8 +185,7 @@ func (m AWSRemoteTFState) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -249,6 +229,16 @@ func (m *AWSRemoteTFState) validateRegion(formats strfmt.Registry) error { return nil } +// ContextValidate validate this a w s remote t f state based on the context it is used +func (m *AWSRemoteTFState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *AWSRemoteTFState) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/a_w_s_storage.go b/client/models/a_w_s_storage.go index e70cfddd..65293674 100644 --- a/client/models/a_w_s_storage.go +++ b/client/models/a_w_s_storage.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -56,21 +56,8 @@ func (m *AWSStorage) Engine() string { // SetEngine sets the engine of this subtype func (m *AWSStorage) SetEngine(val string) { - } -// Bucket gets the bucket of this subtype - -// Endpoint gets the endpoint of this subtype - -// Key gets the key of this subtype - -// Region gets the region of this subtype - -// S3ForcePathStyle gets the s3 force path style of this subtype - -// SkipVerifySsl gets the skip verify ssl of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *AWSStorage) UnmarshalJSON(raw []byte) error { var data struct { @@ -130,15 +117,10 @@ func (m *AWSStorage) UnmarshalJSON(raw []byte) error { } result.Bucket = data.Bucket - result.Endpoint = data.Endpoint - result.Key = data.Key - result.Region = data.Region - result.S3ForcePathStyle = data.S3ForcePathStyle - result.SkipVerifySsl = data.SkipVerifySsl *m = result @@ -190,8 +172,7 @@ func (m AWSStorage) MarshalJSON() ([]byte, error) { S3ForcePathStyle: m.S3ForcePathStyle, SkipVerifySsl: m.SkipVerifySsl, - }, - ) + }) if err != nil { return nil, err } @@ -200,8 +181,7 @@ func (m AWSStorage) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -245,6 +225,16 @@ func (m *AWSStorage) validateRegion(formats strfmt.Registry) error { return nil } +// ContextValidate validate this a w s storage based on the context it is used +func (m *AWSStorage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *AWSStorage) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/api_key.go b/client/models/api_key.go index 227554ad..c813610e 100644 --- a/client/models/api_key.go +++ b/client/models/api_key.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // APIKey API key // // The entity which represents the information of an API key. The "token" field is only filled once, upon creation +// // swagger:model APIKey type APIKey struct { @@ -102,15 +103,15 @@ func (m *APIKey) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -123,7 +124,7 @@ func (m *APIKey) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -145,7 +146,7 @@ func (m *APIKey) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -153,7 +154,6 @@ func (m *APIKey) validateName(formats strfmt.Registry) error { } func (m *APIKey) validateOwner(formats strfmt.Registry) error { - if swag.IsZero(m.Owner) { // not required return nil } @@ -162,6 +162,8 @@ func (m *APIKey) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -185,6 +187,72 @@ func (m *APIKey) validateRules(formats strfmt.Registry) error { if err := m.Rules[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this API key based on the context it is used +func (m *APIKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateRules(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIKey) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if swag.IsZero(m.Owner) { // not required + return nil + } + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + +func (m *APIKey) contextValidateRules(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Rules); i++ { + + if m.Rules[i] != nil { + + if swag.IsZero(m.Rules[i]) { // not required + return nil + } + + if err := m.Rules[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rules" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/app_config.go b/client/models/app_config.go index 851b9526..e39b8ef9 100644 --- a/client/models/app_config.go +++ b/client/models/app_config.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // AppConfig AppConfig // // Global app configuration that includes all the settings and capabilities of the Cycloid instance. It is intended to be used by clients to modify the UI accordingly. +// // swagger:model AppConfig type AppConfig struct { @@ -48,6 +50,39 @@ func (m *AppConfig) validateAuthentication(formats strfmt.Registry) error { if err := m.Authentication.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + } + + return nil +} + +// ContextValidate validate this app config based on the context it is used +func (m *AppConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentication(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AppConfig) contextValidateAuthentication(ctx context.Context, formats strfmt.Registry) error { + + if m.Authentication != nil { + + if err := m.Authentication.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") } return err } diff --git a/client/models/app_version.go b/client/models/app_version.go index 0ded69cf..40377836 100644 --- a/client/models/app_version.go +++ b/client/models/app_version.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // AppVersion AppVersion +// // swagger:model AppVersion type AppVersion struct { @@ -62,7 +64,7 @@ func (m *AppVersion) validateBranch(formats strfmt.Registry) error { return err } - if err := validate.MinLength("branch", "body", string(*m.Branch), 1); err != nil { + if err := validate.MinLength("branch", "body", *m.Branch, 1); err != nil { return err } @@ -75,11 +77,11 @@ func (m *AppVersion) validateRevision(formats strfmt.Registry) error { return err } - if err := validate.MinLength("revision", "body", string(*m.Revision), 8); err != nil { + if err := validate.MinLength("revision", "body", *m.Revision, 8); err != nil { return err } - if err := validate.MaxLength("revision", "body", string(*m.Revision), 40); err != nil { + if err := validate.MaxLength("revision", "body", *m.Revision, 40); err != nil { return err } @@ -92,13 +94,18 @@ func (m *AppVersion) validateVersion(formats strfmt.Registry) error { return err } - if err := validate.MinLength("version", "body", string(*m.Version), 5); err != nil { + if err := validate.MinLength("version", "body", *m.Version, 5); err != nil { return err } return nil } +// ContextValidate validates this app version based on context it is used +func (m *AppVersion) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *AppVersion) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/appearance.go b/client/models/appearance.go index 9794650a..ec0b8619 100644 --- a/client/models/appearance.go +++ b/client/models/appearance.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Appearance Appearance // -// An Appearance holds the values of the branding configuration, which are rendered across an organization +// # An Appearance holds the values of the branding configuration, which are rendered across an organization +// // swagger:model Appearance type Appearance struct { @@ -132,15 +134,15 @@ func (m *Appearance) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -157,6 +159,8 @@ func (m *Appearance) validateColor(formats strfmt.Registry) error { if err := m.Color.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("color") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("color") } return err } @@ -166,12 +170,11 @@ func (m *Appearance) validateColor(formats strfmt.Registry) error { } func (m *Appearance) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -184,11 +187,11 @@ func (m *Appearance) validateDisplayName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("display_name", "body", string(*m.DisplayName), 1); err != nil { + if err := validate.MinLength("display_name", "body", *m.DisplayName, 1); err != nil { return err } - if err := validate.MaxLength("display_name", "body", string(*m.DisplayName), 50); err != nil { + if err := validate.MaxLength("display_name", "body", *m.DisplayName, 50); err != nil { return err } @@ -214,11 +217,11 @@ func (m *Appearance) validateFooter(formats strfmt.Registry) error { return err } - if err := validate.MinLength("footer", "body", string(*m.Footer), 0); err != nil { + if err := validate.MinLength("footer", "body", *m.Footer, 0); err != nil { return err } - if err := validate.MaxLength("footer", "body", string(*m.Footer), 1000); err != nil { + if err := validate.MaxLength("footer", "body", *m.Footer, 1000); err != nil { return err } @@ -244,11 +247,11 @@ func (m *Appearance) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { return err } - if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil { + if err := validate.MaxLength("name", "body", *m.Name, 50); err != nil { return err } @@ -261,11 +264,11 @@ func (m *Appearance) validateTabTitle(formats strfmt.Registry) error { return err } - if err := validate.MinLength("tab_title", "body", string(*m.TabTitle), 1); err != nil { + if err := validate.MinLength("tab_title", "body", *m.TabTitle, 1); err != nil { return err } - if err := validate.MaxLength("tab_title", "body", string(*m.TabTitle), 50); err != nil { + if err := validate.MaxLength("tab_title", "body", *m.TabTitle, 50); err != nil { return err } @@ -273,18 +276,48 @@ func (m *Appearance) validateTabTitle(formats strfmt.Registry) error { } func (m *Appearance) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this appearance based on the context it is used +func (m *Appearance) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateColor(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Appearance) contextValidateColor(ctx context.Context, formats strfmt.Registry) error { + + if m.Color != nil { + + if err := m.Color.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("color") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("color") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Appearance) MarshalBinary() ([]byte, error) { if m == nil { @@ -304,6 +337,7 @@ func (m *Appearance) UnmarshalBinary(b []byte) error { } // AppearanceColor appearance color +// // swagger:model AppearanceColor type AppearanceColor struct { @@ -354,11 +388,11 @@ func (m *AppearanceColor) validateB(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("color"+"."+"b", "body", int64(*m.B), 0, false); err != nil { + if err := validate.MinimumUint("color"+"."+"b", "body", uint64(*m.B), 0, false); err != nil { return err } - if err := validate.MaximumInt("color"+"."+"b", "body", int64(*m.B), 255, false); err != nil { + if err := validate.MaximumUint("color"+"."+"b", "body", uint64(*m.B), 255, false); err != nil { return err } @@ -371,11 +405,11 @@ func (m *AppearanceColor) validateG(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("color"+"."+"g", "body", int64(*m.G), 0, false); err != nil { + if err := validate.MinimumUint("color"+"."+"g", "body", uint64(*m.G), 0, false); err != nil { return err } - if err := validate.MaximumInt("color"+"."+"g", "body", int64(*m.G), 255, false); err != nil { + if err := validate.MaximumUint("color"+"."+"g", "body", uint64(*m.G), 255, false); err != nil { return err } @@ -388,17 +422,22 @@ func (m *AppearanceColor) validateR(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("color"+"."+"r", "body", int64(*m.R), 0, false); err != nil { + if err := validate.MinimumUint("color"+"."+"r", "body", uint64(*m.R), 0, false); err != nil { return err } - if err := validate.MaximumInt("color"+"."+"r", "body", int64(*m.R), 255, false); err != nil { + if err := validate.MaximumUint("color"+"."+"r", "body", uint64(*m.R), 255, false); err != nil { return err } return nil } +// ContextValidate validates this appearance color based on context it is used +func (m *AppearanceColor) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *AppearanceColor) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/auth_config.go b/client/models/auth_config.go index c84b9b3c..dc53e965 100644 --- a/client/models/auth_config.go +++ b/client/models/auth_config.go @@ -7,19 +7,20 @@ package models import ( "bytes" + "context" "encoding/json" "io" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // AuthConfig AuthConfig +// // swagger:model AuthConfig type AuthConfig struct { @@ -95,8 +96,7 @@ func (m AuthConfig) MarshalJSON() ([]byte, error) { Local: m.Local, Saml2: m.Saml2, - }, - ) + }) if err != nil { return nil, err } @@ -105,8 +105,7 @@ func (m AuthConfig) MarshalJSON() ([]byte, error) { }{ Oauth: m.oauthField, - }, - ) + }) if err != nil { return nil, err } @@ -146,6 +145,8 @@ func (m *AuthConfig) validateLocal(formats strfmt.Registry) error { if err := m.Local.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("local") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("local") } return err } @@ -165,6 +166,8 @@ func (m *AuthConfig) validateOauth(formats strfmt.Registry) error { if err := m.oauthField[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("oauth" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("oauth" + "." + strconv.Itoa(i)) } return err } @@ -189,6 +192,94 @@ func (m *AuthConfig) validateSaml2(formats strfmt.Registry) error { if err := m.Saml2[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("saml2" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("saml2" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this auth config based on the context it is used +func (m *AuthConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLocal(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOauth(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSaml2(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AuthConfig) contextValidateLocal(ctx context.Context, formats strfmt.Registry) error { + + if m.Local != nil { + + if err := m.Local.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("local") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("local") + } + return err + } + } + + return nil +} + +func (m *AuthConfig) contextValidateOauth(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Oauth()); i++ { + + if swag.IsZero(m.oauthField[i]) { // not required + return nil + } + + if err := m.oauthField[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oauth" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("oauth" + "." + strconv.Itoa(i)) + } + return err + } + + } + + return nil +} + +func (m *AuthConfig) contextValidateSaml2(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Saml2); i++ { + + if m.Saml2[i] != nil { + + if swag.IsZero(m.Saml2[i]) { // not required + return nil + } + + if err := m.Saml2[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("saml2" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("saml2" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/auth_config_local_auth.go b/client/models/auth_config_local_auth.go index 8139bfca..5a8ade19 100644 --- a/client/models/auth_config_local_auth.go +++ b/client/models/auth_config_local_auth.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // AuthConfigLocalAuth AppConfigLocalAuth +// // swagger:model AuthConfigLocalAuth type AuthConfigLocalAuth struct { @@ -45,6 +47,11 @@ func (m *AuthConfigLocalAuth) validateEnabled(formats strfmt.Registry) error { return nil } +// ContextValidate validates this auth config local auth based on context it is used +func (m *AuthConfigLocalAuth) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *AuthConfigLocalAuth) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/auth_config_o_auth.go b/client/models/auth_config_o_auth.go index cbf0924a..107eb340 100644 --- a/client/models/auth_config_o_auth.go +++ b/client/models/auth_config_o_auth.go @@ -7,21 +7,22 @@ package models import ( "bytes" + "context" "encoding/json" "io" - "io/ioutil" - - strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" ) // AuthConfigOAuth AppConfigAuthOAuth +// // swagger:discriminator AuthConfigOAuth type type AuthConfigOAuth interface { runtime.Validatable + runtime.ContextValidatable // ID of the OAuth client. // Required: true @@ -37,6 +38,9 @@ type AuthConfigOAuth interface { // Required: true Type() string SetType(string) + + // AdditionalProperties in base type shoud be handled just like regular properties + // At this moment, the base type property is pushed down to the subtype } type authConfigOAuth struct { @@ -74,7 +78,6 @@ func (m *authConfigOAuth) Type() string { // SetType sets the type of this polymorphic type func (m *authConfigOAuth) SetType(val string) { - } // UnmarshalAuthConfigOAuthSlice unmarshals polymorphic slices of AuthConfigOAuth @@ -98,7 +101,7 @@ func UnmarshalAuthConfigOAuthSlice(reader io.Reader, consumer runtime.Consumer) // UnmarshalAuthConfigOAuth unmarshals polymorphic AuthConfigOAuth func UnmarshalAuthConfigOAuth(reader io.Reader, consumer runtime.Consumer) (AuthConfigOAuth, error) { // we need to read this twice, so first into a buffer - data, err := ioutil.ReadAll(reader) + data, err := io.ReadAll(reader) if err != nil { return nil, err } @@ -129,31 +132,26 @@ func unmarshalAuthConfigOAuth(data []byte, consumer runtime.Consumer) (AuthConfi return nil, err } return &result, nil - case "AzureADAuthConfig": var result AzureADAuthConfig if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "GitHubOAuthConfig": var result GitHubOAuthConfig if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "GoogleOAuthConfig": var result GoogleOAuthConfig if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - } return nil, errors.New(422, "invalid type value: %q", getType.Type) - } // Validate validates this auth config o auth @@ -191,3 +189,8 @@ func (m *authConfigOAuth) validateProvider(formats strfmt.Registry) error { return nil } + +// ContextValidate validates this auth config o auth based on context it is used +func (m *authConfigOAuth) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/client/models/auth_config_s_a_m_l.go b/client/models/auth_config_s_a_m_l.go index 27f7170e..50e8009d 100644 --- a/client/models/auth_config_s_a_m_l.go +++ b/client/models/auth_config_s_a_m_l.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // AuthConfigSAML AppConfigSAML +// // swagger:model AuthConfigSAML type AuthConfigSAML struct { @@ -67,6 +69,11 @@ func (m *AuthConfigSAML) validateSsoURL(formats strfmt.Registry) error { return nil } +// ContextValidate validates this auth config s a m l based on context it is used +func (m *AuthConfigSAML) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *AuthConfigSAML) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/azure_a_d_auth_config.go b/client/models/azure_a_d_auth_config.go index 7270bce3..d45796f3 100644 --- a/client/models/azure_a_d_auth_config.go +++ b/client/models/azure_a_d_auth_config.go @@ -7,18 +7,19 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // AzureADAuthConfig AppConfigAzureADOAuth // -// AzureAD OAuth configuration +// # AzureAD OAuth configuration +// // swagger:model AzureADAuthConfig type AzureADAuthConfig struct { clientIdField *string @@ -57,11 +58,8 @@ func (m *AzureADAuthConfig) Type() string { // SetType sets the type of this subtype func (m *AzureADAuthConfig) SetType(val string) { - } -// TenantID gets the tenant id of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *AzureADAuthConfig) UnmarshalJSON(raw []byte) error { var data struct { @@ -125,8 +123,7 @@ func (m AzureADAuthConfig) MarshalJSON() ([]byte, error) { }{ TenantID: m.TenantID, - }, - ) + }) if err != nil { return nil, err } @@ -143,8 +140,7 @@ func (m AzureADAuthConfig) MarshalJSON() ([]byte, error) { Provider: m.Provider(), Type: m.Type(), - }, - ) + }) if err != nil { return nil, err } @@ -201,6 +197,16 @@ func (m *AzureADAuthConfig) validateTenantID(formats strfmt.Registry) error { return nil } +// ContextValidate validate this azure a d auth config based on the context it is used +func (m *AzureADAuthConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *AzureADAuthConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/azure_cost_export.go b/client/models/azure_cost_export.go index 1572002a..b2c63c5a 100644 --- a/client/models/azure_cost_export.go +++ b/client/models/azure_cost_export.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) @@ -38,15 +38,8 @@ func (m *AzureCostExport) Engine() string { // SetEngine sets the engine of this subtype func (m *AzureCostExport) SetEngine(val string) { - } -// BlobServiceURL gets the blob service url of this subtype - -// Name gets the name of this subtype - -// Scope gets the scope of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *AzureCostExport) UnmarshalJSON(raw []byte) error { var data struct { @@ -89,9 +82,7 @@ func (m *AzureCostExport) UnmarshalJSON(raw []byte) error { } result.BlobServiceURL = data.BlobServiceURL - result.Name = data.Name - result.Scope = data.Scope *m = result @@ -120,8 +111,7 @@ func (m AzureCostExport) MarshalJSON() ([]byte, error) { Name: m.Name, Scope: m.Scope, - }, - ) + }) if err != nil { return nil, err } @@ -130,8 +120,7 @@ func (m AzureCostExport) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -149,6 +138,16 @@ func (m *AzureCostExport) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validate this azure cost export based on the context it is used +func (m *AzureCostExport) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *AzureCostExport) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/azure_remote_t_f_state.go b/client/models/azure_remote_t_f_state.go index 03dfa808..56b903f0 100644 --- a/client/models/azure_remote_t_f_state.go +++ b/client/models/azure_remote_t_f_state.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -47,15 +47,8 @@ func (m *AzureRemoteTFState) Engine() string { // SetEngine sets the engine of this subtype func (m *AzureRemoteTFState) SetEngine(val string) { - } -// Blob gets the blob of this subtype - -// Container gets the container of this subtype - -// Endpoint gets the endpoint of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *AzureRemoteTFState) UnmarshalJSON(raw []byte) error { var data struct { @@ -105,9 +98,7 @@ func (m *AzureRemoteTFState) UnmarshalJSON(raw []byte) error { } result.Blob = data.Blob - result.Container = data.Container - result.Endpoint = data.Endpoint *m = result @@ -143,8 +134,7 @@ func (m AzureRemoteTFState) MarshalJSON() ([]byte, error) { Container: m.Container, Endpoint: m.Endpoint, - }, - ) + }) if err != nil { return nil, err } @@ -153,8 +143,7 @@ func (m AzureRemoteTFState) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -185,6 +174,16 @@ func (m *AzureRemoteTFState) validateContainer(formats strfmt.Registry) error { return nil } +// ContextValidate validate this azure remote t f state based on the context it is used +func (m *AzureRemoteTFState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *AzureRemoteTFState) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/azure_storage.go b/client/models/azure_storage.go index d2703053..d7601763 100644 --- a/client/models/azure_storage.go +++ b/client/models/azure_storage.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -46,15 +46,8 @@ func (m *AzureStorage) Engine() string { // SetEngine sets the engine of this subtype func (m *AzureStorage) SetEngine(val string) { - } -// Blob gets the blob of this subtype - -// Container gets the container of this subtype - -// Endpoint gets the endpoint of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *AzureStorage) UnmarshalJSON(raw []byte) error { var data struct { @@ -104,9 +97,7 @@ func (m *AzureStorage) UnmarshalJSON(raw []byte) error { } result.Blob = data.Blob - result.Container = data.Container - result.Endpoint = data.Endpoint *m = result @@ -142,8 +133,7 @@ func (m AzureStorage) MarshalJSON() ([]byte, error) { Container: m.Container, Endpoint: m.Endpoint, - }, - ) + }) if err != nil { return nil, err } @@ -152,8 +142,7 @@ func (m AzureStorage) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -184,6 +173,16 @@ func (m *AzureStorage) validateContainer(formats strfmt.Registry) error { return nil } +// ContextValidate validate this azure storage based on the context it is used +func (m *AzureStorage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *AzureStorage) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/build.go b/client/models/build.go index e039e6fc..6ba04524 100644 --- a/client/models/build.go +++ b/client/models/build.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // Build Build // // The information relative to a build. +// // swagger:model Build type Build struct { @@ -133,6 +135,11 @@ func (m *Build) validateTeamName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this build based on context it is used +func (m *Build) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Build) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/build_inputs_outputs.go b/client/models/build_inputs_outputs.go index 7857751b..d5d72c83 100644 --- a/client/models/build_inputs_outputs.go +++ b/client/models/build_inputs_outputs.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // BuildInputsOutputs BuildInputsOutputs // // Represent the resources input/output related to a build +// // swagger:model BuildInputsOutputs type BuildInputsOutputs struct { @@ -63,6 +64,8 @@ func (m *BuildInputsOutputs) validateInputs(formats strfmt.Registry) error { if err := m.Inputs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) } return err } @@ -88,6 +91,76 @@ func (m *BuildInputsOutputs) validateOutputs(formats strfmt.Registry) error { if err := m.Outputs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("outputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("outputs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this build inputs outputs based on the context it is used +func (m *BuildInputsOutputs) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInputs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOutputs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BuildInputsOutputs) contextValidateInputs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Inputs); i++ { + + if m.Inputs[i] != nil { + + if swag.IsZero(m.Inputs[i]) { // not required + return nil + } + + if err := m.Inputs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *BuildInputsOutputs) contextValidateOutputs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Outputs); i++ { + + if m.Outputs[i] != nil { + + if swag.IsZero(m.Outputs[i]) { // not required + return nil + } + + if err := m.Outputs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("outputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("outputs" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/build_summary.go b/client/models/build_summary.go index d8cbfc77..dc763f93 100644 --- a/client/models/build_summary.go +++ b/client/models/build_summary.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // BuildSummary BuildSummary // // The information relative to a build summary. +// // swagger:model BuildSummary type BuildSummary struct { @@ -116,6 +118,11 @@ func (m *BuildSummary) validateTeamName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this build summary based on context it is used +func (m *BuildSummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *BuildSummary) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/c_i_version.go b/client/models/c_i_version.go index 992a7f15..b04b5b30 100644 --- a/client/models/c_i_version.go +++ b/client/models/c_i_version.go @@ -6,12 +6,15 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + + "github.com/go-openapi/strfmt" ) // CIVersion CIVersion // -// Represent a version of a resource +// # Represent a version of a resource +// // swagger:model CIVersion type CIVersion map[string]string @@ -19,3 +22,8 @@ type CIVersion map[string]string func (m CIVersion) Validate(formats strfmt.Registry) error { return nil } + +// ContextValidate validates this c i version based on context it is used +func (m CIVersion) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/client/models/can_do_input.go b/client/models/can_do_input.go index 841c91fe..b8be03a3 100644 --- a/client/models/can_do_input.go +++ b/client/models/can_do_input.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // CanDoInput CanDoInput // // The input of the 'can_do' endpoint +// // swagger:model CanDoInput type CanDoInput struct { @@ -64,6 +66,11 @@ func (m *CanDoInput) validateEntityCanonicals(formats strfmt.Registry) error { return nil } +// ContextValidate validates this can do input based on context it is used +func (m *CanDoInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CanDoInput) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/can_do_output.go b/client/models/can_do_output.go index 5a74270b..4b6ad213 100644 --- a/client/models/can_do_output.go +++ b/client/models/can_do_output.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // CanDoOutput CanDoOutput // // The output of the 'can_do' endpoint +// // swagger:model CanDoOutput type CanDoOutput struct { @@ -50,6 +52,11 @@ func (m *CanDoOutput) validateOk(formats strfmt.Registry) error { return nil } +// ContextValidate validates this can do output based on context it is used +func (m *CanDoOutput) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CanDoOutput) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/check_report.go b/client/models/check_report.go index 967477aa..0aa8c3ad 100644 --- a/client/models/check_report.go +++ b/client/models/check_report.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // CheckReport CheckReport +// // swagger:model CheckReport type CheckReport struct { @@ -36,7 +37,7 @@ type CheckReport struct { // The status of the service checked. // Required: true - // Enum: [Unknown Success Error] + // Enum: ["Unknown","Success","Error"] Status *string `json:"status"` } @@ -72,7 +73,7 @@ func (m *CheckReport) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 1); err != nil { return err } @@ -85,7 +86,7 @@ func (m *CheckReport) validateCategory(formats strfmt.Registry) error { return err } - if err := validate.MinLength("category", "body", string(*m.Category), 1); err != nil { + if err := validate.MinLength("category", "body", *m.Category, 1); err != nil { return err } @@ -98,7 +99,7 @@ func (m *CheckReport) validateMessage(formats strfmt.Registry) error { return err } - if err := validate.MinLength("message", "body", string(*m.Message), 1); err != nil { + if err := validate.MinLength("message", "body", *m.Message, 1); err != nil { return err } @@ -131,7 +132,7 @@ const ( // prop value enum func (m *CheckReport) validateStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, checkReportTypeStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, checkReportTypeStatusPropEnum, true); err != nil { return err } return nil @@ -151,6 +152,11 @@ func (m *CheckReport) validateStatus(formats strfmt.Registry) error { return nil } +// ContextValidate validates this check report based on context it is used +func (m *CheckReport) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CheckReport) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/clear_task_cache.go b/client/models/clear_task_cache.go index 0abb1a3f..7a4f83d8 100644 --- a/client/models/clear_task_cache.go +++ b/client/models/clear_task_cache.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // ClearTaskCache ClearTaskCache // // The entity which represents number of cache cleared for a task. +// // swagger:model ClearTaskCache type ClearTaskCache struct { @@ -47,6 +49,11 @@ func (m *ClearTaskCache) validateCachesRemoved(formats strfmt.Registry) error { return nil } +// ContextValidate validates this clear task cache based on context it is used +func (m *ClearTaskCache) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ClearTaskCache) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_cost_management_account.go b/client/models/cloud_cost_management_account.go index 886c548c..0c4d2b57 100644 --- a/client/models/cloud_cost_management_account.go +++ b/client/models/cloud_cost_management_account.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // CloudCostManagementAccount CloudCostManagementAccount // -// Object containing Cloud Cost Management account parameters +// # Object containing Cloud Cost Management account parameters +// // swagger:model CloudCostManagementAccount type CloudCostManagementAccount struct { @@ -72,12 +73,12 @@ type CloudCostManagementAccount struct { ParentAccountID string `json:"parent_account_id,omitempty"` // phase - // Enum: [green blue] + // Enum: ["green","blue"] Phase string `json:"phase,omitempty"` // status // Required: true - // Enum: [idle error import] + // Enum: ["idle","error","import"] Status *string `json:"status"` // status message @@ -173,15 +174,15 @@ func (m *CloudCostManagementAccount) validateCanonical(formats strfmt.Registry) return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -198,6 +199,8 @@ func (m *CloudCostManagementAccount) validateCloudProvider(formats strfmt.Regist if err := m.CloudProvider.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("cloud_provider") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloud_provider") } return err } @@ -212,7 +215,7 @@ func (m *CloudCostManagementAccount) validateCreatedAt(formats strfmt.Registry) return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -220,7 +223,6 @@ func (m *CloudCostManagementAccount) validateCreatedAt(formats strfmt.Registry) } func (m *CloudCostManagementAccount) validateCredential(formats strfmt.Registry) error { - if swag.IsZero(m.Credential) { // not required return nil } @@ -229,6 +231,8 @@ func (m *CloudCostManagementAccount) validateCredential(formats strfmt.Registry) if err := m.Credential.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("credential") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("credential") } return err } @@ -247,7 +251,6 @@ func (m *CloudCostManagementAccount) validateEnabled(formats strfmt.Registry) er } func (m *CloudCostManagementAccount) validateExternalBackend(formats strfmt.Registry) error { - if swag.IsZero(m.ExternalBackend) { // not required return nil } @@ -256,6 +259,8 @@ func (m *CloudCostManagementAccount) validateExternalBackend(formats strfmt.Regi if err := m.ExternalBackend.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("external_backend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backend") } return err } @@ -270,7 +275,7 @@ func (m *CloudCostManagementAccount) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -278,12 +283,11 @@ func (m *CloudCostManagementAccount) validateID(formats strfmt.Registry) error { } func (m *CloudCostManagementAccount) validateLastIngestionEndedAt(formats strfmt.Registry) error { - if swag.IsZero(m.LastIngestionEndedAt) { // not required return nil } - if err := validate.MinimumInt("last_ingestion_ended_at", "body", int64(*m.LastIngestionEndedAt), 0, false); err != nil { + if err := validate.MinimumUint("last_ingestion_ended_at", "body", *m.LastIngestionEndedAt, 0, false); err != nil { return err } @@ -291,12 +295,11 @@ func (m *CloudCostManagementAccount) validateLastIngestionEndedAt(formats strfmt } func (m *CloudCostManagementAccount) validateLastIngestionStartedAt(formats strfmt.Registry) error { - if swag.IsZero(m.LastIngestionStartedAt) { // not required return nil } - if err := validate.MinimumInt("last_ingestion_started_at", "body", int64(*m.LastIngestionStartedAt), 0, false); err != nil { + if err := validate.MinimumUint("last_ingestion_started_at", "body", *m.LastIngestionStartedAt, 0, false); err != nil { return err } @@ -335,14 +338,13 @@ const ( // prop value enum func (m *CloudCostManagementAccount) validatePhaseEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, cloudCostManagementAccountTypePhasePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, cloudCostManagementAccountTypePhasePropEnum, true); err != nil { return err } return nil } func (m *CloudCostManagementAccount) validatePhase(formats strfmt.Registry) error { - if swag.IsZero(m.Phase) { // not required return nil } @@ -381,7 +383,7 @@ const ( // prop value enum func (m *CloudCostManagementAccount) validateStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, cloudCostManagementAccountTypeStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, cloudCostManagementAccountTypeStatusPropEnum, true); err != nil { return err } return nil @@ -407,13 +409,94 @@ func (m *CloudCostManagementAccount) validateUpdatedAt(formats strfmt.Registry) return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this cloud cost management account based on the context it is used +func (m *CloudCostManagementAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCloudProvider(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateCredential(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateExternalBackend(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementAccount) contextValidateCloudProvider(ctx context.Context, formats strfmt.Registry) error { + + if m.CloudProvider != nil { + + if err := m.CloudProvider.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloud_provider") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloud_provider") + } + return err + } + } + + return nil +} + +func (m *CloudCostManagementAccount) contextValidateCredential(ctx context.Context, formats strfmt.Registry) error { + + if m.Credential != nil { + + if swag.IsZero(m.Credential) { // not required + return nil + } + + if err := m.Credential.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("credential") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("credential") + } + return err + } + } + + return nil +} + +func (m *CloudCostManagementAccount) contextValidateExternalBackend(ctx context.Context, formats strfmt.Registry) error { + + if m.ExternalBackend != nil { + + if swag.IsZero(m.ExternalBackend) { // not required + return nil + } + + if err := m.ExternalBackend.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("external_backend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backend") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *CloudCostManagementAccount) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_cost_management_account_parent.go b/client/models/cloud_cost_management_account_parent.go index c7167aba..79ecf091 100644 --- a/client/models/cloud_cost_management_account_parent.go +++ b/client/models/cloud_cost_management_account_parent.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -67,7 +67,7 @@ type CloudCostManagementAccountParent struct { // status // Required: true - // Enum: [idle error import] + // Enum: ["idle","error","import"] Status *string `json:"status"` // status message @@ -148,15 +148,15 @@ func (m *CloudCostManagementAccountParent) validateCanonical(formats strfmt.Regi return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -173,6 +173,8 @@ func (m *CloudCostManagementAccountParent) validateCloudProvider(formats strfmt. if err := m.CloudProvider.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("cloud_provider") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloud_provider") } return err } @@ -187,7 +189,7 @@ func (m *CloudCostManagementAccountParent) validateCreatedAt(formats strfmt.Regi return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -209,7 +211,7 @@ func (m *CloudCostManagementAccountParent) validateID(formats strfmt.Registry) e return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -217,12 +219,11 @@ func (m *CloudCostManagementAccountParent) validateID(formats strfmt.Registry) e } func (m *CloudCostManagementAccountParent) validateLastIngestionEndedAt(formats strfmt.Registry) error { - if swag.IsZero(m.LastIngestionEndedAt) { // not required return nil } - if err := validate.MinimumInt("last_ingestion_ended_at", "body", int64(*m.LastIngestionEndedAt), 0, false); err != nil { + if err := validate.MinimumUint("last_ingestion_ended_at", "body", *m.LastIngestionEndedAt, 0, false); err != nil { return err } @@ -230,12 +231,11 @@ func (m *CloudCostManagementAccountParent) validateLastIngestionEndedAt(formats } func (m *CloudCostManagementAccountParent) validateLastIngestionStartedAt(formats strfmt.Registry) error { - if swag.IsZero(m.LastIngestionStartedAt) { // not required return nil } - if err := validate.MinimumInt("last_ingestion_started_at", "body", int64(*m.LastIngestionStartedAt), 0, false); err != nil { + if err := validate.MinimumUint("last_ingestion_started_at", "body", *m.LastIngestionStartedAt, 0, false); err != nil { return err } @@ -277,7 +277,7 @@ const ( // prop value enum func (m *CloudCostManagementAccountParent) validateStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, cloudCostManagementAccountParentTypeStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, cloudCostManagementAccountParentTypeStatusPropEnum, true); err != nil { return err } return nil @@ -303,13 +303,44 @@ func (m *CloudCostManagementAccountParent) validateUpdatedAt(formats strfmt.Regi return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this cloud cost management account parent based on the context it is used +func (m *CloudCostManagementAccountParent) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCloudProvider(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementAccountParent) contextValidateCloudProvider(ctx context.Context, formats strfmt.Registry) error { + + if m.CloudProvider != nil { + + if err := m.CloudProvider.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloud_provider") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloud_provider") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *CloudCostManagementAccountParent) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_cost_management_bucket.go b/client/models/cloud_cost_management_bucket.go index 087dd77a..642043f8 100644 --- a/client/models/cloud_cost_management_bucket.go +++ b/client/models/cloud_cost_management_bucket.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -81,7 +81,6 @@ func (m *CloudCostManagementBucket) Validate(formats strfmt.Registry) error { } func (m *CloudCostManagementBucket) validateBuckets(formats strfmt.Registry) error { - if swag.IsZero(m.Buckets) { // not required return nil } @@ -95,6 +94,8 @@ func (m *CloudCostManagementBucket) validateBuckets(formats strfmt.Registry) err if err := m.Buckets[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("buckets" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("buckets" + "." + strconv.Itoa(i)) } return err } @@ -141,6 +142,45 @@ func (m *CloudCostManagementBucket) validateValue(formats strfmt.Registry) error return nil } +// ContextValidate validate this cloud cost management bucket based on the context it is used +func (m *CloudCostManagementBucket) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBuckets(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementBucket) contextValidateBuckets(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Buckets); i++ { + + if m.Buckets[i] != nil { + + if swag.IsZero(m.Buckets[i]) { // not required + return nil + } + + if err := m.Buckets[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("buckets" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("buckets" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *CloudCostManagementBucket) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_cost_management_dashboard.go b/client/models/cloud_cost_management_dashboard.go index 66abe782..5c8f76c7 100644 --- a/client/models/cloud_cost_management_dashboard.go +++ b/client/models/cloud_cost_management_dashboard.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,13 +18,13 @@ import ( // CloudCostManagementDashboard CloudCostManagementDashboard // // The dashboard of the Cloud Cost Management, it contains -// - a histogram of the cost in the period aggregated by provider and -// by time granularity -// - a histogram of the cost aggregated by the top projects and providers -// and filtered by the top projects -// - a list of resources and relative cost for each top projects -// - a map containing properties that can be specified filtering the -// returned results, with a set of valid values for each. +// - a histogram of the cost in the period aggregated by provider and +// by time granularity +// - a histogram of the cost aggregated by the top projects and providers +// and filtered by the top projects +// - a list of resources and relative cost for each top projects +// - a map containing properties that can be specified filtering the +// returned results, with a set of valid values for each. // // swagger:model CloudCostManagementDashboard type CloudCostManagementDashboard struct { @@ -91,6 +91,8 @@ func (m *CloudCostManagementDashboard) validateFilterValues(formats strfmt.Regis if err := m.FilterValues.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("filter_values") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("filter_values") } return err } @@ -114,6 +116,8 @@ func (m *CloudCostManagementDashboard) validateProjectResources(formats strfmt.R if err := m.ProjectResources[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("project_resources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project_resources" + "." + strconv.Itoa(i)) } return err } @@ -134,6 +138,8 @@ func (m *CloudCostManagementDashboard) validateProjects(formats strfmt.Registry) if err := m.Projects.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("projects") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("projects") } return err } @@ -152,6 +158,110 @@ func (m *CloudCostManagementDashboard) validateProviders(formats strfmt.Registry if err := m.Providers.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("providers") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("providers") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud cost management dashboard based on the context it is used +func (m *CloudCostManagementDashboard) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateFilterValues(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProjectResources(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProjects(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProviders(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementDashboard) contextValidateFilterValues(ctx context.Context, formats strfmt.Registry) error { + + if m.FilterValues != nil { + + if err := m.FilterValues.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("filter_values") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("filter_values") + } + return err + } + } + + return nil +} + +func (m *CloudCostManagementDashboard) contextValidateProjectResources(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ProjectResources); i++ { + + if m.ProjectResources[i] != nil { + + if swag.IsZero(m.ProjectResources[i]) { // not required + return nil + } + + if err := m.ProjectResources[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project_resources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project_resources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CloudCostManagementDashboard) contextValidateProjects(ctx context.Context, formats strfmt.Registry) error { + + if m.Projects != nil { + + if err := m.Projects.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("projects") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("projects") + } + return err + } + } + + return nil +} + +func (m *CloudCostManagementDashboard) contextValidateProviders(ctx context.Context, formats strfmt.Registry) error { + + if m.Providers != nil { + + if err := m.Providers.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("providers") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("providers") } return err } diff --git a/client/models/cloud_cost_management_filter_values.go b/client/models/cloud_cost_management_filter_values.go index 0481f4b3..d9eee873 100644 --- a/client/models/cloud_cost_management_filter_values.go +++ b/client/models/cloud_cost_management_filter_values.go @@ -6,8 +6,9 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) @@ -67,6 +68,11 @@ func (m *CloudCostManagementFilterValues) Validate(formats strfmt.Registry) erro return nil } +// ContextValidate validates this cloud cost management filter values based on context it is used +func (m *CloudCostManagementFilterValues) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CloudCostManagementFilterValues) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_cost_management_histogram.go b/client/models/cloud_cost_management_histogram.go index 1b3068be..110c3cd0 100644 --- a/client/models/cloud_cost_management_histogram.go +++ b/client/models/cloud_cost_management_histogram.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // CloudCostManagementHistogram CloudCostManagementHistogram // // The histogram of the costs for a period composed of buckets that aggregate the costs. +// // swagger:model CloudCostManagementHistogram type CloudCostManagementHistogram struct { @@ -79,6 +80,8 @@ func (m *CloudCostManagementHistogram) validateBuckets(formats strfmt.Registry) if err := m.Buckets[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("buckets" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("buckets" + "." + strconv.Itoa(i)) } return err } @@ -116,6 +119,45 @@ func (m *CloudCostManagementHistogram) validateKwh(formats strfmt.Registry) erro return nil } +// ContextValidate validate this cloud cost management histogram based on the context it is used +func (m *CloudCostManagementHistogram) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBuckets(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementHistogram) contextValidateBuckets(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Buckets); i++ { + + if m.Buckets[i] != nil { + + if swag.IsZero(m.Buckets[i]) { // not required + return nil + } + + if err := m.Buckets[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("buckets" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("buckets" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *CloudCostManagementHistogram) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_cost_management_linked_account.go b/client/models/cloud_cost_management_linked_account.go index 564cf060..872f3f06 100644 --- a/client/models/cloud_cost_management_linked_account.go +++ b/client/models/cloud_cost_management_linked_account.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -91,7 +92,7 @@ func (m *CloudCostManagementLinkedAccount) validateID(formats strfmt.Registry) e return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -107,6 +108,11 @@ func (m *CloudCostManagementLinkedAccount) validateName(formats strfmt.Registry) return nil } +// ContextValidate validates this cloud cost management linked account based on context it is used +func (m *CloudCostManagementLinkedAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CloudCostManagementLinkedAccount) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_cost_management_project_provider_resources.go b/client/models/cloud_cost_management_project_provider_resources.go index 4029fbd8..f4f4303d 100644 --- a/client/models/cloud_cost_management_project_provider_resources.go +++ b/client/models/cloud_cost_management_project_provider_resources.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // CloudCostManagementProjectProviderResources CloudCostManagementProjectProviderResources // -// Trend for a project +// # Trend for a project // // swagger:model CloudCostManagementProjectProviderResources type CloudCostManagementProjectProviderResources struct { @@ -133,6 +134,11 @@ func (m *CloudCostManagementProjectProviderResources) validateResources(formats return nil } +// ContextValidate validates this cloud cost management project provider resources based on context it is used +func (m *CloudCostManagementProjectProviderResources) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CloudCostManagementProjectProviderResources) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_cost_management_project_resources.go b/client/models/cloud_cost_management_project_resources.go index 0b1356ee..690100c7 100644 --- a/client/models/cloud_cost_management_project_resources.go +++ b/client/models/cloud_cost_management_project_resources.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -90,6 +90,47 @@ func (m *CloudCostManagementProjectResources) validateProviders(formats strfmt.R if err := m.Providers[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("providers" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("providers" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this cloud cost management project resources based on the context it is used +func (m *CloudCostManagementProjectResources) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateProviders(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementProjectResources) contextValidateProviders(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Providers); i++ { + + if m.Providers[i] != nil { + + if swag.IsZero(m.Providers[i]) { // not required + return nil + } + + if err := m.Providers[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("providers" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("providers" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/cloud_cost_management_projects_dashboard.go b/client/models/cloud_cost_management_projects_dashboard.go index 11adf952..f1fdb7d4 100644 --- a/client/models/cloud_cost_management_projects_dashboard.go +++ b/client/models/cloud_cost_management_projects_dashboard.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -59,6 +60,8 @@ func (m *CloudCostManagementProjectsDashboard) validateProjectProviders(formats if err := m.ProjectProviders.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("project_providers") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project_providers") } return err } @@ -77,6 +80,60 @@ func (m *CloudCostManagementProjectsDashboard) validateProjects(formats strfmt.R if err := m.Projects.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("projects") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("projects") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud cost management projects dashboard based on the context it is used +func (m *CloudCostManagementProjectsDashboard) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateProjectProviders(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProjects(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementProjectsDashboard) contextValidateProjectProviders(ctx context.Context, formats strfmt.Registry) error { + + if m.ProjectProviders != nil { + + if err := m.ProjectProviders.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project_providers") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project_providers") + } + return err + } + } + + return nil +} + +func (m *CloudCostManagementProjectsDashboard) contextValidateProjects(ctx context.Context, formats strfmt.Registry) error { + + if m.Projects != nil { + + if err := m.Projects.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("projects") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("projects") } return err } diff --git a/client/models/cloud_cost_management_provider_details.go b/client/models/cloud_cost_management_provider_details.go index 66a1b257..4b8f4787 100644 --- a/client/models/cloud_cost_management_provider_details.go +++ b/client/models/cloud_cost_management_provider_details.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // CloudCostManagementProviderDetails CloudCostManagementProviderDetails // -// Description of the costs of a specific provider +// # Description of the costs of a specific provider // // swagger:model CloudCostManagementProviderDetails type CloudCostManagementProviderDetails struct { @@ -56,6 +57,8 @@ func (m *CloudCostManagementProviderDetails) validateCostHistogram(formats strfm if err := m.CostHistogram.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("cost_histogram") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost_histogram") } return err } @@ -65,7 +68,6 @@ func (m *CloudCostManagementProviderDetails) validateCostHistogram(formats strfm } func (m *CloudCostManagementProviderDetails) validateFilterValues(formats strfmt.Registry) error { - if swag.IsZero(m.FilterValues) { // not required return nil } @@ -74,6 +76,64 @@ func (m *CloudCostManagementProviderDetails) validateFilterValues(formats strfmt if err := m.FilterValues.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("filter_values") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("filter_values") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud cost management provider details based on the context it is used +func (m *CloudCostManagementProviderDetails) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCostHistogram(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateFilterValues(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementProviderDetails) contextValidateCostHistogram(ctx context.Context, formats strfmt.Registry) error { + + if m.CostHistogram != nil { + + if err := m.CostHistogram.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost_histogram") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost_histogram") + } + return err + } + } + + return nil +} + +func (m *CloudCostManagementProviderDetails) contextValidateFilterValues(ctx context.Context, formats strfmt.Registry) error { + + if m.FilterValues != nil { + + if swag.IsZero(m.FilterValues) { // not required + return nil + } + + if err := m.FilterValues.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("filter_values") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("filter_values") } return err } diff --git a/client/models/cloud_cost_management_providers.go b/client/models/cloud_cost_management_providers.go index 978ba644..bf4d38b6 100644 --- a/client/models/cloud_cost_management_providers.go +++ b/client/models/cloud_cost_management_providers.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // CloudCostManagementProviders CloudCostManagementProviders // -// Date histogram of the cost of all the providers +// # Date histogram of the cost of all the providers // // swagger:model CloudCostManagementProviders type CloudCostManagementProviders struct { @@ -49,6 +50,39 @@ func (m *CloudCostManagementProviders) validateCostHistogram(formats strfmt.Regi if err := m.CostHistogram.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("cost_histogram") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost_histogram") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud cost management providers based on the context it is used +func (m *CloudCostManagementProviders) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCostHistogram(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudCostManagementProviders) contextValidateCostHistogram(ctx context.Context, formats strfmt.Registry) error { + + if m.CostHistogram != nil { + + if err := m.CostHistogram.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost_histogram") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost_histogram") } return err } diff --git a/client/models/cloud_cost_management_tag_mapping.go b/client/models/cloud_cost_management_tag_mapping.go index 8eac91ee..0d6a38e3 100644 --- a/client/models/cloud_cost_management_tag_mapping.go +++ b/client/models/cloud_cost_management_tag_mapping.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -82,7 +83,7 @@ func (m *CloudCostManagementTagMapping) validateCreatedAt(formats strfmt.Registr return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -95,7 +96,7 @@ func (m *CloudCostManagementTagMapping) validateID(formats strfmt.Registry) erro return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -108,13 +109,18 @@ func (m *CloudCostManagementTagMapping) validateUpdatedAt(formats strfmt.Registr return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validates this cloud cost management tag mapping based on context it is used +func (m *CloudCostManagementTagMapping) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CloudCostManagementTagMapping) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_provider.go b/client/models/cloud_provider.go index 04b68604..6d40ce03 100644 --- a/client/models/cloud_provider.go +++ b/client/models/cloud_provider.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // CloudProvider Cloud Provider // // CloudProvider represents a cloud provider. Those cloud providers are used to identify the scope of projects and/or stacks. +// // swagger:model CloudProvider type CloudProvider struct { @@ -31,7 +32,7 @@ type CloudProvider struct { // Max Length: 100 // Min Length: 3 // Pattern: ^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$ - // Enum: [aws google azurerm flexibleengine openstack scaleway vmware ovh alibaba oracle vsphere kubernetes] + // Enum: ["aws","google","azurerm","flexibleengine","openstack","scaleway","vmware","ovh","alibaba","oracle","vsphere","kubernetes"] Canonical *string `json:"canonical"` // created at @@ -91,16 +92,15 @@ func (m *CloudProvider) Validate(formats strfmt.Registry) error { } func (m *CloudProvider) validateAbbreviation(formats strfmt.Registry) error { - if swag.IsZero(m.Abbreviation) { // not required return nil } - if err := validate.MinLength("abbreviation", "body", string(m.Abbreviation), 2); err != nil { + if err := validate.MinLength("abbreviation", "body", m.Abbreviation, 2); err != nil { return err } - if err := validate.MaxLength("abbreviation", "body", string(m.Abbreviation), 60); err != nil { + if err := validate.MaxLength("abbreviation", "body", m.Abbreviation, 60); err != nil { return err } @@ -160,7 +160,7 @@ const ( // prop value enum func (m *CloudProvider) validateCanonicalEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, cloudProviderTypeCanonicalPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, cloudProviderTypeCanonicalPropEnum, true); err != nil { return err } return nil @@ -172,15 +172,15 @@ func (m *CloudProvider) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -193,12 +193,11 @@ func (m *CloudProvider) validateCanonical(formats strfmt.Registry) error { } func (m *CloudProvider) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -206,12 +205,11 @@ func (m *CloudProvider) validateCreatedAt(formats strfmt.Registry) error { } func (m *CloudProvider) validateID(formats strfmt.Registry) error { - if swag.IsZero(m.ID) { // not required return nil } - if err := validate.MinimumInt("id", "body", int64(m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(m.ID), 1, false); err != nil { return err } @@ -224,11 +222,11 @@ func (m *CloudProvider) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 2); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 2); err != nil { return err } - if err := validate.MaxLength("name", "body", string(*m.Name), 60); err != nil { + if err := validate.MaxLength("name", "body", *m.Name, 60); err != nil { return err } @@ -236,18 +234,22 @@ func (m *CloudProvider) validateName(formats strfmt.Registry) error { } func (m *CloudProvider) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validates this cloud provider based on context it is used +func (m *CloudProvider) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CloudProvider) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_provider_a_w_s_configuration.go b/client/models/cloud_provider_a_w_s_configuration.go index 157d03ec..089079fb 100644 --- a/client/models/cloud_provider_a_w_s_configuration.go +++ b/client/models/cloud_provider_a_w_s_configuration.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -34,11 +34,8 @@ func (m *CloudProviderAWSConfiguration) Type() string { // SetType sets the type of this subtype func (m *CloudProviderAWSConfiguration) SetType(val string) { - } -// Region gets the region of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *CloudProviderAWSConfiguration) UnmarshalJSON(raw []byte) error { var data struct { @@ -96,8 +93,7 @@ func (m CloudProviderAWSConfiguration) MarshalJSON() ([]byte, error) { }{ Region: m.Region, - }, - ) + }) if err != nil { return nil, err } @@ -106,8 +102,7 @@ func (m CloudProviderAWSConfiguration) MarshalJSON() ([]byte, error) { }{ Type: m.Type(), - }, - ) + }) if err != nil { return nil, err } @@ -138,6 +133,16 @@ func (m *CloudProviderAWSConfiguration) validateRegion(formats strfmt.Registry) return nil } +// ContextValidate validate this cloud provider a w s configuration based on the context it is used +func (m *CloudProviderAWSConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *CloudProviderAWSConfiguration) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_provider_azure_configuration.go b/client/models/cloud_provider_azure_configuration.go index a9c8787d..cf9709df 100644 --- a/client/models/cloud_provider_azure_configuration.go +++ b/client/models/cloud_provider_azure_configuration.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -40,13 +40,8 @@ func (m *CloudProviderAzureConfiguration) Type() string { // SetType sets the type of this subtype func (m *CloudProviderAzureConfiguration) SetType(val string) { - } -// Environment gets the environment of this subtype - -// ResourceGroupNames gets the resource group names of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *CloudProviderAzureConfiguration) UnmarshalJSON(raw []byte) error { var data struct { @@ -91,7 +86,6 @@ func (m *CloudProviderAzureConfiguration) UnmarshalJSON(raw []byte) error { } result.Environment = data.Environment - result.ResourceGroupNames = data.ResourceGroupNames *m = result @@ -120,8 +114,7 @@ func (m CloudProviderAzureConfiguration) MarshalJSON() ([]byte, error) { Environment: m.Environment, ResourceGroupNames: m.ResourceGroupNames, - }, - ) + }) if err != nil { return nil, err } @@ -130,8 +123,7 @@ func (m CloudProviderAzureConfiguration) MarshalJSON() ([]byte, error) { }{ Type: m.Type(), - }, - ) + }) if err != nil { return nil, err } @@ -181,6 +173,16 @@ func (m *CloudProviderAzureConfiguration) validateResourceGroupNames(formats str return nil } +// ContextValidate validate this cloud provider azure configuration based on the context it is used +func (m *CloudProviderAzureConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *CloudProviderAzureConfiguration) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_provider_configuration.go b/client/models/cloud_provider_configuration.go index 4d194100..ebe0e0a8 100644 --- a/client/models/cloud_provider_configuration.go +++ b/client/models/cloud_provider_configuration.go @@ -7,26 +7,30 @@ package models import ( "bytes" + "context" "encoding/json" "io" - "io/ioutil" - - strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" ) // CloudProviderConfiguration cloud provider configuration +// // swagger:discriminator CloudProviderConfiguration type type CloudProviderConfiguration interface { runtime.Validatable + runtime.ContextValidatable // type // Required: true Type() string SetType(string) + + // AdditionalProperties in base type shoud be handled just like regular properties + // At this moment, the base type property is pushed down to the subtype } type cloudProviderConfiguration struct { @@ -40,7 +44,6 @@ func (m *cloudProviderConfiguration) Type() string { // SetType sets the type of this polymorphic type func (m *cloudProviderConfiguration) SetType(val string) { - } // UnmarshalCloudProviderConfigurationSlice unmarshals polymorphic slices of CloudProviderConfiguration @@ -64,7 +67,7 @@ func UnmarshalCloudProviderConfigurationSlice(reader io.Reader, consumer runtime // UnmarshalCloudProviderConfiguration unmarshals polymorphic CloudProviderConfiguration func UnmarshalCloudProviderConfiguration(reader io.Reader, consumer runtime.Consumer) (CloudProviderConfiguration, error) { // we need to read this twice, so first into a buffer - data, err := ioutil.ReadAll(reader) + data, err := io.ReadAll(reader) if err != nil { return nil, err } @@ -95,41 +98,40 @@ func unmarshalCloudProviderConfiguration(data []byte, consumer runtime.Consumer) return nil, err } return &result, nil - case "CloudProviderAzureConfiguration": var result CloudProviderAzureConfiguration if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "CloudProviderConfiguration": var result cloudProviderConfiguration if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "CloudProviderGCPConfiguration": var result CloudProviderGCPConfiguration if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "CloudProviderVMWareVSphereConfiguration": var result CloudProviderVMWareVSphereConfiguration if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - } return nil, errors.New(422, "invalid type value: %q", getType.Type) - } // Validate validates this cloud provider configuration func (m *cloudProviderConfiguration) Validate(formats strfmt.Registry) error { return nil } + +// ContextValidate validates this cloud provider configuration based on context it is used +func (m *cloudProviderConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/client/models/cloud_provider_g_c_p_configuration.go b/client/models/cloud_provider_g_c_p_configuration.go index 30ba3026..c4efd84e 100644 --- a/client/models/cloud_provider_g_c_p_configuration.go +++ b/client/models/cloud_provider_g_c_p_configuration.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -39,13 +39,8 @@ func (m *CloudProviderGCPConfiguration) Type() string { // SetType sets the type of this subtype func (m *CloudProviderGCPConfiguration) SetType(val string) { - } -// Project gets the project of this subtype - -// Region gets the region of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *CloudProviderGCPConfiguration) UnmarshalJSON(raw []byte) error { var data struct { @@ -89,7 +84,6 @@ func (m *CloudProviderGCPConfiguration) UnmarshalJSON(raw []byte) error { } result.Project = data.Project - result.Region = data.Region *m = result @@ -117,8 +111,7 @@ func (m CloudProviderGCPConfiguration) MarshalJSON() ([]byte, error) { Project: m.Project, Region: m.Region, - }, - ) + }) if err != nil { return nil, err } @@ -127,8 +120,7 @@ func (m CloudProviderGCPConfiguration) MarshalJSON() ([]byte, error) { }{ Type: m.Type(), - }, - ) + }) if err != nil { return nil, err } @@ -172,6 +164,16 @@ func (m *CloudProviderGCPConfiguration) validateRegion(formats strfmt.Registry) return nil } +// ContextValidate validate this cloud provider g c p configuration based on the context it is used +func (m *CloudProviderGCPConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *CloudProviderGCPConfiguration) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cloud_provider_vm_ware_v_sphere_configuration.go b/client/models/cloud_provider_vm_ware_v_sphere_configuration.go index 3ef98415..911e824a 100644 --- a/client/models/cloud_provider_vm_ware_v_sphere_configuration.go +++ b/client/models/cloud_provider_vm_ware_v_sphere_configuration.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -39,13 +39,8 @@ func (m *CloudProviderVMWareVSphereConfiguration) Type() string { // SetType sets the type of this subtype func (m *CloudProviderVMWareVSphereConfiguration) SetType(val string) { - } -// AllowUnverifiedSsl gets the allow unverified ssl of this subtype - -// Server gets the server of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *CloudProviderVMWareVSphereConfiguration) UnmarshalJSON(raw []byte) error { var data struct { @@ -89,7 +84,6 @@ func (m *CloudProviderVMWareVSphereConfiguration) UnmarshalJSON(raw []byte) erro } result.AllowUnverifiedSsl = data.AllowUnverifiedSsl - result.Server = data.Server *m = result @@ -117,8 +111,7 @@ func (m CloudProviderVMWareVSphereConfiguration) MarshalJSON() ([]byte, error) { AllowUnverifiedSsl: m.AllowUnverifiedSsl, Server: m.Server, - }, - ) + }) if err != nil { return nil, err } @@ -127,8 +120,7 @@ func (m CloudProviderVMWareVSphereConfiguration) MarshalJSON() ([]byte, error) { }{ Type: m.Type(), - }, - ) + }) if err != nil { return nil, err } @@ -172,6 +164,16 @@ func (m *CloudProviderVMWareVSphereConfiguration) validateServer(formats strfmt. return nil } +// ContextValidate validate this cloud provider VM ware v sphere configuration based on the context it is used +func (m *CloudProviderVMWareVSphereConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *CloudProviderVMWareVSphereConfiguration) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/config_file.go b/client/models/config_file.go index 2e8894e1..ffccc011 100644 --- a/client/models/config_file.go +++ b/client/models/config_file.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // ConfigFile SC config file // -// This object contains SC config file name and its content +// # This object contains SC config file name and its content +// // swagger:model ConfigFile type ConfigFile struct { @@ -53,8 +55,6 @@ func (m *ConfigFile) validateContent(formats strfmt.Registry) error { return err } - // Format "byte" (base64 string) is already validated when unmarshalled - return nil } @@ -67,6 +67,11 @@ func (m *ConfigFile) validatePath(formats strfmt.Registry) error { return nil } +// ContextValidate validates this config file based on context it is used +func (m *ConfigFile) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ConfigFile) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/config_repository.go b/client/models/config_repository.go index d4365247..0d3cf93f 100644 --- a/client/models/config_repository.go +++ b/client/models/config_repository.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // ConfigRepository ConfigRepository +// // swagger:model ConfigRepository type ConfigRepository struct { @@ -108,15 +110,15 @@ func (m *ConfigRepository) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -124,12 +126,11 @@ func (m *ConfigRepository) validateCanonical(formats strfmt.Registry) error { } func (m *ConfigRepository) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -137,20 +138,19 @@ func (m *ConfigRepository) validateCreatedAt(formats strfmt.Registry) error { } func (m *ConfigRepository) validateCredentialCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CredentialCanonical) { // not required return nil } - if err := validate.MinLength("credential_canonical", "body", string(m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -172,7 +172,7 @@ func (m *ConfigRepository) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -189,12 +189,11 @@ func (m *ConfigRepository) validateName(formats strfmt.Registry) error { } func (m *ConfigRepository) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -207,13 +206,18 @@ func (m *ConfigRepository) validateURL(formats strfmt.Registry) error { return err } - if err := validate.Pattern("url", "body", string(*m.URL), `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { + if err := validate.Pattern("url", "body", *m.URL, `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { return err } return nil } +// ContextValidate validates this config repository based on context it is used +func (m *ConfigRepository) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ConfigRepository) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cost_estimation_component.go b/client/models/cost_estimation_component.go index a7cb51cf..8e2ee608 100644 --- a/client/models/cost_estimation_component.go +++ b/client/models/cost_estimation_component.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // CostEstimationComponent CostEstimationComponent // // Cost component of a cloud resource estimate. +// // swagger:model CostEstimationComponent type CostEstimationComponent struct { @@ -76,7 +78,6 @@ func (m *CostEstimationComponent) validateLabel(formats strfmt.Registry) error { } func (m *CostEstimationComponent) validatePlanned(formats strfmt.Registry) error { - if swag.IsZero(m.Planned) { // not required return nil } @@ -85,6 +86,8 @@ func (m *CostEstimationComponent) validatePlanned(formats strfmt.Registry) error if err := m.Planned.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("planned") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("planned") } return err } @@ -94,7 +97,6 @@ func (m *CostEstimationComponent) validatePlanned(formats strfmt.Registry) error } func (m *CostEstimationComponent) validatePrior(formats strfmt.Registry) error { - if swag.IsZero(m.Prior) { // not required return nil } @@ -103,6 +105,8 @@ func (m *CostEstimationComponent) validatePrior(formats strfmt.Registry) error { if err := m.Prior.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("prior") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("prior") } return err } @@ -120,6 +124,66 @@ func (m *CostEstimationComponent) validateRate(formats strfmt.Registry) error { return nil } +// ContextValidate validate this cost estimation component based on the context it is used +func (m *CostEstimationComponent) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePlanned(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePrior(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CostEstimationComponent) contextValidatePlanned(ctx context.Context, formats strfmt.Registry) error { + + if m.Planned != nil { + + if swag.IsZero(m.Planned) { // not required + return nil + } + + if err := m.Planned.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("planned") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("planned") + } + return err + } + } + + return nil +} + +func (m *CostEstimationComponent) contextValidatePrior(ctx context.Context, formats strfmt.Registry) error { + + if m.Prior != nil { + + if swag.IsZero(m.Prior) { // not required + return nil + } + + if err := m.Prior.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("prior") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("prior") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *CostEstimationComponent) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cost_estimation_component_state.go b/client/models/cost_estimation_component_state.go index 95179972..f875fe69 100644 --- a/client/models/cost_estimation_component_state.go +++ b/client/models/cost_estimation_component_state.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // CostEstimationComponentState CostEstimationComponentState // // Either a Prior or Planned cost component state. +// // swagger:model CostEstimationComponentState type CostEstimationComponentState struct { @@ -98,6 +100,11 @@ func (m *CostEstimationComponentState) validateQuantity(formats strfmt.Registry) return nil } +// ContextValidate validates this cost estimation component state based on context it is used +func (m *CostEstimationComponentState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CostEstimationComponentState) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cost_estimation_resource_estimate.go b/client/models/cost_estimation_resource_estimate.go index 9cc145b2..c8cf0f2f 100644 --- a/client/models/cost_estimation_resource_estimate.go +++ b/client/models/cost_estimation_resource_estimate.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // CostEstimationResourceEstimate CostEstimationResourceEstimate // // Estimate for a single cloud resource. +// // swagger:model CostEstimationResourceEstimate type CostEstimationResourceEstimate struct { @@ -108,6 +109,8 @@ func (m *CostEstimationResourceEstimate) validateComponents(formats strfmt.Regis if err := m.Components[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("components" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("components" + "." + strconv.Itoa(i)) } return err } @@ -119,7 +122,6 @@ func (m *CostEstimationResourceEstimate) validateComponents(formats strfmt.Regis } func (m *CostEstimationResourceEstimate) validateImage(formats strfmt.Registry) error { - if swag.IsZero(m.Image) { // not required return nil } @@ -149,6 +151,45 @@ func (m *CostEstimationResourceEstimate) validateType(formats strfmt.Registry) e return nil } +// ContextValidate validate this cost estimation resource estimate based on the context it is used +func (m *CostEstimationResourceEstimate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateComponents(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CostEstimationResourceEstimate) contextValidateComponents(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Components); i++ { + + if m.Components[i] != nil { + + if swag.IsZero(m.Components[i]) { // not required + return nil + } + + if err := m.Components[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("components" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("components" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *CostEstimationResourceEstimate) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cost_estimation_result.go b/client/models/cost_estimation_result.go index 0fd42a18..332683f4 100644 --- a/client/models/cost_estimation_result.go +++ b/client/models/cost_estimation_result.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // CostEstimationResult CostEstimationResult // // The result of cost estimation. +// // swagger:model CostEstimationResult type CostEstimationResult struct { @@ -78,6 +79,47 @@ func (m *CostEstimationResult) validateResourceEstimates(formats strfmt.Registry if err := m.ResourceEstimates[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("resource_estimates" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resource_estimates" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this cost estimation result based on the context it is used +func (m *CostEstimationResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateResourceEstimates(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CostEstimationResult) contextValidateResourceEstimates(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ResourceEstimates); i++ { + + if m.ResourceEstimates[i] != nil { + + if swag.IsZero(m.ResourceEstimates[i]) { // not required + return nil + } + + if err := m.ResourceEstimates[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_estimates" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resource_estimates" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/cost_group.go b/client/models/cost_group.go index aed33377..82e7b1ab 100644 --- a/client/models/cost_group.go +++ b/client/models/cost_group.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // CostGroup CostGroup // // This object contains the items described in https://docs.aws.amazon.com/sdk-for-go/api/service/costexplorer/#Group The groups hold the information about the price per key(s) for each iteration over the time range requested. +// // swagger:model CostGroup type CostGroup struct { @@ -66,15 +68,15 @@ func (m *CostGroup) validateAmount(formats strfmt.Registry) error { return err } - if err := validate.MinLength("amount", "body", string(*m.Amount), 3); err != nil { + if err := validate.MinLength("amount", "body", *m.Amount, 3); err != nil { return err } - if err := validate.MaxLength("amount", "body", string(*m.Amount), 100); err != nil { + if err := validate.MaxLength("amount", "body", *m.Amount, 100); err != nil { return err } - if err := validate.Pattern("amount", "body", string(*m.Amount), `^[0-9]+.[0-9]+$`); err != nil { + if err := validate.Pattern("amount", "body", *m.Amount, `^[0-9]+.[0-9]+$`); err != nil { return err } @@ -96,21 +98,26 @@ func (m *CostGroup) validateUnit(formats strfmt.Registry) error { return err } - if err := validate.MinLength("unit", "body", string(*m.Unit), 3); err != nil { + if err := validate.MinLength("unit", "body", *m.Unit, 3); err != nil { return err } - if err := validate.MaxLength("unit", "body", string(*m.Unit), 3); err != nil { + if err := validate.MaxLength("unit", "body", *m.Unit, 3); err != nil { return err } - if err := validate.Pattern("unit", "body", string(*m.Unit), `^[A-Z]+$`); err != nil { + if err := validate.Pattern("unit", "body", *m.Unit, `^[A-Z]+$`); err != nil { return err } return nil } +// ContextValidate validates this cost group based on context it is used +func (m *CostGroup) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CostGroup) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cost_group_definitions.go b/client/models/cost_group_definitions.go index 394b39fb..5a2832a5 100644 --- a/client/models/cost_group_definitions.go +++ b/client/models/cost_group_definitions.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // CostGroupDefinitions CostGroupDefinitions // // This object contains the items describe in https://docs.aws.amazon.com/sdk-for-go/api/service/costexplorer/#GroupDefinition It also grouping the costs based on different elements: az, services, tags, etc +// // swagger:model CostGroupDefinitions type CostGroupDefinitions struct { @@ -58,15 +60,15 @@ func (m *CostGroupDefinitions) validateGroup(formats strfmt.Registry) error { return err } - if err := validate.MinLength("group", "body", string(*m.Group), 1); err != nil { + if err := validate.MinLength("group", "body", *m.Group, 1); err != nil { return err } - if err := validate.MaxLength("group", "body", string(*m.Group), 100); err != nil { + if err := validate.MaxLength("group", "body", *m.Group, 100); err != nil { return err } - if err := validate.Pattern("group", "body", string(*m.Group), `^[a-zA-Z]+$`); err != nil { + if err := validate.Pattern("group", "body", *m.Group, `^[a-zA-Z]+$`); err != nil { return err } @@ -79,21 +81,26 @@ func (m *CostGroupDefinitions) validateKey(formats strfmt.Registry) error { return err } - if err := validate.MinLength("key", "body", string(*m.Key), 1); err != nil { + if err := validate.MinLength("key", "body", *m.Key, 1); err != nil { return err } - if err := validate.MaxLength("key", "body", string(*m.Key), 100); err != nil { + if err := validate.MaxLength("key", "body", *m.Key, 100); err != nil { return err } - if err := validate.Pattern("key", "body", string(*m.Key), `^[a-zA-Z]+$`); err != nil { + if err := validate.Pattern("key", "body", *m.Key, `^[a-zA-Z]+$`); err != nil { return err } return nil } +// ContextValidate validates this cost group definitions based on context it is used +func (m *CostGroupDefinitions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CostGroupDefinitions) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cost_result_by_time.go b/client/models/cost_result_by_time.go index 94acc255..8c683993 100644 --- a/client/models/cost_result_by_time.go +++ b/client/models/cost_result_by_time.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // CostResultByTime CostResultByTime // // This object contains the items described in https://docs.aws.amazon.com/sdk-for-go/api/service/costexplorer/#ResultByTime It is basically containing information about the cost per group(s) and per granularity (daily/monthly) over the period of time selected. The total and unit fields have bee modified to fit our requirements, while the groups hold the information about each iteration over the time range. +// // swagger:model CostResultByTime type CostResultByTime struct { @@ -102,6 +103,8 @@ func (m *CostResultByTime) validateGroups(formats strfmt.Registry) error { if err := m.Groups[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("groups" + "." + strconv.Itoa(i)) } return err } @@ -122,6 +125,8 @@ func (m *CostResultByTime) validatePeriod(formats strfmt.Registry) error { if err := m.Period.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("period") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("period") } return err } @@ -136,15 +141,15 @@ func (m *CostResultByTime) validateTotal(formats strfmt.Registry) error { return err } - if err := validate.MinLength("total", "body", string(*m.Total), 3); err != nil { + if err := validate.MinLength("total", "body", *m.Total, 3); err != nil { return err } - if err := validate.MaxLength("total", "body", string(*m.Total), 100); err != nil { + if err := validate.MaxLength("total", "body", *m.Total, 100); err != nil { return err } - if err := validate.Pattern("total", "body", string(*m.Total), `^[0-9]+.[0-9]+$`); err != nil { + if err := validate.Pattern("total", "body", *m.Total, `^[0-9]+.[0-9]+$`); err != nil { return err } @@ -157,21 +162,81 @@ func (m *CostResultByTime) validateUnit(formats strfmt.Registry) error { return err } - if err := validate.MinLength("unit", "body", string(*m.Unit), 2); err != nil { + if err := validate.MinLength("unit", "body", *m.Unit, 2); err != nil { return err } - if err := validate.MaxLength("unit", "body", string(*m.Unit), 3); err != nil { + if err := validate.MaxLength("unit", "body", *m.Unit, 3); err != nil { return err } - if err := validate.Pattern("unit", "body", string(*m.Unit), `^[a-zA-Z]+$`); err != nil { + if err := validate.Pattern("unit", "body", *m.Unit, `^[a-zA-Z]+$`); err != nil { return err } return nil } +// ContextValidate validate this cost result by time based on the context it is used +func (m *CostResultByTime) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateGroups(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePeriod(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CostResultByTime) contextValidateGroups(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Groups); i++ { + + if m.Groups[i] != nil { + + if swag.IsZero(m.Groups[i]) { // not required + return nil + } + + if err := m.Groups[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("groups" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CostResultByTime) contextValidatePeriod(ctx context.Context, formats strfmt.Registry) error { + + if m.Period != nil { + + if err := m.Period.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("period") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("period") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *CostResultByTime) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cost_time_period.go b/client/models/cost_time_period.go index 93e90530..e5159155 100644 --- a/client/models/cost_time_period.go +++ b/client/models/cost_time_period.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // CostTimePeriod CostTimePeriod // // This object contains the items described in https://docs.aws.amazon.com/sdk-for-go/api/service/costexplorer/#DateInterval It defines the beginning and the end of the time frame for which, the API should gather costs. +// // swagger:model CostTimePeriod type CostTimePeriod struct { @@ -58,15 +60,15 @@ func (m *CostTimePeriod) validateBegin(formats strfmt.Registry) error { return err } - if err := validate.MinLength("begin", "body", string(*m.Begin), 10); err != nil { + if err := validate.MinLength("begin", "body", *m.Begin, 10); err != nil { return err } - if err := validate.MaxLength("begin", "body", string(*m.Begin), 10); err != nil { + if err := validate.MaxLength("begin", "body", *m.Begin, 10); err != nil { return err } - if err := validate.Pattern("begin", "body", string(*m.Begin), `^[0-9]{4}-[0-9]{2}-[0-9]{2}$`); err != nil { + if err := validate.Pattern("begin", "body", *m.Begin, `^[0-9]{4}-[0-9]{2}-[0-9]{2}$`); err != nil { return err } @@ -79,21 +81,26 @@ func (m *CostTimePeriod) validateEnd(formats strfmt.Registry) error { return err } - if err := validate.MinLength("end", "body", string(*m.End), 10); err != nil { + if err := validate.MinLength("end", "body", *m.End, 10); err != nil { return err } - if err := validate.MaxLength("end", "body", string(*m.End), 10); err != nil { + if err := validate.MaxLength("end", "body", *m.End, 10); err != nil { return err } - if err := validate.Pattern("end", "body", string(*m.End), `^[0-9]{4}-[0-9]{2}-[0-9]{2}$`); err != nil { + if err := validate.Pattern("end", "body", *m.End, `^[0-9]{4}-[0-9]{2}-[0-9]{2}$`); err != nil { return err } return nil } +// ContextValidate validates this cost time period based on context it is used +func (m *CostTimePeriod) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CostTimePeriod) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/country.go b/client/models/country.go index b22ccd04..c20d37ae 100644 --- a/client/models/country.go +++ b/client/models/country.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Country Country // -// Single country Representation +// # Single country Representation +// // swagger:model Country type Country struct { @@ -53,7 +55,7 @@ func (m *Country) validateCode(formats strfmt.Registry) error { return err } - if err := validate.Pattern("code", "body", string(*m.Code), `^[A-Z]{2}$`); err != nil { + if err := validate.Pattern("code", "body", *m.Code, `^[A-Z]{2}$`); err != nil { return err } @@ -69,6 +71,11 @@ func (m *Country) validateName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this country based on context it is used +func (m *Country) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Country) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/credential.go b/client/models/credential.go index c3f6bc46..a9713757 100644 --- a/client/models/credential.go +++ b/client/models/credential.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Credential Credential // -// Represents the Credential +// # Represents the Credential +// // swagger:model Credential type Credential struct { @@ -67,7 +68,7 @@ type Credential struct { // type // Required: true - // Enum: [ssh aws custom azure azure_storage gcp basic_auth elasticsearch swift vmware] + // Enum: ["ssh","aws","custom","azure","azure_storage","gcp","basic_auth","elasticsearch","swift","vmware"] Type *string `json:"type"` // updated at @@ -135,15 +136,15 @@ func (m *Credential) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -151,12 +152,11 @@ func (m *Credential) validateCanonical(formats strfmt.Registry) error { } func (m *Credential) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -169,7 +169,7 @@ func (m *Credential) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -177,7 +177,6 @@ func (m *Credential) validateID(formats strfmt.Registry) error { } func (m *Credential) validateInUse(formats strfmt.Registry) error { - if swag.IsZero(m.InUse) { // not required return nil } @@ -186,6 +185,8 @@ func (m *Credential) validateInUse(formats strfmt.Registry) error { if err := m.InUse.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("in_use") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("in_use") } return err } @@ -213,7 +214,6 @@ func (m *Credential) validateName(formats strfmt.Registry) error { } func (m *Credential) validateOwner(formats strfmt.Registry) error { - if swag.IsZero(m.Owner) { // not required return nil } @@ -222,6 +222,8 @@ func (m *Credential) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -249,6 +251,8 @@ func (m *Credential) validateRaw(formats strfmt.Registry) error { if err := m.Raw.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("raw") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("raw") } return err } @@ -304,7 +308,7 @@ const ( // prop value enum func (m *Credential) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, credentialTypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, credentialTypeTypePropEnum, true); err != nil { return err } return nil @@ -325,18 +329,98 @@ func (m *Credential) validateType(formats strfmt.Registry) error { } func (m *Credential) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this credential based on the context it is used +func (m *Credential) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInUse(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateRaw(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Credential) contextValidateInUse(ctx context.Context, formats strfmt.Registry) error { + + if m.InUse != nil { + + if swag.IsZero(m.InUse) { // not required + return nil + } + + if err := m.InUse.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("in_use") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("in_use") + } + return err + } + } + + return nil +} + +func (m *Credential) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if swag.IsZero(m.Owner) { // not required + return nil + } + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + +func (m *Credential) contextValidateRaw(ctx context.Context, formats strfmt.Registry) error { + + if m.Raw != nil { + + if err := m.Raw.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("raw") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("raw") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Credential) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/credential_in_use.go b/client/models/credential_in_use.go index caf50f31..121ac0cd 100644 --- a/client/models/credential_in_use.go +++ b/client/models/credential_in_use.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) @@ -54,7 +54,6 @@ func (m *CredentialInUse) Validate(formats strfmt.Registry) error { } func (m *CredentialInUse) validateConfigRepositories(formats strfmt.Registry) error { - if swag.IsZero(m.ConfigRepositories) { // not required return nil } @@ -68,6 +67,8 @@ func (m *CredentialInUse) validateConfigRepositories(formats strfmt.Registry) er if err := m.ConfigRepositories[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("config_repositories" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("config_repositories" + "." + strconv.Itoa(i)) } return err } @@ -79,7 +80,6 @@ func (m *CredentialInUse) validateConfigRepositories(formats strfmt.Registry) er } func (m *CredentialInUse) validateExternalBackends(formats strfmt.Registry) error { - if swag.IsZero(m.ExternalBackends) { // not required return nil } @@ -93,6 +93,8 @@ func (m *CredentialInUse) validateExternalBackends(formats strfmt.Registry) erro if err := m.ExternalBackends[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("external_backends" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backends" + "." + strconv.Itoa(i)) } return err } @@ -104,7 +106,6 @@ func (m *CredentialInUse) validateExternalBackends(formats strfmt.Registry) erro } func (m *CredentialInUse) validateServiceCatalogSources(formats strfmt.Registry) error { - if swag.IsZero(m.ServiceCatalogSources) { // not required return nil } @@ -118,6 +119,105 @@ func (m *CredentialInUse) validateServiceCatalogSources(formats strfmt.Registry) if err := m.ServiceCatalogSources[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("service_catalog_sources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_catalog_sources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this credential in use based on the context it is used +func (m *CredentialInUse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfigRepositories(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateExternalBackends(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateServiceCatalogSources(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CredentialInUse) contextValidateConfigRepositories(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ConfigRepositories); i++ { + + if m.ConfigRepositories[i] != nil { + + if swag.IsZero(m.ConfigRepositories[i]) { // not required + return nil + } + + if err := m.ConfigRepositories[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("config_repositories" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("config_repositories" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CredentialInUse) contextValidateExternalBackends(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ExternalBackends); i++ { + + if m.ExternalBackends[i] != nil { + + if swag.IsZero(m.ExternalBackends[i]) { // not required + return nil + } + + if err := m.ExternalBackends[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("external_backends" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backends" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CredentialInUse) contextValidateServiceCatalogSources(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ServiceCatalogSources); i++ { + + if m.ServiceCatalogSources[i] != nil { + + if swag.IsZero(m.ServiceCatalogSources[i]) { // not required + return nil + } + + if err := m.ServiceCatalogSources[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service_catalog_sources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_catalog_sources" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/credential_raw.go b/client/models/credential_raw.go index 65592568..f33e69df 100644 --- a/client/models/credential_raw.go +++ b/client/models/credential_raw.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // CredentialRaw Credential Raw // -// All the possible fields inside it +// # All the possible fields inside it +// // swagger:model CredentialRaw type CredentialRaw struct { @@ -43,7 +44,7 @@ type CredentialRaw struct { DomainID string `json:"domain_id,omitempty"` // environment - // Enum: [public usgovernment china german] + // Enum: ["public","usgovernment","china","german"] Environment string `json:"environment,omitempty"` // json key @@ -114,14 +115,13 @@ const ( // prop value enum func (m *CredentialRaw) validateEnvironmentEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, credentialRawTypeEnvironmentPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, credentialRawTypeEnvironmentPropEnum, true); err != nil { return err } return nil } func (m *CredentialRaw) validateEnvironment(formats strfmt.Registry) error { - if swag.IsZero(m.Environment) { // not required return nil } @@ -134,6 +134,11 @@ func (m *CredentialRaw) validateEnvironment(formats strfmt.Registry) error { return nil } +// ContextValidate validates this credential raw based on context it is used +func (m *CredentialRaw) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *CredentialRaw) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/credential_simple.go b/client/models/credential_simple.go index 57e0703d..c8ac5693 100644 --- a/client/models/credential_simple.go +++ b/client/models/credential_simple.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // CredentialSimple Credential Simple // -// Represents the Credential without the raw and owner +// # Represents the Credential without the raw and owner +// // swagger:model CredentialSimple type CredentialSimple struct { @@ -63,7 +64,7 @@ type CredentialSimple struct { // type // Required: true - // Enum: [ssh aws custom azure azure_storage gcp basic_auth elasticsearch swift vmware] + // Enum: ["ssh","aws","custom","azure","azure_storage","gcp","basic_auth","elasticsearch","swift","vmware"] Type *string `json:"type"` // updated at @@ -127,15 +128,15 @@ func (m *CredentialSimple) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -143,12 +144,11 @@ func (m *CredentialSimple) validateCanonical(formats strfmt.Registry) error { } func (m *CredentialSimple) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -161,7 +161,7 @@ func (m *CredentialSimple) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -169,7 +169,6 @@ func (m *CredentialSimple) validateID(formats strfmt.Registry) error { } func (m *CredentialSimple) validateInUse(formats strfmt.Registry) error { - if swag.IsZero(m.InUse) { // not required return nil } @@ -178,6 +177,8 @@ func (m *CredentialSimple) validateInUse(formats strfmt.Registry) error { if err := m.InUse.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("in_use") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("in_use") } return err } @@ -205,7 +206,6 @@ func (m *CredentialSimple) validateName(formats strfmt.Registry) error { } func (m *CredentialSimple) validateOwner(formats strfmt.Registry) error { - if swag.IsZero(m.Owner) { // not required return nil } @@ -214,6 +214,8 @@ func (m *CredentialSimple) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -278,7 +280,7 @@ const ( // prop value enum func (m *CredentialSimple) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, credentialSimpleTypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, credentialSimpleTypeTypePropEnum, true); err != nil { return err } return nil @@ -299,18 +301,77 @@ func (m *CredentialSimple) validateType(formats strfmt.Registry) error { } func (m *CredentialSimple) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this credential simple based on the context it is used +func (m *CredentialSimple) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInUse(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CredentialSimple) contextValidateInUse(ctx context.Context, formats strfmt.Registry) error { + + if m.InUse != nil { + + if swag.IsZero(m.InUse) { // not required + return nil + } + + if err := m.InUse.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("in_use") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("in_use") + } + return err + } + } + + return nil +} + +func (m *CredentialSimple) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if swag.IsZero(m.Owner) { // not required + return nil + } + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *CredentialSimple) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/elasticsearch_logs.go b/client/models/elasticsearch_logs.go index e5ae5a29..44552d12 100644 --- a/client/models/elasticsearch_logs.go +++ b/client/models/elasticsearch_logs.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -46,15 +46,8 @@ func (m *ElasticsearchLogs) Engine() string { // SetEngine sets the engine of this subtype func (m *ElasticsearchLogs) SetEngine(val string) { - } -// Sources gets the sources of this subtype - -// Urls gets the urls of this subtype - -// Version gets the version of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *ElasticsearchLogs) UnmarshalJSON(raw []byte) error { var data struct { @@ -104,9 +97,7 @@ func (m *ElasticsearchLogs) UnmarshalJSON(raw []byte) error { } result.Sources = data.Sources - result.Urls = data.Urls - result.Version = data.Version *m = result @@ -142,8 +133,7 @@ func (m ElasticsearchLogs) MarshalJSON() ([]byte, error) { Urls: m.Urls, Version: m.Version, - }, - ) + }) if err != nil { return nil, err } @@ -152,8 +142,7 @@ func (m ElasticsearchLogs) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -185,12 +174,20 @@ func (m *ElasticsearchLogs) Validate(formats strfmt.Registry) error { func (m *ElasticsearchLogs) validateSources(formats strfmt.Registry) error { + if err := validate.Required("sources", "body", m.Sources); err != nil { + return err + } + for k := range m.Sources { if err := validate.Required("sources"+"."+k, "body", m.Sources[k]); err != nil { return err } + if err := validate.Required("sources"+"."+k, "body", m.Sources[k]); err != nil { + return err + } + for kk := range m.Sources[k] { if err := validate.Required("sources"+"."+k+"."+kk, "body", m.Sources[k][kk]); err != nil { @@ -198,6 +195,11 @@ func (m *ElasticsearchLogs) validateSources(formats strfmt.Registry) error { } if val, ok := m.Sources[k][kk]; ok { if err := val.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sources" + "." + k + "." + kk) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sources" + "." + k + "." + kk) + } return err } } @@ -227,6 +229,47 @@ func (m *ElasticsearchLogs) validateVersion(formats strfmt.Registry) error { return nil } +// ContextValidate validate this elasticsearch logs based on the context it is used +func (m *ElasticsearchLogs) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSources(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ElasticsearchLogs) contextValidateSources(ctx context.Context, formats strfmt.Registry) error { + + if err := validate.Required("sources", "body", m.Sources); err != nil { + return err + } + + for k := range m.Sources { + + if err := validate.Required("sources"+"."+k, "body", m.Sources[k]); err != nil { + return err + } + + for kk := range m.Sources[k] { + + if val, ok := m.Sources[k][kk]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { + return err + } + } + + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *ElasticsearchLogs) MarshalBinary() ([]byte, error) { if m == nil { @@ -246,6 +289,7 @@ func (m *ElasticsearchLogs) UnmarshalBinary(b []byte) error { } // ElasticsearchLogsSourcesAnon elasticsearch logs sources anon +// // swagger:model ElasticsearchLogsSourcesAnon type ElasticsearchLogsSourcesAnon struct { @@ -281,7 +325,6 @@ func (m *ElasticsearchLogsSourcesAnon) Validate(formats strfmt.Registry) error { } func (m *ElasticsearchLogsSourcesAnon) validateMapping(formats strfmt.Registry) error { - if swag.IsZero(m.Mapping) { // not required return nil } @@ -290,6 +333,43 @@ func (m *ElasticsearchLogsSourcesAnon) validateMapping(formats strfmt.Registry) if err := m.Mapping.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("mapping") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("mapping") + } + return err + } + } + + return nil +} + +// ContextValidate validate this elasticsearch logs sources anon based on the context it is used +func (m *ElasticsearchLogsSourcesAnon) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateMapping(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ElasticsearchLogsSourcesAnon) contextValidateMapping(ctx context.Context, formats strfmt.Registry) error { + + if m.Mapping != nil { + + if swag.IsZero(m.Mapping) { // not required + return nil + } + + if err := m.Mapping.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("mapping") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("mapping") } return err } @@ -387,6 +467,11 @@ func (m *ElasticsearchLogsSourcesAnonMapping) validateTimestamp(formats strfmt.R return nil } +// ContextValidate validates this elasticsearch logs sources anon mapping based on context it is used +func (m *ElasticsearchLogsSourcesAnonMapping) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ElasticsearchLogsSourcesAnonMapping) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/ensure_plan.go b/client/models/ensure_plan.go index 40557e74..adc0026e 100644 --- a/client/models/ensure_plan.go +++ b/client/models/ensure_plan.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // EnsurePlan EnsurePlan // // The plan to ensure to be run. +// // swagger:model EnsurePlan type EnsurePlan struct { @@ -56,6 +58,8 @@ func (m *EnsurePlan) validateNext(formats strfmt.Registry) error { if err := m.Next.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") } return err } @@ -74,6 +78,60 @@ func (m *EnsurePlan) validateStep(formats strfmt.Registry) error { if err := m.Step.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") + } + return err + } + } + + return nil +} + +// ContextValidate validate this ensure plan based on the context it is used +func (m *EnsurePlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNext(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStep(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EnsurePlan) contextValidateNext(ctx context.Context, formats strfmt.Registry) error { + + if m.Next != nil { + + if err := m.Next.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") + } + return err + } + } + + return nil +} + +func (m *EnsurePlan) contextValidateStep(ctx context.Context, formats strfmt.Registry) error { + + if m.Step != nil { + + if err := m.Step.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") } return err } diff --git a/client/models/environment.go b/client/models/environment.go index 5314972b..52fc4ba1 100644 --- a/client/models/environment.go +++ b/client/models/environment.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Environment Environment // -// Represent an environment with may be related to a Project and Pipeline +// # Represent an environment with may be related to a Project and Pipeline +// // swagger:model Environment type Environment struct { @@ -112,15 +114,15 @@ func (m *Environment) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[\da-zA-Z]+(?:[\da-zA-Z\-._]+[\da-zA-Z]|[\da-zA-Z])$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[\da-zA-Z]+(?:[\da-zA-Z\-._]+[\da-zA-Z]|[\da-zA-Z])$`); err != nil { return err } @@ -128,7 +130,6 @@ func (m *Environment) validateCanonical(formats strfmt.Registry) error { } func (m *Environment) validateCloudProvider(formats strfmt.Registry) error { - if swag.IsZero(m.CloudProvider) { // not required return nil } @@ -137,6 +138,8 @@ func (m *Environment) validateCloudProvider(formats strfmt.Registry) error { if err := m.CloudProvider.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("cloud_provider") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloud_provider") } return err } @@ -151,7 +154,7 @@ func (m *Environment) validateColor(formats strfmt.Registry) error { return err } - if err := validate.MaxLength("color", "body", string(*m.Color), 64); err != nil { + if err := validate.MaxLength("color", "body", *m.Color, 64); err != nil { return err } @@ -164,7 +167,7 @@ func (m *Environment) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -177,7 +180,7 @@ func (m *Environment) validateIcon(formats strfmt.Registry) error { return err } - if err := validate.MaxLength("icon", "body", string(*m.Icon), 64); err != nil { + if err := validate.MaxLength("icon", "body", *m.Icon, 64); err != nil { return err } @@ -190,7 +193,7 @@ func (m *Environment) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -203,7 +206,7 @@ func (m *Environment) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -211,26 +214,60 @@ func (m *Environment) validateUpdatedAt(formats strfmt.Registry) error { } func (m *Environment) validateUseCase(formats strfmt.Registry) error { - if swag.IsZero(m.UseCase) { // not required return nil } - if err := validate.MinLength("use_case", "body", string(m.UseCase), 3); err != nil { + if err := validate.MinLength("use_case", "body", m.UseCase, 3); err != nil { return err } - if err := validate.MaxLength("use_case", "body", string(m.UseCase), 100); err != nil { + if err := validate.MaxLength("use_case", "body", m.UseCase, 100); err != nil { return err } - if err := validate.Pattern("use_case", "body", string(m.UseCase), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("use_case", "body", m.UseCase, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validate this environment based on the context it is used +func (m *Environment) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCloudProvider(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Environment) contextValidateCloudProvider(ctx context.Context, formats strfmt.Registry) error { + + if m.CloudProvider != nil { + + if swag.IsZero(m.CloudProvider) { // not required + return nil + } + + if err := m.CloudProvider.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloud_provider") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloud_provider") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Environment) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/error_details_item.go b/client/models/error_details_item.go index 6e403c15..37fe16bf 100644 --- a/client/models/error_details_item.go +++ b/client/models/error_details_item.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // ErrorDetailsItem Error details item // // Represents an item of the list of details of an error. +// // swagger:model ErrorDetailsItem type ErrorDetailsItem struct { @@ -67,6 +69,11 @@ func (m *ErrorDetailsItem) validateMessage(formats strfmt.Registry) error { return nil } +// ContextValidate validates this error details item based on context it is used +func (m *ErrorDetailsItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ErrorDetailsItem) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/error_payload.go b/client/models/error_payload.go index a9c568ac..59f4858e 100644 --- a/client/models/error_payload.go +++ b/client/models/error_payload.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -56,6 +56,47 @@ func (m *ErrorPayload) validateErrors(formats strfmt.Registry) error { if err := m.Errors[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("errors" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("errors" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this error payload based on the context it is used +func (m *ErrorPayload) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateErrors(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ErrorPayload) contextValidateErrors(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Errors); i++ { + + if m.Errors[i] != nil { + + if swag.IsZero(m.Errors[i]) { // not required + return nil + } + + if err := m.Errors[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("errors" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("errors" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/event.go b/client/models/event.go index f06f31e4..39eee34d 100644 --- a/client/models/event.go +++ b/client/models/event.go @@ -6,12 +6,12 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -19,6 +19,7 @@ import ( // Event An event // // A event which has registered an activity in the Cycloid platform. +// // swagger:model Event type Event struct { @@ -43,7 +44,7 @@ type Event struct { // The severity associated to the event. // Required: true - // Enum: [info warn err crit] + // Enum: ["info","warn","err","crit"] Severity *string `json:"severity"` // The list of tags associated to the event. @@ -61,7 +62,7 @@ type Event struct { // The type of the event // Required: true - // Enum: [Cycloid AWS Monitoring Custom] + // Enum: ["Cycloid","AWS","Monitoring","Custom"] Type *string `json:"type"` } @@ -112,20 +113,19 @@ func (m *Event) Validate(formats strfmt.Registry) error { } func (m *Event) validateColor(formats strfmt.Registry) error { - if swag.IsZero(m.Color) { // not required return nil } - if err := validate.MinLength("color", "body", string(m.Color), 3); err != nil { + if err := validate.MinLength("color", "body", m.Color, 3); err != nil { return err } - if err := validate.MaxLength("color", "body", string(m.Color), 20); err != nil { + if err := validate.MaxLength("color", "body", m.Color, 20); err != nil { return err } - if err := validate.Pattern("color", "body", string(m.Color), `[a-z]+`); err != nil { + if err := validate.Pattern("color", "body", m.Color, `[a-z]+`); err != nil { return err } @@ -133,12 +133,11 @@ func (m *Event) validateColor(formats strfmt.Registry) error { } func (m *Event) validateIcon(formats strfmt.Registry) error { - if swag.IsZero(m.Icon) { // not required return nil } - if err := validate.MinLength("icon", "body", string(m.Icon), 3); err != nil { + if err := validate.MinLength("icon", "body", m.Icon, 3); err != nil { return err } @@ -160,7 +159,7 @@ func (m *Event) validateMessage(formats strfmt.Registry) error { return err } - if err := validate.MinLength("message", "body", string(*m.Message), 1); err != nil { + if err := validate.MinLength("message", "body", *m.Message, 1); err != nil { return err } @@ -196,7 +195,7 @@ const ( // prop value enum func (m *Event) validateSeverityEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, eventTypeSeverityPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, eventTypeSeverityPropEnum, true); err != nil { return err } return nil @@ -231,6 +230,8 @@ func (m *Event) validateTags(formats strfmt.Registry) error { if err := m.Tags[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("tags" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags" + "." + strconv.Itoa(i)) } return err } @@ -256,7 +257,7 @@ func (m *Event) validateTitle(formats strfmt.Registry) error { return err } - if err := validate.MinLength("title", "body", string(*m.Title), 1); err != nil { + if err := validate.MinLength("title", "body", *m.Title, 1); err != nil { return err } @@ -292,7 +293,7 @@ const ( // prop value enum func (m *Event) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, eventTypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, eventTypeTypePropEnum, true); err != nil { return err } return nil @@ -312,6 +313,45 @@ func (m *Event) validateType(formats strfmt.Registry) error { return nil } +// ContextValidate validate this event based on the context it is used +func (m *Event) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Event) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Tags); i++ { + + if m.Tags[i] != nil { + + if swag.IsZero(m.Tags[i]) { // not required + return nil + } + + if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *Event) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/external_backend.go b/client/models/external_backend.go index 416d143a..fdb61060 100644 --- a/client/models/external_backend.go +++ b/client/models/external_backend.go @@ -7,13 +7,13 @@ package models import ( "bytes" + "context" "encoding/json" "io" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -21,6 +21,7 @@ import ( // ExternalBackend External backend // // An external backend contains the configuration needed in order to be plugged into the Cycloid system. A backend is a general purpose concept, but Cycloid specifies which ones are supported and the list of those which are supported for every concrete feature. +// // swagger:model ExternalBackend type ExternalBackend struct { configurationField ExternalBackendConfiguration @@ -191,8 +192,7 @@ func (m ExternalBackend) MarshalJSON() ([]byte, error) { Purpose: m.Purpose, UpdatedAt: m.UpdatedAt, - }, - ) + }) if err != nil { return nil, err } @@ -201,8 +201,7 @@ func (m ExternalBackend) MarshalJSON() ([]byte, error) { }{ Configuration: m.configurationField, - }, - ) + }) if err != nil { return nil, err } @@ -265,6 +264,8 @@ func (m *ExternalBackend) validateConfiguration(formats strfmt.Registry) error { if err := m.Configuration().Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") } return err } @@ -273,12 +274,11 @@ func (m *ExternalBackend) validateConfiguration(formats strfmt.Registry) error { } func (m *ExternalBackend) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -286,20 +286,19 @@ func (m *ExternalBackend) validateCreatedAt(formats strfmt.Registry) error { } func (m *ExternalBackend) validateCredentialCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CredentialCanonical) { // not required return nil } - if err := validate.MinLength("credential_canonical", "body", string(m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -316,20 +315,19 @@ func (m *ExternalBackend) validateDefault(formats strfmt.Registry) error { } func (m *ExternalBackend) validateEnvironmentCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.EnvironmentCanonical) { // not required return nil } - if err := validate.MinLength("environment_canonical", "body", string(m.EnvironmentCanonical), 1); err != nil { + if err := validate.MinLength("environment_canonical", "body", m.EnvironmentCanonical, 1); err != nil { return err } - if err := validate.MaxLength("environment_canonical", "body", string(m.EnvironmentCanonical), 100); err != nil { + if err := validate.MaxLength("environment_canonical", "body", m.EnvironmentCanonical, 100); err != nil { return err } - if err := validate.Pattern("environment_canonical", "body", string(m.EnvironmentCanonical), `^[\da-zA-Z]+(?:(?:[\da-zA-Z\-._]+)?[\da-zA-Z])?$`); err != nil { + if err := validate.Pattern("environment_canonical", "body", m.EnvironmentCanonical, `^[\da-zA-Z]+(?:(?:[\da-zA-Z\-._]+)?[\da-zA-Z])?$`); err != nil { return err } @@ -337,12 +335,11 @@ func (m *ExternalBackend) validateEnvironmentCanonical(formats strfmt.Registry) } func (m *ExternalBackend) validateID(formats strfmt.Registry) error { - if swag.IsZero(m.ID) { // not required return nil } - if err := validate.MinimumInt("id", "body", int64(m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(m.ID), 1, false); err != nil { return err } @@ -350,20 +347,19 @@ func (m *ExternalBackend) validateID(formats strfmt.Registry) error { } func (m *ExternalBackend) validateProjectCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ProjectCanonical) { // not required return nil } - if err := validate.MinLength("project_canonical", "body", string(m.ProjectCanonical), 1); err != nil { + if err := validate.MinLength("project_canonical", "body", m.ProjectCanonical, 1); err != nil { return err } - if err := validate.MaxLength("project_canonical", "body", string(m.ProjectCanonical), 100); err != nil { + if err := validate.MaxLength("project_canonical", "body", m.ProjectCanonical, 100); err != nil { return err } - if err := validate.Pattern("project_canonical", "body", string(m.ProjectCanonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("project_canonical", "body", m.ProjectCanonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -380,12 +376,39 @@ func (m *ExternalBackend) validatePurpose(formats strfmt.Registry) error { } func (m *ExternalBackend) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this external backend based on the context it is used +func (m *ExternalBackend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfiguration(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExternalBackend) contextValidateConfiguration(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Configuration().ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") + } return err } diff --git a/client/models/external_backend_configuration.go b/client/models/external_backend_configuration.go index 59f630df..89bdfb64 100644 --- a/client/models/external_backend_configuration.go +++ b/client/models/external_backend_configuration.go @@ -7,26 +7,30 @@ package models import ( "bytes" + "context" "encoding/json" "io" - "io/ioutil" - - strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" ) // ExternalBackendConfiguration external backend configuration +// // swagger:discriminator ExternalBackendConfiguration engine type ExternalBackendConfiguration interface { runtime.Validatable + runtime.ContextValidatable // engine // Required: true Engine() string SetEngine(string) + + // AdditionalProperties in base type shoud be handled just like regular properties + // At this moment, the base type property is pushed down to the subtype } type externalBackendConfiguration struct { @@ -40,7 +44,6 @@ func (m *externalBackendConfiguration) Engine() string { // SetEngine sets the engine of this polymorphic type func (m *externalBackendConfiguration) SetEngine(val string) { - } // UnmarshalExternalBackendConfigurationSlice unmarshals polymorphic slices of ExternalBackendConfiguration @@ -64,7 +67,7 @@ func UnmarshalExternalBackendConfigurationSlice(reader io.Reader, consumer runti // UnmarshalExternalBackendConfiguration unmarshals polymorphic ExternalBackendConfiguration func UnmarshalExternalBackendConfiguration(reader io.Reader, consumer runtime.Consumer) (ExternalBackendConfiguration, error) { // we need to read this twice, so first into a buffer - data, err := ioutil.ReadAll(reader) + data, err := io.ReadAll(reader) if err != nil { return nil, err } @@ -95,118 +98,106 @@ func unmarshalExternalBackendConfiguration(data []byte, consumer runtime.Consume return nil, err } return &result, nil - case "AWSRemoteTFState": var result AWSRemoteTFState if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "AWSStorage": var result AWSStorage if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "AzureCostExport": var result AzureCostExport if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "AzureRemoteTFState": var result AzureRemoteTFState if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "AzureStorage": var result AzureStorage if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "ElasticsearchLogs": var result ElasticsearchLogs if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "ExternalBackendConfiguration": var result externalBackendConfiguration if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "GCPCostStorage": var result GCPCostStorage if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "GCPRemoteTFState": var result GCPRemoteTFState if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "GCPStorage": var result GCPStorage if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "GitLabHTTPStorage": var result GitLabHTTPStorage if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "HTTPStorage": var result HTTPStorage if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "SwiftRemoteTFState": var result SwiftRemoteTFState if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "SwiftStorage": var result SwiftStorage if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - case "VMwareVsphere": var result VMwareVsphere if err := consumer.Consume(buf2, &result); err != nil { return nil, err } return &result, nil - } return nil, errors.New(422, "invalid engine value: %q", getType.Engine) - } // Validate validates this external backend configuration func (m *externalBackendConfiguration) Validate(formats strfmt.Registry) error { return nil } + +// ContextValidate validates this external backend configuration based on context it is used +func (m *externalBackendConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/client/models/filters.go b/client/models/filters.go index 26ba0b6b..12cbeaae 100644 --- a/client/models/filters.go +++ b/client/models/filters.go @@ -7,6 +7,7 @@ package models // Filters Filters // -// Filters is the possible values the filters can have on list requests +// # Filters is the possible values the filters can have on list requests +// // swagger:model Filters type Filters interface{} diff --git a/client/models/form_entity.go b/client/models/form_entity.go index 0292452e..6b0d28df 100644 --- a/client/models/form_entity.go +++ b/client/models/form_entity.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // FormEntity Forms file's Entity // -// This describes all the attributes possible to configure a form's variable +// # This describes all the attributes possible to configure a form's variable +// // swagger:model FormEntity type FormEntity struct { @@ -63,7 +64,7 @@ type FormEntity struct { // The type of data handled - used to manipulate/validate the input, and also validate default/values // Required: true - // Enum: [integer float string array boolean map] + // Enum: ["integer","float","string","array","boolean","map"] Type *string `json:"type"` // The unit to be displayed for the variable, helping to know what's being manipulated: amount of servers, Go, users, etc. @@ -94,7 +95,7 @@ type FormEntity struct { // The widget used to display the data in the most suitable way // Required: true - // Enum: [auto_complete dropdown radios slider_list slider_range number simple_text switch text_area cy_cred cy_scs cy_crs cy_branch cy_inventory_resource hidden] + // Enum: ["auto_complete","dropdown","radios","slider_list","slider_range","number","simple_text","switch","text_area","cy_cred","cy_scs","cy_crs","cy_branch","cy_inventory_resource","hidden"] Widget *string `json:"widget"` // Some specific configuration that could be applied to that widget. Currently only a few widgets can be configured: @@ -194,7 +195,7 @@ const ( // prop value enum func (m *FormEntity) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, formEntityTypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, formEntityTypeTypePropEnum, true); err != nil { return err } return nil @@ -276,7 +277,7 @@ const ( // prop value enum func (m *FormEntity) validateWidgetEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, formEntityTypeWidgetPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, formEntityTypeWidgetPropEnum, true); err != nil { return err } return nil @@ -296,6 +297,11 @@ func (m *FormEntity) validateWidget(formats strfmt.Registry) error { return nil } +// ContextValidate validates this form entity based on context it is used +func (m *FormEntity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *FormEntity) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/form_group.go b/client/models/form_group.go index 95a06d59..0d258531 100644 --- a/client/models/form_group.go +++ b/client/models/form_group.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // FormGroup Forms File Group +// // swagger:model FormGroup type FormGroup struct { @@ -93,6 +94,47 @@ func (m *FormGroup) validateVars(formats strfmt.Registry) error { if err := m.Vars[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("vars" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vars" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this form group based on the context it is used +func (m *FormGroup) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVars(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *FormGroup) contextValidateVars(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Vars); i++ { + + if m.Vars[i] != nil { + + if swag.IsZero(m.Vars[i]) { // not required + return nil + } + + if err := m.Vars[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vars" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vars" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/form_input.go b/client/models/form_input.go index 0925b375..b4070728 100644 --- a/client/models/form_input.go +++ b/client/models/form_input.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -103,13 +104,18 @@ func (m *FormInput) validateUseCase(formats strfmt.Registry) error { func (m *FormInput) validateVars(formats strfmt.Registry) error { - if err := validate.Required("vars", "body", m.Vars); err != nil { - return err + if m.Vars == nil { + return errors.Required("vars", "body", nil) } return nil } +// ContextValidate validates this form input based on context it is used +func (m *FormInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *FormInput) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/form_inputs.go b/client/models/form_inputs.go index 53d06e35..abc16d2f 100644 --- a/client/models/form_inputs.go +++ b/client/models/form_inputs.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -68,6 +68,8 @@ func (m *FormInputs) validateInputs(formats strfmt.Registry) error { if err := m.Inputs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) } return err } @@ -87,6 +89,45 @@ func (m *FormInputs) validateServiceCatalogRef(formats strfmt.Registry) error { return nil } +// ContextValidate validate this form inputs based on the context it is used +func (m *FormInputs) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInputs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *FormInputs) contextValidateInputs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Inputs); i++ { + + if m.Inputs[i] != nil { + + if swag.IsZero(m.Inputs[i]) { // not required + return nil + } + + if err := m.Inputs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *FormInputs) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/form_section.go b/client/models/form_section.go index 2bf851f9..ad9ae72a 100644 --- a/client/models/form_section.go +++ b/client/models/form_section.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // FormSection Forms File Section +// // swagger:model FormSection type FormSection struct { @@ -61,6 +62,8 @@ func (m *FormSection) validateGroups(formats strfmt.Registry) error { if err := m.Groups[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("groups" + "." + strconv.Itoa(i)) } return err } @@ -80,6 +83,45 @@ func (m *FormSection) validateName(formats strfmt.Registry) error { return nil } +// ContextValidate validate this form section based on the context it is used +func (m *FormSection) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateGroups(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *FormSection) contextValidateGroups(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Groups); i++ { + + if m.Groups[i] != nil { + + if swag.IsZero(m.Groups[i]) { // not required + return nil + } + + if err := m.Groups[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("groups" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *FormSection) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/form_use_case.go b/client/models/form_use_case.go index ddf6552d..3f6e5456 100644 --- a/client/models/form_use_case.go +++ b/client/models/form_use_case.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // FormUseCase Forms File Use case +// // swagger:model FormUseCase type FormUseCase struct { @@ -70,6 +71,47 @@ func (m *FormUseCase) validateSections(formats strfmt.Registry) error { if err := m.Sections[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("sections" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sections" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this form use case based on the context it is used +func (m *FormUseCase) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSections(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *FormUseCase) contextValidateSections(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Sections); i++ { + + if m.Sections[i] != nil { + + if swag.IsZero(m.Sections[i]) { // not required + return nil + } + + if err := m.Sections[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sections" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sections" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/forms_file_v2.go b/client/models/forms_file_v2.go index 771fdd2f..4407e1b6 100644 --- a/client/models/forms_file_v2.go +++ b/client/models/forms_file_v2.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // FormsFileV2 Forms File V2 +// // swagger:model FormsFileV2 type FormsFileV2 struct { @@ -61,6 +62,8 @@ func (m *FormsFileV2) validateUseCases(formats strfmt.Registry) error { if err := m.UseCases[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("use_cases" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("use_cases" + "." + strconv.Itoa(i)) } return err } @@ -80,6 +83,45 @@ func (m *FormsFileV2) validateVersion(formats strfmt.Registry) error { return nil } +// ContextValidate validate this forms file v2 based on the context it is used +func (m *FormsFileV2) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateUseCases(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *FormsFileV2) contextValidateUseCases(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.UseCases); i++ { + + if m.UseCases[i] != nil { + + if swag.IsZero(m.UseCases[i]) { // not required + return nil + } + + if err := m.UseCases[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("use_cases" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("use_cases" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *FormsFileV2) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/forms_validation.go b/client/models/forms_validation.go index 3fa483e8..4ea2dbfc 100644 --- a/client/models/forms_validation.go +++ b/client/models/forms_validation.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" ) // FormsValidation Forms validation // -// Validates a given Form's file +// # Validates a given Form's file +// // swagger:model FormsValidation type FormsValidation struct { @@ -40,13 +41,18 @@ func (m *FormsValidation) Validate(formats strfmt.Registry) error { func (m *FormsValidation) validateFormFile(formats strfmt.Registry) error { - if err := validate.Required("form_file", "body", m.FormFile); err != nil { - return err + if m.FormFile == nil { + return errors.Required("form_file", "body", nil) } return nil } +// ContextValidate validates this forms validation based on context it is used +func (m *FormsValidation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *FormsValidation) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/forms_validation_result.go b/client/models/forms_validation_result.go index 9028ce5c..edec0402 100644 --- a/client/models/forms_validation_result.go +++ b/client/models/forms_validation_result.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // FormsValidationResult FormsValidationResult // -// The result of the validation, if errors is empty means that is correct +// # The result of the validation, if errors is empty means that is correct +// // swagger:model FormsValidationResult type FormsValidationResult struct { @@ -65,6 +67,39 @@ func (m *FormsValidationResult) validateForms(formats strfmt.Registry) error { if err := m.Forms.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("forms") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("forms") + } + return err + } + } + + return nil +} + +// ContextValidate validate this forms validation result based on the context it is used +func (m *FormsValidationResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateForms(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *FormsValidationResult) contextValidateForms(ctx context.Context, formats strfmt.Registry) error { + + if m.Forms != nil { + + if err := m.Forms.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("forms") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("forms") } return err } diff --git a/client/models/forms_values_ref.go b/client/models/forms_values_ref.go index 3ff617cc..1841ab5c 100644 --- a/client/models/forms_values_ref.go +++ b/client/models/forms_values_ref.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // FormsValuesRef Forms values ref // -// It has the information to get the values of an entity of the Form +// # It has the information to get the values of an entity of the Form +// // swagger:model FormsValuesRef type FormsValuesRef struct { @@ -47,6 +49,11 @@ func (m *FormsValuesRef) validateURL(formats strfmt.Registry) error { return nil } +// ContextValidate validates this forms values ref based on context it is used +func (m *FormsValuesRef) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *FormsValuesRef) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/g_c_p_cost_storage.go b/client/models/g_c_p_cost_storage.go index 114d4c33..917639ad 100644 --- a/client/models/g_c_p_cost_storage.go +++ b/client/models/g_c_p_cost_storage.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) @@ -41,15 +41,8 @@ func (m *GCPCostStorage) Engine() string { // SetEngine sets the engine of this subtype func (m *GCPCostStorage) SetEngine(val string) { - } -// Dataset gets the dataset of this subtype - -// ProjectID gets the project id of this subtype - -// Table gets the table of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *GCPCostStorage) UnmarshalJSON(raw []byte) error { var data struct { @@ -95,9 +88,7 @@ func (m *GCPCostStorage) UnmarshalJSON(raw []byte) error { } result.Dataset = data.Dataset - result.ProjectID = data.ProjectID - result.Table = data.Table *m = result @@ -129,8 +120,7 @@ func (m GCPCostStorage) MarshalJSON() ([]byte, error) { ProjectID: m.ProjectID, Table: m.Table, - }, - ) + }) if err != nil { return nil, err } @@ -139,8 +129,7 @@ func (m GCPCostStorage) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -158,6 +147,16 @@ func (m *GCPCostStorage) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validate this g c p cost storage based on the context it is used +func (m *GCPCostStorage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *GCPCostStorage) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/g_c_p_remote_t_f_state.go b/client/models/g_c_p_remote_t_f_state.go index 3aea7928..15806da7 100644 --- a/client/models/g_c_p_remote_t_f_state.go +++ b/client/models/g_c_p_remote_t_f_state.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -40,13 +40,8 @@ func (m *GCPRemoteTFState) Engine() string { // SetEngine sets the engine of this subtype func (m *GCPRemoteTFState) SetEngine(val string) { - } -// Bucket gets the bucket of this subtype - -// Object gets the object of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *GCPRemoteTFState) UnmarshalJSON(raw []byte) error { var data struct { @@ -89,7 +84,6 @@ func (m *GCPRemoteTFState) UnmarshalJSON(raw []byte) error { } result.Bucket = data.Bucket - result.Object = data.Object *m = result @@ -116,8 +110,7 @@ func (m GCPRemoteTFState) MarshalJSON() ([]byte, error) { Bucket: m.Bucket, Object: m.Object, - }, - ) + }) if err != nil { return nil, err } @@ -126,8 +119,7 @@ func (m GCPRemoteTFState) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -158,6 +150,16 @@ func (m *GCPRemoteTFState) validateBucket(formats strfmt.Registry) error { return nil } +// ContextValidate validate this g c p remote t f state based on the context it is used +func (m *GCPRemoteTFState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *GCPRemoteTFState) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/g_c_p_storage.go b/client/models/g_c_p_storage.go index 5ae17f05..dadedd8d 100644 --- a/client/models/g_c_p_storage.go +++ b/client/models/g_c_p_storage.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -40,13 +40,8 @@ func (m *GCPStorage) Engine() string { // SetEngine sets the engine of this subtype func (m *GCPStorage) SetEngine(val string) { - } -// Bucket gets the bucket of this subtype - -// Object gets the object of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *GCPStorage) UnmarshalJSON(raw []byte) error { var data struct { @@ -90,7 +85,6 @@ func (m *GCPStorage) UnmarshalJSON(raw []byte) error { } result.Bucket = data.Bucket - result.Object = data.Object *m = result @@ -118,8 +112,7 @@ func (m GCPStorage) MarshalJSON() ([]byte, error) { Bucket: m.Bucket, Object: m.Object, - }, - ) + }) if err != nil { return nil, err } @@ -128,8 +121,7 @@ func (m GCPStorage) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -160,6 +152,16 @@ func (m *GCPStorage) validateBucket(formats strfmt.Registry) error { return nil } +// ContextValidate validate this g c p storage based on the context it is used +func (m *GCPStorage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *GCPStorage) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/general_status.go b/client/models/general_status.go index ff8b4c00..321e4c93 100644 --- a/client/models/general_status.go +++ b/client/models/general_status.go @@ -6,17 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // GeneralStatus GeneralStatus +// // swagger:model GeneralStatus type GeneralStatus struct { @@ -31,7 +32,7 @@ type GeneralStatus struct { // The overall status for the application. // Required: true - // Enum: [Unknown Success Error] + // Enum: ["Unknown","Success","Error"] Status *string `json:"status"` } @@ -72,6 +73,8 @@ func (m *GeneralStatus) validateChecks(formats strfmt.Registry) error { if err := m.Checks[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("checks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("checks" + "." + strconv.Itoa(i)) } return err } @@ -88,7 +91,7 @@ func (m *GeneralStatus) validateMessage(formats strfmt.Registry) error { return err } - if err := validate.MinLength("message", "body", string(*m.Message), 1); err != nil { + if err := validate.MinLength("message", "body", *m.Message, 1); err != nil { return err } @@ -121,7 +124,7 @@ const ( // prop value enum func (m *GeneralStatus) validateStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, generalStatusTypeStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, generalStatusTypeStatusPropEnum, true); err != nil { return err } return nil @@ -141,6 +144,45 @@ func (m *GeneralStatus) validateStatus(formats strfmt.Registry) error { return nil } +// ContextValidate validate this general status based on the context it is used +func (m *GeneralStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateChecks(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *GeneralStatus) contextValidateChecks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Checks); i++ { + + if m.Checks[i] != nil { + + if swag.IsZero(m.Checks[i]) { // not required + return nil + } + + if err := m.Checks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("checks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("checks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *GeneralStatus) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/get_plan.go b/client/models/get_plan.go index 679a724f..fe2e7a20 100644 --- a/client/models/get_plan.go +++ b/client/models/get_plan.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // GetPlan GetPlan // // The plan to get before running another one. +// // swagger:model GetPlan type GetPlan struct { @@ -89,11 +90,11 @@ func (m *GetPlan) validateResource(formats strfmt.Registry) error { func (m *GetPlan) validateSource(formats strfmt.Registry) error { - for k := range m.Source { + if err := validate.Required("source", "body", m.Source); err != nil { + return err + } - if err := validate.Required("source"+"."+k, "body", m.Source[k]); err != nil { - return err - } + for k := range m.Source { if err := validate.Required("source"+"."+k, "body", m.Source[k]); err != nil { return err @@ -114,7 +115,6 @@ func (m *GetPlan) validateType(formats strfmt.Registry) error { } func (m *GetPlan) validateVersionedResourceTypes(formats strfmt.Registry) error { - if swag.IsZero(m.VersionedResourceTypes) { // not required return nil } @@ -128,6 +128,47 @@ func (m *GetPlan) validateVersionedResourceTypes(formats strfmt.Registry) error if err := m.VersionedResourceTypes[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this get plan based on the context it is used +func (m *GetPlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVersionedResourceTypes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *GetPlan) contextValidateVersionedResourceTypes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.VersionedResourceTypes); i++ { + + if m.VersionedResourceTypes[i] != nil { + + if swag.IsZero(m.VersionedResourceTypes[i]) { // not required + return nil + } + + if err := m.VersionedResourceTypes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/git_hub_o_auth_config.go b/client/models/git_hub_o_auth_config.go index 0db55601..4c56ee28 100644 --- a/client/models/git_hub_o_auth_config.go +++ b/client/models/git_hub_o_auth_config.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -19,6 +19,7 @@ import ( // GitHubOAuthConfig AppConfigGitHubOAuth // // GitHub OAuth configuration. +// // swagger:model GitHubOAuthConfig type GitHubOAuthConfig struct { clientIdField *string @@ -60,11 +61,8 @@ func (m *GitHubOAuthConfig) Type() string { // SetType sets the type of this subtype func (m *GitHubOAuthConfig) SetType(val string) { - } -// HostAddress gets the host address of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *GitHubOAuthConfig) UnmarshalJSON(raw []byte) error { var data struct { @@ -134,8 +132,7 @@ func (m GitHubOAuthConfig) MarshalJSON() ([]byte, error) { }{ HostAddress: m.HostAddress, - }, - ) + }) if err != nil { return nil, err } @@ -152,8 +149,7 @@ func (m GitHubOAuthConfig) MarshalJSON() ([]byte, error) { Provider: m.Provider(), Type: m.Type(), - }, - ) + }) if err != nil { return nil, err } @@ -210,6 +206,16 @@ func (m *GitHubOAuthConfig) validateHostAddress(formats strfmt.Registry) error { return nil } +// ContextValidate validate this git hub o auth config based on the context it is used +func (m *GitHubOAuthConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *GitHubOAuthConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/git_lab_http_storage.go b/client/models/git_lab_http_storage.go index 482da70e..7ed212f5 100644 --- a/client/models/git_lab_http_storage.go +++ b/client/models/git_lab_http_storage.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -35,11 +35,8 @@ func (m *GitLabHTTPStorage) Engine() string { // SetEngine sets the engine of this subtype func (m *GitLabHTTPStorage) SetEngine(val string) { - } -// URL gets the url of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *GitLabHTTPStorage) UnmarshalJSON(raw []byte) error { var data struct { @@ -97,8 +94,7 @@ func (m GitLabHTTPStorage) MarshalJSON() ([]byte, error) { }{ URL: m.URL, - }, - ) + }) if err != nil { return nil, err } @@ -107,8 +103,7 @@ func (m GitLabHTTPStorage) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -139,6 +134,16 @@ func (m *GitLabHTTPStorage) validateURL(formats strfmt.Registry) error { return nil } +// ContextValidate validate this git lab HTTP storage based on the context it is used +func (m *GitLabHTTPStorage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *GitLabHTTPStorage) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/google_o_auth_config.go b/client/models/google_o_auth_config.go index 9a16dd4a..85d54034 100644 --- a/client/models/google_o_auth_config.go +++ b/client/models/google_o_auth_config.go @@ -7,18 +7,19 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // GoogleOAuthConfig AppConfigGoogleOAuth // -// Google OAuth configuration +// # Google OAuth configuration +// // swagger:model GoogleOAuthConfig type GoogleOAuthConfig struct { clientIdField *string @@ -53,7 +54,6 @@ func (m *GoogleOAuthConfig) Type() string { // SetType sets the type of this subtype func (m *GoogleOAuthConfig) SetType(val string) { - } // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure @@ -106,8 +106,7 @@ func (m GoogleOAuthConfig) MarshalJSON() ([]byte, error) { var b1, b2, b3 []byte var err error b1, err = json.Marshal(struct { - }{}, - ) + }{}) if err != nil { return nil, err } @@ -124,8 +123,7 @@ func (m GoogleOAuthConfig) MarshalJSON() ([]byte, error) { Provider: m.Provider(), Type: m.Type(), - }, - ) + }) if err != nil { return nil, err } @@ -169,6 +167,16 @@ func (m *GoogleOAuthConfig) validateProvider(formats strfmt.Registry) error { return nil } +// ContextValidate validate this google o auth config based on the context it is used +func (m *GoogleOAuthConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *GoogleOAuthConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/group_config.go b/client/models/group_config.go index 3d9c5b10..a0a13ea4 100644 --- a/client/models/group_config.go +++ b/client/models/group_config.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // GroupConfig GroupConfig // -// The entity which represents pipeline group config +// # The entity which represents pipeline group config +// // swagger:model GroupConfig type GroupConfig struct { @@ -53,6 +55,11 @@ func (m *GroupConfig) validateName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this group config based on context it is used +func (m *GroupConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *GroupConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/http_storage.go b/client/models/http_storage.go index 9f4b1d1d..88b4533c 100644 --- a/client/models/http_storage.go +++ b/client/models/http_storage.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -35,11 +35,8 @@ func (m *HTTPStorage) Engine() string { // SetEngine sets the engine of this subtype func (m *HTTPStorage) SetEngine(val string) { - } -// URL gets the url of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *HTTPStorage) UnmarshalJSON(raw []byte) error { var data struct { @@ -97,8 +94,7 @@ func (m HTTPStorage) MarshalJSON() ([]byte, error) { }{ URL: m.URL, - }, - ) + }) if err != nil { return nil, err } @@ -107,8 +103,7 @@ func (m HTTPStorage) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -139,6 +134,16 @@ func (m *HTTPStorage) validateURL(formats strfmt.Registry) error { return nil } +// ContextValidate validate this HTTP storage based on the context it is used +func (m *HTTPStorage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *HTTPStorage) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/in_use_config_repository.go b/client/models/in_use_config_repository.go index 26b766a6..424d963a 100644 --- a/client/models/in_use_config_repository.go +++ b/client/models/in_use_config_repository.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InUseConfigRepository InUseConfigRepository // -// Represents a Config repository that's using credential +// # Represents a Config repository that's using credential +// // swagger:model InUseConfigRepository type InUseConfigRepository struct { @@ -55,15 +57,15 @@ func (m *InUseConfigRepository) validateCanonical(formats strfmt.Registry) error return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -79,6 +81,11 @@ func (m *InUseConfigRepository) validateName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this in use config repository based on context it is used +func (m *InUseConfigRepository) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InUseConfigRepository) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/in_use_environment.go b/client/models/in_use_environment.go index 11833b8f..2c05d243 100644 --- a/client/models/in_use_environment.go +++ b/client/models/in_use_environment.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InUseEnvironment InUseEnvironment // -// Represents an environment that's using credential +// # Represents an environment that's using credential +// // swagger:model InUseEnvironment type InUseEnvironment struct { @@ -47,21 +49,26 @@ func (m *InUseEnvironment) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } return nil } +// ContextValidate validates this in use environment based on context it is used +func (m *InUseEnvironment) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InUseEnvironment) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/in_use_external_backend.go b/client/models/in_use_external_backend.go index 0a2af177..86830827 100644 --- a/client/models/in_use_external_backend.go +++ b/client/models/in_use_external_backend.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InUseExternalBackend InUseExternalBackend // -// Represents a external backend that's using credential +// # Represents a external backend that's using credential +// // swagger:model InUseExternalBackend type InUseExternalBackend struct { @@ -70,7 +72,6 @@ func (m *InUseExternalBackend) validateEngine(formats strfmt.Registry) error { } func (m *InUseExternalBackend) validateEnvironment(formats strfmt.Registry) error { - if swag.IsZero(m.Environment) { // not required return nil } @@ -79,6 +80,8 @@ func (m *InUseExternalBackend) validateEnvironment(formats strfmt.Registry) erro if err := m.Environment.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") } return err } @@ -88,7 +91,6 @@ func (m *InUseExternalBackend) validateEnvironment(formats strfmt.Registry) erro } func (m *InUseExternalBackend) validateProject(formats strfmt.Registry) error { - if swag.IsZero(m.Project) { // not required return nil } @@ -97,6 +99,8 @@ func (m *InUseExternalBackend) validateProject(formats strfmt.Registry) error { if err := m.Project.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("project") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project") } return err } @@ -114,6 +118,66 @@ func (m *InUseExternalBackend) validatePurpose(formats strfmt.Registry) error { return nil } +// ContextValidate validate this in use external backend based on the context it is used +func (m *InUseExternalBackend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEnvironment(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProject(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InUseExternalBackend) contextValidateEnvironment(ctx context.Context, formats strfmt.Registry) error { + + if m.Environment != nil { + + if swag.IsZero(m.Environment) { // not required + return nil + } + + if err := m.Environment.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") + } + return err + } + } + + return nil +} + +func (m *InUseExternalBackend) contextValidateProject(ctx context.Context, formats strfmt.Registry) error { + + if m.Project != nil { + + if swag.IsZero(m.Project) { // not required + return nil + } + + if err := m.Project.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *InUseExternalBackend) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/in_use_project.go b/client/models/in_use_project.go index 44c35651..d2c25599 100644 --- a/client/models/in_use_project.go +++ b/client/models/in_use_project.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InUseProject InUseProject // -// Represents a project that's using credential +// # Represents a project that's using credential +// // swagger:model InUseProject type InUseProject struct { @@ -55,15 +57,15 @@ func (m *InUseProject) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -79,6 +81,11 @@ func (m *InUseProject) validateName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this in use project based on context it is used +func (m *InUseProject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InUseProject) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/in_use_service_catalog_source.go b/client/models/in_use_service_catalog_source.go index 9e89cf39..47ea1e3c 100644 --- a/client/models/in_use_service_catalog_source.go +++ b/client/models/in_use_service_catalog_source.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InUseServiceCatalogSource InUseServiceCatalogSource // -// Represents a Service catalog source that's using credential +// # Represents a Service catalog source that's using credential +// // swagger:model InUseServiceCatalogSource type InUseServiceCatalogSource struct { @@ -55,15 +57,15 @@ func (m *InUseServiceCatalogSource) validateCanonical(formats strfmt.Registry) e return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -79,6 +81,11 @@ func (m *InUseServiceCatalogSource) validateName(formats strfmt.Registry) error return nil } +// ContextValidate validates this in use service catalog source based on context it is used +func (m *InUseServiceCatalogSource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InUseServiceCatalogSource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/infra_import.go b/client/models/infra_import.go index 4ecbeca8..699a7ca3 100644 --- a/client/models/infra_import.go +++ b/client/models/infra_import.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -42,7 +42,7 @@ type InfraImport struct { // The import process status. // Required: true - // Enum: [succeeded failed importing] + // Enum: ["succeeded","failed","importing"] Status *string `json:"status"` } @@ -95,20 +95,19 @@ func (m *InfraImport) validateLogs(formats strfmt.Registry) error { } func (m *InfraImport) validateProjectCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ProjectCanonical) { // not required return nil } - if err := validate.MinLength("project_canonical", "body", string(m.ProjectCanonical), 1); err != nil { + if err := validate.MinLength("project_canonical", "body", m.ProjectCanonical, 1); err != nil { return err } - if err := validate.MaxLength("project_canonical", "body", string(m.ProjectCanonical), 100); err != nil { + if err := validate.MaxLength("project_canonical", "body", m.ProjectCanonical, 100); err != nil { return err } - if err := validate.Pattern("project_canonical", "body", string(m.ProjectCanonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("project_canonical", "body", m.ProjectCanonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -150,7 +149,7 @@ const ( // prop value enum func (m *InfraImport) validateStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, infraImportTypeStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, infraImportTypeStatusPropEnum, true); err != nil { return err } return nil @@ -170,6 +169,11 @@ func (m *InfraImport) validateStatus(formats strfmt.Registry) error { return nil } +// ContextValidate validates this infra import based on context it is used +func (m *InfraImport) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InfraImport) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/infra_import_preset.go b/client/models/infra_import_preset.go index 02614a74..56fbbf23 100644 --- a/client/models/infra_import_preset.go +++ b/client/models/infra_import_preset.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -65,6 +66,11 @@ func (m *InfraImportPreset) validateResources(formats strfmt.Registry) error { return nil } +// ContextValidate validates this infra import preset based on context it is used +func (m *InfraImportPreset) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InfraImportPreset) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/infra_import_resource.go b/client/models/infra_import_resource.go index 3baea86c..8a21923f 100644 --- a/client/models/infra_import_resource.go +++ b/client/models/infra_import_resource.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -48,6 +49,11 @@ func (m *InfraImportResource) validateID(formats strfmt.Registry) error { return nil } +// ContextValidate validates this infra import resource based on context it is used +func (m *InfraImportResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InfraImportResource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/infra_import_resource_body.go b/client/models/infra_import_resource_body.go index f9be29b9..3e970da6 100644 --- a/client/models/infra_import_resource_body.go +++ b/client/models/infra_import_resource_body.go @@ -7,20 +7,21 @@ package models import ( "bytes" + "context" "encoding/json" "io" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InfraImportResourceBody Provider Resources body // -// Entry that represents all the data needed for fetching resource +// # Entry that represents all the data needed for fetching resource +// // swagger:model InfraImportResourceBody type InfraImportResourceBody struct { configurationField CloudProviderConfiguration @@ -97,8 +98,7 @@ func (m InfraImportResourceBody) MarshalJSON() ([]byte, error) { CredentialCanonical: m.CredentialCanonical, Tags: m.Tags, - }, - ) + }) if err != nil { return nil, err } @@ -107,8 +107,7 @@ func (m InfraImportResourceBody) MarshalJSON() ([]byte, error) { }{ Configuration: m.configurationField, - }, - ) + }) if err != nil { return nil, err } @@ -143,6 +142,8 @@ func (m *InfraImportResourceBody) validateConfiguration(formats strfmt.Registry) if err := m.Configuration().Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") } return err } @@ -156,15 +157,43 @@ func (m *InfraImportResourceBody) validateCredentialCanonical(formats strfmt.Reg return err } - if err := validate.MinLength("credential_canonical", "body", string(*m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", *m.CredentialCanonical, 3); err != nil { + return err + } + + if err := validate.MaxLength("credential_canonical", "body", *m.CredentialCanonical, 100); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(*m.CredentialCanonical), 100); err != nil { + if err := validate.Pattern("credential_canonical", "body", *m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(*m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + return nil +} + +// ContextValidate validate this infra import resource body based on the context it is used +func (m *InfraImportResourceBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfiguration(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InfraImportResourceBody) contextValidateConfiguration(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Configuration().ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") + } return err } diff --git a/client/models/infra_import_resources_body.go b/client/models/infra_import_resources_body.go index 0f807939..65a38459 100644 --- a/client/models/infra_import_resources_body.go +++ b/client/models/infra_import_resources_body.go @@ -7,20 +7,21 @@ package models import ( "bytes" + "context" "encoding/json" "io" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InfraImportResourcesBody Provider's Resources body // -// Entry that represents all the data needed for fetching resources +// # Entry that represents all the data needed for fetching resources +// // swagger:model InfraImportResourcesBody type InfraImportResourcesBody struct { configurationField CloudProviderConfiguration @@ -85,8 +86,7 @@ func (m InfraImportResourcesBody) MarshalJSON() ([]byte, error) { }{ CredentialCanonical: m.CredentialCanonical, - }, - ) + }) if err != nil { return nil, err } @@ -95,8 +95,7 @@ func (m InfraImportResourcesBody) MarshalJSON() ([]byte, error) { }{ Configuration: m.configurationField, - }, - ) + }) if err != nil { return nil, err } @@ -131,6 +130,8 @@ func (m *InfraImportResourcesBody) validateConfiguration(formats strfmt.Registry if err := m.Configuration().Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") } return err } @@ -144,15 +145,43 @@ func (m *InfraImportResourcesBody) validateCredentialCanonical(formats strfmt.Re return err } - if err := validate.MinLength("credential_canonical", "body", string(*m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", *m.CredentialCanonical, 3); err != nil { + return err + } + + if err := validate.MaxLength("credential_canonical", "body", *m.CredentialCanonical, 100); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(*m.CredentialCanonical), 100); err != nil { + if err := validate.Pattern("credential_canonical", "body", *m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(*m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + return nil +} + +// ContextValidate validate this infra import resources body based on the context it is used +func (m *InfraImportResourcesBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfiguration(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InfraImportResourcesBody) contextValidateConfiguration(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Configuration().ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") + } return err } diff --git a/client/models/infra_policies_validation_result.go b/client/models/infra_policies_validation_result.go index bc0f3fce..4a4df2e0 100644 --- a/client/models/infra_policies_validation_result.go +++ b/client/models/infra_policies_validation_result.go @@ -6,17 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // InfraPoliciesValidationResult Infra policies validation results. // // The set of not respected rules for the checked policies. +// // swagger:model InfraPoliciesValidationResult type InfraPoliciesValidationResult struct { @@ -53,7 +54,6 @@ func (m *InfraPoliciesValidationResult) Validate(formats strfmt.Registry) error } func (m *InfraPoliciesValidationResult) validateAdvisories(formats strfmt.Registry) error { - if swag.IsZero(m.Advisories) { // not required return nil } @@ -67,6 +67,8 @@ func (m *InfraPoliciesValidationResult) validateAdvisories(formats strfmt.Regist if err := m.Advisories[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("advisories" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("advisories" + "." + strconv.Itoa(i)) } return err } @@ -78,7 +80,6 @@ func (m *InfraPoliciesValidationResult) validateAdvisories(formats strfmt.Regist } func (m *InfraPoliciesValidationResult) validateCriticals(formats strfmt.Registry) error { - if swag.IsZero(m.Criticals) { // not required return nil } @@ -92,6 +93,8 @@ func (m *InfraPoliciesValidationResult) validateCriticals(formats strfmt.Registr if err := m.Criticals[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("criticals" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("criticals" + "." + strconv.Itoa(i)) } return err } @@ -103,7 +106,6 @@ func (m *InfraPoliciesValidationResult) validateCriticals(formats strfmt.Registr } func (m *InfraPoliciesValidationResult) validateWarnings(formats strfmt.Registry) error { - if swag.IsZero(m.Warnings) { // not required return nil } @@ -117,6 +119,105 @@ func (m *InfraPoliciesValidationResult) validateWarnings(formats strfmt.Registry if err := m.Warnings[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("warnings" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("warnings" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this infra policies validation result based on the context it is used +func (m *InfraPoliciesValidationResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAdvisories(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateCriticals(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateWarnings(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InfraPoliciesValidationResult) contextValidateAdvisories(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Advisories); i++ { + + if m.Advisories[i] != nil { + + if swag.IsZero(m.Advisories[i]) { // not required + return nil + } + + if err := m.Advisories[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("advisories" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("advisories" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *InfraPoliciesValidationResult) contextValidateCriticals(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Criticals); i++ { + + if m.Criticals[i] != nil { + + if swag.IsZero(m.Criticals[i]) { // not required + return nil + } + + if err := m.Criticals[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("criticals" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("criticals" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *InfraPoliciesValidationResult) contextValidateWarnings(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Warnings); i++ { + + if m.Warnings[i] != nil { + + if swag.IsZero(m.Warnings[i]) { // not required + return nil + } + + if err := m.Warnings[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("warnings" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("warnings" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/infra_policies_validation_result_item.go b/client/models/infra_policies_validation_result_item.go index 9fbb7a27..40a6b50a 100644 --- a/client/models/infra_policies_validation_result_item.go +++ b/client/models/infra_policies_validation_result_item.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -53,6 +54,39 @@ func (m *InfraPoliciesValidationResultItem) validateInfraPolicy(formats strfmt.R if err := m.InfraPolicy.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("infra_policy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("infra_policy") + } + return err + } + } + + return nil +} + +// ContextValidate validate this infra policies validation result item based on the context it is used +func (m *InfraPoliciesValidationResultItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInfraPolicy(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InfraPoliciesValidationResultItem) contextValidateInfraPolicy(ctx context.Context, formats strfmt.Registry) error { + + if m.InfraPolicy != nil { + + if err := m.InfraPolicy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("infra_policy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("infra_policy") } return err } diff --git a/client/models/infra_policy.go b/client/models/infra_policy.go index c8b3a67f..7634bbc6 100644 --- a/client/models/infra_policy.go +++ b/client/models/infra_policy.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // InfraPolicy InfraPolicy // // The policy to control operations across infrastructure. +// // swagger:model InfraPolicy type InfraPolicy struct { @@ -67,7 +68,7 @@ type InfraPolicy struct { // Uses advisory to allow them but a notification must be send. // // Required: true - // Enum: [critical warning advisory] + // Enum: ["critical","warning","advisory"] Severity *string `json:"severity"` // updated at @@ -140,15 +141,15 @@ func (m *InfraPolicy) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -188,7 +189,7 @@ func (m *InfraPolicy) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -201,7 +202,7 @@ func (m *InfraPolicy) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -209,7 +210,6 @@ func (m *InfraPolicy) validateName(formats strfmt.Registry) error { } func (m *InfraPolicy) validateOwner(formats strfmt.Registry) error { - if swag.IsZero(m.Owner) { // not required return nil } @@ -218,6 +218,8 @@ func (m *InfraPolicy) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -252,7 +254,7 @@ const ( // prop value enum func (m *InfraPolicy) validateSeverityEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, infraPolicyTypeSeverityPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, infraPolicyTypeSeverityPropEnum, true); err != nil { return err } return nil @@ -281,6 +283,41 @@ func (m *InfraPolicy) validateUpdatedAt(formats strfmt.Registry) error { return nil } +// ContextValidate validate this infra policy based on the context it is used +func (m *InfraPolicy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InfraPolicy) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if swag.IsZero(m.Owner) { // not required + return nil + } + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *InfraPolicy) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/infrastructure.go b/client/models/infrastructure.go index 84f5f46c..9fef79d2 100644 --- a/client/models/infrastructure.go +++ b/client/models/infrastructure.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Infrastructure Infrastructure // -// Holds all the Infrastructure of the project in an environment +// # Holds all the Infrastructure of the project in an environment +// // swagger:model Infrastructure type Infrastructure struct { @@ -48,8 +50,8 @@ func (m *Infrastructure) Validate(formats strfmt.Registry) error { func (m *Infrastructure) validateConfig(formats strfmt.Registry) error { - if err := validate.Required("config", "body", m.Config); err != nil { - return err + if m.Config == nil { + return errors.Required("config", "body", nil) } return nil @@ -65,6 +67,39 @@ func (m *Infrastructure) validateGraph(formats strfmt.Registry) error { if err := m.Graph.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("graph") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("graph") + } + return err + } + } + + return nil +} + +// ContextValidate validate this infrastructure based on the context it is used +func (m *Infrastructure) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateGraph(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Infrastructure) contextValidateGraph(ctx context.Context, formats strfmt.Registry) error { + + if m.Graph != nil { + + if err := m.Graph.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("graph") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("graph") } return err } diff --git a/client/models/infrastructure_config.go b/client/models/infrastructure_config.go index 48240cf0..5063972b 100644 --- a/client/models/infrastructure_config.go +++ b/client/models/infrastructure_config.go @@ -7,6 +7,7 @@ package models // InfrastructureConfig InfrastructureConfig // -// Holds all the Infrastructure config of the TFState +// # Holds all the Infrastructure config of the TFState +// // swagger:model InfrastructureConfig type InfrastructureConfig interface{} diff --git a/client/models/infrastructure_graph.go b/client/models/infrastructure_graph.go index bb14497b..03090244 100644 --- a/client/models/infrastructure_graph.go +++ b/client/models/infrastructure_graph.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InfrastructureGraph InfrastructureGraph // -// Holds all the Infrastructure of the project in an environment in Graph format +// # Holds all the Infrastructure of the project in an environment in Graph format +// // swagger:model InfrastructureGraph type InfrastructureGraph struct { @@ -63,6 +64,8 @@ func (m *InfrastructureGraph) validateEdges(formats strfmt.Registry) error { if err := m.Edges[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("edges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("edges" + "." + strconv.Itoa(i)) } return err } @@ -88,6 +91,76 @@ func (m *InfrastructureGraph) validateNodes(formats strfmt.Registry) error { if err := m.Nodes[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("nodes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("nodes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this infrastructure graph based on the context it is used +func (m *InfrastructureGraph) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEdges(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNodes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InfrastructureGraph) contextValidateEdges(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Edges); i++ { + + if m.Edges[i] != nil { + + if swag.IsZero(m.Edges[i]) { // not required + return nil + } + + if err := m.Edges[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("edges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("edges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *InfrastructureGraph) contextValidateNodes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Nodes); i++ { + + if m.Nodes[i] != nil { + + if swag.IsZero(m.Nodes[i]) { // not required + return nil + } + + if err := m.Nodes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("nodes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("nodes" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/infrastructure_graph_edge.go b/client/models/infrastructure_graph_edge.go index a19db9c6..7ffa717a 100644 --- a/client/models/infrastructure_graph_edge.go +++ b/client/models/infrastructure_graph_edge.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InfrastructureGraphEdge Infrastructure // -// Holds the information of an Edge of the Graph +// # Holds the information of an Edge of the Graph +// // swagger:model InfrastructureGraphEdge type InfrastructureGraphEdge struct { @@ -98,6 +100,11 @@ func (m *InfrastructureGraphEdge) validateTarget(formats strfmt.Registry) error return nil } +// ContextValidate validates this infrastructure graph edge based on context it is used +func (m *InfrastructureGraphEdge) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InfrastructureGraphEdge) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/infrastructure_graph_node.go b/client/models/infrastructure_graph_node.go index 2a6cb4f7..c1317b0a 100644 --- a/client/models/infrastructure_graph_node.go +++ b/client/models/infrastructure_graph_node.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InfrastructureGraphNode Infrastructure // -// Holds the information of a Node of the Graph +// # Holds the information of a Node of the Graph +// // swagger:model InfrastructureGraphNode type InfrastructureGraphNode struct { @@ -99,6 +101,39 @@ func (m *InfrastructureGraphNode) validateResource(formats strfmt.Registry) erro if err := m.Resource.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("resource") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resource") + } + return err + } + } + + return nil +} + +// ContextValidate validate this infrastructure graph node based on the context it is used +func (m *InfrastructureGraphNode) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateResource(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InfrastructureGraphNode) contextValidateResource(ctx context.Context, formats strfmt.Registry) error { + + if m.Resource != nil { + + if err := m.Resource.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resource") } return err } diff --git a/client/models/infrastructure_resources_aggregation_item.go b/client/models/infrastructure_resources_aggregation_item.go index 6576b5db..df47d9a8 100644 --- a/client/models/infrastructure_resources_aggregation_item.go +++ b/client/models/infrastructure_resources_aggregation_item.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // InfrastructureResourcesAggregationItem Infrastructure Resource Aggregation Item // // Contains aggregated data of a single type of an infrastructure resource. +// // swagger:model InfrastructureResourcesAggregationItem type InfrastructureResourcesAggregationItem struct { @@ -47,6 +49,11 @@ func (m *InfrastructureResourcesAggregationItem) validateTotalAmount(formats str return nil } +// ContextValidate validates this infrastructure resources aggregation item based on context it is used +func (m *InfrastructureResourcesAggregationItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InfrastructureResourcesAggregationItem) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/inventory_resource.go b/client/models/inventory_resource.go index ed2be50e..ec1c6515 100644 --- a/client/models/inventory_resource.go +++ b/client/models/inventory_resource.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InventoryResource Inventory Resource // -// The Resource of the Inventory representing an element of your infrastructure +// # The Resource of the Inventory representing an element of your infrastructure +// // swagger:model InventoryResource type InventoryResource struct { @@ -138,12 +140,11 @@ func (m *InventoryResource) Validate(formats strfmt.Registry) error { } func (m *InventoryResource) validateCPU(formats strfmt.Registry) error { - if swag.IsZero(m.CPU) { // not required return nil } - if err := validate.MinimumInt("cpu", "body", int64(*m.CPU), 0, false); err != nil { + if err := validate.MinimumUint("cpu", "body", *m.CPU, 0, false); err != nil { return err } @@ -151,12 +152,11 @@ func (m *InventoryResource) validateCPU(formats strfmt.Registry) error { } func (m *InventoryResource) validateEnvironmentCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.EnvironmentCanonical) { // not required return nil } - if err := validate.Pattern("environment_canonical", "body", string(m.EnvironmentCanonical), `^[\da-zA-Z]+(?:(?:[\da-zA-Z\-._]+)?[\da-zA-Z])?$`); err != nil { + if err := validate.Pattern("environment_canonical", "body", m.EnvironmentCanonical, `^[\da-zA-Z]+(?:(?:[\da-zA-Z\-._]+)?[\da-zA-Z])?$`); err != nil { return err } @@ -164,12 +164,11 @@ func (m *InventoryResource) validateEnvironmentCanonical(formats strfmt.Registry } func (m *InventoryResource) validateID(formats strfmt.Registry) error { - if swag.IsZero(m.ID) { // not required return nil } - if err := validate.MinimumInt("id", "body", int64(m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(m.ID), 1, false); err != nil { return err } @@ -177,7 +176,6 @@ func (m *InventoryResource) validateID(formats strfmt.Registry) error { } func (m *InventoryResource) validateImage(formats strfmt.Registry) error { - if swag.IsZero(m.Image) { // not required return nil } @@ -190,12 +188,11 @@ func (m *InventoryResource) validateImage(formats strfmt.Registry) error { } func (m *InventoryResource) validateMemory(formats strfmt.Registry) error { - if swag.IsZero(m.Memory) { // not required return nil } - if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { + if err := validate.MinimumUint("memory", "body", *m.Memory, 0, false); err != nil { return err } @@ -212,12 +209,11 @@ func (m *InventoryResource) validateName(formats strfmt.Registry) error { } func (m *InventoryResource) validateProjectCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ProjectCanonical) { // not required return nil } - if err := validate.Pattern("project_canonical", "body", string(m.ProjectCanonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("project_canonical", "body", m.ProjectCanonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -234,12 +230,11 @@ func (m *InventoryResource) validateProvider(formats strfmt.Registry) error { } func (m *InventoryResource) validateStorage(formats strfmt.Registry) error { - if swag.IsZero(m.Storage) { // not required return nil } - if err := validate.MinimumInt("storage", "body", int64(*m.Storage), 0, false); err != nil { + if err := validate.MinimumUint("storage", "body", *m.Storage, 0, false); err != nil { return err } @@ -255,6 +250,11 @@ func (m *InventoryResource) validateType(formats strfmt.Registry) error { return nil } +// ContextValidate validates this inventory resource based on context it is used +func (m *InventoryResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InventoryResource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/inventory_resource_label.go b/client/models/inventory_resource_label.go index 3a0543bc..7b031112 100644 --- a/client/models/inventory_resource_label.go +++ b/client/models/inventory_resource_label.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InventoryResourceLabel Inventory Resource Label // -// Aggregated information of resources having a label +// # Aggregated information of resources having a label +// // swagger:model InventoryResourceLabel type InventoryResourceLabel struct { @@ -71,7 +73,7 @@ func (m *InventoryResourceLabel) validateCPU(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("cpu", "body", int64(*m.CPU), 0, false); err != nil { + if err := validate.MinimumUint("cpu", "body", *m.CPU, 0, false); err != nil { return err } @@ -84,7 +86,7 @@ func (m *InventoryResourceLabel) validateMemory(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { + if err := validate.MinimumUint("memory", "body", *m.Memory, 0, false); err != nil { return err } @@ -106,13 +108,18 @@ func (m *InventoryResourceLabel) validateStorage(formats strfmt.Registry) error return err } - if err := validate.MinimumInt("storage", "body", int64(*m.Storage), 0, false); err != nil { + if err := validate.MinimumUint("storage", "body", *m.Storage, 0, false); err != nil { return err } return nil } +// ContextValidate validates this inventory resource label based on context it is used +func (m *InventoryResourceLabel) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InventoryResourceLabel) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/invitation.go b/client/models/invitation.go index 4b13ed89..283248f6 100644 --- a/client/models/invitation.go +++ b/client/models/invitation.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // Invitation Invitation // // It represents an Invitation to join an Organization. +// // swagger:model Invitation type Invitation struct { @@ -52,7 +53,7 @@ type Invitation struct { // state // Required: true - // Enum: [pending accepted declined] + // Enum: ["pending","accepted","declined"] State *string `json:"state"` } @@ -104,7 +105,7 @@ func (m *Invitation) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -130,7 +131,7 @@ func (m *Invitation) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -138,7 +139,6 @@ func (m *Invitation) validateID(formats strfmt.Registry) error { } func (m *Invitation) validateInvitedBy(formats strfmt.Registry) error { - if swag.IsZero(m.InvitedBy) { // not required return nil } @@ -147,6 +147,8 @@ func (m *Invitation) validateInvitedBy(formats strfmt.Registry) error { if err := m.InvitedBy.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("invited_by") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("invited_by") } return err } @@ -156,7 +158,6 @@ func (m *Invitation) validateInvitedBy(formats strfmt.Registry) error { } func (m *Invitation) validateInvitee(formats strfmt.Registry) error { - if swag.IsZero(m.Invitee) { // not required return nil } @@ -165,6 +166,8 @@ func (m *Invitation) validateInvitee(formats strfmt.Registry) error { if err := m.Invitee.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("invitee") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("invitee") } return err } @@ -174,12 +177,11 @@ func (m *Invitation) validateInvitee(formats strfmt.Registry) error { } func (m *Invitation) validateResentAt(formats strfmt.Registry) error { - if swag.IsZero(m.ResentAt) { // not required return nil } - if err := validate.MinimumInt("resent_at", "body", int64(*m.ResentAt), 0, false); err != nil { + if err := validate.MinimumUint("resent_at", "body", *m.ResentAt, 0, false); err != nil { return err } @@ -196,6 +198,8 @@ func (m *Invitation) validateRole(formats strfmt.Registry) error { if err := m.Role.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("role") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("role") } return err } @@ -230,7 +234,7 @@ const ( // prop value enum func (m *Invitation) validateStateEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, invitationTypeStatePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, invitationTypeStatePropEnum, true); err != nil { return err } return nil @@ -250,6 +254,87 @@ func (m *Invitation) validateState(formats strfmt.Registry) error { return nil } +// ContextValidate validate this invitation based on the context it is used +func (m *Invitation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInvitedBy(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateInvitee(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateRole(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Invitation) contextValidateInvitedBy(ctx context.Context, formats strfmt.Registry) error { + + if m.InvitedBy != nil { + + if swag.IsZero(m.InvitedBy) { // not required + return nil + } + + if err := m.InvitedBy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("invited_by") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("invited_by") + } + return err + } + } + + return nil +} + +func (m *Invitation) contextValidateInvitee(ctx context.Context, formats strfmt.Registry) error { + + if m.Invitee != nil { + + if swag.IsZero(m.Invitee) { // not required + return nil + } + + if err := m.Invitee.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("invitee") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("invitee") + } + return err + } + } + + return nil +} + +func (m *Invitation) contextValidateRole(ctx context.Context, formats strfmt.Registry) error { + + if m.Role != nil { + + if err := m.Role.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("role") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("role") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Invitation) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/job.go b/client/models/job.go index c4ef22b5..bc627f19 100644 --- a/client/models/job.go +++ b/client/models/job.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // Job Job // // The entity which represents a job output in the application. +// // swagger:model Job type Job struct { @@ -108,7 +109,6 @@ func (m *Job) Validate(formats strfmt.Registry) error { } func (m *Job) validateFinishedBuild(formats strfmt.Registry) error { - if swag.IsZero(m.FinishedBuild) { // not required return nil } @@ -117,6 +117,8 @@ func (m *Job) validateFinishedBuild(formats strfmt.Registry) error { if err := m.FinishedBuild.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("finished_build") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("finished_build") } return err } @@ -135,7 +137,6 @@ func (m *Job) validateID(formats strfmt.Registry) error { } func (m *Job) validateInputs(formats strfmt.Registry) error { - if swag.IsZero(m.Inputs) { // not required return nil } @@ -149,6 +150,8 @@ func (m *Job) validateInputs(formats strfmt.Registry) error { if err := m.Inputs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) } return err } @@ -169,7 +172,6 @@ func (m *Job) validateName(formats strfmt.Registry) error { } func (m *Job) validateNextBuild(formats strfmt.Registry) error { - if swag.IsZero(m.NextBuild) { // not required return nil } @@ -178,6 +180,8 @@ func (m *Job) validateNextBuild(formats strfmt.Registry) error { if err := m.NextBuild.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("next_build") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next_build") } return err } @@ -187,7 +191,6 @@ func (m *Job) validateNextBuild(formats strfmt.Registry) error { } func (m *Job) validateOutputs(formats strfmt.Registry) error { - if swag.IsZero(m.Outputs) { // not required return nil } @@ -201,6 +204,8 @@ func (m *Job) validateOutputs(formats strfmt.Registry) error { if err := m.Outputs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("outputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("outputs" + "." + strconv.Itoa(i)) } return err } @@ -212,7 +217,6 @@ func (m *Job) validateOutputs(formats strfmt.Registry) error { } func (m *Job) validateTransitionBuild(formats strfmt.Registry) error { - if swag.IsZero(m.TransitionBuild) { // not required return nil } @@ -221,6 +225,151 @@ func (m *Job) validateTransitionBuild(formats strfmt.Registry) error { if err := m.TransitionBuild.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("transition_build") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("transition_build") + } + return err + } + } + + return nil +} + +// ContextValidate validate this job based on the context it is used +func (m *Job) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateFinishedBuild(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateInputs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNextBuild(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOutputs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTransitionBuild(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Job) contextValidateFinishedBuild(ctx context.Context, formats strfmt.Registry) error { + + if m.FinishedBuild != nil { + + if swag.IsZero(m.FinishedBuild) { // not required + return nil + } + + if err := m.FinishedBuild.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("finished_build") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("finished_build") + } + return err + } + } + + return nil +} + +func (m *Job) contextValidateInputs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Inputs); i++ { + + if m.Inputs[i] != nil { + + if swag.IsZero(m.Inputs[i]) { // not required + return nil + } + + if err := m.Inputs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Job) contextValidateNextBuild(ctx context.Context, formats strfmt.Registry) error { + + if m.NextBuild != nil { + + if swag.IsZero(m.NextBuild) { // not required + return nil + } + + if err := m.NextBuild.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("next_build") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next_build") + } + return err + } + } + + return nil +} + +func (m *Job) contextValidateOutputs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Outputs); i++ { + + if m.Outputs[i] != nil { + + if swag.IsZero(m.Outputs[i]) { // not required + return nil + } + + if err := m.Outputs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("outputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("outputs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Job) contextValidateTransitionBuild(ctx context.Context, formats strfmt.Registry) error { + + if m.TransitionBuild != nil { + + if swag.IsZero(m.TransitionBuild) { // not required + return nil + } + + if err := m.TransitionBuild.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("transition_build") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("transition_build") } return err } diff --git a/client/models/job_input.go b/client/models/job_input.go index 096596c6..6fab3f9f 100644 --- a/client/models/job_input.go +++ b/client/models/job_input.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // JobInput JobInput // // The entity which represents a job input in the application. +// // swagger:model JobInput type JobInput struct { @@ -92,7 +94,6 @@ func (m *JobInput) validateTrigger(formats strfmt.Registry) error { } func (m *JobInput) validateVersion(formats strfmt.Registry) error { - if swag.IsZero(m.Version) { // not required return nil } @@ -101,6 +102,43 @@ func (m *JobInput) validateVersion(formats strfmt.Registry) error { if err := m.Version.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("version") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("version") + } + return err + } + } + + return nil +} + +// ContextValidate validate this job input based on the context it is used +func (m *JobInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVersion(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *JobInput) contextValidateVersion(ctx context.Context, formats strfmt.Registry) error { + + if m.Version != nil { + + if swag.IsZero(m.Version) { // not required + return nil + } + + if err := m.Version.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("version") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("version") } return err } diff --git a/client/models/job_output.go b/client/models/job_output.go index 26c50558..01d5e3b9 100644 --- a/client/models/job_output.go +++ b/client/models/job_output.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // JobOutput JobOutput // // The entity which represents a job output in the application. +// // swagger:model JobOutput type JobOutput struct { @@ -64,6 +66,11 @@ func (m *JobOutput) validateResource(formats strfmt.Registry) error { return nil } +// ContextValidate validates this job output based on context it is used +func (m *JobOutput) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *JobOutput) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/k_p_i.go b/client/models/k_p_i.go index ad3a3f52..1d1c8620 100644 --- a/client/models/k_p_i.go +++ b/client/models/k_p_i.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // KPI KPI // -// A KPI +// # A KPI +// // swagger:model KPI type KPI struct { @@ -82,7 +83,7 @@ type KPI struct { // type // Required: true - // Enum: [build_avg_time build_frequency build_history code_coverage time_to_release] + // Enum: ["build_avg_time","build_frequency","build_history","code_coverage","time_to_release"] Type *string `json:"type"` // updated at @@ -92,7 +93,7 @@ type KPI struct { // widget // Required: true - // Enum: [bars stackbars doughnut history line pie summary] + // Enum: ["bars","stackbars","doughnut","history","line","pie","summary"] Widget *string `json:"widget"` } @@ -160,15 +161,15 @@ func (m *KPI) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -177,8 +178,8 @@ func (m *KPI) validateCanonical(formats strfmt.Registry) error { func (m *KPI) validateConfig(formats strfmt.Registry) error { - if err := validate.Required("config", "body", m.Config); err != nil { - return err + if m.Config == nil { + return errors.Required("config", "body", nil) } return nil @@ -190,7 +191,7 @@ func (m *KPI) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -207,20 +208,19 @@ func (m *KPI) validateDescription(formats strfmt.Registry) error { } func (m *KPI) validateEnvironmentCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.EnvironmentCanonical) { // not required return nil } - if err := validate.MinLength("environment_canonical", "body", string(m.EnvironmentCanonical), 1); err != nil { + if err := validate.MinLength("environment_canonical", "body", m.EnvironmentCanonical, 1); err != nil { return err } - if err := validate.MaxLength("environment_canonical", "body", string(m.EnvironmentCanonical), 100); err != nil { + if err := validate.MaxLength("environment_canonical", "body", m.EnvironmentCanonical, 100); err != nil { return err } - if err := validate.Pattern("environment_canonical", "body", string(m.EnvironmentCanonical), `^[\da-zA-Z]+(?:[\da-zA-Z\-._]+[\da-zA-Z]|[\da-zA-Z])$`); err != nil { + if err := validate.Pattern("environment_canonical", "body", m.EnvironmentCanonical, `^[\da-zA-Z]+(?:[\da-zA-Z\-._]+[\da-zA-Z]|[\da-zA-Z])$`); err != nil { return err } @@ -242,7 +242,7 @@ func (m *KPI) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -255,7 +255,7 @@ func (m *KPI) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -263,20 +263,19 @@ func (m *KPI) validateName(formats strfmt.Registry) error { } func (m *KPI) validateProjectCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ProjectCanonical) { // not required return nil } - if err := validate.MinLength("project_canonical", "body", string(m.ProjectCanonical), 1); err != nil { + if err := validate.MinLength("project_canonical", "body", m.ProjectCanonical, 1); err != nil { return err } - if err := validate.MaxLength("project_canonical", "body", string(m.ProjectCanonical), 100); err != nil { + if err := validate.MaxLength("project_canonical", "body", m.ProjectCanonical, 100); err != nil { return err } - if err := validate.Pattern("project_canonical", "body", string(m.ProjectCanonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("project_canonical", "body", m.ProjectCanonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -315,7 +314,7 @@ const ( // prop value enum func (m *KPI) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, kPITypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, kPITypeTypePropEnum, true); err != nil { return err } return nil @@ -341,7 +340,7 @@ func (m *KPI) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -386,7 +385,7 @@ const ( // prop value enum func (m *KPI) validateWidgetEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, kPITypeWidgetPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, kPITypeWidgetPropEnum, true); err != nil { return err } return nil @@ -406,6 +405,11 @@ func (m *KPI) validateWidget(formats strfmt.Registry) error { return nil } +// ContextValidate validates this k p i based on context it is used +func (m *KPI) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *KPI) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/licence.go b/client/models/licence.go index 5850949f..4ae4adef 100644 --- a/client/models/licence.go +++ b/client/models/licence.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Licence Licence // -// Object containing licence parameters +// # Object containing licence parameters +// // swagger:model Licence type Licence struct { @@ -130,7 +132,7 @@ func (m *Licence) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -143,7 +145,7 @@ func (m *Licence) validateCurrentMembers(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("current_members", "body", int64(*m.CurrentMembers), 0, false); err != nil { + if err := validate.MinimumUint("current_members", "body", *m.CurrentMembers, 0, false); err != nil { return err } @@ -165,7 +167,7 @@ func (m *Licence) validateExpiresAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("expires_at", "body", int64(*m.ExpiresAt), 0, false); err != nil { + if err := validate.MinimumUint("expires_at", "body", *m.ExpiresAt, 0, false); err != nil { return err } @@ -187,7 +189,7 @@ func (m *Licence) validateMembersCount(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("members_count", "body", int64(*m.MembersCount), 0, false); err != nil { + if err := validate.MinimumUint("members_count", "body", *m.MembersCount, 0, false); err != nil { return err } @@ -209,7 +211,7 @@ func (m *Licence) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -225,6 +227,11 @@ func (m *Licence) validateVersion(formats strfmt.Registry) error { return nil } +// ContextValidate validates this licence based on context it is used +func (m *Licence) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Licence) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/log_source.go b/client/models/log_source.go index 16c37cb8..10f9bf8c 100644 --- a/client/models/log_source.go +++ b/client/models/log_source.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // LogSource A log source // // The data associated to a log's source. Each log source is the context of a list of entries which are registered through the time. +// // swagger:model LogSource type LogSource struct { @@ -45,13 +47,18 @@ func (m *LogSource) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinLength("id", "body", string(*m.ID), 1); err != nil { + if err := validate.MinLength("id", "body", *m.ID, 1); err != nil { return err } return nil } +// ContextValidate validates this log source based on context it is used +func (m *LogSource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *LogSource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/log_source_entry.go b/client/models/log_source_entry.go index bfe12920..96756909 100644 --- a/client/models/log_source_entry.go +++ b/client/models/log_source_entry.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // LogSourceEntry Log entry // // A log's entry which pertains to a specific log's source. +// // swagger:model LogSourceEntry type LogSourceEntry struct { @@ -62,7 +64,7 @@ func (m *LogSourceEntry) validateHost(formats strfmt.Registry) error { return err } - if err := validate.MinLength("host", "body", string(*m.Host), 1); err != nil { + if err := validate.MinLength("host", "body", *m.Host, 1); err != nil { return err } @@ -75,7 +77,7 @@ func (m *LogSourceEntry) validateMessage(formats strfmt.Registry) error { return err } - if err := validate.MinLength("message", "body", string(*m.Message), 1); err != nil { + if err := validate.MinLength("message", "body", *m.Message, 1); err != nil { return err } @@ -91,6 +93,11 @@ func (m *LogSourceEntry) validateTimestamp(formats strfmt.Registry) error { return nil } +// ContextValidate validates this log source entry based on context it is used +func (m *LogSourceEntry) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *LogSourceEntry) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/member_assignation.go b/client/models/member_assignation.go index a8c7def2..76045f21 100644 --- a/client/models/member_assignation.go +++ b/client/models/member_assignation.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // MemberAssignation Member assignation // // Member is a user who is associated to an entity of the system. The user is newly assigned or reassigned for updating is data. +// // swagger:model MemberAssignation type MemberAssignation struct { @@ -47,21 +49,26 @@ func (m *MemberAssignation) validateRoleCanonical(formats strfmt.Registry) error return err } - if err := validate.MinLength("role_canonical", "body", string(*m.RoleCanonical), 3); err != nil { + if err := validate.MinLength("role_canonical", "body", *m.RoleCanonical, 3); err != nil { return err } - if err := validate.MaxLength("role_canonical", "body", string(*m.RoleCanonical), 100); err != nil { + if err := validate.MaxLength("role_canonical", "body", *m.RoleCanonical, 100); err != nil { return err } - if err := validate.Pattern("role_canonical", "body", string(*m.RoleCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("role_canonical", "body", *m.RoleCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this member assignation based on context it is used +func (m *MemberAssignation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *MemberAssignation) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/member_org.go b/client/models/member_org.go index 053dd193..f54a126d 100644 --- a/client/models/member_org.go +++ b/client/models/member_org.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // MemberOrg Member of an organization // // Member is a user who is associated to an organization. +// // swagger:model MemberOrg type MemberOrg struct { @@ -59,7 +60,7 @@ type MemberOrg struct { // User's preferred language // Required: true - // Enum: [en fr es] + // Enum: ["en","fr","es"] Locale *string `json:"locale"` // mfa enabled @@ -158,7 +159,7 @@ func (m *MemberOrg) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -184,7 +185,7 @@ func (m *MemberOrg) validateFamilyName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("family_name", "body", string(*m.FamilyName), 2); err != nil { + if err := validate.MinLength("family_name", "body", *m.FamilyName, 2); err != nil { return err } @@ -197,7 +198,7 @@ func (m *MemberOrg) validateGivenName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("given_name", "body", string(*m.GivenName), 2); err != nil { + if err := validate.MinLength("given_name", "body", *m.GivenName, 2); err != nil { return err } @@ -210,7 +211,7 @@ func (m *MemberOrg) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -218,12 +219,11 @@ func (m *MemberOrg) validateID(formats strfmt.Registry) error { } func (m *MemberOrg) validateInvitedAt(formats strfmt.Registry) error { - if swag.IsZero(m.InvitedAt) { // not required return nil } - if err := validate.MinimumInt("invited_at", "body", int64(*m.InvitedAt), 0, false); err != nil { + if err := validate.MinimumUint("invited_at", "body", *m.InvitedAt, 0, false); err != nil { return err } @@ -231,7 +231,6 @@ func (m *MemberOrg) validateInvitedAt(formats strfmt.Registry) error { } func (m *MemberOrg) validateInvitedBy(formats strfmt.Registry) error { - if swag.IsZero(m.InvitedBy) { // not required return nil } @@ -240,6 +239,8 @@ func (m *MemberOrg) validateInvitedBy(formats strfmt.Registry) error { if err := m.InvitedBy.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("invited_by") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("invited_by") } return err } @@ -249,12 +250,11 @@ func (m *MemberOrg) validateInvitedBy(formats strfmt.Registry) error { } func (m *MemberOrg) validateLastLoginAt(formats strfmt.Registry) error { - if swag.IsZero(m.LastLoginAt) { // not required return nil } - if err := validate.MinimumInt("last_login_at", "body", int64(*m.LastLoginAt), 0, false); err != nil { + if err := validate.MinimumUint("last_login_at", "body", *m.LastLoginAt, 0, false); err != nil { return err } @@ -287,7 +287,7 @@ const ( // prop value enum func (m *MemberOrg) validateLocaleEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, memberOrgTypeLocalePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, memberOrgTypeLocalePropEnum, true); err != nil { return err } return nil @@ -317,7 +317,6 @@ func (m *MemberOrg) validateMfaEnabled(formats strfmt.Registry) error { } func (m *MemberOrg) validatePictureURL(formats strfmt.Registry) error { - if swag.IsZero(m.PictureURL) { // not required return nil } @@ -339,6 +338,8 @@ func (m *MemberOrg) validateRole(formats strfmt.Registry) error { if err := m.Role.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("role") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("role") } return err } @@ -348,12 +349,11 @@ func (m *MemberOrg) validateRole(formats strfmt.Registry) error { } func (m *MemberOrg) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -366,21 +366,77 @@ func (m *MemberOrg) validateUsername(formats strfmt.Registry) error { return err } - if err := validate.MinLength("username", "body", string(*m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", *m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(*m.Username), 100); err != nil { + if err := validate.MaxLength("username", "body", *m.Username, 100); err != nil { return err } - if err := validate.Pattern("username", "body", string(*m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", *m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validate this member org based on the context it is used +func (m *MemberOrg) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInvitedBy(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateRole(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *MemberOrg) contextValidateInvitedBy(ctx context.Context, formats strfmt.Registry) error { + + if m.InvitedBy != nil { + + if swag.IsZero(m.InvitedBy) { // not required + return nil + } + + if err := m.InvitedBy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("invited_by") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("invited_by") + } + return err + } + } + + return nil +} + +func (m *MemberOrg) contextValidateRole(ctx context.Context, formats strfmt.Registry) error { + + if m.Role != nil { + + if err := m.Role.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("role") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("role") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *MemberOrg) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/member_team.go b/client/models/member_team.go index 9eb908db..0bd81669 100644 --- a/client/models/member_team.go +++ b/client/models/member_team.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // MemberTeam Member of a team // // Member is a user who is associated to a team. +// // swagger:model MemberTeam type MemberTeam struct { @@ -131,7 +133,7 @@ func (m *MemberTeam) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -157,7 +159,7 @@ func (m *MemberTeam) validateFamilyName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("family_name", "body", string(*m.FamilyName), 2); err != nil { + if err := validate.MinLength("family_name", "body", *m.FamilyName, 2); err != nil { return err } @@ -170,7 +172,7 @@ func (m *MemberTeam) validateGivenName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("given_name", "body", string(*m.GivenName), 2); err != nil { + if err := validate.MinLength("given_name", "body", *m.GivenName, 2); err != nil { return err } @@ -183,7 +185,7 @@ func (m *MemberTeam) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -191,7 +193,6 @@ func (m *MemberTeam) validateID(formats strfmt.Registry) error { } func (m *MemberTeam) validateInvitedBy(formats strfmt.Registry) error { - if swag.IsZero(m.InvitedBy) { // not required return nil } @@ -200,6 +201,8 @@ func (m *MemberTeam) validateInvitedBy(formats strfmt.Registry) error { if err := m.InvitedBy.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("invited_by") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("invited_by") } return err } @@ -209,12 +212,11 @@ func (m *MemberTeam) validateInvitedBy(formats strfmt.Registry) error { } func (m *MemberTeam) validateLastLoginAt(formats strfmt.Registry) error { - if swag.IsZero(m.LastLoginAt) { // not required return nil } - if err := validate.MinimumInt("last_login_at", "body", int64(*m.LastLoginAt), 0, false); err != nil { + if err := validate.MinimumUint("last_login_at", "body", *m.LastLoginAt, 0, false); err != nil { return err } @@ -231,7 +233,6 @@ func (m *MemberTeam) validateMfaEnabled(formats strfmt.Registry) error { } func (m *MemberTeam) validatePictureURL(formats strfmt.Registry) error { - if swag.IsZero(m.PictureURL) { // not required return nil } @@ -244,12 +245,11 @@ func (m *MemberTeam) validatePictureURL(formats strfmt.Registry) error { } func (m *MemberTeam) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -262,21 +262,56 @@ func (m *MemberTeam) validateUsername(formats strfmt.Registry) error { return err } - if err := validate.MinLength("username", "body", string(*m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", *m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(*m.Username), 100); err != nil { + if err := validate.MaxLength("username", "body", *m.Username, 100); err != nil { return err } - if err := validate.Pattern("username", "body", string(*m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", *m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validate this member team based on the context it is used +func (m *MemberTeam) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInvitedBy(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *MemberTeam) contextValidateInvitedBy(ctx context.Context, formats strfmt.Registry) error { + + if m.InvitedBy != nil { + + if swag.IsZero(m.InvitedBy) { // not required + return nil + } + + if err := m.InvitedBy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("invited_by") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("invited_by") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *MemberTeam) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/metadata_field.go b/client/models/metadata_field.go index 53644383..6918a73e 100644 --- a/client/models/metadata_field.go +++ b/client/models/metadata_field.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // MetadataField MetadataField // -// Represent the metadata of a build input +// # Represent the metadata of a build input +// // swagger:model MetadataField type MetadataField struct { @@ -64,6 +66,11 @@ func (m *MetadataField) validateValue(formats strfmt.Registry) error { return nil } +// ContextValidate validates this metadata field based on context it is used +func (m *MetadataField) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *MetadataField) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_a_w_s_marketplace_user_account.go b/client/models/new_a_w_s_marketplace_user_account.go index c4342083..270d1ba3 100644 --- a/client/models/new_a_w_s_marketplace_user_account.go +++ b/client/models/new_a_w_s_marketplace_user_account.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // NewAWSMarketplaceUserAccount Sign up from AWS Marketplace // // Create a new AWS Marketplace user account. +// // swagger:model NewAWSMarketplaceUserAccount type NewAWSMarketplaceUserAccount struct { @@ -46,7 +47,7 @@ type NewAWSMarketplaceUserAccount struct { GivenName *string `json:"given_name"` // User's preferred language - // Enum: [en fr es] + // Enum: ["en","fr","es"] Locale string `json:"locale,omitempty"` // password @@ -111,7 +112,7 @@ func (m *NewAWSMarketplaceUserAccount) validateAwsMarketplaceToken(formats strfm return err } - if err := validate.MinLength("aws_marketplace_token", "body", string(*m.AwsMarketplaceToken), 1); err != nil { + if err := validate.MinLength("aws_marketplace_token", "body", *m.AwsMarketplaceToken, 1); err != nil { return err } @@ -119,12 +120,11 @@ func (m *NewAWSMarketplaceUserAccount) validateAwsMarketplaceToken(formats strfm } func (m *NewAWSMarketplaceUserAccount) validateCountryCode(formats strfmt.Registry) error { - if swag.IsZero(m.CountryCode) { // not required return nil } - if err := validate.Pattern("country_code", "body", string(m.CountryCode), `^[A-Z]{2}$`); err != nil { + if err := validate.Pattern("country_code", "body", m.CountryCode, `^[A-Z]{2}$`); err != nil { return err } @@ -150,7 +150,7 @@ func (m *NewAWSMarketplaceUserAccount) validateFamilyName(formats strfmt.Registr return err } - if err := validate.MinLength("family_name", "body", string(*m.FamilyName), 2); err != nil { + if err := validate.MinLength("family_name", "body", *m.FamilyName, 2); err != nil { return err } @@ -163,7 +163,7 @@ func (m *NewAWSMarketplaceUserAccount) validateGivenName(formats strfmt.Registry return err } - if err := validate.MinLength("given_name", "body", string(*m.GivenName), 2); err != nil { + if err := validate.MinLength("given_name", "body", *m.GivenName, 2); err != nil { return err } @@ -196,14 +196,13 @@ const ( // prop value enum func (m *NewAWSMarketplaceUserAccount) validateLocaleEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newAWSMarketplaceUserAccountTypeLocalePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newAWSMarketplaceUserAccountTypeLocalePropEnum, true); err != nil { return err } return nil } func (m *NewAWSMarketplaceUserAccount) validateLocale(formats strfmt.Registry) error { - if swag.IsZero(m.Locale) { // not required return nil } @@ -222,7 +221,7 @@ func (m *NewAWSMarketplaceUserAccount) validatePassword(formats strfmt.Registry) return err } - if err := validate.MinLength("password", "body", string(*m.Password), 8); err != nil { + if err := validate.MinLength("password", "body", m.Password.String(), 8); err != nil { return err } @@ -239,21 +238,26 @@ func (m *NewAWSMarketplaceUserAccount) validateUsername(formats strfmt.Registry) return err } - if err := validate.MinLength("username", "body", string(*m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", *m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(*m.Username), 100); err != nil { + if err := validate.MaxLength("username", "body", *m.Username, 100); err != nil { return err } - if err := validate.Pattern("username", "body", string(*m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", *m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this new a w s marketplace user account based on context it is used +func (m *NewAWSMarketplaceUserAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewAWSMarketplaceUserAccount) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_api_key.go b/client/models/new_api_key.go index 4d16f8cf..6acf165f 100644 --- a/client/models/new_api_key.go +++ b/client/models/new_api_key.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // NewAPIKey Create API key // // The entity which represents the information of a new API key. +// // swagger:model NewAPIKey type NewAPIKey struct { @@ -69,20 +70,19 @@ func (m *NewAPIKey) Validate(formats strfmt.Registry) error { } func (m *NewAPIKey) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -95,7 +95,7 @@ func (m *NewAPIKey) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -117,6 +117,47 @@ func (m *NewAPIKey) validateRules(formats strfmt.Registry) error { if err := m.Rules[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this new API key based on the context it is used +func (m *NewAPIKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRules(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewAPIKey) contextValidateRules(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Rules); i++ { + + if m.Rules[i] != nil { + + if swag.IsZero(m.Rules[i]) { // not required + return nil + } + + if err := m.Rules[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rules" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/new_appearance.go b/client/models/new_appearance.go index b82c1844..dcb0f8cb 100644 --- a/client/models/new_appearance.go +++ b/client/models/new_appearance.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewAppearance Appearance // -// An Appearance holds the values of the branding configuration, which are rendered across an organization +// # An Appearance holds the values of the branding configuration, which are rendered across an organization +// // swagger:model NewAppearance type NewAppearance struct { @@ -106,6 +108,8 @@ func (m *NewAppearance) validateColor(formats strfmt.Registry) error { if err := m.Color.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("color") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("color") } return err } @@ -120,11 +124,11 @@ func (m *NewAppearance) validateDisplayName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("display_name", "body", string(*m.DisplayName), 1); err != nil { + if err := validate.MinLength("display_name", "body", *m.DisplayName, 1); err != nil { return err } - if err := validate.MaxLength("display_name", "body", string(*m.DisplayName), 50); err != nil { + if err := validate.MaxLength("display_name", "body", *m.DisplayName, 50); err != nil { return err } @@ -150,11 +154,11 @@ func (m *NewAppearance) validateFooter(formats strfmt.Registry) error { return err } - if err := validate.MinLength("footer", "body", string(*m.Footer), 0); err != nil { + if err := validate.MinLength("footer", "body", *m.Footer, 0); err != nil { return err } - if err := validate.MaxLength("footer", "body", string(*m.Footer), 1000); err != nil { + if err := validate.MaxLength("footer", "body", *m.Footer, 1000); err != nil { return err } @@ -180,11 +184,11 @@ func (m *NewAppearance) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { return err } - if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil { + if err := validate.MaxLength("name", "body", *m.Name, 50); err != nil { return err } @@ -197,17 +201,48 @@ func (m *NewAppearance) validateTabTitle(formats strfmt.Registry) error { return err } - if err := validate.MinLength("tab_title", "body", string(*m.TabTitle), 1); err != nil { + if err := validate.MinLength("tab_title", "body", *m.TabTitle, 1); err != nil { return err } - if err := validate.MaxLength("tab_title", "body", string(*m.TabTitle), 50); err != nil { + if err := validate.MaxLength("tab_title", "body", *m.TabTitle, 50); err != nil { return err } return nil } +// ContextValidate validate this new appearance based on the context it is used +func (m *NewAppearance) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateColor(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewAppearance) contextValidateColor(ctx context.Context, formats strfmt.Registry) error { + + if m.Color != nil { + + if err := m.Color.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("color") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("color") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *NewAppearance) MarshalBinary() ([]byte, error) { if m == nil { @@ -227,6 +262,7 @@ func (m *NewAppearance) UnmarshalBinary(b []byte) error { } // NewAppearanceColor new appearance color +// // swagger:model NewAppearanceColor type NewAppearanceColor struct { @@ -277,11 +313,11 @@ func (m *NewAppearanceColor) validateB(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("color"+"."+"b", "body", int64(*m.B), 0, false); err != nil { + if err := validate.MinimumUint("color"+"."+"b", "body", uint64(*m.B), 0, false); err != nil { return err } - if err := validate.MaximumInt("color"+"."+"b", "body", int64(*m.B), 255, false); err != nil { + if err := validate.MaximumUint("color"+"."+"b", "body", uint64(*m.B), 255, false); err != nil { return err } @@ -294,11 +330,11 @@ func (m *NewAppearanceColor) validateG(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("color"+"."+"g", "body", int64(*m.G), 0, false); err != nil { + if err := validate.MinimumUint("color"+"."+"g", "body", uint64(*m.G), 0, false); err != nil { return err } - if err := validate.MaximumInt("color"+"."+"g", "body", int64(*m.G), 255, false); err != nil { + if err := validate.MaximumUint("color"+"."+"g", "body", uint64(*m.G), 255, false); err != nil { return err } @@ -311,17 +347,22 @@ func (m *NewAppearanceColor) validateR(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("color"+"."+"r", "body", int64(*m.R), 0, false); err != nil { + if err := validate.MinimumUint("color"+"."+"r", "body", uint64(*m.R), 0, false); err != nil { return err } - if err := validate.MaximumInt("color"+"."+"r", "body", int64(*m.R), 255, false); err != nil { + if err := validate.MaximumUint("color"+"."+"r", "body", uint64(*m.R), 255, false); err != nil { return err } return nil } +// ContextValidate validates this new appearance color based on context it is used +func (m *NewAppearanceColor) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewAppearanceColor) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_cloud_cost_management_account.go b/client/models/new_cloud_cost_management_account.go index 21f60ce1..e6749a59 100644 --- a/client/models/new_cloud_cost_management_account.go +++ b/client/models/new_cloud_cost_management_account.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -54,20 +55,19 @@ func (m *NewCloudCostManagementAccount) Validate(formats strfmt.Registry) error } func (m *NewCloudCostManagementAccount) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -84,6 +84,39 @@ func (m *NewCloudCostManagementAccount) validateExternalBackend(formats strfmt.R if err := m.ExternalBackend.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("external_backend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backend") + } + return err + } + } + + return nil +} + +// ContextValidate validate this new cloud cost management account based on the context it is used +func (m *NewCloudCostManagementAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateExternalBackend(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewCloudCostManagementAccount) contextValidateExternalBackend(ctx context.Context, formats strfmt.Registry) error { + + if m.ExternalBackend != nil { + + if err := m.ExternalBackend.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("external_backend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backend") } return err } diff --git a/client/models/new_cloud_cost_management_account_child.go b/client/models/new_cloud_cost_management_account_child.go index b584862a..b6c3eb87 100644 --- a/client/models/new_cloud_cost_management_account_child.go +++ b/client/models/new_cloud_cost_management_account_child.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -63,20 +64,19 @@ func (m *NewCloudCostManagementAccountChild) Validate(formats strfmt.Registry) e } func (m *NewCloudCostManagementAccountChild) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -101,6 +101,11 @@ func (m *NewCloudCostManagementAccountChild) validateParentAccountID(formats str return nil } +// ContextValidate validates this new cloud cost management account child based on context it is used +func (m *NewCloudCostManagementAccountChild) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewCloudCostManagementAccountChild) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_config_repository.go b/client/models/new_config_repository.go index e9e881a7..5d973e05 100644 --- a/client/models/new_config_repository.go +++ b/client/models/new_config_repository.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewConfigRepository NewConfigRepository +// // swagger:model NewConfigRepository type NewConfigRepository struct { @@ -92,20 +94,19 @@ func (m *NewConfigRepository) validateBranch(formats strfmt.Registry) error { } func (m *NewConfigRepository) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -118,15 +119,15 @@ func (m *NewConfigRepository) validateCredentialCanonical(formats strfmt.Registr return err } - if err := validate.MinLength("credential_canonical", "body", string(*m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", *m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(*m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", *m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(*m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", *m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -157,13 +158,18 @@ func (m *NewConfigRepository) validateURL(formats strfmt.Registry) error { return err } - if err := validate.Pattern("url", "body", string(*m.URL), `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { + if err := validate.Pattern("url", "body", *m.URL, `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { return err } return nil } +// ContextValidate validates this new config repository based on context it is used +func (m *NewConfigRepository) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewConfigRepository) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_credential.go b/client/models/new_credential.go index 691e43a9..6a645408 100644 --- a/client/models/new_credential.go +++ b/client/models/new_credential.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewCredential Credential // -// Represents the Credential +// # Represents the Credential +// // swagger:model NewCredential type NewCredential struct { @@ -51,7 +52,7 @@ type NewCredential struct { // type // Required: true - // Enum: [ssh aws custom azure azure_storage gcp basic_auth elasticsearch swift vmware] + // Enum: ["ssh","aws","custom","azure","azure_storage","gcp","basic_auth","elasticsearch","swift","vmware"] Type *string `json:"type"` } @@ -86,20 +87,19 @@ func (m *NewCredential) Validate(formats strfmt.Registry) error { } func (m *NewCredential) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -121,7 +121,7 @@ func (m *NewCredential) validatePath(formats strfmt.Registry) error { return err } - if err := validate.Pattern("path", "body", string(*m.Path), `[a-zA-z0-9_\-./]`); err != nil { + if err := validate.Pattern("path", "body", *m.Path, `[a-zA-z0-9_\-./]`); err != nil { return err } @@ -138,6 +138,8 @@ func (m *NewCredential) validateRaw(formats strfmt.Registry) error { if err := m.Raw.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("raw") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("raw") } return err } @@ -193,7 +195,7 @@ const ( // prop value enum func (m *NewCredential) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newCredentialTypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newCredentialTypeTypePropEnum, true); err != nil { return err } return nil @@ -213,6 +215,37 @@ func (m *NewCredential) validateType(formats strfmt.Registry) error { return nil } +// ContextValidate validate this new credential based on the context it is used +func (m *NewCredential) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRaw(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewCredential) contextValidateRaw(ctx context.Context, formats strfmt.Registry) error { + + if m.Raw != nil { + + if err := m.Raw.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("raw") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("raw") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *NewCredential) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_environment.go b/client/models/new_environment.go index 1178c203..21062c05 100644 --- a/client/models/new_environment.go +++ b/client/models/new_environment.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewEnvironment NewEnvironment // -// Represent an entity necessary for environment creation +// # Represent an entity necessary for environment creation +// // swagger:model NewEnvironment type NewEnvironment struct { @@ -73,15 +75,15 @@ func (m *NewEnvironment) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[\da-zA-Z]+(?:[\da-zA-Z\-._]+[\da-zA-Z]|[\da-zA-Z])$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[\da-zA-Z]+(?:[\da-zA-Z\-._]+[\da-zA-Z]|[\da-zA-Z])$`); err != nil { return err } @@ -89,20 +91,19 @@ func (m *NewEnvironment) validateCanonical(formats strfmt.Registry) error { } func (m *NewEnvironment) validateCloudProviderCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CloudProviderCanonical) { // not required return nil } - if err := validate.MinLength("cloud_provider_canonical", "body", string(m.CloudProviderCanonical), 3); err != nil { + if err := validate.MinLength("cloud_provider_canonical", "body", m.CloudProviderCanonical, 3); err != nil { return err } - if err := validate.MaxLength("cloud_provider_canonical", "body", string(m.CloudProviderCanonical), 100); err != nil { + if err := validate.MaxLength("cloud_provider_canonical", "body", m.CloudProviderCanonical, 100); err != nil { return err } - if err := validate.Pattern("cloud_provider_canonical", "body", string(m.CloudProviderCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("cloud_provider_canonical", "body", m.CloudProviderCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -110,12 +111,11 @@ func (m *NewEnvironment) validateCloudProviderCanonical(formats strfmt.Registry) } func (m *NewEnvironment) validateColor(formats strfmt.Registry) error { - if swag.IsZero(m.Color) { // not required return nil } - if err := validate.MaxLength("color", "body", string(m.Color), 64); err != nil { + if err := validate.MaxLength("color", "body", m.Color, 64); err != nil { return err } @@ -123,18 +123,22 @@ func (m *NewEnvironment) validateColor(formats strfmt.Registry) error { } func (m *NewEnvironment) validateIcon(formats strfmt.Registry) error { - if swag.IsZero(m.Icon) { // not required return nil } - if err := validate.MaxLength("icon", "body", string(m.Icon), 64); err != nil { + if err := validate.MaxLength("icon", "body", m.Icon, 64); err != nil { return err } return nil } +// ContextValidate validates this new environment based on context it is used +func (m *NewEnvironment) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewEnvironment) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_event.go b/client/models/new_event.go index 860713a5..19b8f594 100644 --- a/client/models/new_event.go +++ b/client/models/new_event.go @@ -6,12 +6,12 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -19,6 +19,7 @@ import ( // NewEvent A new event // // A new event to register in the Cycloid platform. +// // swagger:model NewEvent type NewEvent struct { @@ -39,7 +40,7 @@ type NewEvent struct { // tThe severity associated to the event. // Required: true - // Enum: [info warn err crit] + // Enum: ["info","warn","err","crit"] Severity *string `json:"severity"` // The list of tags associated to the event. @@ -53,7 +54,7 @@ type NewEvent struct { // The type of the event // Required: true - // Enum: [Cycloid AWS Monitoring Custom] + // Enum: ["Cycloid","AWS","Monitoring","Custom"] Type *string `json:"type"` } @@ -96,20 +97,19 @@ func (m *NewEvent) Validate(formats strfmt.Registry) error { } func (m *NewEvent) validateColor(formats strfmt.Registry) error { - if swag.IsZero(m.Color) { // not required return nil } - if err := validate.MinLength("color", "body", string(m.Color), 3); err != nil { + if err := validate.MinLength("color", "body", m.Color, 3); err != nil { return err } - if err := validate.MaxLength("color", "body", string(m.Color), 20); err != nil { + if err := validate.MaxLength("color", "body", m.Color, 20); err != nil { return err } - if err := validate.Pattern("color", "body", string(m.Color), `[a-z]+`); err != nil { + if err := validate.Pattern("color", "body", m.Color, `[a-z]+`); err != nil { return err } @@ -117,12 +117,11 @@ func (m *NewEvent) validateColor(formats strfmt.Registry) error { } func (m *NewEvent) validateIcon(formats strfmt.Registry) error { - if swag.IsZero(m.Icon) { // not required return nil } - if err := validate.MinLength("icon", "body", string(m.Icon), 3); err != nil { + if err := validate.MinLength("icon", "body", m.Icon, 3); err != nil { return err } @@ -135,7 +134,7 @@ func (m *NewEvent) validateMessage(formats strfmt.Registry) error { return err } - if err := validate.MinLength("message", "body", string(*m.Message), 1); err != nil { + if err := validate.MinLength("message", "body", *m.Message, 1); err != nil { return err } @@ -171,7 +170,7 @@ const ( // prop value enum func (m *NewEvent) validateSeverityEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newEventTypeSeverityPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newEventTypeSeverityPropEnum, true); err != nil { return err } return nil @@ -206,6 +205,8 @@ func (m *NewEvent) validateTags(formats strfmt.Registry) error { if err := m.Tags[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("tags" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags" + "." + strconv.Itoa(i)) } return err } @@ -222,7 +223,7 @@ func (m *NewEvent) validateTitle(formats strfmt.Registry) error { return err } - if err := validate.MinLength("title", "body", string(*m.Title), 1); err != nil { + if err := validate.MinLength("title", "body", *m.Title, 1); err != nil { return err } @@ -258,7 +259,7 @@ const ( // prop value enum func (m *NewEvent) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newEventTypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newEventTypeTypePropEnum, true); err != nil { return err } return nil @@ -278,6 +279,45 @@ func (m *NewEvent) validateType(formats strfmt.Registry) error { return nil } +// ContextValidate validate this new event based on the context it is used +func (m *NewEvent) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewEvent) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Tags); i++ { + + if m.Tags[i] != nil { + + if swag.IsZero(m.Tags[i]) { // not required + return nil + } + + if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *NewEvent) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_external_backend.go b/client/models/new_external_backend.go index b167c2a4..96902af3 100644 --- a/client/models/new_external_backend.go +++ b/client/models/new_external_backend.go @@ -7,13 +7,13 @@ package models import ( "bytes" + "context" "encoding/json" "io" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -21,6 +21,7 @@ import ( // NewExternalBackend New External backend // // An external backend contains the configuration needed in order to be plugged into the Cycloid system. A backend is a general purpose concept, but Cycloid specifies which ones are supported and the list of those which are supported for every concrete feature. +// // swagger:model NewExternalBackend type NewExternalBackend struct { configurationField ExternalBackendConfiguration @@ -49,7 +50,7 @@ type NewExternalBackend struct { // purpose // Required: true - // Enum: [events logs remote_tfstate cost_explorer] + // Enum: ["events","logs","remote_tfstate","cost_explorer"] Purpose *string `json:"purpose"` } @@ -141,8 +142,7 @@ func (m NewExternalBackend) MarshalJSON() ([]byte, error) { ProjectCanonical: m.ProjectCanonical, Purpose: m.Purpose, - }, - ) + }) if err != nil { return nil, err } @@ -151,8 +151,7 @@ func (m NewExternalBackend) MarshalJSON() ([]byte, error) { }{ Configuration: m.configurationField, - }, - ) + }) if err != nil { return nil, err } @@ -199,6 +198,8 @@ func (m *NewExternalBackend) validateConfiguration(formats strfmt.Registry) erro if err := m.Configuration().Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") } return err } @@ -207,20 +208,19 @@ func (m *NewExternalBackend) validateConfiguration(formats strfmt.Registry) erro } func (m *NewExternalBackend) validateCredentialCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CredentialCanonical) { // not required return nil } - if err := validate.MinLength("credential_canonical", "body", string(m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -228,20 +228,19 @@ func (m *NewExternalBackend) validateCredentialCanonical(formats strfmt.Registry } func (m *NewExternalBackend) validateEnvironmentCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.EnvironmentCanonical) { // not required return nil } - if err := validate.MinLength("environment_canonical", "body", string(m.EnvironmentCanonical), 1); err != nil { + if err := validate.MinLength("environment_canonical", "body", m.EnvironmentCanonical, 1); err != nil { return err } - if err := validate.MaxLength("environment_canonical", "body", string(m.EnvironmentCanonical), 100); err != nil { + if err := validate.MaxLength("environment_canonical", "body", m.EnvironmentCanonical, 100); err != nil { return err } - if err := validate.Pattern("environment_canonical", "body", string(m.EnvironmentCanonical), `^[\da-zA-Z]+(?:(?:[\da-zA-Z\-._]+)?[\da-zA-Z])?$`); err != nil { + if err := validate.Pattern("environment_canonical", "body", m.EnvironmentCanonical, `^[\da-zA-Z]+(?:(?:[\da-zA-Z\-._]+)?[\da-zA-Z])?$`); err != nil { return err } @@ -249,20 +248,19 @@ func (m *NewExternalBackend) validateEnvironmentCanonical(formats strfmt.Registr } func (m *NewExternalBackend) validateProjectCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ProjectCanonical) { // not required return nil } - if err := validate.MinLength("project_canonical", "body", string(m.ProjectCanonical), 1); err != nil { + if err := validate.MinLength("project_canonical", "body", m.ProjectCanonical, 1); err != nil { return err } - if err := validate.MaxLength("project_canonical", "body", string(m.ProjectCanonical), 100); err != nil { + if err := validate.MaxLength("project_canonical", "body", m.ProjectCanonical, 100); err != nil { return err } - if err := validate.Pattern("project_canonical", "body", string(m.ProjectCanonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("project_canonical", "body", m.ProjectCanonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -298,7 +296,7 @@ const ( // prop value enum func (m *NewExternalBackend) validatePurposeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newExternalBackendTypePurposePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newExternalBackendTypePurposePropEnum, true); err != nil { return err } return nil @@ -318,6 +316,34 @@ func (m *NewExternalBackend) validatePurpose(formats strfmt.Registry) error { return nil } +// ContextValidate validate this new external backend based on the context it is used +func (m *NewExternalBackend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfiguration(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewExternalBackend) contextValidateConfiguration(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Configuration().ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") + } + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *NewExternalBackend) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_infra_import.go b/client/models/new_infra_import.go index 4198d7b5..2098529d 100644 --- a/client/models/new_infra_import.go +++ b/client/models/new_infra_import.go @@ -7,20 +7,21 @@ package models import ( "bytes" + "context" "encoding/json" "io" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewInfraImport New Infra Import // -// Entry that represents all the data needed to import a stack +// # Entry that represents all the data needed to import a stack +// // swagger:model NewInfraImport type NewInfraImport struct { configurationField CloudProviderConfiguration @@ -182,8 +183,7 @@ func (m NewInfraImport) MarshalJSON() ([]byte, error) { Tags: m.Tags, Targets: m.Targets, - }, - ) + }) if err != nil { return nil, err } @@ -192,8 +192,7 @@ func (m NewInfraImport) MarshalJSON() ([]byte, error) { }{ Configuration: m.configurationField, - }, - ) + }) if err != nil { return nil, err } @@ -244,6 +243,8 @@ func (m *NewInfraImport) validateConfiguration(formats strfmt.Registry) error { if err := m.Configuration().Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") } return err } @@ -257,15 +258,15 @@ func (m *NewInfraImport) validateCredentialCanonical(formats strfmt.Registry) er return err } - if err := validate.MinLength("credential_canonical", "body", string(*m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", *m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(*m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", *m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(*m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", *m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -273,7 +274,6 @@ func (m *NewInfraImport) validateCredentialCanonical(formats strfmt.Registry) er } func (m *NewInfraImport) validateEnvironment(formats strfmt.Registry) error { - if swag.IsZero(m.Environment) { // not required return nil } @@ -282,6 +282,8 @@ func (m *NewInfraImport) validateEnvironment(formats strfmt.Registry) error { if err := m.Environment.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") } return err } @@ -291,7 +293,6 @@ func (m *NewInfraImport) validateEnvironment(formats strfmt.Registry) error { } func (m *NewInfraImport) validateExternalBackend(formats strfmt.Registry) error { - if swag.IsZero(m.ExternalBackend) { // not required return nil } @@ -300,6 +301,8 @@ func (m *NewInfraImport) validateExternalBackend(formats strfmt.Registry) error if err := m.ExternalBackend.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("external_backend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backend") } return err } @@ -309,7 +312,6 @@ func (m *NewInfraImport) validateExternalBackend(formats strfmt.Registry) error } func (m *NewInfraImport) validateProject(formats strfmt.Registry) error { - if swag.IsZero(m.Project) { // not required return nil } @@ -318,6 +320,8 @@ func (m *NewInfraImport) validateProject(formats strfmt.Registry) error { if err := m.Project.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("project") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project") } return err } @@ -336,6 +340,132 @@ func (m *NewInfraImport) validateStack(formats strfmt.Registry) error { if err := m.Stack.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("stack") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("stack") + } + return err + } + } + + return nil +} + +// ContextValidate validate this new infra import based on the context it is used +func (m *NewInfraImport) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfiguration(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateEnvironment(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateExternalBackend(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProject(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStack(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewInfraImport) contextValidateConfiguration(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Configuration().ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") + } + return err + } + + return nil +} + +func (m *NewInfraImport) contextValidateEnvironment(ctx context.Context, formats strfmt.Registry) error { + + if m.Environment != nil { + + if swag.IsZero(m.Environment) { // not required + return nil + } + + if err := m.Environment.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") + } + return err + } + } + + return nil +} + +func (m *NewInfraImport) contextValidateExternalBackend(ctx context.Context, formats strfmt.Registry) error { + + if m.ExternalBackend != nil { + + if swag.IsZero(m.ExternalBackend) { // not required + return nil + } + + if err := m.ExternalBackend.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("external_backend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backend") + } + return err + } + } + + return nil +} + +func (m *NewInfraImport) contextValidateProject(ctx context.Context, formats strfmt.Registry) error { + + if m.Project != nil { + + if swag.IsZero(m.Project) { // not required + return nil + } + + if err := m.Project.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project") + } + return err + } + } + + return nil +} + +func (m *NewInfraImport) contextValidateStack(ctx context.Context, formats strfmt.Registry) error { + + if m.Stack != nil { + + if err := m.Stack.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("stack") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("stack") } return err } diff --git a/client/models/new_infra_import_external_backend.go b/client/models/new_infra_import_external_backend.go index be10550b..102f386b 100644 --- a/client/models/new_infra_import_external_backend.go +++ b/client/models/new_infra_import_external_backend.go @@ -7,13 +7,13 @@ package models import ( "bytes" + "context" "encoding/json" "io" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -21,6 +21,7 @@ import ( // NewInfraImportExternalBackend New External backend // // An external backend contains the configuration needed in order to be plugged into the Cycloid system. A backend is a general purpose concept, but Cycloid specifies which ones are supported and the list of those which are supported for every concrete feature. +// // swagger:model NewInfraImportExternalBackend type NewInfraImportExternalBackend struct { configurationField ExternalBackendConfiguration @@ -84,8 +85,7 @@ func (m NewInfraImportExternalBackend) MarshalJSON() ([]byte, error) { }{ CredentialCanonical: m.CredentialCanonical, - }, - ) + }) if err != nil { return nil, err } @@ -94,8 +94,7 @@ func (m NewInfraImportExternalBackend) MarshalJSON() ([]byte, error) { }{ Configuration: m.configurationField, - }, - ) + }) if err != nil { return nil, err } @@ -130,6 +129,8 @@ func (m *NewInfraImportExternalBackend) validateConfiguration(formats strfmt.Reg if err := m.Configuration().Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") } return err } @@ -138,20 +139,47 @@ func (m *NewInfraImportExternalBackend) validateConfiguration(formats strfmt.Reg } func (m *NewInfraImportExternalBackend) validateCredentialCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CredentialCanonical) { // not required return nil } - if err := validate.MinLength("credential_canonical", "body", string(m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", m.CredentialCanonical, 3); err != nil { + return err + } + + if err := validate.MaxLength("credential_canonical", "body", m.CredentialCanonical, 100); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(m.CredentialCanonical), 100); err != nil { + if err := validate.Pattern("credential_canonical", "body", m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + return nil +} + +// ContextValidate validate this new infra import external backend based on the context it is used +func (m *NewInfraImportExternalBackend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfiguration(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewInfraImportExternalBackend) contextValidateConfiguration(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Configuration().ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") + } return err } diff --git a/client/models/new_infra_import_project.go b/client/models/new_infra_import_project.go index d6a02246..33b83221 100644 --- a/client/models/new_infra_import_project.go +++ b/client/models/new_infra_import_project.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // NewInfraImportProject Create Project for the Infra Import // // The entity which represents the information of a new project. +// // swagger:model NewInfraImportProject type NewInfraImportProject struct { @@ -66,20 +68,19 @@ func (m *NewInfraImportProject) Validate(formats strfmt.Registry) error { } func (m *NewInfraImportProject) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -92,15 +93,15 @@ func (m *NewInfraImportProject) validateConfigRepositoryCanonical(formats strfmt return err } - if err := validate.MinLength("config_repository_canonical", "body", string(*m.ConfigRepositoryCanonical), 3); err != nil { + if err := validate.MinLength("config_repository_canonical", "body", *m.ConfigRepositoryCanonical, 3); err != nil { return err } - if err := validate.MaxLength("config_repository_canonical", "body", string(*m.ConfigRepositoryCanonical), 100); err != nil { + if err := validate.MaxLength("config_repository_canonical", "body", *m.ConfigRepositoryCanonical, 100); err != nil { return err } - if err := validate.Pattern("config_repository_canonical", "body", string(*m.ConfigRepositoryCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("config_repository_canonical", "body", *m.ConfigRepositoryCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -113,13 +114,18 @@ func (m *NewInfraImportProject) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { return err } return nil } +// ContextValidate validates this new infra import project based on context it is used +func (m *NewInfraImportProject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewInfraImportProject) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_infra_policy.go b/client/models/new_infra_policy.go index 3ed82c8c..38a471b4 100644 --- a/client/models/new_infra_policy.go +++ b/client/models/new_infra_policy.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // NewInfraPolicy Create InfraPolicy // // Create a new policy to control operations across infrastructure. +// // swagger:model NewInfraPolicy type NewInfraPolicy struct { @@ -53,7 +54,7 @@ type NewInfraPolicy struct { // severity // Required: true - // Enum: [critical warning advisory] + // Enum: ["critical","warning","advisory"] Severity *string `json:"severity"` } @@ -97,20 +98,19 @@ func (m *NewInfraPolicy) validateBody(formats strfmt.Registry) error { } func (m *NewInfraPolicy) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -123,7 +123,7 @@ func (m *NewInfraPolicy) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -136,15 +136,15 @@ func (m *NewInfraPolicy) validateOwner(formats strfmt.Registry) error { return err } - if err := validate.MinLength("owner", "body", string(*m.Owner), 3); err != nil { + if err := validate.MinLength("owner", "body", *m.Owner, 3); err != nil { return err } - if err := validate.MaxLength("owner", "body", string(*m.Owner), 100); err != nil { + if err := validate.MaxLength("owner", "body", *m.Owner, 100); err != nil { return err } - if err := validate.Pattern("owner", "body", string(*m.Owner), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("owner", "body", *m.Owner, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -177,7 +177,7 @@ const ( // prop value enum func (m *NewInfraPolicy) validateSeverityEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newInfraPolicyTypeSeverityPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newInfraPolicyTypeSeverityPropEnum, true); err != nil { return err } return nil @@ -197,6 +197,11 @@ func (m *NewInfraPolicy) validateSeverity(formats strfmt.Registry) error { return nil } +// ContextValidate validates this new infra policy based on context it is used +func (m *NewInfraPolicy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewInfraPolicy) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_inventory_resource.go b/client/models/new_inventory_resource.go index 7c87c2ff..81cb4bf3 100644 --- a/client/models/new_inventory_resource.go +++ b/client/models/new_inventory_resource.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewInventoryResource New Inventory Resource // -// The Resource of the Inventory representing an element of your infrastructure +// # The Resource of the Inventory representing an element of your infrastructure +// // swagger:model NewInventoryResource type NewInventoryResource struct { @@ -24,9 +26,11 @@ type NewInventoryResource struct { CPU *uint64 `json:"cpu,omitempty"` // List of attributes (key value object) of the Resource, can be anything + // Example: {"another":"one","custom":"attribute"} CustomAttributes interface{} `json:"custom_attributes,omitempty"` // A way to distinguish and categorize resources + // Example: my-label // Required: true Label *string `json:"label"` @@ -90,12 +94,11 @@ func (m *NewInventoryResource) Validate(formats strfmt.Registry) error { } func (m *NewInventoryResource) validateCPU(formats strfmt.Registry) error { - if swag.IsZero(m.CPU) { // not required return nil } - if err := validate.MinimumInt("cpu", "body", int64(*m.CPU), 0, false); err != nil { + if err := validate.MinimumUint("cpu", "body", *m.CPU, 0, false); err != nil { return err } @@ -112,12 +115,11 @@ func (m *NewInventoryResource) validateLabel(formats strfmt.Registry) error { } func (m *NewInventoryResource) validateMemory(formats strfmt.Registry) error { - if swag.IsZero(m.Memory) { // not required return nil } - if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { + if err := validate.MinimumUint("memory", "body", *m.Memory, 0, false); err != nil { return err } @@ -143,12 +145,11 @@ func (m *NewInventoryResource) validateProvider(formats strfmt.Registry) error { } func (m *NewInventoryResource) validateStorage(formats strfmt.Registry) error { - if swag.IsZero(m.Storage) { // not required return nil } - if err := validate.MinimumInt("storage", "body", int64(*m.Storage), 0, false); err != nil { + if err := validate.MinimumUint("storage", "body", *m.Storage, 0, false); err != nil { return err } @@ -164,6 +165,11 @@ func (m *NewInventoryResource) validateType(formats strfmt.Registry) error { return nil } +// ContextValidate validates this new inventory resource based on context it is used +func (m *NewInventoryResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewInventoryResource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_k_p_i.go b/client/models/new_k_p_i.go index 198d8477..5ce583e2 100644 --- a/client/models/new_k_p_i.go +++ b/client/models/new_k_p_i.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewKPI New KPI // -// A KPI's configuration that needs to be saved +// # A KPI's configuration that needs to be saved +// // swagger:model NewKPI type NewKPI struct { @@ -59,12 +60,12 @@ type NewKPI struct { // type // Required: true - // Enum: [build_avg_time build_frequency build_history code_coverage time_to_release] + // Enum: ["build_avg_time","build_frequency","build_history","code_coverage","time_to_release"] Type *string `json:"type"` // widget // Required: true - // Enum: [bars stackbars doughnut history line pie summary] + // Enum: ["bars","stackbars","doughnut","history","line","pie","summary"] Widget *string `json:"widget"` } @@ -103,20 +104,19 @@ func (m *NewKPI) Validate(formats strfmt.Registry) error { } func (m *NewKPI) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -124,20 +124,19 @@ func (m *NewKPI) validateCanonical(formats strfmt.Registry) error { } func (m *NewKPI) validateEnvironmentCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.EnvironmentCanonical) { // not required return nil } - if err := validate.MinLength("environment_canonical", "body", string(m.EnvironmentCanonical), 1); err != nil { + if err := validate.MinLength("environment_canonical", "body", m.EnvironmentCanonical, 1); err != nil { return err } - if err := validate.MaxLength("environment_canonical", "body", string(m.EnvironmentCanonical), 100); err != nil { + if err := validate.MaxLength("environment_canonical", "body", m.EnvironmentCanonical, 100); err != nil { return err } - if err := validate.Pattern("environment_canonical", "body", string(m.EnvironmentCanonical), `^[\da-zA-Z]+(?:[\da-zA-Z\-._]+[\da-zA-Z]|[\da-zA-Z])$`); err != nil { + if err := validate.Pattern("environment_canonical", "body", m.EnvironmentCanonical, `^[\da-zA-Z]+(?:[\da-zA-Z\-._]+[\da-zA-Z]|[\da-zA-Z])$`); err != nil { return err } @@ -150,7 +149,7 @@ func (m *NewKPI) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -158,20 +157,19 @@ func (m *NewKPI) validateName(formats strfmt.Registry) error { } func (m *NewKPI) validateProjectCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ProjectCanonical) { // not required return nil } - if err := validate.MinLength("project_canonical", "body", string(m.ProjectCanonical), 1); err != nil { + if err := validate.MinLength("project_canonical", "body", m.ProjectCanonical, 1); err != nil { return err } - if err := validate.MaxLength("project_canonical", "body", string(m.ProjectCanonical), 100); err != nil { + if err := validate.MaxLength("project_canonical", "body", m.ProjectCanonical, 100); err != nil { return err } - if err := validate.Pattern("project_canonical", "body", string(m.ProjectCanonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("project_canonical", "body", m.ProjectCanonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -210,7 +208,7 @@ const ( // prop value enum func (m *NewKPI) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newKPITypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newKPITypeTypePropEnum, true); err != nil { return err } return nil @@ -268,7 +266,7 @@ const ( // prop value enum func (m *NewKPI) validateWidgetEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newKPITypeWidgetPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newKPITypeWidgetPropEnum, true); err != nil { return err } return nil @@ -288,6 +286,11 @@ func (m *NewKPI) validateWidget(formats strfmt.Registry) error { return nil } +// ContextValidate validates this new k p i based on context it is used +func (m *NewKPI) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewKPI) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_licence.go b/client/models/new_licence.go index ec9edc64..57b6074e 100644 --- a/client/models/new_licence.go +++ b/client/models/new_licence.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewLicence Licence // -// Object containing licence parameters +// # Object containing licence parameters +// // swagger:model NewLicence type NewLicence struct { @@ -47,6 +49,11 @@ func (m *NewLicence) validateKey(formats strfmt.Registry) error { return nil } +// ContextValidate validates this new licence based on context it is used +func (m *NewLicence) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewLicence) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_member_invitation.go b/client/models/new_member_invitation.go index 5d08925b..5c131627 100644 --- a/client/models/new_member_invitation.go +++ b/client/models/new_member_invitation.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // NewMemberInvitation Invite user // // Send an invitation to a user to something. Something can be to create an account, to join to an organization, to join to a team, etc. API operation determines the operation to perform. +// // swagger:model NewMemberInvitation type NewMemberInvitation struct { @@ -69,21 +71,26 @@ func (m *NewMemberInvitation) validateRoleCanonical(formats strfmt.Registry) err return err } - if err := validate.MinLength("role_canonical", "body", string(*m.RoleCanonical), 3); err != nil { + if err := validate.MinLength("role_canonical", "body", *m.RoleCanonical, 3); err != nil { return err } - if err := validate.MaxLength("role_canonical", "body", string(*m.RoleCanonical), 100); err != nil { + if err := validate.MaxLength("role_canonical", "body", *m.RoleCanonical, 100); err != nil { return err } - if err := validate.Pattern("role_canonical", "body", string(*m.RoleCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("role_canonical", "body", *m.RoleCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this new member invitation based on context it is used +func (m *NewMemberInvitation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewMemberInvitation) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_o_auth_user.go b/client/models/new_o_auth_user.go index 2112c65e..14213c20 100644 --- a/client/models/new_o_auth_user.go +++ b/client/models/new_o_auth_user.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewOAuthUser User's OAuth information // -// The User OAuth information +// # The User OAuth information +// // swagger:model NewOAuthUser type NewOAuthUser struct { @@ -42,7 +43,7 @@ type NewOAuthUser struct { InvitationToken string `json:"invitation_token,omitempty"` // User's preferred language - // Enum: [en fr es] + // Enum: ["en","fr","es"] Locale string `json:"locale,omitempty"` // picture url @@ -104,12 +105,11 @@ func (m *NewOAuthUser) Validate(formats strfmt.Registry) error { } func (m *NewOAuthUser) validateCountryCode(formats strfmt.Registry) error { - if swag.IsZero(m.CountryCode) { // not required return nil } - if err := validate.Pattern("country_code", "body", string(m.CountryCode), `^[A-Z]{2}$`); err != nil { + if err := validate.Pattern("country_code", "body", m.CountryCode, `^[A-Z]{2}$`); err != nil { return err } @@ -139,12 +139,11 @@ func (m *NewOAuthUser) validateGivenName(formats strfmt.Registry) error { } func (m *NewOAuthUser) validateInvitationToken(formats strfmt.Registry) error { - if swag.IsZero(m.InvitationToken) { // not required return nil } - if err := validate.MinLength("invitation_token", "body", string(m.InvitationToken), 5); err != nil { + if err := validate.MinLength("invitation_token", "body", m.InvitationToken, 5); err != nil { return err } @@ -177,14 +176,13 @@ const ( // prop value enum func (m *NewOAuthUser) validateLocaleEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newOAuthUserTypeLocalePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newOAuthUserTypeLocalePropEnum, true); err != nil { return err } return nil } func (m *NewOAuthUser) validateLocale(formats strfmt.Registry) error { - if swag.IsZero(m.Locale) { // not required return nil } @@ -198,7 +196,6 @@ func (m *NewOAuthUser) validateLocale(formats strfmt.Registry) error { } func (m *NewOAuthUser) validatePictureURL(formats strfmt.Registry) error { - if swag.IsZero(m.PictureURL) { // not required return nil } @@ -225,21 +222,26 @@ func (m *NewOAuthUser) validateUsername(formats strfmt.Registry) error { return err } - if err := validate.MinLength("username", "body", string(*m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", *m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(*m.Username), 100); err != nil { + if err := validate.MaxLength("username", "body", *m.Username, 100); err != nil { return err } - if err := validate.Pattern("username", "body", string(*m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", *m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this new o auth user based on context it is used +func (m *NewOAuthUser) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewOAuthUser) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_organization.go b/client/models/new_organization.go index 7c42623f..ef0ede7b 100644 --- a/client/models/new_organization.go +++ b/client/models/new_organization.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // NewOrganization Create Organization // // The entity which represents a new organization to create in the application. +// // swagger:model NewOrganization type NewOrganization struct { @@ -50,20 +52,19 @@ func (m *NewOrganization) Validate(formats strfmt.Registry) error { } func (m *NewOrganization) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -76,13 +77,18 @@ func (m *NewOrganization) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } return nil } +// ContextValidate validates this new organization based on context it is used +func (m *NewOrganization) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewOrganization) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_pipeline.go b/client/models/new_pipeline.go index ff2d1bb5..058f57f6 100644 --- a/client/models/new_pipeline.go +++ b/client/models/new_pipeline.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // NewPipeline Create Pipeline // // The entity which represents a new pipeline to create in the application. +// // swagger:model NewPipeline type NewPipeline struct { @@ -78,6 +80,8 @@ func (m *NewPipeline) validateEnvironment(formats strfmt.Registry) error { if err := m.Environment.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") } return err } @@ -92,15 +96,15 @@ func (m *NewPipeline) validatePipelineName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("pipeline_name", "body", string(*m.PipelineName), 3); err != nil { + if err := validate.MinLength("pipeline_name", "body", *m.PipelineName, 3); err != nil { return err } - if err := validate.MaxLength("pipeline_name", "body", string(*m.PipelineName), 50); err != nil { + if err := validate.MaxLength("pipeline_name", "body", *m.PipelineName, 50); err != nil { return err } - if err := validate.Pattern("pipeline_name", "body", string(*m.PipelineName), `^[a-z0-9]+[a-z0-9\-._]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("pipeline_name", "body", *m.PipelineName, `^[a-z0-9]+[a-z0-9\-._]+[a-z0-9]+$`); err != nil { return err } @@ -108,26 +112,56 @@ func (m *NewPipeline) validatePipelineName(formats strfmt.Registry) error { } func (m *NewPipeline) validateUseCase(formats strfmt.Registry) error { - if swag.IsZero(m.UseCase) { // not required return nil } - if err := validate.MinLength("use_case", "body", string(m.UseCase), 3); err != nil { + if err := validate.MinLength("use_case", "body", m.UseCase, 3); err != nil { return err } - if err := validate.MaxLength("use_case", "body", string(m.UseCase), 100); err != nil { + if err := validate.MaxLength("use_case", "body", m.UseCase, 100); err != nil { return err } - if err := validate.Pattern("use_case", "body", string(m.UseCase), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("use_case", "body", m.UseCase, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validate this new pipeline based on the context it is used +func (m *NewPipeline) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEnvironment(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewPipeline) contextValidateEnvironment(ctx context.Context, formats strfmt.Registry) error { + + if m.Environment != nil { + + if err := m.Environment.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *NewPipeline) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_project.go b/client/models/new_project.go index 789ca545..3c339be1 100644 --- a/client/models/new_project.go +++ b/client/models/new_project.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // NewProject Create Project // // The entity which represents the information of a new project. +// // swagger:model NewProject type NewProject struct { @@ -113,20 +114,19 @@ func (m *NewProject) Validate(formats strfmt.Registry) error { } func (m *NewProject) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -139,15 +139,15 @@ func (m *NewProject) validateConfigRepositoryCanonical(formats strfmt.Registry) return err } - if err := validate.MinLength("config_repository_canonical", "body", string(*m.ConfigRepositoryCanonical), 3); err != nil { + if err := validate.MinLength("config_repository_canonical", "body", *m.ConfigRepositoryCanonical, 3); err != nil { return err } - if err := validate.MaxLength("config_repository_canonical", "body", string(*m.ConfigRepositoryCanonical), 100); err != nil { + if err := validate.MaxLength("config_repository_canonical", "body", *m.ConfigRepositoryCanonical, 100); err != nil { return err } - if err := validate.Pattern("config_repository_canonical", "body", string(*m.ConfigRepositoryCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("config_repository_canonical", "body", *m.ConfigRepositoryCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -155,7 +155,6 @@ func (m *NewProject) validateConfigRepositoryCanonical(formats strfmt.Registry) } func (m *NewProject) validateInputs(formats strfmt.Registry) error { - if swag.IsZero(m.Inputs) { // not required return nil } @@ -169,6 +168,8 @@ func (m *NewProject) validateInputs(formats strfmt.Registry) error { if err := m.Inputs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) } return err } @@ -185,7 +186,7 @@ func (m *NewProject) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { return err } @@ -193,7 +194,6 @@ func (m *NewProject) validateName(formats strfmt.Registry) error { } func (m *NewProject) validatePipelines(formats strfmt.Registry) error { - if swag.IsZero(m.Pipelines) { // not required return nil } @@ -213,6 +213,8 @@ func (m *NewProject) validatePipelines(formats strfmt.Registry) error { if err := m.Pipelines[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("pipelines" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pipelines" + "." + strconv.Itoa(i)) } return err } @@ -233,26 +235,93 @@ func (m *NewProject) validateServiceCatalogRef(formats strfmt.Registry) error { } func (m *NewProject) validateTeamCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.TeamCanonical) { // not required return nil } - if err := validate.MinLength("team_canonical", "body", string(m.TeamCanonical), 3); err != nil { + if err := validate.MinLength("team_canonical", "body", m.TeamCanonical, 3); err != nil { return err } - if err := validate.MaxLength("team_canonical", "body", string(m.TeamCanonical), 100); err != nil { + if err := validate.MaxLength("team_canonical", "body", m.TeamCanonical, 100); err != nil { return err } - if err := validate.Pattern("team_canonical", "body", string(m.TeamCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("team_canonical", "body", m.TeamCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validate this new project based on the context it is used +func (m *NewProject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInputs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePipelines(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewProject) contextValidateInputs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Inputs); i++ { + + if m.Inputs[i] != nil { + + if swag.IsZero(m.Inputs[i]) { // not required + return nil + } + + if err := m.Inputs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *NewProject) contextValidatePipelines(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Pipelines); i++ { + + if m.Pipelines[i] != nil { + + if swag.IsZero(m.Pipelines[i]) { // not required + return nil + } + + if err := m.Pipelines[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pipelines" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pipelines" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *NewProject) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_quota.go b/client/models/new_quota.go index 0d2c57f9..59440184 100644 --- a/client/models/new_quota.go +++ b/client/models/new_quota.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewQuota New Quota // -// The Quota defines the basic needs to create a quota +// # The Quota defines the basic needs to create a quota +// // swagger:model NewQuota type NewQuota struct { @@ -85,7 +87,7 @@ func (m *NewQuota) validateCPU(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("cpu", "body", int64(*m.CPU), 0, false); err != nil { + if err := validate.MinimumUint("cpu", "body", *m.CPU, 0, false); err != nil { return err } @@ -98,7 +100,7 @@ func (m *NewQuota) validateMemory(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { + if err := validate.MinimumUint("memory", "body", *m.Memory, 0, false); err != nil { return err } @@ -111,15 +113,15 @@ func (m *NewQuota) validateResourcePoolCanonical(formats strfmt.Registry) error return err } - if err := validate.MinLength("resource_pool_canonical", "body", string(*m.ResourcePoolCanonical), 3); err != nil { + if err := validate.MinLength("resource_pool_canonical", "body", *m.ResourcePoolCanonical, 3); err != nil { return err } - if err := validate.MaxLength("resource_pool_canonical", "body", string(*m.ResourcePoolCanonical), 100); err != nil { + if err := validate.MaxLength("resource_pool_canonical", "body", *m.ResourcePoolCanonical, 100); err != nil { return err } - if err := validate.Pattern("resource_pool_canonical", "body", string(*m.ResourcePoolCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("resource_pool_canonical", "body", *m.ResourcePoolCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -132,7 +134,7 @@ func (m *NewQuota) validateStorage(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("storage", "body", int64(*m.Storage), 0, false); err != nil { + if err := validate.MinimumUint("storage", "body", *m.Storage, 0, false); err != nil { return err } @@ -145,21 +147,26 @@ func (m *NewQuota) validateTeamCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("team_canonical", "body", string(*m.TeamCanonical), 3); err != nil { + if err := validate.MinLength("team_canonical", "body", *m.TeamCanonical, 3); err != nil { return err } - if err := validate.MaxLength("team_canonical", "body", string(*m.TeamCanonical), 100); err != nil { + if err := validate.MaxLength("team_canonical", "body", *m.TeamCanonical, 100); err != nil { return err } - if err := validate.Pattern("team_canonical", "body", string(*m.TeamCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("team_canonical", "body", *m.TeamCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this new quota based on context it is used +func (m *NewQuota) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewQuota) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_resource_pool.go b/client/models/new_resource_pool.go index e5b05d69..c12b4918 100644 --- a/client/models/new_resource_pool.go +++ b/client/models/new_resource_pool.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // NewResourcePool New Resource Pool // // The Resource Pool defines the basic needs to create/update a resource pool +// // swagger:model NewResourcePool type NewResourcePool struct { @@ -64,6 +66,11 @@ func (m *NewResourcePool) validateName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this new resource pool based on context it is used +func (m *NewResourcePool) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewResourcePool) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_role.go b/client/models/new_role.go index 4cf8e469..fbacba85 100644 --- a/client/models/new_role.go +++ b/client/models/new_role.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // NewRole New role access control // // New role represents the authorization level that a user has access to. A role contains a list of rules to define the access control. Note not all the entities supports roles access control; see the API endpoints to know which entities support them. +// // swagger:model NewRole type NewRole struct { @@ -64,20 +65,19 @@ func (m *NewRole) Validate(formats strfmt.Registry) error { } func (m *NewRole) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -90,11 +90,11 @@ func (m *NewRole) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } - if err := validate.MaxLength("name", "body", string(*m.Name), 100); err != nil { + if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { return err } @@ -116,6 +116,47 @@ func (m *NewRole) validateRules(formats strfmt.Registry) error { if err := m.Rules[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this new role based on the context it is used +func (m *NewRole) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRules(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewRole) contextValidateRules(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Rules); i++ { + + if m.Rules[i] != nil { + + if swag.IsZero(m.Rules[i]) { // not required + return nil + } + + if err := m.Rules[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rules" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/new_rule.go b/client/models/new_rule.go index 13390858..226fb2a6 100644 --- a/client/models/new_rule.go +++ b/client/models/new_rule.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // NewRule NewRule // // NewRule represents an existing or new permission or constraint to access to an entity of the system. A Rule is aggregated into roles in order to be applied. +// // swagger:model NewRule type NewRule struct { @@ -27,7 +28,7 @@ type NewRule struct { // effect // Required: true - // Enum: [allow] + // Enum: ["allow"] Effect *string `json:"effect"` // It is the list of resources in which this Rule applies to, the format of it is the one on the Policy.Code but with the `canonical` of the entities like `organization:org-can:team:team-can` for an action of `organization:team:read` @@ -81,7 +82,7 @@ const ( // prop value enum func (m *NewRule) validateEffectEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newRuleTypeEffectPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newRuleTypeEffectPropEnum, true); err != nil { return err } return nil @@ -101,6 +102,11 @@ func (m *NewRule) validateEffect(formats strfmt.Registry) error { return nil } +// ContextValidate validates this new rule based on context it is used +func (m *NewRule) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewRule) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_service_catalog.go b/client/models/new_service_catalog.go index aa208699..ee3ed5ad 100644 --- a/client/models/new_service_catalog.go +++ b/client/models/new_service_catalog.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewServiceCatalog Service Catalog // -// Represents the Service Catalog item +// # Represents the Service Catalog item +// // swagger:model NewServiceCatalog type NewServiceCatalog struct { @@ -136,20 +137,19 @@ func (m *NewServiceCatalog) validateAuthor(formats strfmt.Registry) error { } func (m *NewServiceCatalog) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -157,12 +157,11 @@ func (m *NewServiceCatalog) validateCanonical(formats strfmt.Registry) error { } func (m *NewServiceCatalog) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -170,7 +169,6 @@ func (m *NewServiceCatalog) validateCreatedAt(formats strfmt.Registry) error { } func (m *NewServiceCatalog) validateDependencies(formats strfmt.Registry) error { - if swag.IsZero(m.Dependencies) { // not required return nil } @@ -184,6 +182,8 @@ func (m *NewServiceCatalog) validateDependencies(formats strfmt.Registry) error if err := m.Dependencies[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("dependencies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dependencies" + "." + strconv.Itoa(i)) } return err } @@ -204,7 +204,6 @@ func (m *NewServiceCatalog) validateDescription(formats strfmt.Registry) error { } func (m *NewServiceCatalog) validateImage(formats strfmt.Registry) error { - if swag.IsZero(m.Image) { // not required return nil } @@ -240,15 +239,15 @@ func (m *NewServiceCatalog) validateServiceCatalogSourceCanonical(formats strfmt return err } - if err := validate.MinLength("service_catalog_source_canonical", "body", string(*m.ServiceCatalogSourceCanonical), 3); err != nil { + if err := validate.MinLength("service_catalog_source_canonical", "body", *m.ServiceCatalogSourceCanonical, 3); err != nil { return err } - if err := validate.MaxLength("service_catalog_source_canonical", "body", string(*m.ServiceCatalogSourceCanonical), 100); err != nil { + if err := validate.MaxLength("service_catalog_source_canonical", "body", *m.ServiceCatalogSourceCanonical, 100); err != nil { return err } - if err := validate.Pattern("service_catalog_source_canonical", "body", string(*m.ServiceCatalogSourceCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("service_catalog_source_canonical", "body", *m.ServiceCatalogSourceCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -256,7 +255,6 @@ func (m *NewServiceCatalog) validateServiceCatalogSourceCanonical(formats strfmt } func (m *NewServiceCatalog) validateTechnologies(formats strfmt.Registry) error { - if swag.IsZero(m.Technologies) { // not required return nil } @@ -270,6 +268,8 @@ func (m *NewServiceCatalog) validateTechnologies(formats strfmt.Registry) error if err := m.Technologies[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("technologies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("technologies" + "." + strconv.Itoa(i)) } return err } @@ -281,18 +281,85 @@ func (m *NewServiceCatalog) validateTechnologies(formats strfmt.Registry) error } func (m *NewServiceCatalog) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this new service catalog based on the context it is used +func (m *NewServiceCatalog) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDependencies(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTechnologies(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NewServiceCatalog) contextValidateDependencies(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Dependencies); i++ { + + if m.Dependencies[i] != nil { + + if swag.IsZero(m.Dependencies[i]) { // not required + return nil + } + + if err := m.Dependencies[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dependencies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dependencies" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *NewServiceCatalog) contextValidateTechnologies(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Technologies); i++ { + + if m.Technologies[i] != nil { + + if swag.IsZero(m.Technologies[i]) { // not required + return nil + } + + if err := m.Technologies[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("technologies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("technologies" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *NewServiceCatalog) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_service_catalog_from_template.go b/client/models/new_service_catalog_from_template.go index 4c2f9c03..30916bb3 100644 --- a/client/models/new_service_catalog_from_template.go +++ b/client/models/new_service_catalog_from_template.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewServiceCatalogFromTemplate Service Catalog // -// Represents the Service Catalog item +// # Represents the Service Catalog item +// // swagger:model NewServiceCatalogFromTemplate type NewServiceCatalogFromTemplate struct { @@ -93,15 +95,15 @@ func (m *NewServiceCatalogFromTemplate) validateCanonical(formats strfmt.Registr return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -109,12 +111,11 @@ func (m *NewServiceCatalogFromTemplate) validateCanonical(formats strfmt.Registr } func (m *NewServiceCatalogFromTemplate) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -136,15 +137,15 @@ func (m *NewServiceCatalogFromTemplate) validateServiceCatalogSourceCanonical(fo return err } - if err := validate.MinLength("service_catalog_source_canonical", "body", string(*m.ServiceCatalogSourceCanonical), 3); err != nil { + if err := validate.MinLength("service_catalog_source_canonical", "body", *m.ServiceCatalogSourceCanonical, 3); err != nil { return err } - if err := validate.MaxLength("service_catalog_source_canonical", "body", string(*m.ServiceCatalogSourceCanonical), 100); err != nil { + if err := validate.MaxLength("service_catalog_source_canonical", "body", *m.ServiceCatalogSourceCanonical, 100); err != nil { return err } - if err := validate.Pattern("service_catalog_source_canonical", "body", string(*m.ServiceCatalogSourceCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("service_catalog_source_canonical", "body", *m.ServiceCatalogSourceCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -152,12 +153,11 @@ func (m *NewServiceCatalogFromTemplate) validateServiceCatalogSourceCanonical(fo } func (m *NewServiceCatalogFromTemplate) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -173,6 +173,11 @@ func (m *NewServiceCatalogFromTemplate) validateUseCase(formats strfmt.Registry) return nil } +// ContextValidate validates this new service catalog from template based on context it is used +func (m *NewServiceCatalogFromTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewServiceCatalogFromTemplate) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_service_catalog_source.go b/client/models/new_service_catalog_source.go index 034b894b..9a7c32bf 100644 --- a/client/models/new_service_catalog_source.go +++ b/client/models/new_service_catalog_source.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewServiceCatalogSource NewServiceCatalogSource +// // swagger:model NewServiceCatalogSource type NewServiceCatalogSource struct { @@ -89,20 +91,19 @@ func (m *NewServiceCatalogSource) validateBranch(formats strfmt.Registry) error } func (m *NewServiceCatalogSource) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -110,20 +111,19 @@ func (m *NewServiceCatalogSource) validateCanonical(formats strfmt.Registry) err } func (m *NewServiceCatalogSource) validateCredentialCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CredentialCanonical) { // not required return nil } - if err := validate.MinLength("credential_canonical", "body", string(m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -145,13 +145,18 @@ func (m *NewServiceCatalogSource) validateURL(formats strfmt.Registry) error { return err } - if err := validate.Pattern("url", "body", string(*m.URL), `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { + if err := validate.Pattern("url", "body", *m.URL, `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { return err } return nil } +// ContextValidate validates this new service catalog source based on context it is used +func (m *NewServiceCatalogSource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewServiceCatalogSource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_subscription.go b/client/models/new_subscription.go index 07c1d04b..e5cadde5 100644 --- a/client/models/new_subscription.go +++ b/client/models/new_subscription.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewSubscription New Subscription // -// It reflects the creation of a Subscription +// # It reflects the creation of a Subscription +// // swagger:model NewSubscription type NewSubscription struct { @@ -47,21 +49,26 @@ func (m *NewSubscription) validatePlanCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("plan_canonical", "body", string(*m.PlanCanonical), 3); err != nil { + if err := validate.MinLength("plan_canonical", "body", *m.PlanCanonical, 3); err != nil { return err } - if err := validate.MaxLength("plan_canonical", "body", string(*m.PlanCanonical), 100); err != nil { + if err := validate.MaxLength("plan_canonical", "body", *m.PlanCanonical, 100); err != nil { return err } - if err := validate.Pattern("plan_canonical", "body", string(*m.PlanCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("plan_canonical", "body", *m.PlanCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this new subscription based on context it is used +func (m *NewSubscription) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewSubscription) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_team.go b/client/models/new_team.go index 1dc148ad..6e4fa275 100644 --- a/client/models/new_team.go +++ b/client/models/new_team.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // NewTeam Create Team // // The entity which represents the information of a new team. +// // swagger:model NewTeam type NewTeam struct { @@ -66,20 +67,19 @@ func (m *NewTeam) Validate(formats strfmt.Registry) error { } func (m *NewTeam) validateCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.Canonical) { // not required return nil } - if err := validate.MinLength("canonical", "body", string(m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -92,7 +92,7 @@ func (m *NewTeam) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -107,15 +107,15 @@ func (m *NewTeam) validateRolesCanonical(formats strfmt.Registry) error { for i := 0; i < len(m.RolesCanonical); i++ { - if err := validate.MinLength("roles_canonical"+"."+strconv.Itoa(i), "body", string(m.RolesCanonical[i]), 3); err != nil { + if err := validate.MinLength("roles_canonical"+"."+strconv.Itoa(i), "body", m.RolesCanonical[i], 3); err != nil { return err } - if err := validate.MaxLength("roles_canonical"+"."+strconv.Itoa(i), "body", string(m.RolesCanonical[i]), 100); err != nil { + if err := validate.MaxLength("roles_canonical"+"."+strconv.Itoa(i), "body", m.RolesCanonical[i], 100); err != nil { return err } - if err := validate.Pattern("roles_canonical"+"."+strconv.Itoa(i), "body", string(m.RolesCanonical[i]), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("roles_canonical"+"."+strconv.Itoa(i), "body", m.RolesCanonical[i], `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -124,6 +124,11 @@ func (m *NewTeam) validateRolesCanonical(formats strfmt.Registry) error { return nil } +// ContextValidate validates this new team based on context it is used +func (m *NewTeam) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewTeam) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_team_member_assignation.go b/client/models/new_team_member_assignation.go index a0bb47ee..8c4d0387 100644 --- a/client/models/new_team_member_assignation.go +++ b/client/models/new_team_member_assignation.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NewTeamMemberAssignation Assign user // -// Member is a user assigned to a Team +// # Member is a user assigned to a Team +// // swagger:model NewTeamMemberAssignation type NewTeamMemberAssignation struct { @@ -47,6 +49,11 @@ func (m *NewTeamMemberAssignation) validateUsername(formats strfmt.Registry) err return nil } +// ContextValidate validates this new team member assignation based on context it is used +func (m *NewTeamMemberAssignation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewTeamMemberAssignation) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/new_user_account.go b/client/models/new_user_account.go index 4ce64dfa..aabcae9a 100644 --- a/client/models/new_user_account.go +++ b/client/models/new_user_account.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // NewUserAccount Sign up // // Create a new user account. +// // swagger:model NewUserAccount type NewUserAccount struct { @@ -45,7 +46,7 @@ type NewUserAccount struct { InvitationToken string `json:"invitation_token,omitempty"` // User's preferred language - // Enum: [en fr es] + // Enum: ["en","fr","es"] Locale string `json:"locale,omitempty"` // password @@ -105,12 +106,11 @@ func (m *NewUserAccount) Validate(formats strfmt.Registry) error { } func (m *NewUserAccount) validateCountryCode(formats strfmt.Registry) error { - if swag.IsZero(m.CountryCode) { // not required return nil } - if err := validate.Pattern("country_code", "body", string(m.CountryCode), `^[A-Z]{2}$`); err != nil { + if err := validate.Pattern("country_code", "body", m.CountryCode, `^[A-Z]{2}$`); err != nil { return err } @@ -136,7 +136,7 @@ func (m *NewUserAccount) validateFamilyName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("family_name", "body", string(*m.FamilyName), 2); err != nil { + if err := validate.MinLength("family_name", "body", *m.FamilyName, 2); err != nil { return err } @@ -149,7 +149,7 @@ func (m *NewUserAccount) validateGivenName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("given_name", "body", string(*m.GivenName), 2); err != nil { + if err := validate.MinLength("given_name", "body", *m.GivenName, 2); err != nil { return err } @@ -157,12 +157,11 @@ func (m *NewUserAccount) validateGivenName(formats strfmt.Registry) error { } func (m *NewUserAccount) validateInvitationToken(formats strfmt.Registry) error { - if swag.IsZero(m.InvitationToken) { // not required return nil } - if err := validate.MinLength("invitation_token", "body", string(m.InvitationToken), 5); err != nil { + if err := validate.MinLength("invitation_token", "body", m.InvitationToken, 5); err != nil { return err } @@ -195,14 +194,13 @@ const ( // prop value enum func (m *NewUserAccount) validateLocaleEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, newUserAccountTypeLocalePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, newUserAccountTypeLocalePropEnum, true); err != nil { return err } return nil } func (m *NewUserAccount) validateLocale(formats strfmt.Registry) error { - if swag.IsZero(m.Locale) { // not required return nil } @@ -221,7 +219,7 @@ func (m *NewUserAccount) validatePassword(formats strfmt.Registry) error { return err } - if err := validate.MinLength("password", "body", string(*m.Password), 8); err != nil { + if err := validate.MinLength("password", "body", m.Password.String(), 8); err != nil { return err } @@ -238,21 +236,26 @@ func (m *NewUserAccount) validateUsername(formats strfmt.Registry) error { return err } - if err := validate.MinLength("username", "body", string(*m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", *m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(*m.Username), 100); err != nil { + if err := validate.MaxLength("username", "body", *m.Username, 100); err != nil { return err } - if err := validate.Pattern("username", "body", string(*m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", *m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this new user account based on context it is used +func (m *NewUserAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *NewUserAccount) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/on_failure_plan.go b/client/models/on_failure_plan.go index 0ef9ef1e..9177bd9c 100644 --- a/client/models/on_failure_plan.go +++ b/client/models/on_failure_plan.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // OnFailurePlan OnFailurePlan // // The plan definition when the action has failed. +// // swagger:model OnFailurePlan type OnFailurePlan struct { @@ -56,6 +58,8 @@ func (m *OnFailurePlan) validateNext(formats strfmt.Registry) error { if err := m.Next.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") } return err } @@ -74,6 +78,60 @@ func (m *OnFailurePlan) validateStep(formats strfmt.Registry) error { if err := m.Step.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") + } + return err + } + } + + return nil +} + +// ContextValidate validate this on failure plan based on the context it is used +func (m *OnFailurePlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNext(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStep(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OnFailurePlan) contextValidateNext(ctx context.Context, formats strfmt.Registry) error { + + if m.Next != nil { + + if err := m.Next.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") + } + return err + } + } + + return nil +} + +func (m *OnFailurePlan) contextValidateStep(ctx context.Context, formats strfmt.Registry) error { + + if m.Step != nil { + + if err := m.Step.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") } return err } diff --git a/client/models/on_success_plan.go b/client/models/on_success_plan.go index 48203538..21bf0fa3 100644 --- a/client/models/on_success_plan.go +++ b/client/models/on_success_plan.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // OnSuccessPlan OnSuccessPlan // // The plan definition when the action has been successful. +// // swagger:model OnSuccessPlan type OnSuccessPlan struct { @@ -56,6 +58,8 @@ func (m *OnSuccessPlan) validateNext(formats strfmt.Registry) error { if err := m.Next.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") } return err } @@ -74,6 +78,60 @@ func (m *OnSuccessPlan) validateStep(formats strfmt.Registry) error { if err := m.Step.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") + } + return err + } + } + + return nil +} + +// ContextValidate validate this on success plan based on the context it is used +func (m *OnSuccessPlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNext(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStep(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OnSuccessPlan) contextValidateNext(ctx context.Context, formats strfmt.Registry) error { + + if m.Next != nil { + + if err := m.Next.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") + } + return err + } + } + + return nil +} + +func (m *OnSuccessPlan) contextValidateStep(ctx context.Context, formats strfmt.Registry) error { + + if m.Step != nil { + + if err := m.Step.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") } return err } diff --git a/client/models/organization.go b/client/models/organization.go index fbcc2603..e41080bf 100644 --- a/client/models/organization.go +++ b/client/models/organization.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // Organization Organization // // The entity which holds all the direct information attached to an organization. +// // swagger:model Organization type Organization struct { @@ -173,7 +174,6 @@ func (m *Organization) Validate(formats strfmt.Registry) error { } func (m *Organization) validateAdmins(formats strfmt.Registry) error { - if swag.IsZero(m.Admins) { // not required return nil } @@ -187,6 +187,8 @@ func (m *Organization) validateAdmins(formats strfmt.Registry) error { if err := m.Admins[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("admins" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("admins" + "." + strconv.Itoa(i)) } return err } @@ -198,7 +200,6 @@ func (m *Organization) validateAdmins(formats strfmt.Registry) error { } func (m *Organization) validateAppearance(formats strfmt.Registry) error { - if swag.IsZero(m.Appearance) { // not required return nil } @@ -207,6 +208,8 @@ func (m *Organization) validateAppearance(formats strfmt.Registry) error { if err := m.Appearance.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("appearance") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("appearance") } return err } @@ -248,15 +251,15 @@ func (m *Organization) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -296,7 +299,7 @@ func (m *Organization) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -318,7 +321,7 @@ func (m *Organization) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -340,7 +343,7 @@ func (m *Organization) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -357,7 +360,6 @@ func (m *Organization) validateQuotas(formats strfmt.Registry) error { } func (m *Organization) validateSubscription(formats strfmt.Registry) error { - if swag.IsZero(m.Subscription) { // not required return nil } @@ -366,6 +368,8 @@ func (m *Organization) validateSubscription(formats strfmt.Registry) error { if err := m.Subscription.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("subscription") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("subscription") } return err } @@ -380,13 +384,102 @@ func (m *Organization) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this organization based on the context it is used +func (m *Organization) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAdmins(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateAppearance(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSubscription(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Organization) contextValidateAdmins(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Admins); i++ { + + if m.Admins[i] != nil { + + if swag.IsZero(m.Admins[i]) { // not required + return nil + } + + if err := m.Admins[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("admins" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("admins" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Organization) contextValidateAppearance(ctx context.Context, formats strfmt.Registry) error { + + if m.Appearance != nil { + + if swag.IsZero(m.Appearance) { // not required + return nil + } + + if err := m.Appearance.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("appearance") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("appearance") + } + return err + } + } + + return nil +} + +func (m *Organization) contextValidateSubscription(ctx context.Context, formats strfmt.Registry) error { + + if m.Subscription != nil { + + if swag.IsZero(m.Subscription) { // not required + return nil + } + + if err := m.Subscription.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("subscription") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("subscription") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Organization) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/page_concourse.go b/client/models/page_concourse.go index 49fc6ea9..d1737cc0 100644 --- a/client/models/page_concourse.go +++ b/client/models/page_concourse.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PageConcourse PageConcourse +// // swagger:model PageConcourse type PageConcourse struct { @@ -79,6 +81,11 @@ func (m *PageConcourse) validateUntil(formats strfmt.Registry) error { return nil } +// ContextValidate validates this page concourse based on context it is used +func (m *PageConcourse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *PageConcourse) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pagination.go b/client/models/pagination.go index 974deecc..530ea98b 100644 --- a/client/models/pagination.go +++ b/client/models/pagination.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Pagination Pagination +// // swagger:model Pagination type Pagination struct { @@ -61,7 +63,7 @@ func (m *Pagination) validateIndex(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("index", "body", int64(*m.Index), 1, false); err != nil { + if err := validate.MinimumUint("index", "body", *m.Index, 1, false); err != nil { return err } @@ -74,7 +76,7 @@ func (m *Pagination) validateSize(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("size", "body", int64(*m.Size), 0, false); err != nil { + if err := validate.MinimumUint("size", "body", *m.Size, 0, false); err != nil { return err } @@ -87,13 +89,18 @@ func (m *Pagination) validateTotal(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("total", "body", int64(*m.Total), 0, false); err != nil { + if err := validate.MinimumUint("total", "body", *m.Total, 0, false); err != nil { return err } return nil } +// ContextValidate validates this pagination based on context it is used +func (m *Pagination) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Pagination) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pagination_a_w_s.go b/client/models/pagination_a_w_s.go index 6c1b931d..07c2fe59 100644 --- a/client/models/pagination_a_w_s.go +++ b/client/models/pagination_a_w_s.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PaginationAWS AWS Pagination +// // swagger:model PaginationAWS type PaginationAWS struct { @@ -45,6 +47,11 @@ func (m *PaginationAWS) validateNext(formats strfmt.Registry) error { return nil } +// ContextValidate validates this pagination a w s based on context it is used +func (m *PaginationAWS) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *PaginationAWS) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pagination_concourse.go b/client/models/pagination_concourse.go index 5e77bdec..fb380cc9 100644 --- a/client/models/pagination_concourse.go +++ b/client/models/pagination_concourse.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PaginationConcourse PaginationConcourse +// // swagger:model PaginationConcourse type PaginationConcourse struct { @@ -54,6 +56,8 @@ func (m *PaginationConcourse) validateNext(formats strfmt.Registry) error { if err := m.Next.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") } return err } @@ -72,6 +76,60 @@ func (m *PaginationConcourse) validatePrevious(formats strfmt.Registry) error { if err := m.Previous.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("previous") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("previous") + } + return err + } + } + + return nil +} + +// ContextValidate validate this pagination concourse based on the context it is used +func (m *PaginationConcourse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNext(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePrevious(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PaginationConcourse) contextValidateNext(ctx context.Context, formats strfmt.Registry) error { + + if m.Next != nil { + + if err := m.Next.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") + } + return err + } + } + + return nil +} + +func (m *PaginationConcourse) contextValidatePrevious(ctx context.Context, formats strfmt.Registry) error { + + if m.Previous != nil { + + if err := m.Previous.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("previous") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("previous") } return err } diff --git a/client/models/pending_invite.go b/client/models/pending_invite.go index d69e28e2..c0d4eca0 100644 --- a/client/models/pending_invite.go +++ b/client/models/pending_invite.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PendingInvite PendingInvite // -// Contains the email used for the invitation +// # Contains the email used for the invitation +// // swagger:model PendingInvite type PendingInvite struct { @@ -52,6 +54,11 @@ func (m *PendingInvite) validateEmail(formats strfmt.Registry) error { return nil } +// ContextValidate validates this pending invite based on context it is used +func (m *PendingInvite) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *PendingInvite) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pin_comment.go b/client/models/pin_comment.go index 45e5ea3c..cbd37df8 100644 --- a/client/models/pin_comment.go +++ b/client/models/pin_comment.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PinComment PinComment // -// Represents a pin comment of a resource +// # Represents a pin comment of a resource +// // swagger:model PinComment type PinComment struct { @@ -47,6 +49,11 @@ func (m *PinComment) validatePinComment(formats strfmt.Registry) error { return nil } +// ContextValidate validates this pin comment based on context it is used +func (m *PinComment) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *PinComment) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pipeline.go b/client/models/pipeline.go index 32020014..a103ce3d 100644 --- a/client/models/pipeline.go +++ b/client/models/pipeline.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -148,7 +148,7 @@ func (m *Pipeline) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -165,6 +165,8 @@ func (m *Pipeline) validateEnvironment(formats strfmt.Registry) error { if err := m.Environment.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") } return err } @@ -174,7 +176,6 @@ func (m *Pipeline) validateEnvironment(formats strfmt.Registry) error { } func (m *Pipeline) validateGroups(formats strfmt.Registry) error { - if swag.IsZero(m.Groups) { // not required return nil } @@ -188,6 +189,8 @@ func (m *Pipeline) validateGroups(formats strfmt.Registry) error { if err := m.Groups[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("groups" + "." + strconv.Itoa(i)) } return err } @@ -222,6 +225,8 @@ func (m *Pipeline) validateJobs(formats strfmt.Registry) error { if err := m.Jobs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("jobs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobs" + "." + strconv.Itoa(i)) } return err } @@ -260,6 +265,8 @@ func (m *Pipeline) validateProject(formats strfmt.Registry) error { if err := m.Project.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("project") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project") } return err } @@ -292,7 +299,7 @@ func (m *Pipeline) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -305,21 +312,131 @@ func (m *Pipeline) validateUseCase(formats strfmt.Registry) error { return err } - if err := validate.MinLength("use_case", "body", string(*m.UseCase), 1); err != nil { + if err := validate.MinLength("use_case", "body", *m.UseCase, 1); err != nil { return err } - if err := validate.MaxLength("use_case", "body", string(*m.UseCase), 100); err != nil { + if err := validate.MaxLength("use_case", "body", *m.UseCase, 100); err != nil { return err } - if err := validate.Pattern("use_case", "body", string(*m.UseCase), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("use_case", "body", *m.UseCase, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } return nil } +// ContextValidate validate this pipeline based on the context it is used +func (m *Pipeline) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEnvironment(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateGroups(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateJobs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProject(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Pipeline) contextValidateEnvironment(ctx context.Context, formats strfmt.Registry) error { + + if m.Environment != nil { + + if err := m.Environment.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") + } + return err + } + } + + return nil +} + +func (m *Pipeline) contextValidateGroups(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Groups); i++ { + + if m.Groups[i] != nil { + + if swag.IsZero(m.Groups[i]) { // not required + return nil + } + + if err := m.Groups[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("groups" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Pipeline) contextValidateJobs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Jobs); i++ { + + if m.Jobs[i] != nil { + + if swag.IsZero(m.Jobs[i]) { // not required + return nil + } + + if err := m.Jobs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("jobs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Pipeline) contextValidateProject(ctx context.Context, formats strfmt.Registry) error { + + if m.Project != nil { + + if err := m.Project.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Pipeline) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pipeline_diff.go b/client/models/pipeline_diff.go index 0f74d3e0..96942ed8 100644 --- a/client/models/pipeline_diff.go +++ b/client/models/pipeline_diff.go @@ -6,12 +6,12 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -19,6 +19,7 @@ import ( // PipelineDiff PipelineDiff // // Represents a diff element of a PipelineDiffs. +// // swagger:model PipelineDiff type PipelineDiff struct { @@ -32,7 +33,7 @@ type PipelineDiff struct { // Represents the status of the element (added, removed, changed) // Required: true - // Enum: [added removed changed] + // Enum: ["added","removed","changed"] Status *string `json:"status"` } @@ -73,6 +74,8 @@ func (m *PipelineDiff) validateDiff(formats strfmt.Registry) error { if err := m.Diff[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("diff" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("diff" + "." + strconv.Itoa(i)) } return err } @@ -118,7 +121,7 @@ const ( // prop value enum func (m *PipelineDiff) validateStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, pipelineDiffTypeStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, pipelineDiffTypeStatusPropEnum, true); err != nil { return err } return nil @@ -138,6 +141,45 @@ func (m *PipelineDiff) validateStatus(formats strfmt.Registry) error { return nil } +// ContextValidate validate this pipeline diff based on the context it is used +func (m *PipelineDiff) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDiff(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PipelineDiff) contextValidateDiff(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Diff); i++ { + + if m.Diff[i] != nil { + + if swag.IsZero(m.Diff[i]) { // not required + return nil + } + + if err := m.Diff[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("diff" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("diff" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *PipelineDiff) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pipeline_diff_record.go b/client/models/pipeline_diff_record.go index 6733e6a0..d1935115 100644 --- a/client/models/pipeline_diff_record.go +++ b/client/models/pipeline_diff_record.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PipelineDiffRecord PipelineDiffRecord // -// Represents a diff record of a pipeline diff +// # Represents a diff record of a pipeline diff +// // swagger:model PipelineDiffRecord type PipelineDiffRecord struct { @@ -64,6 +66,11 @@ func (m *PipelineDiffRecord) validateLine(formats strfmt.Registry) error { return nil } +// ContextValidate validates this pipeline diff record based on context it is used +func (m *PipelineDiffRecord) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *PipelineDiffRecord) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pipeline_diffs.go b/client/models/pipeline_diffs.go index 81247b57..1eaa688a 100644 --- a/client/models/pipeline_diffs.go +++ b/client/models/pipeline_diffs.go @@ -6,17 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // PipelineDiffs PipelineDiffs // -// Represents the diffs between two pipelines +// # Represents the diffs between two pipelines +// // swagger:model PipelineDiffs type PipelineDiffs struct { @@ -60,7 +61,6 @@ func (m *PipelineDiffs) Validate(formats strfmt.Registry) error { } func (m *PipelineDiffs) validateGroups(formats strfmt.Registry) error { - if swag.IsZero(m.Groups) { // not required return nil } @@ -74,6 +74,8 @@ func (m *PipelineDiffs) validateGroups(formats strfmt.Registry) error { if err := m.Groups[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("groups" + "." + strconv.Itoa(i)) } return err } @@ -85,7 +87,6 @@ func (m *PipelineDiffs) validateGroups(formats strfmt.Registry) error { } func (m *PipelineDiffs) validateJobs(formats strfmt.Registry) error { - if swag.IsZero(m.Jobs) { // not required return nil } @@ -99,6 +100,8 @@ func (m *PipelineDiffs) validateJobs(formats strfmt.Registry) error { if err := m.Jobs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("jobs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobs" + "." + strconv.Itoa(i)) } return err } @@ -110,7 +113,6 @@ func (m *PipelineDiffs) validateJobs(formats strfmt.Registry) error { } func (m *PipelineDiffs) validateResourceTypes(formats strfmt.Registry) error { - if swag.IsZero(m.ResourceTypes) { // not required return nil } @@ -124,6 +126,8 @@ func (m *PipelineDiffs) validateResourceTypes(formats strfmt.Registry) error { if err := m.ResourceTypes[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("resource_types" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resource_types" + "." + strconv.Itoa(i)) } return err } @@ -135,7 +139,6 @@ func (m *PipelineDiffs) validateResourceTypes(formats strfmt.Registry) error { } func (m *PipelineDiffs) validateResources(formats strfmt.Registry) error { - if swag.IsZero(m.Resources) { // not required return nil } @@ -149,6 +152,134 @@ func (m *PipelineDiffs) validateResources(formats strfmt.Registry) error { if err := m.Resources[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("resources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this pipeline diffs based on the context it is used +func (m *PipelineDiffs) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateGroups(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateJobs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateResourceTypes(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateResources(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PipelineDiffs) contextValidateGroups(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Groups); i++ { + + if m.Groups[i] != nil { + + if swag.IsZero(m.Groups[i]) { // not required + return nil + } + + if err := m.Groups[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("groups" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PipelineDiffs) contextValidateJobs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Jobs); i++ { + + if m.Jobs[i] != nil { + + if swag.IsZero(m.Jobs[i]) { // not required + return nil + } + + if err := m.Jobs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("jobs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PipelineDiffs) contextValidateResourceTypes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ResourceTypes); i++ { + + if m.ResourceTypes[i] != nil { + + if swag.IsZero(m.ResourceTypes[i]) { // not required + return nil + } + + if err := m.ResourceTypes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_types" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resource_types" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PipelineDiffs) contextValidateResources(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Resources); i++ { + + if m.Resources[i] != nil { + + if swag.IsZero(m.Resources[i]) { // not required + return nil + } + + if err := m.Resources[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resources" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/pipeline_status.go b/client/models/pipeline_status.go index f0e88bfc..0ad29bd0 100644 --- a/client/models/pipeline_status.go +++ b/client/models/pipeline_status.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // PipelineStatus PipelineStatus // // Pipeline status returned upon pipelines comparison between the one locally stored in the database and its counter part on git. +// // swagger:model PipelineStatus type PipelineStatus struct { @@ -33,7 +34,7 @@ type PipelineStatus struct { // - out_of_sync: database & git pipelines have some differences // - errored: both pipelines got retrieved but the comparison triggered an error // Required: true - // Enum: [unknown synced out_of_sync errored] + // Enum: ["unknown","synced","out_of_sync","errored"] Synced *string `json:"synced"` } @@ -56,7 +57,6 @@ func (m *PipelineStatus) Validate(formats strfmt.Registry) error { } func (m *PipelineStatus) validateDiffs(formats strfmt.Registry) error { - if swag.IsZero(m.Diffs) { // not required return nil } @@ -65,6 +65,8 @@ func (m *PipelineStatus) validateDiffs(formats strfmt.Registry) error { if err := m.Diffs.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("diffs") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("diffs") } return err } @@ -102,7 +104,7 @@ const ( // prop value enum func (m *PipelineStatus) validateSyncedEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, pipelineStatusTypeSyncedPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, pipelineStatusTypeSyncedPropEnum, true); err != nil { return err } return nil @@ -122,6 +124,41 @@ func (m *PipelineStatus) validateSynced(formats strfmt.Registry) error { return nil } +// ContextValidate validate this pipeline status based on the context it is used +func (m *PipelineStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDiffs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PipelineStatus) contextValidateDiffs(ctx context.Context, formats strfmt.Registry) error { + + if m.Diffs != nil { + + if swag.IsZero(m.Diffs) { // not required + return nil + } + + if err := m.Diffs.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("diffs") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("diffs") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *PipelineStatus) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/pipeline_variables.go b/client/models/pipeline_variables.go index 28745c46..37978936 100644 --- a/client/models/pipeline_variables.go +++ b/client/models/pipeline_variables.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // PipelineVariables Pipeline variables // // The entity which contains pipeline's variables. +// // swagger:model PipelineVariables type PipelineVariables struct { @@ -67,6 +69,11 @@ func (m *PipelineVariables) validateYamlVars(formats strfmt.Registry) error { return nil } +// ContextValidate validates this pipeline variables based on context it is used +func (m *PipelineVariables) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *PipelineVariables) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/plan.go b/client/models/plan.go index 1ff88aa6..625c4f05 100644 --- a/client/models/plan.go +++ b/client/models/plan.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // Plan Plan // // The plan is what represent a concourse build. +// // swagger:model Plan type Plan struct { @@ -117,7 +118,6 @@ func (m *Plan) Validate(formats strfmt.Registry) error { } func (m *Plan) validateDo(formats strfmt.Registry) error { - if swag.IsZero(m.Do) { // not required return nil } @@ -131,6 +131,8 @@ func (m *Plan) validateDo(formats strfmt.Registry) error { if err := m.Do[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("do" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("do" + "." + strconv.Itoa(i)) } return err } @@ -142,7 +144,6 @@ func (m *Plan) validateDo(formats strfmt.Registry) error { } func (m *Plan) validateEnsure(formats strfmt.Registry) error { - if swag.IsZero(m.Ensure) { // not required return nil } @@ -151,6 +152,8 @@ func (m *Plan) validateEnsure(formats strfmt.Registry) error { if err := m.Ensure.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("ensure") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ensure") } return err } @@ -160,7 +163,6 @@ func (m *Plan) validateEnsure(formats strfmt.Registry) error { } func (m *Plan) validateGet(formats strfmt.Registry) error { - if swag.IsZero(m.Get) { // not required return nil } @@ -169,6 +171,8 @@ func (m *Plan) validateGet(formats strfmt.Registry) error { if err := m.Get.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("get") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("get") } return err } @@ -187,7 +191,6 @@ func (m *Plan) validateID(formats strfmt.Registry) error { } func (m *Plan) validateOnFailure(formats strfmt.Registry) error { - if swag.IsZero(m.OnFailure) { // not required return nil } @@ -196,6 +199,8 @@ func (m *Plan) validateOnFailure(formats strfmt.Registry) error { if err := m.OnFailure.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("on_failure") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("on_failure") } return err } @@ -205,7 +210,6 @@ func (m *Plan) validateOnFailure(formats strfmt.Registry) error { } func (m *Plan) validateOnSuccess(formats strfmt.Registry) error { - if swag.IsZero(m.OnSuccess) { // not required return nil } @@ -214,6 +218,8 @@ func (m *Plan) validateOnSuccess(formats strfmt.Registry) error { if err := m.OnSuccess.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("on_success") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("on_success") } return err } @@ -223,7 +229,6 @@ func (m *Plan) validateOnSuccess(formats strfmt.Registry) error { } func (m *Plan) validatePut(formats strfmt.Registry) error { - if swag.IsZero(m.Put) { // not required return nil } @@ -232,6 +237,8 @@ func (m *Plan) validatePut(formats strfmt.Registry) error { if err := m.Put.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("put") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("put") } return err } @@ -241,7 +248,6 @@ func (m *Plan) validatePut(formats strfmt.Registry) error { } func (m *Plan) validateRetry(formats strfmt.Registry) error { - if swag.IsZero(m.Retry) { // not required return nil } @@ -255,6 +261,8 @@ func (m *Plan) validateRetry(formats strfmt.Registry) error { if err := m.Retry[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("retry" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("retry" + "." + strconv.Itoa(i)) } return err } @@ -266,7 +274,6 @@ func (m *Plan) validateRetry(formats strfmt.Registry) error { } func (m *Plan) validateTask(formats strfmt.Registry) error { - if swag.IsZero(m.Task) { // not required return nil } @@ -275,6 +282,8 @@ func (m *Plan) validateTask(formats strfmt.Registry) error { if err := m.Task.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("task") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("task") } return err } @@ -284,7 +293,6 @@ func (m *Plan) validateTask(formats strfmt.Registry) error { } func (m *Plan) validateTimeout(formats strfmt.Registry) error { - if swag.IsZero(m.Timeout) { // not required return nil } @@ -293,6 +301,8 @@ func (m *Plan) validateTimeout(formats strfmt.Registry) error { if err := m.Timeout.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("timeout") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("timeout") } return err } @@ -302,7 +312,6 @@ func (m *Plan) validateTimeout(formats strfmt.Registry) error { } func (m *Plan) validateTry(formats strfmt.Registry) error { - if swag.IsZero(m.Try) { // not required return nil } @@ -311,6 +320,276 @@ func (m *Plan) validateTry(formats strfmt.Registry) error { if err := m.Try.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("try") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("try") + } + return err + } + } + + return nil +} + +// ContextValidate validate this plan based on the context it is used +func (m *Plan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDo(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateEnsure(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateGet(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOnFailure(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOnSuccess(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePut(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateRetry(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTask(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTimeout(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTry(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Plan) contextValidateDo(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Do); i++ { + + if m.Do[i] != nil { + + if swag.IsZero(m.Do[i]) { // not required + return nil + } + + if err := m.Do[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("do" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("do" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Plan) contextValidateEnsure(ctx context.Context, formats strfmt.Registry) error { + + if m.Ensure != nil { + + if swag.IsZero(m.Ensure) { // not required + return nil + } + + if err := m.Ensure.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ensure") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ensure") + } + return err + } + } + + return nil +} + +func (m *Plan) contextValidateGet(ctx context.Context, formats strfmt.Registry) error { + + if m.Get != nil { + + if swag.IsZero(m.Get) { // not required + return nil + } + + if err := m.Get.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("get") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("get") + } + return err + } + } + + return nil +} + +func (m *Plan) contextValidateOnFailure(ctx context.Context, formats strfmt.Registry) error { + + if m.OnFailure != nil { + + if swag.IsZero(m.OnFailure) { // not required + return nil + } + + if err := m.OnFailure.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("on_failure") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("on_failure") + } + return err + } + } + + return nil +} + +func (m *Plan) contextValidateOnSuccess(ctx context.Context, formats strfmt.Registry) error { + + if m.OnSuccess != nil { + + if swag.IsZero(m.OnSuccess) { // not required + return nil + } + + if err := m.OnSuccess.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("on_success") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("on_success") + } + return err + } + } + + return nil +} + +func (m *Plan) contextValidatePut(ctx context.Context, formats strfmt.Registry) error { + + if m.Put != nil { + + if swag.IsZero(m.Put) { // not required + return nil + } + + if err := m.Put.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("put") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("put") + } + return err + } + } + + return nil +} + +func (m *Plan) contextValidateRetry(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Retry); i++ { + + if m.Retry[i] != nil { + + if swag.IsZero(m.Retry[i]) { // not required + return nil + } + + if err := m.Retry[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("retry" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("retry" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Plan) contextValidateTask(ctx context.Context, formats strfmt.Registry) error { + + if m.Task != nil { + + if swag.IsZero(m.Task) { // not required + return nil + } + + if err := m.Task.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("task") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("task") + } + return err + } + } + + return nil +} + +func (m *Plan) contextValidateTimeout(ctx context.Context, formats strfmt.Registry) error { + + if m.Timeout != nil { + + if swag.IsZero(m.Timeout) { // not required + return nil + } + + if err := m.Timeout.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("timeout") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("timeout") + } + return err + } + } + + return nil +} + +func (m *Plan) contextValidateTry(ctx context.Context, formats strfmt.Registry) error { + + if m.Try != nil { + + if swag.IsZero(m.Try) { // not required + return nil + } + + if err := m.Try.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("try") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("try") } return err } diff --git a/client/models/plan_config.go b/client/models/plan_config.go index 4f1cb2d7..675d4d24 100644 --- a/client/models/plan_config.go +++ b/client/models/plan_config.go @@ -6,17 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // PlanConfig PlanConfig // // The plan configuration when creating new build. +// // swagger:model PlanConfig type PlanConfig struct { @@ -86,7 +87,6 @@ func (m *PlanConfig) Validate(formats strfmt.Registry) error { } func (m *PlanConfig) validateAggregate(formats strfmt.Registry) error { - if swag.IsZero(m.Aggregate) { // not required return nil } @@ -100,6 +100,8 @@ func (m *PlanConfig) validateAggregate(formats strfmt.Registry) error { if err := m.Aggregate[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("aggregate" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("aggregate" + "." + strconv.Itoa(i)) } return err } @@ -111,7 +113,6 @@ func (m *PlanConfig) validateAggregate(formats strfmt.Registry) error { } func (m *PlanConfig) validateDo(formats strfmt.Registry) error { - if swag.IsZero(m.Do) { // not required return nil } @@ -125,6 +126,8 @@ func (m *PlanConfig) validateDo(formats strfmt.Registry) error { if err := m.Do[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("do" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("do" + "." + strconv.Itoa(i)) } return err } @@ -136,7 +139,6 @@ func (m *PlanConfig) validateDo(formats strfmt.Registry) error { } func (m *PlanConfig) validateTaskConfig(formats strfmt.Registry) error { - if swag.IsZero(m.TaskConfig) { // not required return nil } @@ -145,6 +147,101 @@ func (m *PlanConfig) validateTaskConfig(formats strfmt.Registry) error { if err := m.TaskConfig.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("taskConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("taskConfig") + } + return err + } + } + + return nil +} + +// ContextValidate validate this plan config based on the context it is used +func (m *PlanConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAggregate(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateDo(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTaskConfig(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PlanConfig) contextValidateAggregate(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Aggregate); i++ { + + if m.Aggregate[i] != nil { + + if swag.IsZero(m.Aggregate[i]) { // not required + return nil + } + + if err := m.Aggregate[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("aggregate" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("aggregate" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PlanConfig) contextValidateDo(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Do); i++ { + + if m.Do[i] != nil { + + if swag.IsZero(m.Do[i]) { // not required + return nil + } + + if err := m.Do[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("do" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("do" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PlanConfig) contextValidateTaskConfig(ctx context.Context, formats strfmt.Registry) error { + + if m.TaskConfig != nil { + + if swag.IsZero(m.TaskConfig) { // not required + return nil + } + + if err := m.TaskConfig.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("taskConfig") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("taskConfig") } return err } diff --git a/client/models/policy.go b/client/models/policy.go index e2440174..9091d275 100644 --- a/client/models/policy.go +++ b/client/models/policy.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // Policy Policy // // Policy represents a permission or constraint to access to an entity of the system. A policy is aggregated into roles in order to be applied. +// // swagger:model Policy type Policy struct { @@ -83,15 +85,15 @@ func (m *Policy) validateCode(formats strfmt.Registry) error { return err } - if err := validate.MinLength("code", "body", string(*m.Code), 5); err != nil { + if err := validate.MinLength("code", "body", *m.Code, 5); err != nil { return err } - if err := validate.MaxLength("code", "body", string(*m.Code), 60); err != nil { + if err := validate.MaxLength("code", "body", *m.Code, 60); err != nil { return err } - if err := validate.Pattern("code", "body", string(*m.Code), `(?:[a-z]+_)*[a-z]+(?::(?:[a-z]+_)*[a-z]+)*$`); err != nil { + if err := validate.Pattern("code", "body", *m.Code, `(?:[a-z]+_)*[a-z]+(?::(?:[a-z]+_)*[a-z]+)*$`); err != nil { return err } @@ -99,12 +101,11 @@ func (m *Policy) validateCode(formats strfmt.Registry) error { } func (m *Policy) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -126,7 +127,7 @@ func (m *Policy) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -134,18 +135,22 @@ func (m *Policy) validateID(formats strfmt.Registry) error { } func (m *Policy) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validates this policy based on context it is used +func (m *Policy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Policy) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/preparation.go b/client/models/preparation.go index 3dde594d..ecf8d8fc 100644 --- a/client/models/preparation.go +++ b/client/models/preparation.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Preparation Preparation +// // swagger:model Preparation type Preparation struct { @@ -95,8 +97,8 @@ func (m *Preparation) validateBuildID(formats strfmt.Registry) error { func (m *Preparation) validateInputs(formats strfmt.Registry) error { - if err := validate.Required("inputs", "body", m.Inputs); err != nil { - return err + if m.Inputs == nil { + return errors.Required("inputs", "body", nil) } return nil @@ -104,8 +106,8 @@ func (m *Preparation) validateInputs(formats strfmt.Registry) error { func (m *Preparation) validateInputsSatisfied(formats strfmt.Registry) error { - if err := validate.Required("inputs_satisfied", "body", m.InputsSatisfied); err != nil { - return err + if m.InputsSatisfied == nil { + return errors.Required("inputs_satisfied", "body", nil) } return nil @@ -122,8 +124,8 @@ func (m *Preparation) validateMaxRunningBuilds(formats strfmt.Registry) error { func (m *Preparation) validateMissingInputReasons(formats strfmt.Registry) error { - if err := validate.Required("missing_input_reasons", "body", m.MissingInputReasons); err != nil { - return err + if m.MissingInputReasons == nil { + return errors.Required("missing_input_reasons", "body", nil) } return nil @@ -147,6 +149,11 @@ func (m *Preparation) validatePausedPipeline(formats strfmt.Registry) error { return nil } +// ContextValidate validates this preparation based on context it is used +func (m *Preparation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Preparation) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/project.go b/client/models/project.go index a32c21a5..addc1aec 100644 --- a/client/models/project.go +++ b/client/models/project.go @@ -6,12 +6,12 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -19,6 +19,7 @@ import ( // Project Project // // The entity which represents the information of a project. +// // swagger:model Project type Project struct { @@ -56,7 +57,7 @@ type Project struct { ID *uint32 `json:"id"` // The import process status. - // Enum: [succeeded failed importing] + // Enum: ["succeeded","failed","importing"] ImportStatus string `json:"import_status,omitempty"` // name @@ -142,15 +143,15 @@ func (m *Project) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -158,20 +159,19 @@ func (m *Project) validateCanonical(formats strfmt.Registry) error { } func (m *Project) validateConfigRepositoryCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ConfigRepositoryCanonical) { // not required return nil } - if err := validate.MinLength("config_repository_canonical", "body", string(m.ConfigRepositoryCanonical), 3); err != nil { + if err := validate.MinLength("config_repository_canonical", "body", m.ConfigRepositoryCanonical, 3); err != nil { return err } - if err := validate.MaxLength("config_repository_canonical", "body", string(m.ConfigRepositoryCanonical), 100); err != nil { + if err := validate.MaxLength("config_repository_canonical", "body", m.ConfigRepositoryCanonical, 100); err != nil { return err } - if err := validate.Pattern("config_repository_canonical", "body", string(m.ConfigRepositoryCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("config_repository_canonical", "body", m.ConfigRepositoryCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -184,7 +184,7 @@ func (m *Project) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -206,6 +206,8 @@ func (m *Project) validateEnvironments(formats strfmt.Registry) error { if err := m.Environments[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("environments" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environments" + "." + strconv.Itoa(i)) } return err } @@ -222,7 +224,7 @@ func (m *Project) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -255,14 +257,13 @@ const ( // prop value enum func (m *Project) validateImportStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, projectTypeImportStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, projectTypeImportStatusPropEnum, true); err != nil { return err } return nil } func (m *Project) validateImportStatus(formats strfmt.Registry) error { - if swag.IsZero(m.ImportStatus) { // not required return nil } @@ -281,7 +282,7 @@ func (m *Project) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { return err } @@ -289,7 +290,6 @@ func (m *Project) validateName(formats strfmt.Registry) error { } func (m *Project) validateOwner(formats strfmt.Registry) error { - if swag.IsZero(m.Owner) { // not required return nil } @@ -298,6 +298,8 @@ func (m *Project) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -307,7 +309,6 @@ func (m *Project) validateOwner(formats strfmt.Registry) error { } func (m *Project) validateServiceCatalog(formats strfmt.Registry) error { - if swag.IsZero(m.ServiceCatalog) { // not required return nil } @@ -316,6 +317,8 @@ func (m *Project) validateServiceCatalog(formats strfmt.Registry) error { if err := m.ServiceCatalog.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("service_catalog") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_catalog") } return err } @@ -325,7 +328,6 @@ func (m *Project) validateServiceCatalog(formats strfmt.Registry) error { } func (m *Project) validateTeam(formats strfmt.Registry) error { - if swag.IsZero(m.Team) { // not required return nil } @@ -334,6 +336,8 @@ func (m *Project) validateTeam(formats strfmt.Registry) error { if err := m.Team.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("team") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("team") } return err } @@ -348,13 +352,127 @@ func (m *Project) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this project based on the context it is used +func (m *Project) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEnvironments(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateServiceCatalog(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTeam(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Project) contextValidateEnvironments(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Environments); i++ { + + if m.Environments[i] != nil { + + if swag.IsZero(m.Environments[i]) { // not required + return nil + } + + if err := m.Environments[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environments" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environments" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Project) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if swag.IsZero(m.Owner) { // not required + return nil + } + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + +func (m *Project) contextValidateServiceCatalog(ctx context.Context, formats strfmt.Registry) error { + + if m.ServiceCatalog != nil { + + if swag.IsZero(m.ServiceCatalog) { // not required + return nil + } + + if err := m.ServiceCatalog.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service_catalog") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_catalog") + } + return err + } + } + + return nil +} + +func (m *Project) contextValidateTeam(ctx context.Context, formats strfmt.Registry) error { + + if m.Team != nil { + + if swag.IsZero(m.Team) { // not required + return nil + } + + if err := m.Team.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("team") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("team") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Project) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/project_environment_config.go b/client/models/project_environment_config.go index d697eddc..f1469f09 100644 --- a/client/models/project_environment_config.go +++ b/client/models/project_environment_config.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -62,6 +63,8 @@ func (m *ProjectEnvironmentConfig) validateForms(formats strfmt.Registry) error if err := m.Forms.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("forms") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("forms") } return err } @@ -79,6 +82,37 @@ func (m *ProjectEnvironmentConfig) validateUseCase(formats strfmt.Registry) erro return nil } +// ContextValidate validate this project environment config based on the context it is used +func (m *ProjectEnvironmentConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateForms(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectEnvironmentConfig) contextValidateForms(ctx context.Context, formats strfmt.Registry) error { + + if m.Forms != nil { + + if err := m.Forms.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("forms") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("forms") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *ProjectEnvironmentConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/project_environment_consumption.go b/client/models/project_environment_consumption.go index 4bbc21fc..10029ae1 100644 --- a/client/models/project_environment_consumption.go +++ b/client/models/project_environment_consumption.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // ProjectEnvironmentConsumption ProjectEnvironmentConsumption // -// The Consumption of a Project in an Environment +// # The Consumption of a Project in an Environment +// // swagger:model ProjectEnvironmentConsumption type ProjectEnvironmentConsumption struct { @@ -88,7 +90,7 @@ func (m *ProjectEnvironmentConsumption) validateCPU(formats strfmt.Registry) err return err } - if err := validate.MinimumInt("cpu", "body", int64(*m.CPU), 0, false); err != nil { + if err := validate.MinimumUint("cpu", "body", *m.CPU, 0, false); err != nil { return err } @@ -105,6 +107,8 @@ func (m *ProjectEnvironmentConsumption) validateEnvironment(formats strfmt.Regis if err := m.Environment.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") } return err } @@ -119,7 +123,7 @@ func (m *ProjectEnvironmentConsumption) validateID(formats strfmt.Registry) erro return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -132,7 +136,7 @@ func (m *ProjectEnvironmentConsumption) validateMemory(formats strfmt.Registry) return err } - if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { + if err := validate.MinimumUint("memory", "body", *m.Memory, 0, false); err != nil { return err } @@ -149,6 +153,8 @@ func (m *ProjectEnvironmentConsumption) validateProject(formats strfmt.Registry) if err := m.Project.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("project") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project") } return err } @@ -163,13 +169,65 @@ func (m *ProjectEnvironmentConsumption) validateStorage(formats strfmt.Registry) return err } - if err := validate.MinimumInt("storage", "body", int64(*m.Storage), 0, false); err != nil { + if err := validate.MinimumUint("storage", "body", *m.Storage, 0, false); err != nil { return err } return nil } +// ContextValidate validate this project environment consumption based on the context it is used +func (m *ProjectEnvironmentConsumption) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEnvironment(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateProject(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectEnvironmentConsumption) contextValidateEnvironment(ctx context.Context, formats strfmt.Registry) error { + + if m.Environment != nil { + + if err := m.Environment.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environment") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environment") + } + return err + } + } + + return nil +} + +func (m *ProjectEnvironmentConsumption) contextValidateProject(ctx context.Context, formats strfmt.Registry) error { + + if m.Project != nil { + + if err := m.Project.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *ProjectEnvironmentConsumption) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/project_simple.go b/client/models/project_simple.go index 9396c9ae..a8bac89b 100644 --- a/client/models/project_simple.go +++ b/client/models/project_simple.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // ProjectSimple ProjectSimple // // The entity which represents minimal information of a project. +// // swagger:model ProjectSimple type ProjectSimple struct { @@ -45,7 +46,7 @@ type ProjectSimple struct { ID *uint32 `json:"id"` // The import process status. - // Enum: [succeeded failed importing] + // Enum: ["succeeded","failed","importing"] ImportStatus string `json:"import_status,omitempty"` // name @@ -109,15 +110,15 @@ func (m *ProjectSimple) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 1); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 1); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -130,7 +131,7 @@ func (m *ProjectSimple) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -143,7 +144,7 @@ func (m *ProjectSimple) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -176,14 +177,13 @@ const ( // prop value enum func (m *ProjectSimple) validateImportStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, projectSimpleTypeImportStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, projectSimpleTypeImportStatusPropEnum, true); err != nil { return err } return nil } func (m *ProjectSimple) validateImportStatus(formats strfmt.Registry) error { - if swag.IsZero(m.ImportStatus) { // not required return nil } @@ -202,7 +202,7 @@ func (m *ProjectSimple) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { return err } @@ -210,7 +210,6 @@ func (m *ProjectSimple) validateName(formats strfmt.Registry) error { } func (m *ProjectSimple) validateOwner(formats strfmt.Registry) error { - if swag.IsZero(m.Owner) { // not required return nil } @@ -219,6 +218,8 @@ func (m *ProjectSimple) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -233,13 +234,48 @@ func (m *ProjectSimple) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this project simple based on the context it is used +func (m *ProjectSimple) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectSimple) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if swag.IsZero(m.Owner) { // not required + return nil + } + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *ProjectSimple) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/public_build_input.go b/client/models/public_build_input.go index 3f49ca81..41cb045d 100644 --- a/client/models/public_build_input.go +++ b/client/models/public_build_input.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PublicBuildInput PublicBuildInput // -// Represent the information of a build input +// # Represent the information of a build input +// // swagger:model PublicBuildInput type PublicBuildInput struct { @@ -91,6 +93,15 @@ func (m *PublicBuildInput) validatePipelineID(formats strfmt.Registry) error { func (m *PublicBuildInput) validateVersion(formats strfmt.Registry) error { + if err := validate.Required("version", "body", m.Version); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this public build input based on context it is used +func (m *PublicBuildInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } diff --git a/client/models/public_build_output.go b/client/models/public_build_output.go index 9401fd7b..c89dae82 100644 --- a/client/models/public_build_output.go +++ b/client/models/public_build_output.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PublicBuildOutput PublicBuildOutput // -// Represents the information of a build output +// # Represents the information of a build output +// // swagger:model PublicBuildOutput type PublicBuildOutput struct { @@ -57,6 +59,15 @@ func (m *PublicBuildOutput) validateName(formats strfmt.Registry) error { func (m *PublicBuildOutput) validateVersion(formats strfmt.Registry) error { + if err := validate.Required("version", "body", m.Version); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this public build output based on context it is used +func (m *PublicBuildOutput) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } diff --git a/client/models/public_plan.go b/client/models/public_plan.go index a76b8ded..c0edf28d 100644 --- a/client/models/public_plan.go +++ b/client/models/public_plan.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // PublicPlan PublicPlan // // The public plan returned requesting a build plan. +// // swagger:model PublicPlan type PublicPlan struct { @@ -48,8 +50,8 @@ func (m *PublicPlan) Validate(formats strfmt.Registry) error { func (m *PublicPlan) validatePlan(formats strfmt.Registry) error { - if err := validate.Required("plan", "body", m.Plan); err != nil { - return err + if m.Plan == nil { + return errors.Required("plan", "body", nil) } return nil @@ -64,6 +66,11 @@ func (m *PublicPlan) validateSchema(formats strfmt.Registry) error { return nil } +// ContextValidate validates this public plan based on context it is used +func (m *PublicPlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *PublicPlan) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/put_plan.go b/client/models/put_plan.go index 0bd12614..915bfb3c 100644 --- a/client/models/put_plan.go +++ b/client/models/put_plan.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // PutPlan PutPlan // // The put plan following a plan. +// // swagger:model PutPlan type PutPlan struct { @@ -83,11 +84,11 @@ func (m *PutPlan) validateResource(formats strfmt.Registry) error { func (m *PutPlan) validateSource(formats strfmt.Registry) error { - for k := range m.Source { + if err := validate.Required("source", "body", m.Source); err != nil { + return err + } - if err := validate.Required("source"+"."+k, "body", m.Source[k]); err != nil { - return err - } + for k := range m.Source { if err := validate.Required("source"+"."+k, "body", m.Source[k]); err != nil { return err @@ -108,7 +109,6 @@ func (m *PutPlan) validateType(formats strfmt.Registry) error { } func (m *PutPlan) validateVersionedResourceTypes(formats strfmt.Registry) error { - if swag.IsZero(m.VersionedResourceTypes) { // not required return nil } @@ -122,6 +122,47 @@ func (m *PutPlan) validateVersionedResourceTypes(formats strfmt.Registry) error if err := m.VersionedResourceTypes[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this put plan based on the context it is used +func (m *PutPlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVersionedResourceTypes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PutPlan) contextValidateVersionedResourceTypes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.VersionedResourceTypes); i++ { + + if m.VersionedResourceTypes[i] != nil { + + if swag.IsZero(m.VersionedResourceTypes[i]) { // not required + return nil + } + + if err := m.VersionedResourceTypes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/quota.go b/client/models/quota.go index cce29d8c..22aa6d4e 100644 --- a/client/models/quota.go +++ b/client/models/quota.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Quota Quota // -// A Quota holds the information of the restrictions applied to a Team having as source a Resource Pool +// # A Quota holds the information of the restrictions applied to a Team having as source a Resource Pool +// // swagger:model Quota type Quota struct { @@ -115,7 +117,7 @@ func (m *Quota) validateCPU(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("cpu", "body", int64(*m.CPU), 0, false); err != nil { + if err := validate.MinimumUint("cpu", "body", *m.CPU, 0, false); err != nil { return err } @@ -128,7 +130,7 @@ func (m *Quota) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -141,7 +143,7 @@ func (m *Quota) validateMemory(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { + if err := validate.MinimumUint("memory", "body", *m.Memory, 0, false); err != nil { return err } @@ -158,6 +160,8 @@ func (m *Quota) validateResourcePool(formats strfmt.Registry) error { if err := m.ResourcePool.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("resource_pool") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resource_pool") } return err } @@ -172,7 +176,7 @@ func (m *Quota) validateStorage(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("storage", "body", int64(*m.Storage), 0, false); err != nil { + if err := validate.MinimumUint("storage", "body", *m.Storage, 0, false); err != nil { return err } @@ -189,6 +193,8 @@ func (m *Quota) validateTeam(formats strfmt.Registry) error { if err := m.Team.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("team") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("team") } return err } @@ -203,7 +209,7 @@ func (m *Quota) validateUsedCPU(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("used_cpu", "body", int64(*m.UsedCPU), 0, false); err != nil { + if err := validate.MinimumUint("used_cpu", "body", *m.UsedCPU, 0, false); err != nil { return err } @@ -216,7 +222,7 @@ func (m *Quota) validateUsedMemory(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("used_memory", "body", int64(*m.UsedMemory), 0, false); err != nil { + if err := validate.MinimumUint("used_memory", "body", *m.UsedMemory, 0, false); err != nil { return err } @@ -229,13 +235,65 @@ func (m *Quota) validateUsedStorage(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("used_storage", "body", int64(*m.UsedStorage), 0, false); err != nil { + if err := validate.MinimumUint("used_storage", "body", *m.UsedStorage, 0, false); err != nil { return err } return nil } +// ContextValidate validate this quota based on the context it is used +func (m *Quota) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateResourcePool(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTeam(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Quota) contextValidateResourcePool(ctx context.Context, formats strfmt.Registry) error { + + if m.ResourcePool != nil { + + if err := m.ResourcePool.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_pool") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resource_pool") + } + return err + } + } + + return nil +} + +func (m *Quota) contextValidateTeam(ctx context.Context, formats strfmt.Registry) error { + + if m.Team != nil { + + if err := m.Team.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("team") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("team") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Quota) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/resource.go b/client/models/resource.go index 3e3fe7a9..24b62b92 100644 --- a/client/models/resource.go +++ b/client/models/resource.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // Resource Resource // // The entity which represents a resource in the application. +// // swagger:model Resource type Resource struct { @@ -78,7 +80,6 @@ func (m *Resource) Validate(formats strfmt.Registry) error { } func (m *Resource) validateBuild(formats strfmt.Registry) error { - if swag.IsZero(m.Build) { // not required return nil } @@ -87,6 +88,8 @@ func (m *Resource) validateBuild(formats strfmt.Registry) error { if err := m.Build.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("build") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("build") } return err } @@ -113,6 +116,41 @@ func (m *Resource) validateType(formats strfmt.Registry) error { return nil } +// ContextValidate validate this resource based on the context it is used +func (m *Resource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBuild(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Resource) contextValidateBuild(ctx context.Context, formats strfmt.Registry) error { + + if m.Build != nil { + + if swag.IsZero(m.Build) { // not required + return nil + } + + if err := m.Build.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("build") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("build") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Resource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/resource_pool.go b/client/models/resource_pool.go index 985384b2..ccd83412 100644 --- a/client/models/resource_pool.go +++ b/client/models/resource_pool.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // ResourcePool Resource Pool // // A Resource Pool holds the information of all the Resources that have the same label. The Used is the amount used by Projects using Quotas and Allocated is the amount declared by Quotas +// // swagger:model ResourcePool type ResourcePool struct { @@ -152,7 +154,7 @@ func (m *ResourcePool) validateAllocatedCPU(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("allocated_cpu", "body", int64(*m.AllocatedCPU), 0, false); err != nil { + if err := validate.MinimumUint("allocated_cpu", "body", *m.AllocatedCPU, 0, false); err != nil { return err } @@ -165,7 +167,7 @@ func (m *ResourcePool) validateAllocatedMemory(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("allocated_memory", "body", int64(*m.AllocatedMemory), 0, false); err != nil { + if err := validate.MinimumUint("allocated_memory", "body", *m.AllocatedMemory, 0, false); err != nil { return err } @@ -178,7 +180,7 @@ func (m *ResourcePool) validateAllocatedStorage(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("allocated_storage", "body", int64(*m.AllocatedStorage), 0, false); err != nil { + if err := validate.MinimumUint("allocated_storage", "body", *m.AllocatedStorage, 0, false); err != nil { return err } @@ -191,15 +193,15 @@ func (m *ResourcePool) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -212,7 +214,7 @@ func (m *ResourcePool) validateCPU(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("cpu", "body", int64(*m.CPU), 0, false); err != nil { + if err := validate.MinimumUint("cpu", "body", *m.CPU, 0, false); err != nil { return err } @@ -220,12 +222,11 @@ func (m *ResourcePool) validateCPU(formats strfmt.Registry) error { } func (m *ResourcePool) validateID(formats strfmt.Registry) error { - if swag.IsZero(m.ID) { // not required return nil } - if err := validate.MinimumInt("id", "body", int64(m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(m.ID), 1, false); err != nil { return err } @@ -247,7 +248,7 @@ func (m *ResourcePool) validateMemory(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { + if err := validate.MinimumUint("memory", "body", *m.Memory, 0, false); err != nil { return err } @@ -269,7 +270,7 @@ func (m *ResourcePool) validateStorage(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("storage", "body", int64(*m.Storage), 0, false); err != nil { + if err := validate.MinimumUint("storage", "body", *m.Storage, 0, false); err != nil { return err } @@ -282,7 +283,7 @@ func (m *ResourcePool) validateUsedCPU(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("used_cpu", "body", int64(*m.UsedCPU), 0, false); err != nil { + if err := validate.MinimumUint("used_cpu", "body", *m.UsedCPU, 0, false); err != nil { return err } @@ -295,7 +296,7 @@ func (m *ResourcePool) validateUsedMemory(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("used_memory", "body", int64(*m.UsedMemory), 0, false); err != nil { + if err := validate.MinimumUint("used_memory", "body", *m.UsedMemory, 0, false); err != nil { return err } @@ -308,13 +309,18 @@ func (m *ResourcePool) validateUsedStorage(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("used_storage", "body", int64(*m.UsedStorage), 0, false); err != nil { + if err := validate.MinimumUint("used_storage", "body", *m.UsedStorage, 0, false); err != nil { return err } return nil } +// ContextValidate validates this resource pool based on context it is used +func (m *ResourcePool) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ResourcePool) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/resource_version.go b/client/models/resource_version.go index d20360fc..ae39e77b 100644 --- a/client/models/resource_version.go +++ b/client/models/resource_version.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // ResourceVersion ResourceVersion // -// Represent the outputs of a job +// # Represent the outputs of a job +// // swagger:model ResourceVersion type ResourceVersion struct { @@ -82,7 +83,6 @@ func (m *ResourceVersion) validateID(formats strfmt.Registry) error { } func (m *ResourceVersion) validateMetadata(formats strfmt.Registry) error { - if swag.IsZero(m.Metadata) { // not required return nil } @@ -96,6 +96,8 @@ func (m *ResourceVersion) validateMetadata(formats strfmt.Registry) error { if err := m.Metadata[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("metadata" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("metadata" + "." + strconv.Itoa(i)) } return err } @@ -108,6 +110,49 @@ func (m *ResourceVersion) validateMetadata(formats strfmt.Registry) error { func (m *ResourceVersion) validateVersion(formats strfmt.Registry) error { + if err := validate.Required("version", "body", m.Version); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this resource version based on the context it is used +func (m *ResourceVersion) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateMetadata(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ResourceVersion) contextValidateMetadata(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Metadata); i++ { + + if m.Metadata[i] != nil { + + if swag.IsZero(m.Metadata[i]) { // not required + return nil + } + + if err := m.Metadata[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("metadata" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("metadata" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + return nil } diff --git a/client/models/role.go b/client/models/role.go index 5b7ff726..9868f7cc 100644 --- a/client/models/role.go +++ b/client/models/role.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // Role Role access control // // Role represents the authorization level that an user has to access to a specific entity of the system. A role contains a list of rules to define the access control. Note not all the entities supports roles access control; see the API endpoints to know which entities support them. +// // swagger:model Role type Role struct { @@ -108,15 +109,15 @@ func (m *Role) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -124,12 +125,11 @@ func (m *Role) validateCanonical(formats strfmt.Registry) error { } func (m *Role) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -160,7 +160,7 @@ func (m *Role) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -173,11 +173,11 @@ func (m *Role) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } - if err := validate.MaxLength("name", "body", string(*m.Name), 100); err != nil { + if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { return err } @@ -199,6 +199,8 @@ func (m *Role) validateRules(formats strfmt.Registry) error { if err := m.Rules[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rules" + "." + strconv.Itoa(i)) } return err } @@ -210,18 +212,56 @@ func (m *Role) validateRules(formats strfmt.Registry) error { } func (m *Role) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this role based on the context it is used +func (m *Role) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRules(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Role) contextValidateRules(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Rules); i++ { + + if m.Rules[i] != nil { + + if swag.IsZero(m.Rules[i]) { // not required + return nil + } + + if err := m.Rules[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *Role) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/rule.go b/client/models/rule.go index db278e95..78807471 100644 --- a/client/models/rule.go +++ b/client/models/rule.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Rule Rule // -// Rules define the specific access to the platform +// # Rules define the specific access to the platform +// // swagger:model Rule type Rule struct { @@ -27,7 +28,7 @@ type Rule struct { // effect // Required: true - // Enum: [allow] + // Enum: ["allow"] Effect *string `json:"effect"` // This is the id of the row from the database, but for blocking organizations we generate rules that are not in the database. When this happens the id is allowed to be 0. @@ -90,7 +91,7 @@ const ( // prop value enum func (m *Rule) validateEffectEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, ruleTypeEffectPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, ruleTypeEffectPropEnum, true); err != nil { return err } return nil @@ -116,13 +117,18 @@ func (m *Rule) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 0, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 0, false); err != nil { return err } return nil } +// ContextValidate validates this rule based on context it is used +func (m *Rule) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Rule) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/s_c_config.go b/client/models/s_c_config.go index 7a825a75..bcfe597d 100644 --- a/client/models/s_c_config.go +++ b/client/models/s_c_config.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SCConfig SC Config // -// This entity is being used for automatic creation of SC config +// # This entity is being used for automatic creation of SC config +// // swagger:model SCConfig type SCConfig struct { @@ -55,6 +56,47 @@ func (m *SCConfig) validateConfigs(formats strfmt.Registry) error { if err := m.Configs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("configs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this s c config based on the context it is used +func (m *SCConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfigs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SCConfig) contextValidateConfigs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Configs); i++ { + + if m.Configs[i] != nil { + + if swag.IsZero(m.Configs[i]) { // not required + return nil + } + + if err := m.Configs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configs" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/s_c_config_form_data.go b/client/models/s_c_config_form_data.go index de570214..e9fed390 100644 --- a/client/models/s_c_config_form_data.go +++ b/client/models/s_c_config_form_data.go @@ -6,17 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SCConfigFormData Form Data // -// Represents the Data related to Forms that is stored in a SC Configuration for a given Use Case +// # Represents the Data related to Forms that is stored in a SC Configuration for a given Use Case +// // swagger:model SCConfigFormData type SCConfigFormData map[string]map[string][]FormEntity @@ -37,6 +39,43 @@ func (m SCConfigFormData) Validate(formats strfmt.Registry) error { if err := m[k][kk][i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName(k + "." + kk + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k + "." + kk + "." + strconv.Itoa(i)) + } + return err + } + + } + + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this s c config form data based on the context it is used +func (m SCConfigFormData) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + for kk := range m[k] { + + for i := 0; i < len(m[k][kk]); i++ { + + if swag.IsZero(m[k][kk][i]) { // not required + return nil + } + + if err := m[k][kk][i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k + "." + kk + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k + "." + kk + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/s_c_config_path_config.go b/client/models/s_c_config_path_config.go index 5be4b228..658c3c43 100644 --- a/client/models/s_c_config_path_config.go +++ b/client/models/s_c_config_path_config.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SCConfigPathConfig Path Configuration // -// Represents a Configuration which holds Path and Content +// # Represents a Configuration which holds Path and Content +// // swagger:model SCConfigPathConfig type SCConfigPathConfig struct { @@ -64,6 +66,11 @@ func (m *SCConfigPathConfig) validatePath(formats strfmt.Registry) error { return nil } +// ContextValidate validates this s c config path config based on context it is used +func (m *SCConfigPathConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *SCConfigPathConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/s_c_config_path_dest_config.go b/client/models/s_c_config_path_dest_config.go index d34d77ff..f3727eab 100644 --- a/client/models/s_c_config_path_dest_config.go +++ b/client/models/s_c_config_path_dest_config.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SCConfigPathDestConfig Path and Destination Configuration // -// Represents a Configuration which holds Path, Destination and Content +// # Represents a Configuration which holds Path, Destination and Content +// // swagger:model SCConfigPathDestConfig type SCConfigPathDestConfig struct { @@ -81,6 +83,11 @@ func (m *SCConfigPathDestConfig) validatePath(formats strfmt.Registry) error { return nil } +// ContextValidate validates this s c config path dest config based on context it is used +func (m *SCConfigPathDestConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *SCConfigPathDestConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/s_c_config_pipeline_config.go b/client/models/s_c_config_pipeline_config.go index c11770bc..96152b2e 100644 --- a/client/models/s_c_config_pipeline_config.go +++ b/client/models/s_c_config_pipeline_config.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SCConfigPipelineConfig Pipeline Configuration // -// Represents the Service Catalog Configuration for a Pipeline of a given Use Case +// # Represents the Service Catalog Configuration for a Pipeline of a given Use Case +// // swagger:model SCConfigPipelineConfig type SCConfigPipelineConfig struct { @@ -56,6 +58,8 @@ func (m *SCConfigPipelineConfig) validatePipeline(formats strfmt.Registry) error if err := m.Pipeline.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("pipeline") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pipeline") } return err } @@ -74,6 +78,60 @@ func (m *SCConfigPipelineConfig) validateVariables(formats strfmt.Registry) erro if err := m.Variables.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("variables") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("variables") + } + return err + } + } + + return nil +} + +// ContextValidate validate this s c config pipeline config based on the context it is used +func (m *SCConfigPipelineConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePipeline(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVariables(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SCConfigPipelineConfig) contextValidatePipeline(ctx context.Context, formats strfmt.Registry) error { + + if m.Pipeline != nil { + + if err := m.Pipeline.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pipeline") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pipeline") + } + return err + } + } + + return nil +} + +func (m *SCConfigPipelineConfig) contextValidateVariables(ctx context.Context, formats strfmt.Registry) error { + + if m.Variables != nil { + + if err := m.Variables.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("variables") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("variables") } return err } diff --git a/client/models/s_c_config_tech_config.go b/client/models/s_c_config_tech_config.go index 56f95d83..c670078e 100644 --- a/client/models/s_c_config_tech_config.go +++ b/client/models/s_c_config_tech_config.go @@ -6,15 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" ) // SCConfigTechConfig Tech Configuration // -// Represents the Service Catalog Configuration for a Technology of a given Use Case +// # Represents the Service Catalog Configuration for a Technology of a given Use Case +// // swagger:model SCConfigTechConfig type SCConfigTechConfig map[string]SCConfigPathDestConfig @@ -29,6 +31,31 @@ func (m SCConfigTechConfig) Validate(formats strfmt.Registry) error { } if val, ok := m[k]; ok { if err := val.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this s c config tech config based on the context it is used +func (m SCConfigTechConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { return err } } diff --git a/client/models/s_c_config_use_case_config.go b/client/models/s_c_config_use_case_config.go index 382cdf77..b3b576d6 100644 --- a/client/models/s_c_config_use_case_config.go +++ b/client/models/s_c_config_use_case_config.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SCConfigUseCaseConfig Use Case Configuration // -// Represents the Service Catalog Configuration for a given Use Case +// # Represents the Service Catalog Configuration for a given Use Case +// // swagger:model SCConfigUseCaseConfig type SCConfigUseCaseConfig struct { @@ -84,16 +86,19 @@ func (m *SCConfigUseCaseConfig) Validate(formats strfmt.Registry) error { } func (m *SCConfigUseCaseConfig) validateAnsible(formats strfmt.Registry) error { - if swag.IsZero(m.Ansible) { // not required return nil } - if err := m.Ansible.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ansible") + if m.Ansible != nil { + if err := m.Ansible.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ansible") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ansible") + } + return err } - return err } return nil @@ -118,7 +123,6 @@ func (m *SCConfigUseCaseConfig) validateDescription(formats strfmt.Registry) err } func (m *SCConfigUseCaseConfig) validateForms(formats strfmt.Registry) error { - if swag.IsZero(m.Forms) { // not required return nil } @@ -127,6 +131,8 @@ func (m *SCConfigUseCaseConfig) validateForms(formats strfmt.Registry) error { if err := m.Forms.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("forms") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("forms") } return err } @@ -154,6 +160,8 @@ func (m *SCConfigUseCaseConfig) validatePipeline(formats strfmt.Registry) error if err := m.Pipeline.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("pipeline") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pipeline") } return err } @@ -163,14 +171,117 @@ func (m *SCConfigUseCaseConfig) validatePipeline(formats strfmt.Registry) error } func (m *SCConfigUseCaseConfig) validateTerraform(formats strfmt.Registry) error { + if swag.IsZero(m.Terraform) { // not required + return nil + } + + if m.Terraform != nil { + if err := m.Terraform.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("terraform") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("terraform") + } + return err + } + } + + return nil +} + +// ContextValidate validate this s c config use case config based on the context it is used +func (m *SCConfigUseCaseConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAnsible(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateForms(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePipeline(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTerraform(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SCConfigUseCaseConfig) contextValidateAnsible(ctx context.Context, formats strfmt.Registry) error { + + if swag.IsZero(m.Ansible) { // not required + return nil + } + + if err := m.Ansible.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ansible") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ansible") + } + return err + } + + return nil +} + +func (m *SCConfigUseCaseConfig) contextValidateForms(ctx context.Context, formats strfmt.Registry) error { + + if m.Forms != nil { + + if swag.IsZero(m.Forms) { // not required + return nil + } + + if err := m.Forms.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("forms") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("forms") + } + return err + } + } + + return nil +} + +func (m *SCConfigUseCaseConfig) contextValidatePipeline(ctx context.Context, formats strfmt.Registry) error { + + if m.Pipeline != nil { + + if err := m.Pipeline.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pipeline") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pipeline") + } + return err + } + } + + return nil +} + +func (m *SCConfigUseCaseConfig) contextValidateTerraform(ctx context.Context, formats strfmt.Registry) error { if swag.IsZero(m.Terraform) { // not required return nil } - if err := m.Terraform.Validate(formats); err != nil { + if err := m.Terraform.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("terraform") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("terraform") } return err } diff --git a/client/models/service_catalog.go b/client/models/service_catalog.go index 9674c587..6331aabd 100644 --- a/client/models/service_catalog.go +++ b/client/models/service_catalog.go @@ -6,19 +6,20 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // ServiceCatalog Service Catalog // -// Represents the Service Catalog item +// # Represents the Service Catalog item +// // swagger:model ServiceCatalog type ServiceCatalog struct { @@ -62,7 +63,7 @@ type ServiceCatalog struct { Image strfmt.URI `json:"image,omitempty"` // The import process status. - // Enum: [succeeded failed importing] + // Enum: ["succeeded","failed","importing"] ImportStatus string `json:"import_status,omitempty"` // keywords @@ -202,15 +203,15 @@ func (m *ServiceCatalog) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -218,12 +219,11 @@ func (m *ServiceCatalog) validateCanonical(formats strfmt.Registry) error { } func (m *ServiceCatalog) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -231,7 +231,6 @@ func (m *ServiceCatalog) validateCreatedAt(formats strfmt.Registry) error { } func (m *ServiceCatalog) validateDependencies(formats strfmt.Registry) error { - if swag.IsZero(m.Dependencies) { // not required return nil } @@ -245,6 +244,8 @@ func (m *ServiceCatalog) validateDependencies(formats strfmt.Registry) error { if err := m.Dependencies[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("dependencies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dependencies" + "." + strconv.Itoa(i)) } return err } @@ -288,7 +289,7 @@ func (m *ServiceCatalog) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -296,7 +297,6 @@ func (m *ServiceCatalog) validateID(formats strfmt.Registry) error { } func (m *ServiceCatalog) validateImage(formats strfmt.Registry) error { - if swag.IsZero(m.Image) { // not required return nil } @@ -334,14 +334,13 @@ const ( // prop value enum func (m *ServiceCatalog) validateImportStatusEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, serviceCatalogTypeImportStatusPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, serviceCatalogTypeImportStatusPropEnum, true); err != nil { return err } return nil } func (m *ServiceCatalog) validateImportStatus(formats strfmt.Registry) error { - if swag.IsZero(m.ImportStatus) { // not required return nil } @@ -391,20 +390,19 @@ func (m *ServiceCatalog) validateRef(formats strfmt.Registry) error { } func (m *ServiceCatalog) validateServiceCatalogSourceCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ServiceCatalogSourceCanonical) { // not required return nil } - if err := validate.MinLength("service_catalog_source_canonical", "body", string(m.ServiceCatalogSourceCanonical), 3); err != nil { + if err := validate.MinLength("service_catalog_source_canonical", "body", m.ServiceCatalogSourceCanonical, 3); err != nil { return err } - if err := validate.MaxLength("service_catalog_source_canonical", "body", string(m.ServiceCatalogSourceCanonical), 100); err != nil { + if err := validate.MaxLength("service_catalog_source_canonical", "body", m.ServiceCatalogSourceCanonical, 100); err != nil { return err } - if err := validate.Pattern("service_catalog_source_canonical", "body", string(m.ServiceCatalogSourceCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("service_catalog_source_canonical", "body", m.ServiceCatalogSourceCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -412,7 +410,6 @@ func (m *ServiceCatalog) validateServiceCatalogSourceCanonical(formats strfmt.Re } func (m *ServiceCatalog) validateTechnologies(formats strfmt.Registry) error { - if swag.IsZero(m.Technologies) { // not required return nil } @@ -426,6 +423,8 @@ func (m *ServiceCatalog) validateTechnologies(formats strfmt.Registry) error { if err := m.Technologies[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("technologies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("technologies" + "." + strconv.Itoa(i)) } return err } @@ -446,18 +445,85 @@ func (m *ServiceCatalog) validateTrusted(formats strfmt.Registry) error { } func (m *ServiceCatalog) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this service catalog based on the context it is used +func (m *ServiceCatalog) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDependencies(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTechnologies(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceCatalog) contextValidateDependencies(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Dependencies); i++ { + + if m.Dependencies[i] != nil { + + if swag.IsZero(m.Dependencies[i]) { // not required + return nil + } + + if err := m.Dependencies[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dependencies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dependencies" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *ServiceCatalog) contextValidateTechnologies(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Technologies); i++ { + + if m.Technologies[i] != nil { + + if swag.IsZero(m.Technologies[i]) { // not required + return nil + } + + if err := m.Technologies[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("technologies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("technologies" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *ServiceCatalog) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/service_catalog_changes.go b/client/models/service_catalog_changes.go index 40591fe7..4a3ced95 100644 --- a/client/models/service_catalog_changes.go +++ b/client/models/service_catalog_changes.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // ServiceCatalogChanges ServiceCatalogChanges // // Represents list of service catalogs changes during the refresh of a service catalog source. +// // swagger:model ServiceCatalogChanges type ServiceCatalogChanges struct { @@ -71,6 +72,8 @@ func (m *ServiceCatalogChanges) validateCreated(formats strfmt.Registry) error { if err := m.Created[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("created" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("created" + "." + strconv.Itoa(i)) } return err } @@ -96,6 +99,8 @@ func (m *ServiceCatalogChanges) validateDeleted(formats strfmt.Registry) error { if err := m.Deleted[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("deleted" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("deleted" + "." + strconv.Itoa(i)) } return err } @@ -121,6 +126,105 @@ func (m *ServiceCatalogChanges) validateUpdated(formats strfmt.Registry) error { if err := m.Updated[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("updated" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updated" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this service catalog changes based on the context it is used +func (m *ServiceCatalogChanges) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCreated(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateDeleted(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateUpdated(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceCatalogChanges) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Created); i++ { + + if m.Created[i] != nil { + + if swag.IsZero(m.Created[i]) { // not required + return nil + } + + if err := m.Created[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("created" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("created" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *ServiceCatalogChanges) contextValidateDeleted(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Deleted); i++ { + + if m.Deleted[i] != nil { + + if swag.IsZero(m.Deleted[i]) { // not required + return nil + } + + if err := m.Deleted[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("deleted" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("deleted" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *ServiceCatalogChanges) contextValidateUpdated(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Updated); i++ { + + if m.Updated[i] != nil { + + if swag.IsZero(m.Updated[i]) { // not required + return nil + } + + if err := m.Updated[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("updated" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("updated" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/service_catalog_config.go b/client/models/service_catalog_config.go index 6b51b694..aafba38e 100644 --- a/client/models/service_catalog_config.go +++ b/client/models/service_catalog_config.go @@ -6,15 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" ) // ServiceCatalogConfig Service Catalog Configuration // -// Represents a Service Catalog's Config item +// # Represents a Service Catalog's Config item +// // swagger:model ServiceCatalogConfig type ServiceCatalogConfig map[string]SCConfigUseCaseConfig @@ -29,6 +31,31 @@ func (m ServiceCatalogConfig) Validate(formats strfmt.Registry) error { } if val, ok := m[k]; ok { if err := val.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this service catalog config based on the context it is used +func (m ServiceCatalogConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { return err } } diff --git a/client/models/service_catalog_dependencies_validation_result.go b/client/models/service_catalog_dependencies_validation_result.go index 8cc43303..5f14c3ea 100644 --- a/client/models/service_catalog_dependencies_validation_result.go +++ b/client/models/service_catalog_dependencies_validation_result.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // ServiceCatalogDependenciesValidationResult ServiceCatalogValidationResult // // The result of the Service Catalog dependencies validation. If errors and warnings are empty then it means that the dependencies are respected. +// // swagger:model ServiceCatalogDependenciesValidationResult type ServiceCatalogDependenciesValidationResult struct { @@ -64,6 +66,11 @@ func (m *ServiceCatalogDependenciesValidationResult) validateWarnings(formats st return nil } +// ContextValidate validates this service catalog dependencies validation result based on context it is used +func (m *ServiceCatalogDependenciesValidationResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ServiceCatalogDependenciesValidationResult) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/service_catalog_dependency.go b/client/models/service_catalog_dependency.go index 7f905a17..845db473 100644 --- a/client/models/service_catalog_dependency.go +++ b/client/models/service_catalog_dependency.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // ServiceCatalogDependency ServiceCatalogDependency // -// Service Catalog Dependency identifies ServiceCatalog being dependency of other +// # Service Catalog Dependency identifies ServiceCatalog being dependency of other +// // swagger:model ServiceCatalogDependency type ServiceCatalogDependency struct { @@ -29,6 +31,11 @@ func (m *ServiceCatalogDependency) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validates this service catalog dependency based on context it is used +func (m *ServiceCatalogDependency) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ServiceCatalogDependency) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/service_catalog_source.go b/client/models/service_catalog_source.go index 0d52ad12..01db3598 100644 --- a/client/models/service_catalog_source.go +++ b/client/models/service_catalog_source.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // ServiceCatalogSource ServiceCatalogSource +// // swagger:model ServiceCatalogSource type ServiceCatalogSource struct { @@ -144,15 +145,15 @@ func (m *ServiceCatalogSource) validateCanonical(formats strfmt.Registry) error return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -160,7 +161,6 @@ func (m *ServiceCatalogSource) validateCanonical(formats strfmt.Registry) error } func (m *ServiceCatalogSource) validateChanges(formats strfmt.Registry) error { - if swag.IsZero(m.Changes) { // not required return nil } @@ -169,6 +169,8 @@ func (m *ServiceCatalogSource) validateChanges(formats strfmt.Registry) error { if err := m.Changes.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("changes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("changes") } return err } @@ -178,12 +180,11 @@ func (m *ServiceCatalogSource) validateChanges(formats strfmt.Registry) error { } func (m *ServiceCatalogSource) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -191,20 +192,19 @@ func (m *ServiceCatalogSource) validateCreatedAt(formats strfmt.Registry) error } func (m *ServiceCatalogSource) validateCredentialCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CredentialCanonical) { // not required return nil } - if err := validate.MinLength("credential_canonical", "body", string(m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -217,7 +217,7 @@ func (m *ServiceCatalogSource) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -243,6 +243,8 @@ func (m *ServiceCatalogSource) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -252,12 +254,11 @@ func (m *ServiceCatalogSource) validateOwner(formats strfmt.Registry) error { } func (m *ServiceCatalogSource) validateRefreshedAt(formats strfmt.Registry) error { - if swag.IsZero(m.RefreshedAt) { // not required return nil } - if err := validate.MinimumInt("refreshed_at", "body", int64(*m.RefreshedAt), 0, false); err != nil { + if err := validate.MinimumUint("refreshed_at", "body", *m.RefreshedAt, 0, false); err != nil { return err } @@ -265,7 +266,6 @@ func (m *ServiceCatalogSource) validateRefreshedAt(formats strfmt.Registry) erro } func (m *ServiceCatalogSource) validateServiceCatalogs(formats strfmt.Registry) error { - if swag.IsZero(m.ServiceCatalogs) { // not required return nil } @@ -279,6 +279,8 @@ func (m *ServiceCatalogSource) validateServiceCatalogs(formats strfmt.Registry) if err := m.ServiceCatalogs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("service_catalogs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_catalogs" + "." + strconv.Itoa(i)) } return err } @@ -295,7 +297,7 @@ func (m *ServiceCatalogSource) validateStackCount(formats strfmt.Registry) error return err } - if err := validate.MinimumInt("stack_count", "body", int64(*m.StackCount), 0, false); err != nil { + if err := validate.MinimumUint("stack_count", "body", uint64(*m.StackCount), 0, false); err != nil { return err } @@ -303,12 +305,11 @@ func (m *ServiceCatalogSource) validateStackCount(formats strfmt.Registry) error } func (m *ServiceCatalogSource) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -321,13 +322,98 @@ func (m *ServiceCatalogSource) validateURL(formats strfmt.Registry) error { return err } - if err := validate.Pattern("url", "body", string(*m.URL), `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { + if err := validate.Pattern("url", "body", *m.URL, `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { return err } return nil } +// ContextValidate validate this service catalog source based on the context it is used +func (m *ServiceCatalogSource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateChanges(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateServiceCatalogs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceCatalogSource) contextValidateChanges(ctx context.Context, formats strfmt.Registry) error { + + if m.Changes != nil { + + if swag.IsZero(m.Changes) { // not required + return nil + } + + if err := m.Changes.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("changes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("changes") + } + return err + } + } + + return nil +} + +func (m *ServiceCatalogSource) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + +func (m *ServiceCatalogSource) contextValidateServiceCatalogs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ServiceCatalogs); i++ { + + if m.ServiceCatalogs[i] != nil { + + if swag.IsZero(m.ServiceCatalogs[i]) { // not required + return nil + } + + if err := m.ServiceCatalogs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service_catalogs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_catalogs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *ServiceCatalogSource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/service_catalog_technology.go b/client/models/service_catalog_technology.go index 0b5313ac..94f3e12f 100644 --- a/client/models/service_catalog_technology.go +++ b/client/models/service_catalog_technology.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // ServiceCatalogTechnology ServiceCatalogTechnology // -// ServiceCatalogTechnology is a Technology of the Service Catalog +// # ServiceCatalogTechnology is a Technology of the Service Catalog +// // swagger:model ServiceCatalogTechnology type ServiceCatalogTechnology struct { @@ -29,6 +31,11 @@ func (m *ServiceCatalogTechnology) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validates this service catalog technology based on context it is used +func (m *ServiceCatalogTechnology) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *ServiceCatalogTechnology) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/simple_team.go b/client/models/simple_team.go index 58f5d43e..774a07ba 100644 --- a/client/models/simple_team.go +++ b/client/models/simple_team.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // SimpleTeam SimpleTeam // // The entity which represents the information of a team a bit simplified. +// // swagger:model SimpleTeam type SimpleTeam struct { @@ -93,15 +95,15 @@ func (m *SimpleTeam) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -114,7 +116,7 @@ func (m *SimpleTeam) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -127,7 +129,7 @@ func (m *SimpleTeam) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -140,7 +142,7 @@ func (m *SimpleTeam) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -148,7 +150,6 @@ func (m *SimpleTeam) validateName(formats strfmt.Registry) error { } func (m *SimpleTeam) validateOwner(formats strfmt.Registry) error { - if swag.IsZero(m.Owner) { // not required return nil } @@ -157,6 +158,8 @@ func (m *SimpleTeam) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -171,13 +174,48 @@ func (m *SimpleTeam) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this simple team based on the context it is used +func (m *SimpleTeam) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SimpleTeam) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if swag.IsZero(m.Owner) { // not required + return nil + } + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *SimpleTeam) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/state.go b/client/models/state.go index 1b5e7a78..8eaf9939 100644 --- a/client/models/state.go +++ b/client/models/state.go @@ -6,17 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // State State // -// The State of an Inventory of the Project's environment +// # The State of an Inventory of the Project's environment +// // swagger:model State type State struct { @@ -54,7 +55,6 @@ func (m *State) Validate(formats strfmt.Registry) error { } func (m *State) validateResources(formats strfmt.Registry) error { - if swag.IsZero(m.Resources) { // not required return nil } @@ -68,6 +68,47 @@ func (m *State) validateResources(formats strfmt.Registry) error { if err := m.Resources[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("resources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this state based on the context it is used +func (m *State) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateResources(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *State) contextValidateResources(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Resources); i++ { + + if m.Resources[i] != nil { + + if swag.IsZero(m.Resources[i]) { // not required + return nil + } + + if err := m.Resources[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resources" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/state_lock.go b/client/models/state_lock.go index bdba55f4..bb4e6b35 100644 --- a/client/models/state_lock.go +++ b/client/models/state_lock.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // StateLock State Lock // -// The Lock management of a State in the Inventory of the Project's environment +// # The Lock management of a State in the Inventory of the Project's environment +// // swagger:model StateLock type StateLock struct { @@ -41,6 +43,11 @@ func (m *StateLock) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validates this state lock based on context it is used +func (m *StateLock) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *StateLock) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/state_resource.go b/client/models/state_resource.go index a126e9d1..adbc2a90 100644 --- a/client/models/state_resource.go +++ b/client/models/state_resource.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // StateResource State Resource // -// The Resource of a State in the Inventory of the Project's environment +// # The Resource of a State in the Inventory of the Project's environment +// // swagger:model StateResource type StateResource struct { @@ -78,7 +79,6 @@ func (m *StateResource) Validate(formats strfmt.Registry) error { } func (m *StateResource) validateImage(formats strfmt.Registry) error { - if swag.IsZero(m.Image) { // not required return nil } @@ -91,7 +91,6 @@ func (m *StateResource) validateImage(formats strfmt.Registry) error { } func (m *StateResource) validateInstances(formats strfmt.Registry) error { - if swag.IsZero(m.Instances) { // not required return nil } @@ -105,6 +104,47 @@ func (m *StateResource) validateInstances(formats strfmt.Registry) error { if err := m.Instances[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("instances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("instances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this state resource based on the context it is used +func (m *StateResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInstances(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StateResource) contextValidateInstances(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Instances); i++ { + + if m.Instances[i] != nil { + + if swag.IsZero(m.Instances[i]) { // not required + return nil + } + + if err := m.Instances[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("instances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("instances" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/state_resource_instances.go b/client/models/state_resource_instances.go index 17236bcc..d638dfd9 100644 --- a/client/models/state_resource_instances.go +++ b/client/models/state_resource_instances.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // StateResourceInstances State Resource Instances // -// The Instances inside Resources of a State in the Inventory of the Project's environment +// # The Instances inside Resources of a State in the Inventory of the Project's environment +// // swagger:model StateResourceInstances type StateResourceInstances struct { @@ -29,6 +31,11 @@ func (m *StateResourceInstances) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validates this state resource instances based on context it is used +func (m *StateResourceInstances) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *StateResourceInstances) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/subscription.go b/client/models/subscription.go index e47dcc44..4548068e 100644 --- a/client/models/subscription.go +++ b/client/models/subscription.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -66,12 +67,11 @@ func (m *Subscription) Validate(formats strfmt.Registry) error { } func (m *Subscription) validateCurrentMembers(formats strfmt.Registry) error { - if swag.IsZero(m.CurrentMembers) { // not required return nil } - if err := validate.MinimumInt("current_members", "body", int64(*m.CurrentMembers), 0, false); err != nil { + if err := validate.MinimumUint("current_members", "body", *m.CurrentMembers, 0, false); err != nil { return err } @@ -84,7 +84,7 @@ func (m *Subscription) validateExpiresAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("expires_at", "body", int64(*m.ExpiresAt), 0, false); err != nil { + if err := validate.MinimumUint("expires_at", "body", *m.ExpiresAt, 0, false); err != nil { return err } @@ -92,12 +92,11 @@ func (m *Subscription) validateExpiresAt(formats strfmt.Registry) error { } func (m *Subscription) validateMembersCount(formats strfmt.Registry) error { - if swag.IsZero(m.MembersCount) { // not required return nil } - if err := validate.MinimumInt("members_count", "body", int64(*m.MembersCount), 0, false); err != nil { + if err := validate.MinimumUint("members_count", "body", *m.MembersCount, 0, false); err != nil { return err } @@ -114,6 +113,39 @@ func (m *Subscription) validatePlan(formats strfmt.Registry) error { if err := m.Plan.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("plan") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("plan") + } + return err + } + } + + return nil +} + +// ContextValidate validate this subscription based on the context it is used +func (m *Subscription) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePlan(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Subscription) contextValidatePlan(ctx context.Context, formats strfmt.Registry) error { + + if m.Plan != nil { + + if err := m.Plan.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("plan") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("plan") } return err } diff --git a/client/models/subscription_plan.go b/client/models/subscription_plan.go index 2c92b3c9..c0e56fbc 100644 --- a/client/models/subscription_plan.go +++ b/client/models/subscription_plan.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SubscriptionPlan SubscriptionPlan // -// It reflects the Plan used for the subscription +// # It reflects the Plan used for the subscription +// // swagger:model SubscriptionPlan type SubscriptionPlan struct { @@ -56,15 +58,15 @@ func (m *SubscriptionPlan) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -77,13 +79,18 @@ func (m *SubscriptionPlan) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } return nil } +// ContextValidate validates this subscription plan based on context it is used +func (m *SubscriptionPlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *SubscriptionPlan) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/summary.go b/client/models/summary.go index 9b80987e..404d4c47 100644 --- a/client/models/summary.go +++ b/client/models/summary.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Summary Summary of the organization +// // swagger:model Summary type Summary struct { @@ -181,6 +183,11 @@ func (m *Summary) validateUsers(formats strfmt.Registry) error { return nil } +// ContextValidate validates this summary based on context it is used +func (m *Summary) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Summary) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/swift_remote_t_f_state.go b/client/models/swift_remote_t_f_state.go index b6331f37..6048057f 100644 --- a/client/models/swift_remote_t_f_state.go +++ b/client/models/swift_remote_t_f_state.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -49,17 +49,8 @@ func (m *SwiftRemoteTFState) Engine() string { // SetEngine sets the engine of this subtype func (m *SwiftRemoteTFState) SetEngine(val string) { - } -// Container gets the container of this subtype - -// Object gets the object of this subtype - -// Region gets the region of this subtype - -// SkipVerifySsl gets the skip verify ssl of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *SwiftRemoteTFState) UnmarshalJSON(raw []byte) error { var data struct { @@ -111,11 +102,8 @@ func (m *SwiftRemoteTFState) UnmarshalJSON(raw []byte) error { } result.Container = data.Container - result.Object = data.Object - result.Region = data.Region - result.SkipVerifySsl = data.SkipVerifySsl *m = result @@ -155,8 +143,7 @@ func (m SwiftRemoteTFState) MarshalJSON() ([]byte, error) { Region: m.Region, SkipVerifySsl: m.SkipVerifySsl, - }, - ) + }) if err != nil { return nil, err } @@ -165,8 +152,7 @@ func (m SwiftRemoteTFState) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -210,6 +196,16 @@ func (m *SwiftRemoteTFState) validateRegion(formats strfmt.Registry) error { return nil } +// ContextValidate validate this swift remote t f state based on the context it is used +func (m *SwiftRemoteTFState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *SwiftRemoteTFState) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/swift_storage.go b/client/models/swift_storage.go index 4e0d0144..241692ff 100644 --- a/client/models/swift_storage.go +++ b/client/models/swift_storage.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -49,17 +49,8 @@ func (m *SwiftStorage) Engine() string { // SetEngine sets the engine of this subtype func (m *SwiftStorage) SetEngine(val string) { - } -// Container gets the container of this subtype - -// Object gets the object of this subtype - -// Region gets the region of this subtype - -// SkipVerifySsl gets the skip verify ssl of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *SwiftStorage) UnmarshalJSON(raw []byte) error { var data struct { @@ -112,11 +103,8 @@ func (m *SwiftStorage) UnmarshalJSON(raw []byte) error { } result.Container = data.Container - result.Object = data.Object - result.Region = data.Region - result.SkipVerifySsl = data.SkipVerifySsl *m = result @@ -157,8 +145,7 @@ func (m SwiftStorage) MarshalJSON() ([]byte, error) { Region: m.Region, SkipVerifySsl: m.SkipVerifySsl, - }, - ) + }) if err != nil { return nil, err } @@ -167,8 +154,7 @@ func (m SwiftStorage) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -212,6 +198,16 @@ func (m *SwiftStorage) validateRegion(formats strfmt.Registry) error { return nil } +// ContextValidate validate this swift storage based on the context it is used +func (m *SwiftStorage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *SwiftStorage) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/tag.go b/client/models/tag.go index 604cc877..961f2cdd 100644 --- a/client/models/tag.go +++ b/client/models/tag.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // Tag Key and value pair // // Key and value pair defined with the widely adopted name, tag. +// // swagger:model Tag type Tag struct { @@ -56,11 +58,11 @@ func (m *Tag) validateKey(formats strfmt.Registry) error { return err } - if err := validate.MinLength("key", "body", string(*m.Key), 1); err != nil { + if err := validate.MinLength("key", "body", *m.Key, 1); err != nil { return err } - if err := validate.MaxLength("key", "body", string(*m.Key), 254); err != nil { + if err := validate.MaxLength("key", "body", *m.Key, 254); err != nil { return err } @@ -73,17 +75,22 @@ func (m *Tag) validateValue(formats strfmt.Registry) error { return err } - if err := validate.MaxLength("value", "body", string(*m.Value), 254); err != nil { + if err := validate.MaxLength("value", "body", *m.Value, 254); err != nil { return err } - if err := validate.Pattern("value", "body", string(*m.Value), `^(?:[\w\-+=.:/@ ]*)$`); err != nil { + if err := validate.Pattern("value", "body", *m.Value, `^(?:[\w\-+=.:/@ ]*)$`); err != nil { return err } return nil } +// ContextValidate validates this tag based on context it is used +func (m *Tag) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Tag) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/task_config.go b/client/models/task_config.go index 5a541095..270c0c60 100644 --- a/client/models/task_config.go +++ b/client/models/task_config.go @@ -6,17 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // TaskConfig TaskConfig // // The configuration of a concourse task. +// // swagger:model TaskConfig type TaskConfig struct { @@ -58,7 +59,6 @@ func (m *TaskConfig) Validate(formats strfmt.Registry) error { } func (m *TaskConfig) validateInputs(formats strfmt.Registry) error { - if swag.IsZero(m.Inputs) { // not required return nil } @@ -72,6 +72,8 @@ func (m *TaskConfig) validateInputs(formats strfmt.Registry) error { if err := m.Inputs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) } return err } @@ -83,7 +85,6 @@ func (m *TaskConfig) validateInputs(formats strfmt.Registry) error { } func (m *TaskConfig) validateRun(formats strfmt.Registry) error { - if swag.IsZero(m.Run) { // not required return nil } @@ -92,6 +93,72 @@ func (m *TaskConfig) validateRun(formats strfmt.Registry) error { if err := m.Run.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("run") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("run") + } + return err + } + } + + return nil +} + +// ContextValidate validate this task config based on the context it is used +func (m *TaskConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInputs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateRun(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TaskConfig) contextValidateInputs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Inputs); i++ { + + if m.Inputs[i] != nil { + + if swag.IsZero(m.Inputs[i]) { // not required + return nil + } + + if err := m.Inputs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *TaskConfig) contextValidateRun(ctx context.Context, formats strfmt.Registry) error { + + if m.Run != nil { + + if swag.IsZero(m.Run) { // not required + return nil + } + + if err := m.Run.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("run") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("run") } return err } diff --git a/client/models/task_input_config.go b/client/models/task_input_config.go index 74d0c822..e7792ead 100644 --- a/client/models/task_input_config.go +++ b/client/models/task_input_config.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // TaskInputConfig TaskInputConfig // // The configuration of inputs for concourse tasks. +// // swagger:model TaskInputConfig type TaskInputConfig struct { @@ -50,6 +52,11 @@ func (m *TaskInputConfig) validateName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this task input config based on context it is used +func (m *TaskInputConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TaskInputConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/task_plan.go b/client/models/task_plan.go index 172bbcd5..0987e1ca 100644 --- a/client/models/task_plan.go +++ b/client/models/task_plan.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // TaskPlan TaskPlan // // The task plan. +// // swagger:model TaskPlan type TaskPlan struct { @@ -76,7 +77,6 @@ func (m *TaskPlan) Validate(formats strfmt.Registry) error { } func (m *TaskPlan) validateConfig(formats strfmt.Registry) error { - if swag.IsZero(m.Config) { // not required return nil } @@ -85,6 +85,8 @@ func (m *TaskPlan) validateConfig(formats strfmt.Registry) error { if err := m.Config.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("config") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("config") } return err } @@ -103,7 +105,6 @@ func (m *TaskPlan) validatePrivileged(formats strfmt.Registry) error { } func (m *TaskPlan) validateVersionedResourceTypes(formats strfmt.Registry) error { - if swag.IsZero(m.VersionedResourceTypes) { // not required return nil } @@ -117,6 +118,72 @@ func (m *TaskPlan) validateVersionedResourceTypes(formats strfmt.Registry) error if err := m.VersionedResourceTypes[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this task plan based on the context it is used +func (m *TaskPlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfig(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVersionedResourceTypes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TaskPlan) contextValidateConfig(ctx context.Context, formats strfmt.Registry) error { + + if m.Config != nil { + + if swag.IsZero(m.Config) { // not required + return nil + } + + if err := m.Config.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("config") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("config") + } + return err + } + } + + return nil +} + +func (m *TaskPlan) contextValidateVersionedResourceTypes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.VersionedResourceTypes); i++ { + + if m.VersionedResourceTypes[i] != nil { + + if swag.IsZero(m.VersionedResourceTypes[i]) { // not required + return nil + } + + if err := m.VersionedResourceTypes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versioned_resource_types" + "." + strconv.Itoa(i)) } return err } diff --git a/client/models/task_run_config.go b/client/models/task_run_config.go index e92552f8..5525bdc7 100644 --- a/client/models/task_run_config.go +++ b/client/models/task_run_config.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // TaskRunConfig TaskRunConfig // // The configuration of a concourse task-run. +// // swagger:model TaskRunConfig type TaskRunConfig struct { @@ -42,18 +44,22 @@ func (m *TaskRunConfig) Validate(formats strfmt.Registry) error { } func (m *TaskRunConfig) validatePath(formats strfmt.Registry) error { - if swag.IsZero(m.Path) { // not required return nil } - if err := validate.MinLength("path", "body", string(m.Path), 3); err != nil { + if err := validate.MinLength("path", "body", m.Path, 3); err != nil { return err } return nil } +// ContextValidate validates this task run config based on context it is used +func (m *TaskRunConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TaskRunConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/team.go b/client/models/team.go index 668c2ca8..1d94efb9 100644 --- a/client/models/team.go +++ b/client/models/team.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // Team Team // // The entity which represents the information of a team. +// // swagger:model Team type Team struct { @@ -121,15 +122,15 @@ func (m *Team) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -142,7 +143,7 @@ func (m *Team) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -155,7 +156,7 @@ func (m *Team) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -192,6 +193,8 @@ func (m *Team) validateMembersPreview(formats strfmt.Registry) error { if err := m.MembersPreview[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("members_preview" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("members_preview" + "." + strconv.Itoa(i)) } return err } @@ -208,7 +211,7 @@ func (m *Team) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -216,7 +219,6 @@ func (m *Team) validateName(formats strfmt.Registry) error { } func (m *Team) validateOwner(formats strfmt.Registry) error { - if swag.IsZero(m.Owner) { // not required return nil } @@ -225,6 +227,8 @@ func (m *Team) validateOwner(formats strfmt.Registry) error { if err := m.Owner.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") } return err } @@ -254,6 +258,8 @@ func (m *Team) validateRoles(formats strfmt.Registry) error { if err := m.Roles[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("roles" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("roles" + "." + strconv.Itoa(i)) } return err } @@ -270,13 +276,106 @@ func (m *Team) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this team based on the context it is used +func (m *Team) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateMembersPreview(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateRoles(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Team) contextValidateMembersPreview(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.MembersPreview); i++ { + + if m.MembersPreview[i] != nil { + + if swag.IsZero(m.MembersPreview[i]) { // not required + return nil + } + + if err := m.MembersPreview[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("members_preview" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("members_preview" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Team) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + + if swag.IsZero(m.Owner) { // not required + return nil + } + + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + +func (m *Team) contextValidateRoles(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Roles); i++ { + + if m.Roles[i] != nil { + + if swag.IsZero(m.Roles[i]) { // not required + return nil + } + + if err := m.Roles[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("roles" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("roles" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *Team) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_h_c_l_config.go b/client/models/terraform_h_c_l_config.go index c4ae06d1..3c172667 100644 --- a/client/models/terraform_h_c_l_config.go +++ b/client/models/terraform_h_c_l_config.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // TerraformHCLConfig TerraformHCLConfig // -// The HCL config for Terraform +// # The HCL config for Terraform +// // swagger:model TerraformHCLConfig type TerraformHCLConfig struct { @@ -47,6 +49,11 @@ func (m *TerraformHCLConfig) validateConfig(formats strfmt.Registry) error { return nil } +// ContextValidate validates this terraform h c l config based on context it is used +func (m *TerraformHCLConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TerraformHCLConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_image.go b/client/models/terraform_image.go index a56f3e17..084d578e 100644 --- a/client/models/terraform_image.go +++ b/client/models/terraform_image.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // TerraformImage TerraformImage // -// The Image from the TF structure +// # The Image from the TF structure +// // swagger:model TerraformImage type TerraformImage struct { @@ -45,8 +47,11 @@ func (m *TerraformImage) validateImage(formats strfmt.Registry) error { return err } - // Format "byte" (base64 string) is already validated when unmarshalled + return nil +} +// ContextValidate validates this terraform image based on context it is used +func (m *TerraformImage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } diff --git a/client/models/terraform_json_config.go b/client/models/terraform_json_config.go index f6255af8..1bcc2fb4 100644 --- a/client/models/terraform_json_config.go +++ b/client/models/terraform_json_config.go @@ -6,16 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" ) // TerraformJSONConfig TerraformJSONConfig // -// The JSON config for Terraform +// # The JSON config for Terraform +// // swagger:model TerraformJSONConfig type TerraformJSONConfig struct { @@ -40,13 +41,18 @@ func (m *TerraformJSONConfig) Validate(formats strfmt.Registry) error { func (m *TerraformJSONConfig) validateConfig(formats strfmt.Registry) error { - if err := validate.Required("config", "body", m.Config); err != nil { - return err + if m.Config == nil { + return errors.Required("config", "body", nil) } return nil } +// ContextValidate validates this terraform JSON config based on context it is used +func (m *TerraformJSONConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TerraformJSONConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_json_diagram.go b/client/models/terraform_json_diagram.go index 050bc6dd..9a83266b 100644 --- a/client/models/terraform_json_diagram.go +++ b/client/models/terraform_json_diagram.go @@ -7,6 +7,7 @@ package models // TerraformJSONDiagram TerraformDiagram // -// The JSON Diagram structure +// # The JSON Diagram structure +// // swagger:model TerraformJSONDiagram type TerraformJSONDiagram interface{} diff --git a/client/models/terraform_plan_input.go b/client/models/terraform_plan_input.go index 59274793..4c7ac0a5 100644 --- a/client/models/terraform_plan_input.go +++ b/client/models/terraform_plan_input.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // TerraformPlanInput TerraformPlanInput // // Input for endpoints that require a Terraform plan. +// // swagger:model TerraformPlanInput type TerraformPlanInput struct { @@ -47,6 +49,11 @@ func (m *TerraformPlanInput) validateTfplan(formats strfmt.Registry) error { return nil } +// ContextValidate validates this terraform plan input based on context it is used +func (m *TerraformPlanInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TerraformPlanInput) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_provider.go b/client/models/terraform_provider.go index 96a22ae8..a925b97c 100644 --- a/client/models/terraform_provider.go +++ b/client/models/terraform_provider.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // TerraformProvider Provider // -// Provider of infrastructure +// # Provider of infrastructure +// // swagger:model TerraformProvider type TerraformProvider struct { @@ -87,11 +89,11 @@ func (m *TerraformProvider) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -118,13 +120,18 @@ func (m *TerraformProvider) validateName(formats strfmt.Registry) error { func (m *TerraformProvider) validateSchema(formats strfmt.Registry) error { - if err := validate.Required("schema", "body", m.Schema); err != nil { - return err + if m.Schema == nil { + return errors.Required("schema", "body", nil) } return nil } +// ContextValidate validates this terraform provider based on context it is used +func (m *TerraformProvider) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TerraformProvider) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_provider_resource.go b/client/models/terraform_provider_resource.go index c57fd361..dac448e7 100644 --- a/client/models/terraform_provider_resource.go +++ b/client/models/terraform_provider_resource.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // TerraformProviderResource Resource // -// A Resource of a Provider +// # A Resource of a Provider +// // swagger:model TerraformProviderResource type TerraformProviderResource struct { @@ -122,6 +124,8 @@ func (m *TerraformProviderResource) validateAttributes(formats strfmt.Registry) if err := m.Attributes.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("attributes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("attributes") } return err } @@ -136,11 +140,11 @@ func (m *TerraformProviderResource) validateCanonical(formats strfmt.Registry) e return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -166,7 +170,6 @@ func (m *TerraformProviderResource) validateDescription(formats strfmt.Registry) } func (m *TerraformProviderResource) validateImage(formats strfmt.Registry) error { - if swag.IsZero(m.Image) { // not required return nil } @@ -207,8 +210,8 @@ func (m *TerraformProviderResource) validateKeywords(formats strfmt.Registry) er func (m *TerraformProviderResource) validateSchema(formats strfmt.Registry) error { - if err := validate.Required("schema", "body", m.Schema); err != nil { - return err + if m.Schema == nil { + return errors.Required("schema", "body", nil) } return nil @@ -223,6 +226,37 @@ func (m *TerraformProviderResource) validateShortDescription(formats strfmt.Regi return nil } +// ContextValidate validate this terraform provider resource based on the context it is used +func (m *TerraformProviderResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAttributes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerraformProviderResource) contextValidateAttributes(ctx context.Context, formats strfmt.Registry) error { + + if m.Attributes != nil { + + if err := m.Attributes.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("attributes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("attributes") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *TerraformProviderResource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_provider_resource_attributes.go b/client/models/terraform_provider_resource_attributes.go index dd46028d..cefe9d2f 100644 --- a/client/models/terraform_provider_resource_attributes.go +++ b/client/models/terraform_provider_resource_attributes.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // TerraformProviderResourceAttributes ResourceAttributes // -// Holds specific logic of some attributes +// # Holds specific logic of some attributes +// // swagger:model TerraformProviderResourceAttributes type TerraformProviderResourceAttributes struct { @@ -32,6 +34,11 @@ func (m *TerraformProviderResourceAttributes) Validate(formats strfmt.Registry) return nil } +// ContextValidate validates this terraform provider resource attributes based on context it is used +func (m *TerraformProviderResourceAttributes) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TerraformProviderResourceAttributes) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_provider_resource_simple.go b/client/models/terraform_provider_resource_simple.go index 742fc641..4a100315 100644 --- a/client/models/terraform_provider_resource_simple.go +++ b/client/models/terraform_provider_resource_simple.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // TerraformProviderResourceSimple ResourceSimple // -// A Resource of a Provider without the config +// # A Resource of a Provider without the config +// // swagger:model TerraformProviderResourceSimple type TerraformProviderResourceSimple struct { @@ -114,6 +116,8 @@ func (m *TerraformProviderResourceSimple) validateAttributes(formats strfmt.Regi if err := m.Attributes.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("attributes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("attributes") } return err } @@ -128,11 +132,11 @@ func (m *TerraformProviderResourceSimple) validateCanonical(formats strfmt.Regis return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -158,7 +162,6 @@ func (m *TerraformProviderResourceSimple) validateDescription(formats strfmt.Reg } func (m *TerraformProviderResourceSimple) validateImage(formats strfmt.Registry) error { - if swag.IsZero(m.Image) { // not required return nil } @@ -206,6 +209,37 @@ func (m *TerraformProviderResourceSimple) validateShortDescription(formats strfm return nil } +// ContextValidate validate this terraform provider resource simple based on the context it is used +func (m *TerraformProviderResourceSimple) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAttributes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerraformProviderResourceSimple) contextValidateAttributes(ctx context.Context, formats strfmt.Registry) error { + + if m.Attributes != nil { + + if err := m.Attributes.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("attributes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("attributes") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *TerraformProviderResourceSimple) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_provider_simple.go b/client/models/terraform_provider_simple.go index f3af6ba6..854b8cf5 100644 --- a/client/models/terraform_provider_simple.go +++ b/client/models/terraform_provider_simple.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // TerraformProviderSimple TerraformProviderSimple // -// Provider of infrastructure without the config +// # Provider of infrastructure without the config +// // swagger:model TerraformProviderSimple type TerraformProviderSimple struct { @@ -79,11 +81,11 @@ func (m *TerraformProviderSimple) validateCanonical(formats strfmt.Registry) err return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -108,6 +110,11 @@ func (m *TerraformProviderSimple) validateName(formats strfmt.Registry) error { return nil } +// ContextValidate validates this terraform provider simple based on context it is used +func (m *TerraformProviderSimple) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TerraformProviderSimple) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/terraform_validation_result.go b/client/models/terraform_validation_result.go index b79ea9f5..7a0a4b10 100644 --- a/client/models/terraform_validation_result.go +++ b/client/models/terraform_validation_result.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // TerraformValidationResult TerraformValidationResult // -// The result of the validation, if errors is empty means that is correct +// # The result of the validation, if errors is empty means that is correct +// // swagger:model TerraformValidationResult type TerraformValidationResult struct { @@ -47,6 +49,11 @@ func (m *TerraformValidationResult) validateErrors(formats strfmt.Registry) erro return nil } +// ContextValidate validates this terraform validation result based on context it is used +func (m *TerraformValidationResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TerraformValidationResult) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/timeout_plan.go b/client/models/timeout_plan.go index 7f8ac44a..1039483f 100644 --- a/client/models/timeout_plan.go +++ b/client/models/timeout_plan.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // TimeoutPlan EnsurePlan // // The plan to ensure to be run. +// // swagger:model TimeoutPlan type TimeoutPlan struct { @@ -56,6 +58,8 @@ func (m *TimeoutPlan) validateNext(formats strfmt.Registry) error { if err := m.Next.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") } return err } @@ -74,6 +78,60 @@ func (m *TimeoutPlan) validateStep(formats strfmt.Registry) error { if err := m.Step.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") + } + return err + } + } + + return nil +} + +// ContextValidate validate this timeout plan based on the context it is used +func (m *TimeoutPlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNext(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStep(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TimeoutPlan) contextValidateNext(ctx context.Context, formats strfmt.Registry) error { + + if m.Next != nil { + + if err := m.Next.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") + } + return err + } + } + + return nil +} + +func (m *TimeoutPlan) contextValidateStep(ctx context.Context, formats strfmt.Registry) error { + + if m.Step != nil { + + if err := m.Step.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") } return err } diff --git a/client/models/try_plan.go b/client/models/try_plan.go index 130c6115..5f3fade9 100644 --- a/client/models/try_plan.go +++ b/client/models/try_plan.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // TryPlan EnsurePlan // // The plan to ensure to be run. +// // swagger:model TryPlan type TryPlan struct { @@ -56,6 +58,8 @@ func (m *TryPlan) validateNext(formats strfmt.Registry) error { if err := m.Next.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") } return err } @@ -74,6 +78,60 @@ func (m *TryPlan) validateStep(formats strfmt.Registry) error { if err := m.Step.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") + } + return err + } + } + + return nil +} + +// ContextValidate validate this try plan based on the context it is used +func (m *TryPlan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNext(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStep(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TryPlan) contextValidateNext(ctx context.Context, formats strfmt.Registry) error { + + if m.Next != nil { + + if err := m.Next.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("next") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("next") + } + return err + } + } + + return nil +} + +func (m *TryPlan) contextValidateStep(ctx context.Context, formats strfmt.Registry) error { + + if m.Step != nil { + + if err := m.Step.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("step") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("step") } return err } diff --git a/client/models/update_api_key.go b/client/models/update_api_key.go index 5189c268..822c2c51 100644 --- a/client/models/update_api_key.go +++ b/client/models/update_api_key.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -56,13 +57,18 @@ func (m *UpdateAPIKey) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } return nil } +// ContextValidate validates this update API key based on context it is used +func (m *UpdateAPIKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateAPIKey) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_cloud_cost_management_account.go b/client/models/update_cloud_cost_management_account.go index 521ae276..9040fce7 100644 --- a/client/models/update_cloud_cost_management_account.go +++ b/client/models/update_cloud_cost_management_account.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // UpdateCloudCostManagementAccount Update CloudCostManagementAccount // // Update a Cloud Cost Management account to connect CP. +// // swagger:model UpdateCloudCostManagementAccount type UpdateCloudCostManagementAccount struct { @@ -68,6 +70,39 @@ func (m *UpdateCloudCostManagementAccount) validateExternalBackend(formats strfm if err := m.ExternalBackend.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("external_backend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backend") + } + return err + } + } + + return nil +} + +// ContextValidate validate this update cloud cost management account based on the context it is used +func (m *UpdateCloudCostManagementAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateExternalBackend(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateCloudCostManagementAccount) contextValidateExternalBackend(ctx context.Context, formats strfmt.Registry) error { + + if m.ExternalBackend != nil { + + if err := m.ExternalBackend.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("external_backend") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("external_backend") } return err } diff --git a/client/models/update_cloud_cost_management_linked_account.go b/client/models/update_cloud_cost_management_linked_account.go index cb9171a2..ee235166 100644 --- a/client/models/update_cloud_cost_management_linked_account.go +++ b/client/models/update_cloud_cost_management_linked_account.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -48,6 +49,11 @@ func (m *UpdateCloudCostManagementLinkedAccount) validateName(formats strfmt.Reg return nil } +// ContextValidate validates this update cloud cost management linked account based on context it is used +func (m *UpdateCloudCostManagementLinkedAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateCloudCostManagementLinkedAccount) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_cloud_cost_management_tag_mapping.go b/client/models/update_cloud_cost_management_tag_mapping.go index aef28c93..98728288 100644 --- a/client/models/update_cloud_cost_management_tag_mapping.go +++ b/client/models/update_cloud_cost_management_tag_mapping.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // UpdateCloudCostManagementTagMapping Create or Update CloudCostManagementTagMapping // -// Create or Update a Cloud Cost Management tag mapping for projects and environments +// # Create or Update a Cloud Cost Management tag mapping for projects and environments +// // swagger:model UpdateCloudCostManagementTagMapping type UpdateCloudCostManagementTagMapping struct { @@ -35,6 +37,11 @@ func (m *UpdateCloudCostManagementTagMapping) Validate(formats strfmt.Registry) return nil } +// ContextValidate validates this update cloud cost management tag mapping based on context it is used +func (m *UpdateCloudCostManagementTagMapping) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateCloudCostManagementTagMapping) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_config_repository.go b/client/models/update_config_repository.go index a4009c15..47c294b5 100644 --- a/client/models/update_config_repository.go +++ b/client/models/update_config_repository.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // UpdateConfigRepository UpdateConfigRepository +// // swagger:model UpdateConfigRepository type UpdateConfigRepository struct { @@ -87,15 +89,15 @@ func (m *UpdateConfigRepository) validateCredentialCanonical(formats strfmt.Regi return err } - if err := validate.MinLength("credential_canonical", "body", string(*m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", *m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(*m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", *m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(*m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", *m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -126,13 +128,18 @@ func (m *UpdateConfigRepository) validateURL(formats strfmt.Registry) error { return err } - if err := validate.Pattern("url", "body", string(*m.URL), `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { + if err := validate.Pattern("url", "body", *m.URL, `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { return err } return nil } +// ContextValidate validates this update config repository based on context it is used +func (m *UpdateConfigRepository) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateConfigRepository) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_credential.go b/client/models/update_credential.go index 9cab35c6..eed12db5 100644 --- a/client/models/update_credential.go +++ b/client/models/update_credential.go @@ -6,18 +6,19 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // UpdateCredential Credential // -// Represents the Credential +// # Represents the Credential +// // swagger:model UpdateCredential type UpdateCredential struct { @@ -51,7 +52,7 @@ type UpdateCredential struct { // type // Required: true - // Enum: [ssh aws custom azure azure_storage gcp basic_auth elasticsearch vmware] + // Enum: ["ssh","aws","custom","azure","azure_storage","gcp","basic_auth","elasticsearch","vmware"] Type *string `json:"type"` } @@ -91,15 +92,15 @@ func (m *UpdateCredential) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -121,7 +122,7 @@ func (m *UpdateCredential) validatePath(formats strfmt.Registry) error { return err } - if err := validate.Pattern("path", "body", string(*m.Path), `[a-zA-z0-9_\-./]`); err != nil { + if err := validate.Pattern("path", "body", *m.Path, `[a-zA-z0-9_\-./]`); err != nil { return err } @@ -138,6 +139,8 @@ func (m *UpdateCredential) validateRaw(formats strfmt.Registry) error { if err := m.Raw.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("raw") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("raw") } return err } @@ -190,7 +193,7 @@ const ( // prop value enum func (m *UpdateCredential) validateTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, updateCredentialTypeTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, updateCredentialTypeTypePropEnum, true); err != nil { return err } return nil @@ -210,6 +213,37 @@ func (m *UpdateCredential) validateType(formats strfmt.Registry) error { return nil } +// ContextValidate validate this update credential based on the context it is used +func (m *UpdateCredential) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRaw(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateCredential) contextValidateRaw(ctx context.Context, formats strfmt.Registry) error { + + if m.Raw != nil { + + if err := m.Raw.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("raw") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("raw") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *UpdateCredential) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_external_backend.go b/client/models/update_external_backend.go index e88a20c4..9a2d3cda 100644 --- a/client/models/update_external_backend.go +++ b/client/models/update_external_backend.go @@ -7,13 +7,13 @@ package models import ( "bytes" + "context" "encoding/json" "io" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -21,6 +21,7 @@ import ( // UpdateExternalBackend Update External backend // // An external backend contains the configuration needed in order to be plugged into the Cycloid system. A backend is a general purpose concept, but Cycloid specifies which ones are supported and the list of those which are supported for every concrete feature. +// // swagger:model UpdateExternalBackend type UpdateExternalBackend struct { configurationField ExternalBackendConfiguration @@ -53,7 +54,7 @@ type UpdateExternalBackend struct { // purpose // Required: true - // Enum: [events logs remote_tfstate cost_explorer] + // Enum: ["events","logs","remote_tfstate","cost_explorer"] Purpose *string `json:"purpose"` } @@ -154,8 +155,7 @@ func (m UpdateExternalBackend) MarshalJSON() ([]byte, error) { ProjectCanonical: m.ProjectCanonical, Purpose: m.Purpose, - }, - ) + }) if err != nil { return nil, err } @@ -164,8 +164,7 @@ func (m UpdateExternalBackend) MarshalJSON() ([]byte, error) { }{ Configuration: m.configurationField, - }, - ) + }) if err != nil { return nil, err } @@ -216,6 +215,8 @@ func (m *UpdateExternalBackend) validateConfiguration(formats strfmt.Registry) e if err := m.Configuration().Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") } return err } @@ -224,20 +225,19 @@ func (m *UpdateExternalBackend) validateConfiguration(formats strfmt.Registry) e } func (m *UpdateExternalBackend) validateCredentialCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CredentialCanonical) { // not required return nil } - if err := validate.MinLength("credential_canonical", "body", string(m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -245,20 +245,19 @@ func (m *UpdateExternalBackend) validateCredentialCanonical(formats strfmt.Regis } func (m *UpdateExternalBackend) validateEnvironmentCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.EnvironmentCanonical) { // not required return nil } - if err := validate.MinLength("environment_canonical", "body", string(m.EnvironmentCanonical), 1); err != nil { + if err := validate.MinLength("environment_canonical", "body", m.EnvironmentCanonical, 1); err != nil { return err } - if err := validate.MaxLength("environment_canonical", "body", string(m.EnvironmentCanonical), 100); err != nil { + if err := validate.MaxLength("environment_canonical", "body", m.EnvironmentCanonical, 100); err != nil { return err } - if err := validate.Pattern("environment_canonical", "body", string(m.EnvironmentCanonical), `^[\da-zA-Z]+(?:(?:[\da-zA-Z\-._]+)?[\da-zA-Z])?$`); err != nil { + if err := validate.Pattern("environment_canonical", "body", m.EnvironmentCanonical, `^[\da-zA-Z]+(?:(?:[\da-zA-Z\-._]+)?[\da-zA-Z])?$`); err != nil { return err } @@ -266,12 +265,11 @@ func (m *UpdateExternalBackend) validateEnvironmentCanonical(formats strfmt.Regi } func (m *UpdateExternalBackend) validateID(formats strfmt.Registry) error { - if swag.IsZero(m.ID) { // not required return nil } - if err := validate.MinimumInt("id", "body", int64(m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(m.ID), 1, false); err != nil { return err } @@ -279,20 +277,19 @@ func (m *UpdateExternalBackend) validateID(formats strfmt.Registry) error { } func (m *UpdateExternalBackend) validateProjectCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ProjectCanonical) { // not required return nil } - if err := validate.MinLength("project_canonical", "body", string(m.ProjectCanonical), 1); err != nil { + if err := validate.MinLength("project_canonical", "body", m.ProjectCanonical, 1); err != nil { return err } - if err := validate.MaxLength("project_canonical", "body", string(m.ProjectCanonical), 100); err != nil { + if err := validate.MaxLength("project_canonical", "body", m.ProjectCanonical, 100); err != nil { return err } - if err := validate.Pattern("project_canonical", "body", string(m.ProjectCanonical), `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { + if err := validate.Pattern("project_canonical", "body", m.ProjectCanonical, `(^[a-z0-9]+(([a-z0-9\-_]+)?[a-z0-9]+)?$)`); err != nil { return err } @@ -328,7 +325,7 @@ const ( // prop value enum func (m *UpdateExternalBackend) validatePurposeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, updateExternalBackendTypePurposePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, updateExternalBackendTypePurposePropEnum, true); err != nil { return err } return nil @@ -348,6 +345,34 @@ func (m *UpdateExternalBackend) validatePurpose(formats strfmt.Registry) error { return nil } +// ContextValidate validate this update external backend based on the context it is used +func (m *UpdateExternalBackend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfiguration(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateExternalBackend) contextValidateConfiguration(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Configuration().ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configuration") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configuration") + } + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *UpdateExternalBackend) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_infra_policy.go b/client/models/update_infra_policy.go index 420b09cc..a32a76ec 100644 --- a/client/models/update_infra_policy.go +++ b/client/models/update_infra_policy.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // UpdateInfraPolicy Update InfraPolicy // // Update a policy to control operations across infrastructure. +// // swagger:model UpdateInfraPolicy type UpdateInfraPolicy struct { @@ -49,7 +50,7 @@ type UpdateInfraPolicy struct { // severity // Required: true - // Enum: [critical warning advisory] + // Enum: ["critical","warning","advisory"] Severity *string `json:"severity"` } @@ -120,7 +121,7 @@ func (m *UpdateInfraPolicy) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -133,7 +134,7 @@ func (m *UpdateInfraPolicy) validateOwner(formats strfmt.Registry) error { return err } - if err := validate.MaxLength("owner", "body", string(*m.Owner), 100); err != nil { + if err := validate.MaxLength("owner", "body", *m.Owner, 100); err != nil { return err } @@ -166,7 +167,7 @@ const ( // prop value enum func (m *UpdateInfraPolicy) validateSeverityEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, updateInfraPolicyTypeSeverityPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, updateInfraPolicyTypeSeverityPropEnum, true); err != nil { return err } return nil @@ -186,6 +187,11 @@ func (m *UpdateInfraPolicy) validateSeverity(formats strfmt.Registry) error { return nil } +// ContextValidate validates this update infra policy based on context it is used +func (m *UpdateInfraPolicy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateInfraPolicy) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_organization.go b/client/models/update_organization.go index eeeb05a8..2065140d 100644 --- a/client/models/update_organization.go +++ b/client/models/update_organization.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // UpdateOrganization Update Organization // // The entity which represents the information of an organization to be updated. +// // swagger:model UpdateOrganization type UpdateOrganization struct { @@ -54,13 +56,18 @@ func (m *UpdateOrganization) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } return nil } +// ContextValidate validates this update organization based on context it is used +func (m *UpdateOrganization) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateOrganization) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_pipeline.go b/client/models/update_pipeline.go index 9c6dc645..075c81d7 100644 --- a/client/models/update_pipeline.go +++ b/client/models/update_pipeline.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // UpdatePipeline Update Pipeline // // The entity which represents a new pipeline config to update in the application. +// // swagger:model UpdatePipeline type UpdatePipeline struct { @@ -53,6 +55,11 @@ func (m *UpdatePipeline) validatePassedConfig(formats strfmt.Registry) error { return nil } +// ContextValidate validates this update pipeline based on context it is used +func (m *UpdatePipeline) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdatePipeline) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_project.go b/client/models/update_project.go index c2d81251..9677641e 100644 --- a/client/models/update_project.go +++ b/client/models/update_project.go @@ -6,12 +6,12 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -19,13 +19,14 @@ import ( // UpdateProject Update Project // // The entity which represents the information of the project to be updated. +// // swagger:model UpdateProject type UpdateProject struct { // The cloud provider canonical that this project is using - between the // supported ones. // - // Enum: [aws google azurerm flexibleengine openstack] + // Enum: ["aws","google","azurerm","flexibleengine","openstack"] CloudProvider string `json:"cloud_provider,omitempty"` // The config_repository_canonical points to new Config Repository the project @@ -154,14 +155,13 @@ const ( // prop value enum func (m *UpdateProject) validateCloudProviderEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, updateProjectTypeCloudProviderPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, updateProjectTypeCloudProviderPropEnum, true); err != nil { return err } return nil } func (m *UpdateProject) validateCloudProvider(formats strfmt.Registry) error { - if swag.IsZero(m.CloudProvider) { // not required return nil } @@ -175,20 +175,19 @@ func (m *UpdateProject) validateCloudProvider(formats strfmt.Registry) error { } func (m *UpdateProject) validateConfigRepositoryCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.ConfigRepositoryCanonical) { // not required return nil } - if err := validate.MinLength("config_repository_canonical", "body", string(m.ConfigRepositoryCanonical), 3); err != nil { + if err := validate.MinLength("config_repository_canonical", "body", m.ConfigRepositoryCanonical, 3); err != nil { return err } - if err := validate.MaxLength("config_repository_canonical", "body", string(m.ConfigRepositoryCanonical), 100); err != nil { + if err := validate.MaxLength("config_repository_canonical", "body", m.ConfigRepositoryCanonical, 100); err != nil { return err } - if err := validate.Pattern("config_repository_canonical", "body", string(m.ConfigRepositoryCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("config_repository_canonical", "body", m.ConfigRepositoryCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -196,7 +195,6 @@ func (m *UpdateProject) validateConfigRepositoryCanonical(formats strfmt.Registr } func (m *UpdateProject) validateEnvironments(formats strfmt.Registry) error { - if swag.IsZero(m.Environments) { // not required return nil } @@ -216,6 +214,8 @@ func (m *UpdateProject) validateEnvironments(formats strfmt.Registry) error { if err := m.Environments[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("environments" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environments" + "." + strconv.Itoa(i)) } return err } @@ -227,7 +227,6 @@ func (m *UpdateProject) validateEnvironments(formats strfmt.Registry) error { } func (m *UpdateProject) validateInputs(formats strfmt.Registry) error { - if swag.IsZero(m.Inputs) { // not required return nil } @@ -241,6 +240,8 @@ func (m *UpdateProject) validateInputs(formats strfmt.Registry) error { if err := m.Inputs[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) } return err } @@ -257,7 +258,7 @@ func (m *UpdateProject) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { return err } @@ -270,7 +271,7 @@ func (m *UpdateProject) validateServiceCatalogRef(formats strfmt.Registry) error return err } - if err := validate.Pattern("service_catalog_ref", "body", string(*m.ServiceCatalogRef), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+:[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("service_catalog_ref", "body", *m.ServiceCatalogRef, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+:[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -283,13 +284,81 @@ func (m *UpdateProject) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } return nil } +// ContextValidate validate this update project based on the context it is used +func (m *UpdateProject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEnvironments(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateInputs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateProject) contextValidateEnvironments(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Environments); i++ { + + if m.Environments[i] != nil { + + if swag.IsZero(m.Environments[i]) { // not required + return nil + } + + if err := m.Environments[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environments" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environments" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *UpdateProject) contextValidateInputs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Inputs); i++ { + + if m.Inputs[i] != nil { + + if swag.IsZero(m.Inputs[i]) { // not required + return nil + } + + if err := m.Inputs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("inputs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("inputs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *UpdateProject) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_quota.go b/client/models/update_quota.go index 5d8cb462..191de7db 100644 --- a/client/models/update_quota.go +++ b/client/models/update_quota.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // UpdateQuota Update Quota // -// The Quota defines the basic needs to update a create +// # The Quota defines the basic needs to update a create +// // swagger:model UpdateQuota type UpdateQuota struct { @@ -63,7 +65,7 @@ func (m *UpdateQuota) validateCPU(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("cpu", "body", int64(*m.CPU), 0, false); err != nil { + if err := validate.MinimumUint("cpu", "body", *m.CPU, 0, false); err != nil { return err } @@ -76,7 +78,7 @@ func (m *UpdateQuota) validateMemory(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { + if err := validate.MinimumUint("memory", "body", *m.Memory, 0, false); err != nil { return err } @@ -89,13 +91,18 @@ func (m *UpdateQuota) validateStorage(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("storage", "body", int64(*m.Storage), 0, false); err != nil { + if err := validate.MinimumUint("storage", "body", *m.Storage, 0, false); err != nil { return err } return nil } +// ContextValidate validates this update quota based on context it is used +func (m *UpdateQuota) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateQuota) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_service_catalog_source.go b/client/models/update_service_catalog_source.go index 1b17cf30..938f13f8 100644 --- a/client/models/update_service_catalog_source.go +++ b/client/models/update_service_catalog_source.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // UpdateServiceCatalogSource UpdateServiceCatalogSource +// // swagger:model UpdateServiceCatalogSource type UpdateServiceCatalogSource struct { @@ -65,20 +67,19 @@ func (m *UpdateServiceCatalogSource) Validate(formats strfmt.Registry) error { } func (m *UpdateServiceCatalogSource) validateCredentialCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.CredentialCanonical) { // not required return nil } - if err := validate.MinLength("credential_canonical", "body", string(m.CredentialCanonical), 3); err != nil { + if err := validate.MinLength("credential_canonical", "body", m.CredentialCanonical, 3); err != nil { return err } - if err := validate.MaxLength("credential_canonical", "body", string(m.CredentialCanonical), 100); err != nil { + if err := validate.MaxLength("credential_canonical", "body", m.CredentialCanonical, 100); err != nil { return err } - if err := validate.Pattern("credential_canonical", "body", string(m.CredentialCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("credential_canonical", "body", m.CredentialCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -100,13 +101,18 @@ func (m *UpdateServiceCatalogSource) validateURL(formats strfmt.Registry) error return err } - if err := validate.Pattern("url", "body", string(*m.URL), `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { + if err := validate.Pattern("url", "body", *m.URL, `^((/|~)[^/]*)+.(\.git)|(([\w\]+@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(/)?`); err != nil { return err } return nil } +// ContextValidate validates this update service catalog source based on context it is used +func (m *UpdateServiceCatalogSource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateServiceCatalogSource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_team.go b/client/models/update_team.go index 7c0c5ff6..7427457d 100644 --- a/client/models/update_team.go +++ b/client/models/update_team.go @@ -6,11 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -18,6 +18,7 @@ import ( // UpdateTeam Update Team // // The entity which represents the information of the team to be updated. +// // swagger:model UpdateTeam type UpdateTeam struct { @@ -72,15 +73,15 @@ func (m *UpdateTeam) validateCanonical(formats strfmt.Registry) error { return err } - if err := validate.MinLength("canonical", "body", string(*m.Canonical), 3); err != nil { + if err := validate.MinLength("canonical", "body", *m.Canonical, 3); err != nil { return err } - if err := validate.MaxLength("canonical", "body", string(*m.Canonical), 100); err != nil { + if err := validate.MaxLength("canonical", "body", *m.Canonical, 100); err != nil { return err } - if err := validate.Pattern("canonical", "body", string(*m.Canonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("canonical", "body", *m.Canonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -93,7 +94,7 @@ func (m *UpdateTeam) validateName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("name", "body", string(*m.Name), 3); err != nil { + if err := validate.MinLength("name", "body", *m.Name, 3); err != nil { return err } @@ -108,15 +109,15 @@ func (m *UpdateTeam) validateRolesCanonical(formats strfmt.Registry) error { for i := 0; i < len(m.RolesCanonical); i++ { - if err := validate.MinLength("roles_canonical"+"."+strconv.Itoa(i), "body", string(m.RolesCanonical[i]), 3); err != nil { + if err := validate.MinLength("roles_canonical"+"."+strconv.Itoa(i), "body", m.RolesCanonical[i], 3); err != nil { return err } - if err := validate.MaxLength("roles_canonical"+"."+strconv.Itoa(i), "body", string(m.RolesCanonical[i]), 100); err != nil { + if err := validate.MaxLength("roles_canonical"+"."+strconv.Itoa(i), "body", m.RolesCanonical[i], 100); err != nil { return err } - if err := validate.Pattern("roles_canonical"+"."+strconv.Itoa(i), "body", string(m.RolesCanonical[i]), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("roles_canonical"+"."+strconv.Itoa(i), "body", m.RolesCanonical[i], `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -125,6 +126,11 @@ func (m *UpdateTeam) validateRolesCanonical(formats strfmt.Registry) error { return nil } +// ContextValidate validates this update team based on context it is used +func (m *UpdateTeam) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateTeam) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_user_account.go b/client/models/update_user_account.go index f6766628..b50889bc 100644 --- a/client/models/update_user_account.go +++ b/client/models/update_user_account.go @@ -6,12 +6,12 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -19,6 +19,7 @@ import ( // UpdateUserAccount Update user's account // // The user's account information of the authenticated user to be updated. Emails and password can be omitted if they don't have to be updated, because we can now if they have been sent or not although go-swagger doesn't currently support `PATCH` updates (see [comment](https://github.com/cycloidio/youdeploy-http-api/pull/71#issuecomment-321894076)), we do for this one with this 2 properties because they are good for the user, specially for the `password_update` one. In order to detect if they have been sent or not, we check if the length of array of emails is 0 (if it's sent, then the length MUST be greater than 0 as specified with minItems) and in case of the `password_update` field if it's `nil` or not. If the 'picture_url' is not send then it's removed from the user as it implies that it has deleted it, and also because we do not support partial updates +// // swagger:model UpdateUserAccount type UpdateUserAccount struct { @@ -42,7 +43,7 @@ type UpdateUserAccount struct { // User's preferred language // Required: true - // Enum: [en fr es] + // Enum: ["en","fr","es"] Locale *string `json:"locale"` // mfa enabled @@ -111,12 +112,11 @@ func (m *UpdateUserAccount) Validate(formats strfmt.Registry) error { } func (m *UpdateUserAccount) validateCountryCode(formats strfmt.Registry) error { - if swag.IsZero(m.CountryCode) { // not required return nil } - if err := validate.Pattern("country_code", "body", string(m.CountryCode), `^[A-Z]{2}$`); err != nil { + if err := validate.Pattern("country_code", "body", m.CountryCode, `^[A-Z]{2}$`); err != nil { return err } @@ -124,7 +124,6 @@ func (m *UpdateUserAccount) validateCountryCode(formats strfmt.Registry) error { } func (m *UpdateUserAccount) validateEmails(formats strfmt.Registry) error { - if swag.IsZero(m.Emails) { // not required return nil } @@ -144,6 +143,8 @@ func (m *UpdateUserAccount) validateEmails(formats strfmt.Registry) error { if err := m.Emails[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("emails" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("emails" + "." + strconv.Itoa(i)) } return err } @@ -160,7 +161,7 @@ func (m *UpdateUserAccount) validateFamilyName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("family_name", "body", string(*m.FamilyName), 2); err != nil { + if err := validate.MinLength("family_name", "body", *m.FamilyName, 2); err != nil { return err } @@ -173,7 +174,7 @@ func (m *UpdateUserAccount) validateGivenName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("given_name", "body", string(*m.GivenName), 2); err != nil { + if err := validate.MinLength("given_name", "body", *m.GivenName, 2); err != nil { return err } @@ -206,7 +207,7 @@ const ( // prop value enum func (m *UpdateUserAccount) validateLocaleEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, updateUserAccountTypeLocalePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, updateUserAccountTypeLocalePropEnum, true); err != nil { return err } return nil @@ -236,7 +237,6 @@ func (m *UpdateUserAccount) validateMfaEnabled(formats strfmt.Registry) error { } func (m *UpdateUserAccount) validatePasswordUpdate(formats strfmt.Registry) error { - if swag.IsZero(m.PasswordUpdate) { // not required return nil } @@ -245,6 +245,8 @@ func (m *UpdateUserAccount) validatePasswordUpdate(formats strfmt.Registry) erro if err := m.PasswordUpdate.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("password_update") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("password_update") } return err } @@ -254,7 +256,6 @@ func (m *UpdateUserAccount) validatePasswordUpdate(formats strfmt.Registry) erro } func (m *UpdateUserAccount) validatePictureURL(formats strfmt.Registry) error { - if swag.IsZero(m.PictureURL) { // not required return nil } @@ -272,21 +273,85 @@ func (m *UpdateUserAccount) validateUsername(formats strfmt.Registry) error { return err } - if err := validate.MinLength("username", "body", string(*m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", *m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(*m.Username), 100); err != nil { + if err := validate.MaxLength("username", "body", *m.Username, 100); err != nil { return err } - if err := validate.Pattern("username", "body", string(*m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", *m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validate this update user account based on the context it is used +func (m *UpdateUserAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEmails(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePasswordUpdate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateUserAccount) contextValidateEmails(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Emails); i++ { + + if m.Emails[i] != nil { + + if swag.IsZero(m.Emails[i]) { // not required + return nil + } + + if err := m.Emails[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("emails" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("emails" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *UpdateUserAccount) contextValidatePasswordUpdate(ctx context.Context, formats strfmt.Registry) error { + + if m.PasswordUpdate != nil { + + if swag.IsZero(m.PasswordUpdate) { // not required + return nil + } + + if err := m.PasswordUpdate.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("password_update") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("password_update") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *UpdateUserAccount) MarshalBinary() ([]byte, error) { if m == nil { @@ -306,6 +371,7 @@ func (m *UpdateUserAccount) UnmarshalBinary(b []byte) error { } // UpdateUserAccountPasswordUpdate The update password requires to confirm the old password. +// // swagger:model UpdateUserAccountPasswordUpdate type UpdateUserAccountPasswordUpdate struct { @@ -346,7 +412,7 @@ func (m *UpdateUserAccountPasswordUpdate) validateCurrent(formats strfmt.Registr return err } - if err := validate.MinLength("password_update"+"."+"current", "body", string(*m.Current), 8); err != nil { + if err := validate.MinLength("password_update"+"."+"current", "body", m.Current.String(), 8); err != nil { return err } @@ -363,7 +429,7 @@ func (m *UpdateUserAccountPasswordUpdate) validateNew(formats strfmt.Registry) e return err } - if err := validate.MinLength("password_update"+"."+"new", "body", string(*m.New), 8); err != nil { + if err := validate.MinLength("password_update"+"."+"new", "body", m.New.String(), 8); err != nil { return err } @@ -374,6 +440,11 @@ func (m *UpdateUserAccountPasswordUpdate) validateNew(formats strfmt.Registry) e return nil } +// ContextValidate validates this update user account password update based on context it is used +func (m *UpdateUserAccountPasswordUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateUserAccountPasswordUpdate) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/update_user_account_email.go b/client/models/update_user_account_email.go index ece7002b..1be54ae3 100644 --- a/client/models/update_user_account_email.go +++ b/client/models/update_user_account_email.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // UpdateUserAccountEmail User's email // // The email address of a user to be updated. +// // swagger:model UpdateUserAccountEmail type UpdateUserAccountEmail struct { @@ -69,6 +71,11 @@ func (m *UpdateUserAccountEmail) validatePurpose(formats strfmt.Registry) error return nil } +// ContextValidate validates this update user account email based on context it is used +func (m *UpdateUserAccountEmail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UpdateUserAccountEmail) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/user.go b/client/models/user.go index cd877f3d..f7dd7e49 100644 --- a/client/models/user.go +++ b/client/models/user.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // User Basic info of a user // // A summary of a user to be used in places where only the basic information are need or are enough. +// // swagger:model User type User struct { @@ -136,12 +138,11 @@ func (m *User) Validate(formats strfmt.Registry) error { } func (m *User) validateCountryCode(formats strfmt.Registry) error { - if swag.IsZero(m.CountryCode) { // not required return nil } - if err := validate.Pattern("country_code", "body", string(m.CountryCode), `^[A-Z]{2}$`); err != nil { + if err := validate.Pattern("country_code", "body", m.CountryCode, `^[A-Z]{2}$`); err != nil { return err } @@ -154,7 +155,7 @@ func (m *User) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -180,7 +181,7 @@ func (m *User) validateFamilyName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("family_name", "body", string(*m.FamilyName), 2); err != nil { + if err := validate.MinLength("family_name", "body", *m.FamilyName, 2); err != nil { return err } @@ -193,7 +194,7 @@ func (m *User) validateGivenName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("given_name", "body", string(*m.GivenName), 2); err != nil { + if err := validate.MinLength("given_name", "body", *m.GivenName, 2); err != nil { return err } @@ -206,7 +207,7 @@ func (m *User) validateID(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil { + if err := validate.MinimumUint("id", "body", uint64(*m.ID), 1, false); err != nil { return err } @@ -214,12 +215,11 @@ func (m *User) validateID(formats strfmt.Registry) error { } func (m *User) validateLastLoginAt(formats strfmt.Registry) error { - if swag.IsZero(m.LastLoginAt) { // not required return nil } - if err := validate.MinimumInt("last_login_at", "body", int64(*m.LastLoginAt), 0, false); err != nil { + if err := validate.MinimumUint("last_login_at", "body", *m.LastLoginAt, 0, false); err != nil { return err } @@ -232,7 +232,7 @@ func (m *User) validateLocale(formats strfmt.Registry) error { return err } - if err := validate.Pattern("locale", "body", string(*m.Locale), `^[a-z]{2}(?:-[a-z][a-z])?$`); err != nil { + if err := validate.Pattern("locale", "body", *m.Locale, `^[a-z]{2}(?:-[a-z][a-z])?$`); err != nil { return err } @@ -249,7 +249,6 @@ func (m *User) validateMfaEnabled(formats strfmt.Registry) error { } func (m *User) validatePictureURL(formats strfmt.Registry) error { - if swag.IsZero(m.PictureURL) { // not required return nil } @@ -262,12 +261,11 @@ func (m *User) validatePictureURL(formats strfmt.Registry) error { } func (m *User) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required return nil } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -280,21 +278,26 @@ func (m *User) validateUsername(formats strfmt.Registry) error { return err } - if err := validate.MinLength("username", "body", string(*m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", *m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(*m.Username), 30); err != nil { + if err := validate.MaxLength("username", "body", *m.Username, 30); err != nil { return err } - if err := validate.Pattern("username", "body", string(*m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", *m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this user based on context it is used +func (m *User) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *User) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/user_account.go b/client/models/user_account.go index 202e879f..e9371c5d 100644 --- a/client/models/user_account.go +++ b/client/models/user_account.go @@ -6,12 +6,12 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -19,6 +19,7 @@ import ( // UserAccount User's account // // The user's account contains information related with the authenticated user. +// // swagger:model UserAccount type UserAccount struct { @@ -55,7 +56,7 @@ type UserAccount struct { // User's preferred language // Required: true - // Enum: [en fr es] + // Enum: ["en","fr","es"] Locale *string `json:"locale"` // mfa enabled @@ -134,7 +135,6 @@ func (m *UserAccount) Validate(formats strfmt.Registry) error { } func (m *UserAccount) validateCountry(formats strfmt.Registry) error { - if swag.IsZero(m.Country) { // not required return nil } @@ -143,6 +143,8 @@ func (m *UserAccount) validateCountry(formats strfmt.Registry) error { if err := m.Country.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("country") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("country") } return err } @@ -157,7 +159,7 @@ func (m *UserAccount) validateCreatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -185,6 +187,8 @@ func (m *UserAccount) validateEmails(formats strfmt.Registry) error { if err := m.Emails[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("emails" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("emails" + "." + strconv.Itoa(i)) } return err } @@ -201,7 +205,7 @@ func (m *UserAccount) validateFamilyName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("family_name", "body", string(*m.FamilyName), 2); err != nil { + if err := validate.MinLength("family_name", "body", *m.FamilyName, 2); err != nil { return err } @@ -214,7 +218,7 @@ func (m *UserAccount) validateGivenName(formats strfmt.Registry) error { return err } - if err := validate.MinLength("given_name", "body", string(*m.GivenName), 2); err != nil { + if err := validate.MinLength("given_name", "body", *m.GivenName, 2); err != nil { return err } @@ -227,7 +231,7 @@ func (m *UserAccount) validateLastLogin(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("last_login", "body", int64(*m.LastLogin), 0, false); err != nil { + if err := validate.MinimumUint("last_login", "body", *m.LastLogin, 0, false); err != nil { return err } @@ -260,7 +264,7 @@ const ( // prop value enum func (m *UserAccount) validateLocaleEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, userAccountTypeLocalePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, userAccountTypeLocalePropEnum, true); err != nil { return err } return nil @@ -290,7 +294,6 @@ func (m *UserAccount) validateMfaEnabled(formats strfmt.Registry) error { } func (m *UserAccount) validatePictureURL(formats strfmt.Registry) error { - if swag.IsZero(m.PictureURL) { // not required return nil } @@ -308,7 +311,7 @@ func (m *UserAccount) validateUpdatedAt(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("updated_at", "body", int64(*m.UpdatedAt), 0, false); err != nil { + if err := validate.MinimumUint("updated_at", "body", *m.UpdatedAt, 0, false); err != nil { return err } @@ -321,21 +324,85 @@ func (m *UserAccount) validateUsername(formats strfmt.Registry) error { return err } - if err := validate.MinLength("username", "body", string(*m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", *m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(*m.Username), 100); err != nil { + if err := validate.MaxLength("username", "body", *m.Username, 100); err != nil { return err } - if err := validate.Pattern("username", "body", string(*m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", *m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validate this user account based on the context it is used +func (m *UserAccount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCountry(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateEmails(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserAccount) contextValidateCountry(ctx context.Context, formats strfmt.Registry) error { + + if m.Country != nil { + + if swag.IsZero(m.Country) { // not required + return nil + } + + if err := m.Country.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("country") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("country") + } + return err + } + } + + return nil +} + +func (m *UserAccount) contextValidateEmails(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Emails); i++ { + + if m.Emails[i] != nil { + + if swag.IsZero(m.Emails[i]) { // not required + return nil + } + + if err := m.Emails[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("emails" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("emails" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *UserAccount) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/user_account_email.go b/client/models/user_account_email.go index 938c27fe..56605a0c 100644 --- a/client/models/user_account_email.go +++ b/client/models/user_account_email.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // UserAccountEmail User's email // // The email address of a user. +// // swagger:model UserAccountEmail type UserAccountEmail struct { @@ -64,12 +66,11 @@ func (m *UserAccountEmail) Validate(formats strfmt.Registry) error { } func (m *UserAccountEmail) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required return nil } - if err := validate.MinimumInt("created_at", "body", int64(*m.CreatedAt), 0, false); err != nil { + if err := validate.MinimumUint("created_at", "body", *m.CreatedAt, 0, false); err != nil { return err } @@ -107,6 +108,11 @@ func (m *UserAccountEmail) validateVerified(formats strfmt.Registry) error { return nil } +// ContextValidate validates this user account email based on context it is used +func (m *UserAccountEmail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UserAccountEmail) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/user_email.go b/client/models/user_email.go index b7a3b7bf..0c291716 100644 --- a/client/models/user_email.go +++ b/client/models/user_email.go @@ -6,16 +6,18 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // UserEmail User email address // -// The user's email address +// # The user's email address +// // swagger:model UserEmail type UserEmail struct { @@ -52,6 +54,11 @@ func (m *UserEmail) validateEmail(formats strfmt.Registry) error { return nil } +// ContextValidate validates this user email based on context it is used +func (m *UserEmail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UserEmail) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/user_guide.go b/client/models/user_guide.go index d844aadd..255b4cee 100644 --- a/client/models/user_guide.go +++ b/client/models/user_guide.go @@ -7,6 +7,7 @@ package models // UserGuide User guide JSON schema // -// The user's guide progress JSON schema +// # The user's guide progress JSON schema +// // swagger:model UserGuide type UserGuide interface{} diff --git a/client/models/user_login.go b/client/models/user_login.go index c9ddf8f7..22b8a916 100644 --- a/client/models/user_login.go +++ b/client/models/user_login.go @@ -6,9 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "encoding/json" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +18,10 @@ import ( // UserLogin Log in // // Validate the user to access to the application. The user can login with the primary email address or with username. +// +// MinProperties: 2 +// MaxProperties: 2 +// // swagger:model UserLogin type UserLogin struct { @@ -40,12 +46,162 @@ type UserLogin struct { // Min Length: 3 // Pattern: ^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$ Username string `json:"username,omitempty"` + + // user login additional properties + UserLoginAdditionalProperties map[string]interface{} `json:"-"` +} + +// UnmarshalJSON unmarshals this object with additional properties from JSON +func (m *UserLogin) UnmarshalJSON(data []byte) error { + // stage 1, bind the properties + var stage1 struct { + + // email + // Format: email + Email strfmt.Email `json:"email,omitempty"` + + // organization canonical + // Max Length: 100 + // Min Length: 3 + // Pattern: ^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$ + OrganizationCanonical string `json:"organization_canonical,omitempty"` + + // password + // Required: true + // Min Length: 8 + // Format: password + Password *strfmt.Password `json:"password"` + + // username + // Max Length: 100 + // Min Length: 3 + // Pattern: ^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$ + Username string `json:"username,omitempty"` + } + if err := json.Unmarshal(data, &stage1); err != nil { + return err + } + var rcv UserLogin + + rcv.Email = stage1.Email + rcv.OrganizationCanonical = stage1.OrganizationCanonical + rcv.Password = stage1.Password + rcv.Username = stage1.Username + *m = rcv + + // stage 2, remove properties and add to map + stage2 := make(map[string]json.RawMessage) + if err := json.Unmarshal(data, &stage2); err != nil { + return err + } + + delete(stage2, "email") + delete(stage2, "organization_canonical") + delete(stage2, "password") + delete(stage2, "username") + // stage 3, add additional properties values + if len(stage2) > 0 { + result := make(map[string]interface{}) + for k, v := range stage2 { + var toadd interface{} + if err := json.Unmarshal(v, &toadd); err != nil { + return err + } + result[k] = toadd + } + m.UserLoginAdditionalProperties = result + } + + return nil +} + +// MarshalJSON marshals this object with additional properties into a JSON object +func (m UserLogin) MarshalJSON() ([]byte, error) { + var stage1 struct { + + // email + // Format: email + Email strfmt.Email `json:"email,omitempty"` + + // organization canonical + // Max Length: 100 + // Min Length: 3 + // Pattern: ^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$ + OrganizationCanonical string `json:"organization_canonical,omitempty"` + + // password + // Required: true + // Min Length: 8 + // Format: password + Password *strfmt.Password `json:"password"` + + // username + // Max Length: 100 + // Min Length: 3 + // Pattern: ^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$ + Username string `json:"username,omitempty"` + } + + stage1.Email = m.Email + stage1.OrganizationCanonical = m.OrganizationCanonical + stage1.Password = m.Password + stage1.Username = m.Username + + // make JSON object for known properties + props, err := json.Marshal(stage1) + if err != nil { + return nil, err + } + + if len(m.UserLoginAdditionalProperties) == 0 { // no additional properties + return props, nil + } + + // make JSON object for the additional properties + additional, err := json.Marshal(m.UserLoginAdditionalProperties) + if err != nil { + return nil, err + } + + if len(props) < 3 { // "{}": only additional properties + return additional, nil + } + + // concatenate the 2 objects + return swag.ConcatJSON(props, additional), nil } // Validate validates this user login func (m *UserLogin) Validate(formats strfmt.Registry) error { var res []error + // short circuits minProperties > 0 + if m == nil { + return errors.TooFewProperties("", "body", 2) + } + + props := make(map[string]json.RawMessage, 4+10) + j, err := swag.WriteJSON(m) + if err != nil { + return err + } + + if err = swag.ReadJSON(j, &props); err != nil { + return err + } + + nprops := len(props) + + // minProperties: 2 + if nprops < 2 { + return errors.TooFewProperties("", "body", 2) + } + + // maxProperties: 2 + if nprops > 2 { + return errors.TooManyProperties("", "body", 2) + } + if err := m.validateEmail(formats); err != nil { res = append(res, err) } @@ -69,7 +225,6 @@ func (m *UserLogin) Validate(formats strfmt.Registry) error { } func (m *UserLogin) validateEmail(formats strfmt.Registry) error { - if swag.IsZero(m.Email) { // not required return nil } @@ -82,20 +237,19 @@ func (m *UserLogin) validateEmail(formats strfmt.Registry) error { } func (m *UserLogin) validateOrganizationCanonical(formats strfmt.Registry) error { - if swag.IsZero(m.OrganizationCanonical) { // not required return nil } - if err := validate.MinLength("organization_canonical", "body", string(m.OrganizationCanonical), 3); err != nil { + if err := validate.MinLength("organization_canonical", "body", m.OrganizationCanonical, 3); err != nil { return err } - if err := validate.MaxLength("organization_canonical", "body", string(m.OrganizationCanonical), 100); err != nil { + if err := validate.MaxLength("organization_canonical", "body", m.OrganizationCanonical, 100); err != nil { return err } - if err := validate.Pattern("organization_canonical", "body", string(m.OrganizationCanonical), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("organization_canonical", "body", m.OrganizationCanonical, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } @@ -108,7 +262,7 @@ func (m *UserLogin) validatePassword(formats strfmt.Registry) error { return err } - if err := validate.MinLength("password", "body", string(*m.Password), 8); err != nil { + if err := validate.MinLength("password", "body", m.Password.String(), 8); err != nil { return err } @@ -120,26 +274,30 @@ func (m *UserLogin) validatePassword(formats strfmt.Registry) error { } func (m *UserLogin) validateUsername(formats strfmt.Registry) error { - if swag.IsZero(m.Username) { // not required return nil } - if err := validate.MinLength("username", "body", string(m.Username), 3); err != nil { + if err := validate.MinLength("username", "body", m.Username, 3); err != nil { return err } - if err := validate.MaxLength("username", "body", string(m.Username), 100); err != nil { + if err := validate.MaxLength("username", "body", m.Username, 100); err != nil { return err } - if err := validate.Pattern("username", "body", string(m.Username), `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { + if err := validate.Pattern("username", "body", m.Username, `^[a-z0-9]+[a-z0-9\-_]+[a-z0-9]+$`); err != nil { return err } return nil } +// ContextValidate validates this user login based on context it is used +func (m *UserLogin) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UserLogin) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/user_o_auth.go b/client/models/user_o_auth.go index 4b829cce..d0b94cfb 100644 --- a/client/models/user_o_auth.go +++ b/client/models/user_o_auth.go @@ -6,15 +6,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // UserOAuth User's OAuth information // // The User OAuth information, if it's on the platform it'll return the 'token' to login, if not the 'user' to show to the user +// // swagger:model UserOAuth type UserOAuth struct { @@ -40,7 +42,6 @@ func (m *UserOAuth) Validate(formats strfmt.Registry) error { } func (m *UserOAuth) validateUser(formats strfmt.Registry) error { - if swag.IsZero(m.User) { // not required return nil } @@ -49,6 +50,43 @@ func (m *UserOAuth) validateUser(formats strfmt.Registry) error { if err := m.User.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("user") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("user") + } + return err + } + } + + return nil +} + +// ContextValidate validate this user o auth based on the context it is used +func (m *UserOAuth) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateUser(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserOAuth) contextValidateUser(ctx context.Context, formats strfmt.Registry) error { + + if m.User != nil { + + if swag.IsZero(m.User) { // not required + return nil + } + + if err := m.User.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("user") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("user") } return err } diff --git a/client/models/user_password_reset_req.go b/client/models/user_password_reset_req.go index a8a3efe6..dba14bbf 100644 --- a/client/models/user_password_reset_req.go +++ b/client/models/user_password_reset_req.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // UserPasswordResetReq User password reset request // // Request to send a token for allowing the user to reset its current password. +// // swagger:model UserPasswordResetReq type UserPasswordResetReq struct { @@ -52,6 +54,11 @@ func (m *UserPasswordResetReq) validateEmail(formats strfmt.Registry) error { return nil } +// ContextValidate validates this user password reset req based on context it is used +func (m *UserPasswordResetReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UserPasswordResetReq) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/user_password_reset_update.go b/client/models/user_password_reset_update.go index 48aaa71b..7d1a2ba5 100644 --- a/client/models/user_password_reset_update.go +++ b/client/models/user_password_reset_update.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // UserPasswordResetUpdate User password reset update // // Reset the current user password to the one provided. The user must have a valid token for the resetting password action. +// // swagger:model UserPasswordResetUpdate type UserPasswordResetUpdate struct { @@ -55,7 +57,7 @@ func (m *UserPasswordResetUpdate) validatePassword(formats strfmt.Registry) erro return err } - if err := validate.MinLength("password", "body", string(*m.Password), 8); err != nil { + if err := validate.MinLength("password", "body", m.Password.String(), 8); err != nil { return err } @@ -72,13 +74,18 @@ func (m *UserPasswordResetUpdate) validateToken(formats strfmt.Registry) error { return err } - if err := validate.MinLength("token", "body", string(*m.Token), 1); err != nil { + if err := validate.MinLength("token", "body", *m.Token, 1); err != nil { return err } return nil } +// ContextValidate validates this user password reset update based on context it is used +func (m *UserPasswordResetUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *UserPasswordResetUpdate) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/user_session.go b/client/models/user_session.go index d9d43f03..fdd9543b 100644 --- a/client/models/user_session.go +++ b/client/models/user_session.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // UserSession User's session // // The JWT which allows the user to access to the application. +// // swagger:model UserSession type UserSession struct { @@ -65,6 +67,10 @@ func (m *UserSession) validateOwns(formats strfmt.Registry) error { func (m *UserSession) validatePermissions(formats strfmt.Registry) error { + if err := validate.Required("permissions", "body", m.Permissions); err != nil { + return err + } + for k := range m.Permissions { if err := validate.Required("permissions"+"."+k, "body", m.Permissions[k]); err != nil { @@ -72,6 +78,11 @@ func (m *UserSession) validatePermissions(formats strfmt.Registry) error { } if val, ok := m.Permissions[k]; ok { if err := val.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("permissions" + "." + k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("permissions" + "." + k) + } return err } } @@ -90,6 +101,39 @@ func (m *UserSession) validateToken(formats strfmt.Registry) error { return nil } +// ContextValidate validate this user session based on the context it is used +func (m *UserSession) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePermissions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserSession) contextValidatePermissions(ctx context.Context, formats strfmt.Registry) error { + + if err := validate.Required("permissions", "body", m.Permissions); err != nil { + return err + } + + for k := range m.Permissions { + + if val, ok := m.Permissions[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *UserSession) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/v_mware_vsphere.go b/client/models/v_mware_vsphere.go index 27c43cdd..fd69547e 100644 --- a/client/models/v_mware_vsphere.go +++ b/client/models/v_mware_vsphere.go @@ -7,11 +7,11 @@ package models import ( "bytes" + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) @@ -37,13 +37,8 @@ func (m *VMwareVsphere) Engine() string { // SetEngine sets the engine of this subtype func (m *VMwareVsphere) SetEngine(val string) { - } -// AllowUnverifiedSsl gets the allow unverified ssl of this subtype - -// Server gets the server of this subtype - // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure func (m *VMwareVsphere) UnmarshalJSON(raw []byte) error { var data struct { @@ -85,7 +80,6 @@ func (m *VMwareVsphere) UnmarshalJSON(raw []byte) error { } result.AllowUnverifiedSsl = data.AllowUnverifiedSsl - result.Server = data.Server *m = result @@ -111,8 +105,7 @@ func (m VMwareVsphere) MarshalJSON() ([]byte, error) { AllowUnverifiedSsl: m.AllowUnverifiedSsl, Server: m.Server, - }, - ) + }) if err != nil { return nil, err } @@ -121,8 +114,7 @@ func (m VMwareVsphere) MarshalJSON() ([]byte, error) { }{ Engine: m.Engine(), - }, - ) + }) if err != nil { return nil, err } @@ -140,6 +132,16 @@ func (m *VMwareVsphere) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validate this v mware vsphere based on the context it is used +func (m *VMwareVsphere) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + // MarshalBinary interface implementation func (m *VMwareVsphere) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/version_config.go b/client/models/version_config.go index f1c22473..42fa4d92 100644 --- a/client/models/version_config.go +++ b/client/models/version_config.go @@ -6,14 +6,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // VersionConfig VersionConfig // // The entity which represents a version configuration in the application. +// // swagger:model VersionConfig type VersionConfig struct { @@ -32,6 +34,11 @@ func (m *VersionConfig) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validates this version config based on context it is used +func (m *VersionConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *VersionConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/versioned_resource_type.go b/client/models/versioned_resource_type.go index 5476db31..18973249 100644 --- a/client/models/versioned_resource_type.go +++ b/client/models/versioned_resource_type.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // VersionedResourceType VersionedResourceType // // The versioned resources type. +// // swagger:model VersionedResourceType type VersionedResourceType struct { @@ -115,11 +117,11 @@ func (m *VersionedResourceType) validatePrivileged(formats strfmt.Registry) erro func (m *VersionedResourceType) validateSource(formats strfmt.Registry) error { - for k := range m.Source { + if err := validate.Required("source", "body", m.Source); err != nil { + return err + } - if err := validate.Required("source"+"."+k, "body", m.Source[k]); err != nil { - return err - } + for k := range m.Source { if err := validate.Required("source"+"."+k, "body", m.Source[k]); err != nil { return err @@ -132,6 +134,10 @@ func (m *VersionedResourceType) validateSource(formats strfmt.Registry) error { func (m *VersionedResourceType) validateTags(formats strfmt.Registry) error { + if err := validate.Required("tags", "body", m.Tags); err != nil { + return err + } + return nil } @@ -146,6 +152,15 @@ func (m *VersionedResourceType) validateType(formats strfmt.Registry) error { func (m *VersionedResourceType) validateVersion(formats strfmt.Registry) error { + if err := validate.Required("version", "body", m.Version); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this versioned resource type based on context it is used +func (m *VersionedResourceType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } diff --git a/client/models/worker.go b/client/models/worker.go index d969df2d..5e30e38e 100644 --- a/client/models/worker.go +++ b/client/models/worker.go @@ -6,9 +6,10 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) @@ -16,6 +17,7 @@ import ( // Worker Worker // // The entity which represents a worker in the application. +// // swagger:model Worker type Worker struct { @@ -172,6 +174,11 @@ func (m *Worker) validateVersion(formats strfmt.Registry) error { return nil } +// ContextValidate validates this worker based on context it is used +func (m *Worker) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Worker) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/version b/client/version deleted file mode 100644 index 2d5f493f..00000000 --- a/client/version +++ /dev/null @@ -1 +0,0 @@ -v5.0.34 From 8b5f4b23c25a00ec51236f9e181006715b409ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Mon, 10 Jun 2024 17:17:14 +0200 Subject: [PATCH 29/98] fix: update go.mod and go.sum for updated version --- go.mod | 2 +- go.sum | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 83b4de96..30f08713 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cycloidio/cycloid-cli -go 1.18 +go 1.22 require ( dario.cat/mergo v1.0.0 diff --git a/go.sum b/go.sum index 938c7c52..1ebae7bf 100644 --- a/go.sum +++ b/go.sum @@ -197,6 +197,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -278,9 +279,11 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= @@ -351,6 +354,7 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= @@ -407,6 +411,7 @@ go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= +go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -819,6 +824,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= From 15fbb8ebe608b38dc2c7b5e3679e689993b94c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Mon, 10 Jun 2024 17:17:51 +0200 Subject: [PATCH 30/98] fix: update legacy code to new generated client --- cmd/cycloid/common/helpers.go | 4 ++-- cmd/cycloid/middleware/external-backends.go | 2 +- cmd/cycloid/middleware/kpi.go | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index 43b1c04c..1e9d6aa9 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -106,7 +106,7 @@ func WithToken(t string) APIOptions { } type APIClient struct { - *client.APIClient + *client.API Config APIConfig } @@ -148,7 +148,7 @@ func NewAPI(opts ...APIOptions) *APIClient { // tr.DefaultAuthentication = httptransport.BearerToken("token") // api.SetTransport(tr) return &APIClient{ - APIClient: api, + API: api, Config: acfg, } diff --git a/cmd/cycloid/middleware/external-backends.go b/cmd/cycloid/middleware/external-backends.go index ed8cb7aa..16aed6fa 100644 --- a/cmd/cycloid/middleware/external-backends.go +++ b/cmd/cycloid/middleware/external-backends.go @@ -123,7 +123,7 @@ func (m *middleware) CreateExternalBackends(org, project, env, purpose, cred str body.SetConfiguration(ebConfig) params.SetBody(body) if project != "" { - params.SetProject(&project) + params.WithProjectCanonical(&project) } err = body.Validate(strfmt.Default) if err != nil { diff --git a/cmd/cycloid/middleware/kpi.go b/cmd/cycloid/middleware/kpi.go index 3276d3d3..a7e404fe 100644 --- a/cmd/cycloid/middleware/kpi.go +++ b/cmd/cycloid/middleware/kpi.go @@ -17,10 +17,10 @@ func (m *middleware) CreateKpi(name, kpiType, widget, org, project, job, env, co params.SetOrganizationCanonical(org) pipeline := "" if project != "" { - params.SetProject(&project) + params.WithProjectCanonical(&project) } if env != "" { - params.SetEnvironment(&env) + params.WithEnvironmentCanonical(&env) } if project != "" && env != "" { @@ -67,10 +67,10 @@ func (m *middleware) ListKpi(org, project, env string) ([]*models.KPI, error) { params := organization_kpis.NewGetKpisParams() params.SetOrganizationCanonical(org) if project != "" { - params.SetProject(&project) + params.WithProjectCanonical(&project) } if env != "" { - params.SetEnvironment(&env) + params.WithEnvironmentCanonical(&env) } resp, err := m.api.OrganizationKpis.GetKpis(params, m.api.Credentials(&org)) From ca418c0e91d281386d154a091214baee16e5a9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Mon, 10 Jun 2024 17:18:38 +0200 Subject: [PATCH 31/98] misc: add nil value check in forms parsing --- cmd/cycloid/common/helpers.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index 1e9d6aa9..36e34f7f 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -321,9 +321,17 @@ func ParseFormsConfig(conf *models.ProjectEnvironmentConfig, useCase string, get var groups = make(map[string]map[string]any) for _, group := range section.Groups { + if group == nil { + continue + } + vars := make(map[string]any) for _, varEntity := range group.Vars { + if varEntity == nil { + continue + } + value := EntityGetValue(varEntity, getCurrent) // We have to strings.ToLower() the keys otherwise, it will not be // recognized as input for a create-env From 82a2102ada4941a2380d34d9acaabd03d890990e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Mon, 10 Jun 2024 17:19:03 +0200 Subject: [PATCH 32/98] misc: add quick fixes from revie --- cmd/cycloid/internal/version.go | 4 ---- cmd/cycloid/projects/create-env.go | 14 ++++++++------ .../projects/get-stackforms-config-from-env.go | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cmd/cycloid/internal/version.go b/cmd/cycloid/internal/version.go index e716bf78..3483565d 100644 --- a/cmd/cycloid/internal/version.go +++ b/cmd/cycloid/internal/version.go @@ -20,9 +20,7 @@ func Warning(out io.Writer, msg string) { // terminal is able to support colors // But that would be for another PR. fmt.Fprintf(out, "\033[1;35mwarning:\033[0m %s", msg) - break default: - break } } @@ -34,9 +32,7 @@ func Debug(msg ...any) { // But that would be for another PR. fmt.Fprintf(os.Stderr, "\033[1;34mdebug:\033[0m ") fmt.Fprintln(os.Stderr, msg...) - break default: - break } } diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 2c2a94d2..93f6e66f 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -40,7 +40,7 @@ The output will be the generated configuration of the project. `, Example: ` # create 'prod' environment in 'my-project' - cy --org my-org project create-raw-env \ + cy --org my-org project create-stackforms-env \ --project my-project \ --env prod \ --use-case usecase-1 \ @@ -61,10 +61,11 @@ The output will be the generated configuration of the project. common.RequiredPersistentFlag(common.WithFlagEnv, cmd) WithFlagConfig(cmd) cmd.PersistentFlags().String("use-case", "", "the selected use case of the stack") + cmd.MarkFlagRequired("use-case") cmd.PersistentFlags().StringArrayP("var-file", "f", nil, "path to a JSON file containing variables, can be '-' for stdin") cmd.PersistentFlags().StringArray("vars", nil, "JSON string containing variables") cmd.PersistentFlags().BoolP("update", "u", false, "if true, existing environment will be updated, default: false") - cmd.PersistentFlags().StringToStringP("extra-var", "e", nil, "extra variable to be added to the environment in the -e key=value,key=value format") + cmd.PersistentFlags().StringToStringP("extra-var", "e", nil, "extra variable to be added to the environment in the -e key=value -e key=value format") return cmd } @@ -93,8 +94,6 @@ func createEnv(cmd *cobra.Command, args []string) error { usecase, err := cmd.Flags().GetString("use-case") if err != nil { return err - } else if usecase == "" { - return errors.New("--use-case flag is required") } update, err := cmd.Flags().GetBool("update") @@ -141,9 +140,12 @@ func createEnv(cmd *cobra.Command, args []string) error { internal.Debug("finished reading input vars from", varFile) break } + if err != nil { - log.Fatalf("failed to read input vars from "+varFile+": %v", err) - break + if varFile == "-" { + varFile = "stdin" + } + return fmt.Errorf("failed to read input vars from "+varFile+": %v", err) } if err := mergo.Merge(&vars, extractedVars, mergo.WithOverride); err != nil { diff --git a/cmd/cycloid/projects/get-stackforms-config-from-env.go b/cmd/cycloid/projects/get-stackforms-config-from-env.go index 60ca08b4..deee50b5 100644 --- a/cmd/cycloid/projects/get-stackforms-config-from-env.go +++ b/cmd/cycloid/projects/get-stackforms-config-from-env.go @@ -96,7 +96,7 @@ func getStackFormsConfigFromEnv(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get output flag") } - // output as yaml by default + // output as json by default if output == "table" { output = "json" } From d44f36c4416122b83cf866fc2a95619715464c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Mon, 10 Jun 2024 17:19:31 +0200 Subject: [PATCH 33/98] misc: add new generated api client --- client/client/api_client.go | 217 ++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 client/client/api_client.go diff --git a/client/client/api_client.go b/client/client/api_client.go new file mode 100644 index 00000000..036c0047 --- /dev/null +++ b/client/client/api_client.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package client + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/cycloidio/cycloid-cli/client/client/cost_estimation" + "github.com/cycloidio/cycloid-cli/client/client/cycloid" + "github.com/cycloidio/cycloid-cli/client/client/organization_api_keys" + "github.com/cycloidio/cycloid-cli/client/client/organization_children" + "github.com/cycloidio/cycloid-cli/client/client/organization_config_repositories" + "github.com/cycloidio/cycloid-cli/client/client/organization_credentials" + "github.com/cycloidio/cycloid-cli/client/client/organization_external_backends" + "github.com/cycloidio/cycloid-cli/client/client/organization_forms" + "github.com/cycloidio/cycloid-cli/client/client/organization_infrastructure_policies" + "github.com/cycloidio/cycloid-cli/client/client/organization_invitations" + "github.com/cycloidio/cycloid-cli/client/client/organization_kpis" + "github.com/cycloidio/cycloid-cli/client/client/organization_members" + "github.com/cycloidio/cycloid-cli/client/client/organization_pipelines" + "github.com/cycloidio/cycloid-cli/client/client/organization_pipelines_jobs" + "github.com/cycloidio/cycloid-cli/client/client/organization_pipelines_jobs_build" + "github.com/cycloidio/cycloid-cli/client/client/organization_projects" + "github.com/cycloidio/cycloid-cli/client/client/organization_roles" + "github.com/cycloidio/cycloid-cli/client/client/organization_service_catalog_sources" + "github.com/cycloidio/cycloid-cli/client/client/organization_workers" + "github.com/cycloidio/cycloid-cli/client/client/organizations" + "github.com/cycloidio/cycloid-cli/client/client/service_catalogs" + "github.com/cycloidio/cycloid-cli/client/client/user" +) + +// Default API HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "http-api.cycloid.io" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"https"} + +// NewHTTPClient creates a new API HTTP client. +func NewHTTPClient(formats strfmt.Registry) *API { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new API HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *API { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new API client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *API { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(API) + cli.Transport = transport + cli.CostEstimation = cost_estimation.New(transport, formats) + cli.Cycloid = cycloid.New(transport, formats) + cli.OrganizationAPIKeys = organization_api_keys.New(transport, formats) + cli.OrganizationChildren = organization_children.New(transport, formats) + cli.OrganizationConfigRepositories = organization_config_repositories.New(transport, formats) + cli.OrganizationCredentials = organization_credentials.New(transport, formats) + cli.OrganizationExternalBackends = organization_external_backends.New(transport, formats) + cli.OrganizationForms = organization_forms.New(transport, formats) + cli.OrganizationInfrastructurePolicies = organization_infrastructure_policies.New(transport, formats) + cli.OrganizationInvitations = organization_invitations.New(transport, formats) + cli.OrganizationKpis = organization_kpis.New(transport, formats) + cli.OrganizationMembers = organization_members.New(transport, formats) + cli.OrganizationPipelines = organization_pipelines.New(transport, formats) + cli.OrganizationPipelinesJobs = organization_pipelines_jobs.New(transport, formats) + cli.OrganizationPipelinesJobsBuild = organization_pipelines_jobs_build.New(transport, formats) + cli.OrganizationProjects = organization_projects.New(transport, formats) + cli.OrganizationRoles = organization_roles.New(transport, formats) + cli.OrganizationServiceCatalogSources = organization_service_catalog_sources.New(transport, formats) + cli.OrganizationWorkers = organization_workers.New(transport, formats) + cli.Organizations = organizations.New(transport, formats) + cli.ServiceCatalogs = service_catalogs.New(transport, formats) + cli.User = user.New(transport, formats) + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// API is a client for API +type API struct { + CostEstimation cost_estimation.ClientService + + Cycloid cycloid.ClientService + + OrganizationAPIKeys organization_api_keys.ClientService + + OrganizationChildren organization_children.ClientService + + OrganizationConfigRepositories organization_config_repositories.ClientService + + OrganizationCredentials organization_credentials.ClientService + + OrganizationExternalBackends organization_external_backends.ClientService + + OrganizationForms organization_forms.ClientService + + OrganizationInfrastructurePolicies organization_infrastructure_policies.ClientService + + OrganizationInvitations organization_invitations.ClientService + + OrganizationKpis organization_kpis.ClientService + + OrganizationMembers organization_members.ClientService + + OrganizationPipelines organization_pipelines.ClientService + + OrganizationPipelinesJobs organization_pipelines_jobs.ClientService + + OrganizationPipelinesJobsBuild organization_pipelines_jobs_build.ClientService + + OrganizationProjects organization_projects.ClientService + + OrganizationRoles organization_roles.ClientService + + OrganizationServiceCatalogSources organization_service_catalog_sources.ClientService + + OrganizationWorkers organization_workers.ClientService + + Organizations organizations.ClientService + + ServiceCatalogs service_catalogs.ClientService + + User user.ClientService + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *API) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + c.CostEstimation.SetTransport(transport) + c.Cycloid.SetTransport(transport) + c.OrganizationAPIKeys.SetTransport(transport) + c.OrganizationChildren.SetTransport(transport) + c.OrganizationConfigRepositories.SetTransport(transport) + c.OrganizationCredentials.SetTransport(transport) + c.OrganizationExternalBackends.SetTransport(transport) + c.OrganizationForms.SetTransport(transport) + c.OrganizationInfrastructurePolicies.SetTransport(transport) + c.OrganizationInvitations.SetTransport(transport) + c.OrganizationKpis.SetTransport(transport) + c.OrganizationMembers.SetTransport(transport) + c.OrganizationPipelines.SetTransport(transport) + c.OrganizationPipelinesJobs.SetTransport(transport) + c.OrganizationPipelinesJobsBuild.SetTransport(transport) + c.OrganizationProjects.SetTransport(transport) + c.OrganizationRoles.SetTransport(transport) + c.OrganizationServiceCatalogSources.SetTransport(transport) + c.OrganizationWorkers.SetTransport(transport) + c.Organizations.SetTransport(transport) + c.ServiceCatalogs.SetTransport(transport) + c.User.SetTransport(transport) +} From f64a0fded4b3ccd10508f975bf71d63a9b75df8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 16:04:05 +0200 Subject: [PATCH 34/98] fix(tests): fix tests with new indented JSON printer --- e2e/catalog_repositories_test.go | 6 +- e2e/config_repositories_test.go | 9 +-- e2e/creds_test.go | 6 +- e2e/external_backends_test.go | 16 +++--- e2e/helpers.go | 24 +++++++- e2e/infra_policies_test.go | 14 +++-- e2e/kpis_test.go | 15 ++--- e2e/members_test.go | 9 +-- e2e/organizations_test.go | 2 +- e2e/pipelines_test.go | 20 ++++--- e2e/projects_test.go | 95 ++++++++++++++++++++++++++++---- e2e/roles_test.go | 7 ++- e2e/stacks_test.go | 6 +- printer/json/printer_test.go | 12 +++- 14 files changed, 174 insertions(+), 67 deletions(-) diff --git a/e2e/catalog_repositories_test.go b/e2e/catalog_repositories_test.go index 0e2f2125..663f7c12 100644 --- a/e2e/catalog_repositories_test.go +++ b/e2e/catalog_repositories_test.go @@ -34,7 +34,7 @@ func TestCatalogRepositories(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "canonical\":\"stack-aws-sample") + assert.Contains(t, cmdOut, "canonical\": \"stack-aws-sample") }) t.Run("SuccessCatalogRepositoriesList", func(t *testing.T) { @@ -46,7 +46,7 @@ func TestCatalogRepositories(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "canonical\":\"step-by-step") + assert.Contains(t, cmdOut, "canonical\": \"step-by-step") }) t.Run("SuccessCatalogRepositoriesGet", func(t *testing.T) { @@ -59,7 +59,7 @@ func TestCatalogRepositories(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "canonical\":\"stack-aws-sample") + assert.Contains(t, cmdOut, "canonical\": \"stack-aws-sample") }) t.Run("SuccessCatalogRepositoriesRefresh", func(t *testing.T) { diff --git a/e2e/config_repositories_test.go b/e2e/config_repositories_test.go index f4cdd7ca..0189ee62 100644 --- a/e2e/config_repositories_test.go +++ b/e2e/config_repositories_test.go @@ -1,4 +1,5 @@ -//+build e2e +//go:build e2e +// +build e2e package e2e @@ -46,7 +47,7 @@ func TestConfigRepositories(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"default-config") + require.Contains(t, cmdOut, "canonical\": \"default-config") }) t.Run("SuccessConfigRepositoriesList", func(t *testing.T) { @@ -58,7 +59,7 @@ func TestConfigRepositories(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"default-config") + require.Contains(t, cmdOut, "canonical\": \"default-config") }) t.Run("SuccessConfigRepositoriesGet", func(t *testing.T) { @@ -71,7 +72,7 @@ func TestConfigRepositories(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"default-config") + require.Contains(t, cmdOut, "canonical\": \"default-config") }) t.Run("SuccessConfigRepositoriesDelete", func(t *testing.T) { diff --git a/e2e/creds_test.go b/e2e/creds_test.go index 5e042ccd..f7d93eb6 100644 --- a/e2e/creds_test.go +++ b/e2e/creds_test.go @@ -22,7 +22,7 @@ func TestCreds(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"vault") + require.Contains(t, cmdOut, "canonical\": \"vault") }) t.Run("SuccessCredsGet", func(t *testing.T) { @@ -35,7 +35,7 @@ func TestCreds(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"vault") + require.Contains(t, cmdOut, "canonical\": \"vault") }) t.Run("SuccessCredsCreateCustom", func(t *testing.T) { @@ -88,7 +88,7 @@ func TestCreds(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "new\":\"field") + require.Contains(t, cmdOut, "new\": \"field") }) }) t.Run("SuccessCredsCreateCustomWithFile", func(t *testing.T) { diff --git a/e2e/external_backends_test.go b/e2e/external_backends_test.go index eb8b1e1b..ab8b98fa 100644 --- a/e2e/external_backends_test.go +++ b/e2e/external_backends_test.go @@ -1,10 +1,11 @@ -//+build e2e +//go:build e2e +// +build e2e package e2e import ( - "testing" "fmt" + "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -93,7 +94,7 @@ func TestExternalBackends(t *testing.T) { "create", "--name", "eb-test", "--description", "this is a test project", - "--stack-ref", fmt.Sprintf("%s:stack-dummy", CY_TEST_ROOT_ORG), + "--stack-ref", fmt.Sprintf("%s:stack-dummy", CY_TEST_ROOT_ORG), "--config-repo", "project-config", "--env", "test", "--usecase", "default", @@ -112,7 +113,7 @@ func TestExternalBackends(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"eb-test") + require.Contains(t, cmdOut, "canonical\": \"eb-test") }) t.Run("SuccessExternalBackendsCreateAWSRemoteTFState", func(t *testing.T) { @@ -131,7 +132,7 @@ func TestExternalBackends(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "purpose\":\"remote_tfstate") + require.Contains(t, cmdOut, "purpose\": \"remote_tfstate") }) t.Run("SuccessExternalBackendsCreateAWSCloudWatchLogs", func(t *testing.T) { @@ -148,10 +149,9 @@ func TestExternalBackends(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "purpose\":\"logs") + require.Contains(t, cmdOut, "purpose\": \"logs") }) - t.Run("SuccessExternalBackendsList", func(t *testing.T) { cmdOut, cmdErr := executeCommand([]string{ "--output", "json", @@ -161,6 +161,6 @@ func TestExternalBackends(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "purpose\":\"remote_tfstate") + require.Contains(t, cmdOut, "purpose\": \"remote_tfstate") }) } diff --git a/e2e/helpers.go b/e2e/helpers.go index 2a415e84..8f725d49 100644 --- a/e2e/helpers.go +++ b/e2e/helpers.go @@ -4,9 +4,10 @@ import ( "bytes" "encoding/json" "fmt" - "ioutil" + "io" "os" "regexp" + "strings" "time" rootCmd "github.com/cycloidio/cycloid-cli/cmd" @@ -90,7 +91,26 @@ func executeCommand(args []string) (string, error) { cmd.SetArgs(args) cmdErr := cmd.Execute() - cmdOut, err := ioutil.ReadAll(buf) + cmdOut, err := io.ReadAll(buf) + if err != nil { + panic(fmt.Sprintf("Unable to read command output buffer")) + } + return string(cmdOut), cmdErr +} + +func executeCommandWithStdin(args []string, stdin string) (string, error) { + cmd := rootCmd.NewRootCommand() + + buf := new(bytes.Buffer) + errBuf := new(bytes.Buffer) + cmd.SetOut(buf) + cmd.SetErr(errBuf) + + cmd.SetArgs(args) + cmd.SetIn(strings.NewReader(stdin)) + + cmdErr := cmd.Execute() + cmdOut, err := io.ReadAll(buf) if err != nil { panic(fmt.Sprintf("Unable to read command output buffer")) } diff --git a/e2e/infra_policies_test.go b/e2e/infra_policies_test.go index e485623d..1051057a 100644 --- a/e2e/infra_policies_test.go +++ b/e2e/infra_policies_test.go @@ -1,11 +1,13 @@ -//+build e2e +//go:build e2e +// +build e2e package e2e import ( + "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func TestInfraPolicies(t *testing.T) { @@ -31,7 +33,7 @@ func TestInfraPolicies(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"test") + require.Contains(t, cmdOut, "canonical\": \"test") }) // Checks the succesfull get of a new infrapolicy @@ -48,7 +50,7 @@ func TestInfraPolicies(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "description\":\"test infrapolicy") + require.Contains(t, cmdOut, "description\": \"test infrapolicy") }) // Checks the succesfull list of infrapolicies in org @@ -64,7 +66,7 @@ func TestInfraPolicies(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "description\":\"test infrapolicy") + require.Contains(t, cmdOut, "description\": \"test infrapolicy") }) // Checks the succesfull update of a infrapolicy @@ -88,7 +90,7 @@ func TestInfraPolicies(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "description\":\"changed description") + require.Contains(t, cmdOut, "description\": \"changed description") }) // Checks the succesfull deletion of a infrapolicy diff --git a/e2e/kpis_test.go b/e2e/kpis_test.go index 1d3052c6..5c26fd7a 100644 --- a/e2e/kpis_test.go +++ b/e2e/kpis_test.go @@ -1,11 +1,12 @@ -//+build e2e +//go:build e2e +// +build e2e package e2e import ( - "testing" "fmt" "regexp" + "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -85,7 +86,7 @@ func TestKpis(t *testing.T) { "create", "--name", "kpi-test", "--description", "this is a test project", - "--stack-ref", fmt.Sprintf("%s:stack-dummy", CY_TEST_ROOT_ORG), + "--stack-ref", fmt.Sprintf("%s:stack-dummy", CY_TEST_ROOT_ORG), "--config-repo", "project-config", "--env", "test", "--usecase", "default", @@ -104,7 +105,7 @@ func TestKpis(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"kpi-test") + require.Contains(t, cmdOut, "canonical\": \"kpi-test") }) t.Run("SuccessKpisCreate", func(t *testing.T) { @@ -122,7 +123,7 @@ func TestKpis(t *testing.T) { }) require.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"test-") + require.Contains(t, cmdOut, "canonical\": \"test-") }) t.Run("SuccessKpisList", func(t *testing.T) { @@ -134,9 +135,9 @@ func TestKpis(t *testing.T) { }) require.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"test-") + require.Contains(t, cmdOut, "canonical\": \"test-") - re := regexp.MustCompile(`canonical":"(test-[^"]+)"`) + re := regexp.MustCompile(`canonical": "(test-[^"]+)"`) createdKpi = re.FindAllStringSubmatch(cmdOut, 1)[0][1] }) diff --git a/e2e/members_test.go b/e2e/members_test.go index fa832984..a222a8d3 100644 --- a/e2e/members_test.go +++ b/e2e/members_test.go @@ -1,4 +1,5 @@ -//+build e2e +//go:build e2e +// +build e2e package e2e @@ -45,7 +46,7 @@ func TestMembers(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "email\":\"cycloidio@cycloid.io") + assert.Contains(t, cmdOut, "email\": \"cycloidio@cycloid.io") }) t.Run("SuccessMembersGet", func(t *testing.T) { @@ -58,7 +59,7 @@ func TestMembers(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "email\":\"cycloidio@cycloid.io") + assert.Contains(t, cmdOut, "email\": \"cycloidio@cycloid.io") }) t.Run("SuccessMembersInvite", func(t *testing.T) { @@ -84,6 +85,6 @@ func TestMembers(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "email\":\"foo@bli.fr") + assert.Contains(t, cmdOut, "email\": \"foo@bli.fr") }) } diff --git a/e2e/organizations_test.go b/e2e/organizations_test.go index 402b0a7e..1dd0429b 100644 --- a/e2e/organizations_test.go +++ b/e2e/organizations_test.go @@ -23,7 +23,7 @@ func TestOrganizations(t *testing.T) { }) require.NoError(t, cmdErr) - assert.Contains(t, cmdOut, fmt.Sprintf("canonical\":\"%s", CY_TEST_ROOT_ORG)) + assert.Contains(t, cmdOut, fmt.Sprintf("canonical\": \"%s", CY_TEST_ROOT_ORG)) }) childOrg := RandStringBytes(10) diff --git a/e2e/pipelines_test.go b/e2e/pipelines_test.go index 7d21106f..f6c1a04c 100644 --- a/e2e/pipelines_test.go +++ b/e2e/pipelines_test.go @@ -1,4 +1,5 @@ -//+build e2e +//go:build e2e +// +build e2e package e2e @@ -79,7 +80,7 @@ func TestPipelines(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"pipeline-test") + require.Contains(t, cmdOut, "canonical\": \"pipeline-test") }) t.Run("SuccessPipelinesUpdate", func(t *testing.T) { @@ -98,7 +99,7 @@ func TestPipelines(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"pipeline-test") + require.Contains(t, cmdOut, "canonical\": \"pipeline-test") }) t.Run("SuccessPipelinesPause", func(t *testing.T) { @@ -138,7 +139,7 @@ func TestPipelines(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "name\":\"pipeline-test-test") + require.Contains(t, cmdOut, "name\": \"pipeline-test-test") }) t.Run("SuccessPipelinesGet", func(t *testing.T) { @@ -152,7 +153,7 @@ func TestPipelines(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "name\":\"pipeline-test-test") + require.Contains(t, cmdOut, "name\": \"pipeline-test-test") }) t.Run("SuccessPipelinesListJobs", func(t *testing.T) { @@ -166,7 +167,7 @@ func TestPipelines(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "name\":\"job-hello-world") + require.Contains(t, cmdOut, "name\": \"job-hello-world") }) t.Run("SuccessPipelinesGetJob", func(t *testing.T) { @@ -181,7 +182,7 @@ func TestPipelines(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "name\":\"job-hello-world") + require.Contains(t, cmdOut, "name\": \"job-hello-world") }) t.Run("SuccessPipelinesPauseJob", func(t *testing.T) { @@ -240,8 +241,9 @@ func TestPipelines(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "job_name\":\"job-hello-world") + require.Contains(t, cmdOut, "job_name\": \"job-hello-world") }) + t.Run("SuccessPipelinesClearTaskCache", func(t *testing.T) { cmdOut, cmdErr := executeCommand([]string{ "--output", "json", @@ -272,6 +274,6 @@ func TestPipelines(t *testing.T) { // Note: we expect no diff because the pipeline from helpers.go is the same as the dummy-stack. // This mean if someone change the code from the dummy stack, this test could fail because the helper // pipeline will differ from the one in the dummy stack - require.Contains(t, cmdOut, "jobs\":null") + require.Contains(t, cmdOut, "jobs\": null") }) } diff --git a/e2e/projects_test.go b/e2e/projects_test.go index 10bb76c5..5f7e1c9f 100644 --- a/e2e/projects_test.go +++ b/e2e/projects_test.go @@ -1,11 +1,13 @@ -//+build e2e - +// //go:build e2e +// // +build e2e package e2e import ( + "encoding/json" "fmt" "testing" + "github.com/cycloidio/cycloid-cli/client/models" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -62,10 +64,10 @@ func TestProjects(t *testing.T) { // }) // // assert.Nil(t, cmdErr) - // require.Contains(t, cmdOut, "canonical\":\"dummy") + // require.Contains(t, cmdOut, "canonical\": \"dummy") }) - t.Run("SuccessProjectsCreate", func(t *testing.T) { + t.Run("SuccessLegacyProjectsCreate", func(t *testing.T) { WriteFile("/tmp/test_cli-pp-vars", TestPipelineVariables) WriteFile("/tmp/test_cli-pp", TestPipelineSample) @@ -85,7 +87,7 @@ func TestProjects(t *testing.T) { "create", "--name", "snowy", "--description", "this is a test project", - "--stack-ref", fmt.Sprintf("%s:stack-dummy", CY_TEST_ROOT_ORG), + "--stack-ref", fmt.Sprintf("%s:stack-dummy", CY_TEST_ROOT_ORG), "--config-repo", "project-config", "--env", "test", "--usecase", "default", @@ -95,10 +97,10 @@ func TestProjects(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"snowy") + require.Contains(t, cmdOut, "canonical\": \"snowy") }) - t.Run("SuccessProjectsCreateEnv", func(t *testing.T) { + t.Run("SuccessLegacyProjectsCreateEnv", func(t *testing.T) { WriteFile("/tmp/test_cli-pp-vars", TestPipelineVariables) WriteFile("/tmp/test_cli-pp", TestPipelineSample) @@ -116,7 +118,7 @@ func TestProjects(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"snowy") + require.Contains(t, cmdOut, "canonical\": \"snowy") }) t.Run("SuccessProjectsList", func(t *testing.T) { @@ -128,20 +130,88 @@ func TestProjects(t *testing.T) { }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"snowy") + require.Contains(t, cmdOut, "canonical\": \"snowy") + }) + + t.Run("SuccessProjectsCreateStdin", func(t *testing.T) { + cmdOut, cmdErr := executeCommandWithStdin([]string{ + "--output", "json", + "--org", CY_TEST_ROOT_ORG, + "project", + "create-stackforms-env", + "--project", "snowy", + "--env", "testStackformsStdin", + "--use-case", "default", + "-f", "-", + }, `{ "pipeline": { "config": { "message": "filledFromStdin" } } }`) + + assert.Nil(t, cmdErr) + var data = new(models.Project) + err := json.Unmarshal([]byte(cmdOut), data) + assert.NoError(t, err) + + var found = false + for _, env := range data.Environments { + if *env.Canonical == "testStackformsStdin" { + found = true + } + } + + if !found { + t.Errorf("testStackformsStdin not found in create project output") + } }) - t.Run("SuccessProjectsGet", func(t *testing.T) { + t.Run("SuccessProjectGetConfigAsJSON", func(t *testing.T) { cmdOut, cmdErr := executeCommand([]string{ "--output", "json", "--org", CY_TEST_ROOT_ORG, "project", - "get", + "get-env-config", + "--project", "snowy", + "--env", "testStackformsStdin", + }) + + assert.Nil(t, cmdErr) + require.Contains(t, cmdOut, "message\": \"filledFromStdin") + }) + + t.Run("SuccessProjectsCreateStdin", func(t *testing.T) { + cmdOut, cmdErr := executeCommandWithStdin([]string{ + "--output", "json", + "--org", CY_TEST_ROOT_ORG, + "project", + "create-stackform-env", "--project", "snowy", + "--env", "testStackformsStdin", + "-f", "-", + }, `{ "pipeline": { "config": { "message": "filledFromStdin" } } }`) + + assert.Nil(t, cmdErr) + require.Contains(t, cmdOut, "canonical\": \"snowy") + var data models.Project + err := json.Unmarshal([]byte(cmdOut), &data) + assert.Nil(t, err) + }) + + t.Run("SuccessProjectGetStackformEnvStdin", func(t *testing.T) { + cmdOut, cmdErr := executeCommand([]string{ + "--output", "json", + "--org", CY_TEST_ROOT_ORG, + "project", "get-env-config", + "-p", "snowy", "-e", "testStackformsStdin", }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\":\"snowy") + + // Output should be in json by default + var data = make(map[string]map[string]map[string]any) + err := json.Unmarshal([]byte(cmdOut), &data) + assert.NoError(t, err) + + message, ok := data["pipeline"]["config"]["message"] + assert.True(t, ok) + assert.Equal(t, "filledFromStdin", message) }) t.Run("SuccessProjectsDelete", func(t *testing.T) { @@ -156,4 +226,5 @@ func TestProjects(t *testing.T) { assert.Nil(t, cmdErr) require.Equal(t, "", cmdOut) }) + } diff --git a/e2e/roles_test.go b/e2e/roles_test.go index 634fe84b..1e77ea99 100644 --- a/e2e/roles_test.go +++ b/e2e/roles_test.go @@ -1,4 +1,5 @@ -//+build e2e +//go:build e2e +// +build e2e package e2e @@ -21,7 +22,7 @@ func TestRoles(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "canonical\":\"organization-member") + assert.Contains(t, cmdOut, "canonical\": \"organization-member") }) t.Run("SuccessRolesGet", func(t *testing.T) { @@ -34,6 +35,6 @@ func TestRoles(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "canonical\":\"organization-member") + assert.Contains(t, cmdOut, "canonical\": \"organization-member") }) } diff --git a/e2e/stacks_test.go b/e2e/stacks_test.go index 1a61c08a..5ff5b90b 100644 --- a/e2e/stacks_test.go +++ b/e2e/stacks_test.go @@ -36,7 +36,7 @@ func TestStacks(t *testing.T) { // "--canonical", "magento", // }) // - // require.Contains(t, cmdOut, "canonical\":\"magento") + // require.Contains(t, cmdOut, "canonical\": \"magento") // }) t.Run("SuccessStacksList", func(t *testing.T) { @@ -48,7 +48,7 @@ func TestStacks(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "canonical\":\"stack-dummy") + assert.Contains(t, cmdOut, "canonical\": \"stack-dummy") }) t.Run("SuccessStacksGet", func(t *testing.T) { cmdOut, cmdErr := executeCommand([]string{ @@ -60,7 +60,7 @@ func TestStacks(t *testing.T) { }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "canonical\":\"stack-dummy") + assert.Contains(t, cmdOut, "canonical\": \"stack-dummy") }) t.Run("SuccessStacksValidateForm", func(t *testing.T) { diff --git a/printer/json/printer_test.go b/printer/json/printer_test.go index d17032f4..5341b93d 100644 --- a/printer/json/printer_test.go +++ b/printer/json/printer_test.go @@ -25,11 +25,19 @@ func TestJSONPrinter(t *testing.T) { C: []string{"abc", "def"}, } ) - exp := `{"a":"value a","b":"value b","c":["abc","def"]}` + exp := `{ + "a": "value a", + "b": "value b", + "c": [ + "abc", + "def" + ] +} +` err := j.Print(obj, printer.Options{}, &b) require.NoError(t, err) - assert.Equal(t, b.String(), exp) + assert.Equal(t, exp, b.String()) }) From a31d8a0e7436404fd02b08693d81ca65bd045cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:03:03 +0200 Subject: [PATCH 35/98] tests(helpers): add tests for UpdateMapField --- cmd/cycloid/common/helpers.go | 1 + cmd/cycloid/common/helpers_test.go | 46 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index 36e34f7f..f308aae5 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -177,6 +177,7 @@ func (a *APIClient) Credentials(org *string) runtime.ClientAuthInfoWriter { return nil } } + return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error { r.SetHeaderParam("Authorization", "Bearer "+token) return nil diff --git a/cmd/cycloid/common/helpers_test.go b/cmd/cycloid/common/helpers_test.go index d5dadac6..ad811fa3 100644 --- a/cmd/cycloid/common/helpers_test.go +++ b/cmd/cycloid/common/helpers_test.go @@ -39,3 +39,49 @@ func TestGenerateCanonical(t *testing.T) { assert.Equal(t, input.Canonical, common.GenerateCanonical(input.Name)) } } + +func TestUpdateMapField(t *testing.T) { + inputs := []struct { + Field string + Value any + Base map[string]any + Expected map[string]any + }{ + { + Field: "test", + Value: "value", + Base: make(map[string]any), + Expected: map[string]any{ + "test": "value", + }, + }, + { + Field: "test.nested.value", + Value: "hello", + Base: make(map[string]any), + Expected: map[string]any{ + "test": map[string]any{ + "nested": map[string]any{ + "value": "hello", + }, + }, + }, + }, + { + Field: "changed", + Value: "yes", + Base: map[string]any{ + "changed": "notChanged", + }, + Expected: map[string]any{ + "changed": "yes", + }, + }, + } + + for _, input := range inputs { + err := common.UpdateMapField(input.Field, input.Value, input.Base) + assert.Nil(t, err) + assert.Equal(t, input.Expected, input.Base) + } +} From 80f5bb24a79a4e3162b01346f47c03aac3d1d814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:03:40 +0200 Subject: [PATCH 36/98] misc: cleanup legacy param methods in project --- cmd/cycloid/middleware/project.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/cycloid/middleware/project.go b/cmd/cycloid/middleware/project.go index 47b380a2..d6f13f9d 100644 --- a/cmd/cycloid/middleware/project.go +++ b/cmd/cycloid/middleware/project.go @@ -57,7 +57,6 @@ func (m *middleware) GetProjectConfig(org string, project string, env string) (* params.WithOrganizationCanonical(org) params.WithProjectCanonical(project) params.WithEnvironmentCanonical(env) - params.SetContext(nil) resp, err := m.api.OrganizationProjects.GetProjectConfig(params, m.api.Credentials(&org)) if err != nil { @@ -143,8 +142,8 @@ func (m *middleware) CreateProject(org, projectName, projectCanonical, env, pipe func (m *middleware) UpdateProject(org, projectName, projectCanonical string, envs []*models.NewEnvironment, description, stackRef, owner, configRepo string, inputs []*models.FormInput, updatedAt uint64) (*models.Project, error) { params := organization_projects.NewUpdateProjectParams() - params.SetOrganizationCanonical(org) - params.SetProjectCanonical(projectCanonical) + params.WithOrganizationCanonical(org) + params.WithProjectCanonical(projectCanonical) body := &models.UpdateProject{ Name: &projectName, From e607b689d54bdfe9ea82f162d228f62f095d1cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:04:00 +0200 Subject: [PATCH 37/98] misc: replace legacy ReadFile method --- cmd/cycloid/middleware/infra-policies.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/cycloid/middleware/infra-policies.go b/cmd/cycloid/middleware/infra-policies.go index 72ca854f..58fa2a10 100644 --- a/cmd/cycloid/middleware/infra-policies.go +++ b/cmd/cycloid/middleware/infra-policies.go @@ -2,7 +2,7 @@ package middleware import ( "fmt" - "io/ioutil" + "os" "github.com/cycloidio/cycloid-cli/client/client/organization_infrastructure_policies" "github.com/cycloidio/cycloid-cli/client/models" @@ -44,7 +44,7 @@ func (m *middleware) CreateInfraPolicy(org, policyFile, policyCanonical, descrip params := organization_infrastructure_policies.NewCreateInfraPolicyParams() params.SetOrganizationCanonical(org) // Reads file content and converts it into string - policyFileContent, err := ioutil.ReadFile(policyFile) + policyFileContent, err := os.ReadFile(policyFile) if err != nil { return nil, fmt.Errorf("Unable to read rego file: %v", err) } @@ -151,7 +151,7 @@ func (m *middleware) UpdateInfraPolicy(org, infraPolicy, policyFile, description params.SetInfraPolicyCanonical(infraPolicy) // Reads file content and converts it into string - policyFileContent, err := ioutil.ReadFile(policyFile) + policyFileContent, err := os.ReadFile(policyFile) if err != nil { return nil, fmt.Errorf("Unable to read rego file: %v", err) } From dcb09687a6d7cd9b464f11a9463382d194d6b3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:05:14 +0200 Subject: [PATCH 38/98] func(tests): add basic tests for create-env with stackforms --- e2e/projects_test.go | 67 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/e2e/projects_test.go b/e2e/projects_test.go index 5f7e1c9f..dbbfa172 100644 --- a/e2e/projects_test.go +++ b/e2e/projects_test.go @@ -133,59 +133,58 @@ func TestProjects(t *testing.T) { require.Contains(t, cmdOut, "canonical\": \"snowy") }) - t.Run("SuccessProjectsCreateStdin", func(t *testing.T) { - cmdOut, cmdErr := executeCommandWithStdin([]string{ + // Vars + t.Run("SuccessProjectsCreateVars", func(t *testing.T) { + cmdOut, cmdErr := executeCommand([]string{ "--output", "json", "--org", CY_TEST_ROOT_ORG, "project", "create-stackforms-env", "--project", "snowy", - "--env", "testStackformsStdin", + "--env", "sf-vars", "--use-case", "default", - "-f", "-", - }, `{ "pipeline": { "config": { "message": "filledFromStdin" } } }`) + "-V", `{"pipeline": {"config": {"message": "filledFromVars"}}}`, + }) assert.Nil(t, cmdErr) - var data = new(models.Project) - err := json.Unmarshal([]byte(cmdOut), data) - assert.NoError(t, err) - - var found = false - for _, env := range data.Environments { - if *env.Canonical == "testStackformsStdin" { - found = true - } - } - - if !found { - t.Errorf("testStackformsStdin not found in create project output") - } + require.Contains(t, cmdOut, "canonical\": \"snowy") + var data models.Project + err := json.Unmarshal([]byte(cmdOut), &data) + assert.Nil(t, err) }) - t.Run("SuccessProjectGetConfigAsJSON", func(t *testing.T) { + t.Run("SuccessProjectGetStackformConfigVars", func(t *testing.T) { cmdOut, cmdErr := executeCommand([]string{ "--output", "json", "--org", CY_TEST_ROOT_ORG, - "project", - "get-env-config", - "--project", "snowy", - "--env", "testStackformsStdin", + "project", "get-env-config", + "-p", "snowy", "-e", "sf-vars", }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "message\": \"filledFromStdin") + + // Output should be in json by default + var data = make(map[string]map[string]map[string]any) + err := json.Unmarshal([]byte(cmdOut), &data) + assert.NoError(t, err) + + message, ok := data["pipeline"]["config"]["message"] + assert.True(t, ok) + assert.Equal(t, "filledFromVars", message) }) - t.Run("SuccessProjectsCreateStdin", func(t *testing.T) { - cmdOut, cmdErr := executeCommandWithStdin([]string{ + // Extra vars + t.Run("SuccessProjectsCreateExtraVars", func(t *testing.T) { + cmdOut, cmdErr := executeCommand([]string{ "--output", "json", "--org", CY_TEST_ROOT_ORG, "project", - "create-stackform-env", + "create-stackforms-env", "--project", "snowy", - "--env", "testStackformsStdin", - "-f", "-", - }, `{ "pipeline": { "config": { "message": "filledFromStdin" } } }`) + "--env", "sf-extra-vars", + "--use-case", "default", + "-x", `pipeline.config.message=filledFromExtraVars`, + }) assert.Nil(t, cmdErr) require.Contains(t, cmdOut, "canonical\": \"snowy") @@ -194,12 +193,12 @@ func TestProjects(t *testing.T) { assert.Nil(t, err) }) - t.Run("SuccessProjectGetStackformEnvStdin", func(t *testing.T) { + t.Run("SuccessProjectGetStackformConfigExtraVars", func(t *testing.T) { cmdOut, cmdErr := executeCommand([]string{ "--output", "json", "--org", CY_TEST_ROOT_ORG, "project", "get-env-config", - "-p", "snowy", "-e", "testStackformsStdin", + "-p", "snowy", "-e", "sf-extra-vars", }) assert.Nil(t, cmdErr) @@ -211,7 +210,7 @@ func TestProjects(t *testing.T) { message, ok := data["pipeline"]["config"]["message"] assert.True(t, ok) - assert.Equal(t, "filledFromStdin", message) + assert.Equal(t, "filledFromExtraVars", message) }) t.Run("SuccessProjectsDelete", func(t *testing.T) { From ad0fce0981f1d012acd750663fc5389337fd0b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:05:38 +0200 Subject: [PATCH 39/98] misc: update nix flakes for go 1.22 --- flake.lock | 16 ++++++++++------ flake.nix | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 79a8d67f..6e1b61b0 100644 --- a/flake.lock +++ b/flake.lock @@ -20,14 +20,18 @@ }, "nixpkgs": { "locked": { - "lastModified": 1696748673, - "narHash": "sha256-UbPHrH4dKN/66EpfFpoG4St4XZYDX9YcMVRQGWzAUNA=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" + "lastModified": 1717786204, + "narHash": "sha256-4q0s6m0GUcN7q+Y2DqD27iLvbcd1G50T2lv08kKxkSI=", + "owner": "NixOs", + "repo": "nixpkgs", + "rev": "051f920625ab5aabe37c920346e3e69d7d34400e", + "type": "github" }, "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" + "owner": "NixOs", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index 2ddc8f62..6607a828 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "A basic dev shell for nix users"; inputs = { - nixpkgs = { url = "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz"; }; + nixpkgs = { url = "github:NixOs/nixpkgs/nixos-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; }; @@ -22,8 +22,8 @@ # You packages here gnumake - # Prod is built using go 1.18 rn - go_1_18 + go_1_22 + go-swagger ]); }; }); From 419eb5b3c4cfcbc0ddf83ca74c383a2c3f07af78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:07:42 +0200 Subject: [PATCH 40/98] fix(create-env): update flags and add some validations --- cmd/cycloid/projects/create-env.go | 56 ++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 93f6e66f..9c10ff96 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -27,10 +27,10 @@ func NewCreateEnvCommand() *cobra.Command { Long: ` You can provide stackforms variables via files, env var and the --vars flag The precedence order for variable provisioning is as follows: -- --var-file flag +- --var-file (-f) flag - env vars CY_STACKFORMS_VAR -- --vars flag -- --extra-var (-e) flag +- --vars (-V) flag +- --extra-var (-x) flag --vars accept json encoded values. @@ -40,13 +40,12 @@ The output will be the generated configuration of the project. `, Example: ` # create 'prod' environment in 'my-project' - cy --org my-org project create-stackforms-env \ +cy --org my-org project create-stackforms-env \ --project my-project \ --env prod \ --use-case usecase-1 \ --var-file vars.yml \ - --vars '{"myRaw": "vars"}' -`, + --vars '{"myRaw": "vars"}'`, PreRunE: func(cmd *cobra.Command, args []string) error { internal.Warning(cmd.ErrOrStderr(), "This command will replace `cy project create-env` soon.\n"+ @@ -57,15 +56,18 @@ The output will be the generated configuration of the project. RunE: createEnv, } - common.RequiredPersistentFlag(common.WithFlagProject, cmd) - common.RequiredPersistentFlag(common.WithFlagEnv, cmd) - WithFlagConfig(cmd) - cmd.PersistentFlags().String("use-case", "", "the selected use case of the stack") + common.WithFlagOrg(cmd) + cmd.PersistentFlags().StringP("project", "p", "", "the selected project") + cmd.MarkFlagRequired("project") + cmd.PersistentFlags().StringP("use-case", "u", "", "the selected use case of the stack") cmd.MarkFlagRequired("use-case") - cmd.PersistentFlags().StringArrayP("var-file", "f", nil, "path to a JSON file containing variables, can be '-' for stdin") - cmd.PersistentFlags().StringArray("vars", nil, "JSON string containing variables") - cmd.PersistentFlags().BoolP("update", "u", false, "if true, existing environment will be updated, default: false") - cmd.PersistentFlags().StringToStringP("extra-var", "e", nil, "extra variable to be added to the environment in the -e key=value -e key=value format") + cmd.PersistentFlags().StringP("env", "e", "", "the environment name of the stack") + cmd.MarkFlagRequired("env") + cmd.PersistentFlags().StringArrayP("var-file", "f", nil, "path to a JSON file containing variables, can be '-' for stdin, can be set multiple times.") + cmd.PersistentFlags().StringArrayP("vars", "V", nil, "JSON string containing variables, can be set multiple times.") + cmd.PersistentFlags().StringToStringP("extra-var", "x", nil, "extra variable to be added to the environment in the -e key=value -e key=value format") + cmd.PersistentFlags().Bool("update", false, "Allow to override existing environment") + cmd.Flags().SortFlags = false return cmd } @@ -81,21 +83,40 @@ func createEnv(cmd *cobra.Command, args []string) error { return err } + // Right now, in the way orgs are handled, there is a possibility + // of an empty org. + // TODO: Fix in another PR about orgs. + if org == "" { + return errors.New("org is empty, please specify an org with --org") + } + project, err := cmd.Flags().GetString("project") if err != nil { return err } + if len(project) < 2 { + return errors.New("project must be at least 2 characters long") + } + env, err := cmd.Flags().GetString("env") if err != nil { return err } + if len(env) < 2 { + return errors.New("env must be at least 2 characters long") + } + usecase, err := cmd.Flags().GetString("use-case") if err != nil { return err } + if usecase == "" { + return errors.New("use-case is empty, please specify an use-case with --use-case") + } + update, err := cmd.Flags().GetBool("update") if err != nil { return err @@ -211,8 +232,6 @@ func createEnv(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get printer") } - // need to conver the environment to "new environment" as required - // by the API envs := make([]*models.NewEnvironment, len(projectData.Environments)) for i, e := range projectData.Environments { @@ -247,6 +266,7 @@ func createEnv(cmd *cobra.Command, args []string) error { } } + // Infer icon and color based on usecase var cloudProviderCanonical, icon, color string switch strings.ToLower(usecase) { case "aws": @@ -254,7 +274,7 @@ func createEnv(cmd *cobra.Command, args []string) error { icon = "mdi-aws" color = "staging" case "azure": - cloudProviderCanonical = "azure" + cloudProviderCanonical = "azurerm" icon = "mdi-azure" color = "prod" case "gcp": @@ -284,8 +304,6 @@ func createEnv(cmd *cobra.Command, args []string) error { }, } - _, _ = m.CreateFormsConfig(org, project, *projectData.ServiceCatalog.Ref, inputs) - // Send the updateProject call // TODO: Add support for resource pool canonical in case of resource quotas resp, err := m.UpdateProject(org, From d0a9f529b155ef41956aec2b5c442863e952d09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:08:10 +0200 Subject: [PATCH 41/98] misc: update legacy code --- cmd/cycloid/stacks/validate-form.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/cycloid/stacks/validate-form.go b/cmd/cycloid/stacks/validate-form.go index ad6814f8..6f88d7be 100644 --- a/cmd/cycloid/stacks/validate-form.go +++ b/cmd/cycloid/stacks/validate-form.go @@ -1,7 +1,7 @@ package stacks import ( - "io/ioutil" + "os" "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" @@ -48,7 +48,7 @@ func validateForm(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get output flag") } - rawForms, err := ioutil.ReadFile(formPath) + rawForms, err := os.ReadFile(formPath) if err != nil { return errors.Wrap(err, "unable to read the form file") } From 286a0b1757f5c7e77f133f001eca5661eb131be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:08:18 +0200 Subject: [PATCH 42/98] fix(tests): fix expectation with new json printer --- e2e/stacks_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/stacks_test.go b/e2e/stacks_test.go index 5ff5b90b..0265ca4f 100644 --- a/e2e/stacks_test.go +++ b/e2e/stacks_test.go @@ -88,6 +88,6 @@ default: }) require.Nil(t, cmdErr) - assert.Contains(t, cmdOut, "errors\":[]") + assert.Contains(t, cmdOut, "errors\": []") }) } From e2bf01e44f613d9f96a7a8ef1e0c8c90d9191aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 12:18:59 +0200 Subject: [PATCH 43/98] misc: add more review changes --- cmd/cycloid/projects/create-env.go | 7 +++---- .../projects/get-stackforms-config-from-env.go | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 9c10ff96..5a44c3ff 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io" - "log" "os" "strings" @@ -170,7 +169,7 @@ func createEnv(cmd *cobra.Command, args []string) error { } if err := mergo.Merge(&vars, extractedVars, mergo.WithOverride); err != nil { - log.Fatalf("failed to merge input vars from "+varFile+": %v", err) + return fmt.Errorf("failed to merge input vars from "+varFile+": %v", err) } } } @@ -188,7 +187,7 @@ func createEnv(cmd *cobra.Command, args []string) error { } if err := mergo.Merge(&vars, envVars, mergo.WithOverride); err != nil { - log.Fatalf("failed to merge input vars from environment: %v", err) + return fmt.Errorf("failed to merge input vars from environment: %v", err) } } @@ -207,7 +206,7 @@ func createEnv(cmd *cobra.Command, args []string) error { } if err := mergo.Merge(&vars, extractedVars, mergo.WithOverride); err != nil { - log.Fatalf("failed to merge input vars from environment: %v", err) + return fmt.Errorf("failed to merge input vars from environment: %v", err) } } diff --git a/cmd/cycloid/projects/get-stackforms-config-from-env.go b/cmd/cycloid/projects/get-stackforms-config-from-env.go index deee50b5..e5364fe8 100644 --- a/cmd/cycloid/projects/get-stackforms-config-from-env.go +++ b/cmd/cycloid/projects/get-stackforms-config-from-env.go @@ -34,7 +34,7 @@ The output object will be the same format required as input for 'cy project crea The values are generated as following: - First we get the current env value if exists (unless you set --default) -- I no current value is present, we get the default +- If no current value is present, we get the default - If no default is set, we set a zeroed value in the correct type: ("", 0, [], {}) `, Example: ` @@ -52,7 +52,7 @@ cy --org my-org project get-env-config my-project my-project use_case -o yaml common.WithFlagOrg(cmd) cmd.Flags().StringP("project", "p", "", "specify the project") cmd.Flags().StringP("env", "e", "", "specify the env") - cmd.Flags().BoolP("default-values", "d", false, "if set, will fetch the default value from the stack instead of the current ones.") + cmd.Flags().BoolP("default", "d", false, "if set, will fetch the default value from the stack instead of the current ones.") // This will display flag in the order declared above cmd.Flags().SortFlags = false @@ -76,7 +76,7 @@ func getStackFormsConfigFromEnv(cmd *cobra.Command, args []string) error { return fmt.Errorf("missing use case argument") } - getDefault, err := cmd.Flags().GetBool("default-values") + getDefault, err := cmd.Flags().GetBool("default") if err != nil { return err } @@ -108,14 +108,13 @@ func getStackFormsConfigFromEnv(cmd *cobra.Command, args []string) error { } resp, err := m.GetProjectConfig(org, project, env) - if err != nil || resp == nil { + if err != nil { return printer.SmartPrint(p, nil, err, fmt.Sprint("failed to fetch project '", project, "' config for env '", env, "' in org '", org, "'"), printer.Options{}, cmd.OutOrStderr()) } formData, err := common.ParseFormsConfig(resp, *resp.UseCase, !getDefault) if err != nil { - fmt.Println("failed to parse config data") - return printer.SmartPrint(p, nil, err, "failed to get stack config", printer.Options{}, cmd.OutOrStdout()) + return printer.SmartPrint(p, nil, err, "failed to get stack config, parsing failed.", printer.Options{}, cmd.OutOrStdout()) } return printer.SmartPrint(p, formData, err, "failed to get stack config", printer.Options{}, cmd.OutOrStdout()) From 807e8d02b85b8335ed6915db648c988e7c5dca3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:37:53 +0200 Subject: [PATCH 44/98] misc: add nixos dev env shinanigan --- flake.lock | 16 ++++++---------- flake.nix | 6 +++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index 6e1b61b0..79a8d67f 100644 --- a/flake.lock +++ b/flake.lock @@ -20,18 +20,14 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717786204, - "narHash": "sha256-4q0s6m0GUcN7q+Y2DqD27iLvbcd1G50T2lv08kKxkSI=", - "owner": "NixOs", - "repo": "nixpkgs", - "rev": "051f920625ab5aabe37c920346e3e69d7d34400e", - "type": "github" + "lastModified": 1696748673, + "narHash": "sha256-UbPHrH4dKN/66EpfFpoG4St4XZYDX9YcMVRQGWzAUNA=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" }, "original": { - "owner": "NixOs", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" } }, "root": { diff --git a/flake.nix b/flake.nix index 6607a828..2ddc8f62 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "A basic dev shell for nix users"; inputs = { - nixpkgs = { url = "github:NixOs/nixpkgs/nixos-unstable"; }; + nixpkgs = { url = "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz"; }; flake-utils = { url = "github:numtide/flake-utils"; }; }; @@ -22,8 +22,8 @@ # You packages here gnumake - go_1_22 - go-swagger + # Prod is built using go 1.18 rn + go_1_18 ]); }; }); From a0204309d8a6c1c663564b2c0cc4b6a912267201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 6 Jun 2024 16:25:24 +0200 Subject: [PATCH 45/98] func: update go version to 1.21 --- Makefile | 15 ++++++++------- go.mod | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 22b6c9be..3a2bacdf 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ REVISION ?= $(shell git rev-parse --short HEAD 2> /dev/null || echo 'unknow BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown') BUILD_ORIGIN ?= $(USER)@$(shell hostname -f) BUILD_DATE ?= $(shell date --utc -Iseconds) +DOCKER_COMPOSE ?= $(shell docker compose --help >/dev/null 2>&1 && echo "docker compose" || echo "docker-compose") # GO # Setup the -ldflags build option for go here, interpolate the variable values @@ -62,7 +63,7 @@ SWAGGER_GENERATE = swagger generate client \ SWAGGER_DOCKER_GENERATE = rm -rf ./client; \ mkdir ./client; \ - docker-compose run $(SWAGGER_COMMAND) + $(DOCKER_COMPOSE) run $(SWAGGER_COMMAND) # E2E tests CY_API_URL ?= http://127.0.0.1:3001 @@ -79,7 +80,7 @@ AWS_ACCOUNT_ID ?= $(shell vault read -field=account_id secret/cycloid/aws # Local BE LOCAL_BE_GIT_PATH ?= ../youdeploy-http-api YD_API_TAG ?= staging -API_LICENCE_KEY ?= +API_LICENCE_KEY ?= .PHONY: help help: ## Show this help @@ -110,7 +111,7 @@ generate-client: ## Generate client from file at SWAGGER_FILE path .PHONY: generate-client-from-local generate-client-from-local: reset-old-client ## Generates client using docker and local swagger (version -> v0.0-dev) - docker-compose run $(SWAGGER_GENERATE) + $(DOCKER_COMPOSE) run $(SWAGGER_GENERATE) echo 'v0.0-dev' > client/version .PHONY: generate-client-from-docs @@ -118,7 +119,7 @@ generate-client-from-docs: reset-old-client ## Generates client using docker and @wget https://docs.cycloid.io/api/swagger.yml @export SWAGGER_VERSION=$$(python -c 'import yaml, sys; y = yaml.safe_load(sys.stdin); print(y["info"]["version"])' < swagger.yml); \ if [ -z "$$SWAGGER_VERSION" ]; then echo "Unable to read version from swagger"; exit 1; fi; \ - docker-compose run $(SWAGGER_GENERATE) && \ + $(DOCKER_COMPOSE) run $(SWAGGER_GENERATE) && \ echo $$SWAGGER_VERSION > client/version; \ echo "Please run the following git commands:"; \ echo "git add client" && \ @@ -136,10 +137,10 @@ start-local-be: ## Starts local BE instance. Note! Only for cycloid developers @echo "Generating fake data to be used in the tests..." @cd $(LOCAL_BE_GIT_PATH) && sed -i '/cost-explorer-es/d' config.yml @cd $(LOCAL_BE_GIT_PATH) && YD_API_TAG=${YD_API_TAG} API_LICENCE_KEY=${API_LICENCE_KEY} \ - docker-compose -f docker-compose.yml -f docker-compose.cli.yml up youdeploy-init + $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE).yml -f $(DOCKER_COMPOSE).cli.yml up youdeploy-init @echo "Running BE server with the fake data generated..." @cd $(LOCAL_BE_GIT_PATH) && YD_API_TAG=${YD_API_TAG} API_LICENCE_KEY=${API_LICENCE_KEY} \ - docker-compose -f docker-compose.yml -f docker-compose.cli.yml up -d youdeploy-api + $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE).yml -f $(DOCKER_COMPOSE).cli.yml up -d youdeploy-api .PHONY: local-e2e-test local-e2e-test: ## Launches local e2e tests. Note! Only for cycloid developers @@ -152,7 +153,7 @@ local-e2e-test: ## Launches local e2e tests. Note! Only for cycloid developers delete-local-be: ## Creates local BE instance and starts e2e tests. Note! Only for cycloid developers @if [ ! -d ${LOCAL_BE_GIT_PATH} ]; then echo "Unable to find BE at LOCAL_BE_GIT_PATH"; exit 1; fi; @echo "Deleting local BE instances !" - @cd $(LOCAL_BE_GIT_PATH) && docker-compose down -v --remove-orphans + @cd $(LOCAL_BE_GIT_PATH) && $(DOCKER_COMPOSE) down -v --remove-orphans .PHONY: new-changelog-entry new-changelog-entry: ## Create a new entry for unreleased element diff --git a/go.mod b/go.mod index 30f08713..8ac13551 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cycloidio/cycloid-cli -go 1.22 +go 1.21 require ( dario.cat/mergo v1.0.0 From d7187a12c2e83c9d6ad38f240cefa427522cbeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 6 Jun 2024 16:27:15 +0200 Subject: [PATCH 46/98] misc: add changelog --- changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml diff --git a/changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml b/changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml new file mode 100644 index 00000000..d874f2e7 --- /dev/null +++ b/changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml @@ -0,0 +1,8 @@ +component: CLI +kind: INTERNAL +body: Update go version to 1.21 +time: 2024-06-06T14:27:03.879461344Z +custom: + DETAILS: "" + PR: "272" + TYPE: CLI From 2981a9ab55d0eaf5328814339e5ada87fcd263ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 6 Jun 2024 16:28:59 +0200 Subject: [PATCH 47/98] misc: fix docker compose file ref --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3a2bacdf..60d421a3 100644 --- a/Makefile +++ b/Makefile @@ -137,10 +137,10 @@ start-local-be: ## Starts local BE instance. Note! Only for cycloid developers @echo "Generating fake data to be used in the tests..." @cd $(LOCAL_BE_GIT_PATH) && sed -i '/cost-explorer-es/d' config.yml @cd $(LOCAL_BE_GIT_PATH) && YD_API_TAG=${YD_API_TAG} API_LICENCE_KEY=${API_LICENCE_KEY} \ - $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE).yml -f $(DOCKER_COMPOSE).cli.yml up youdeploy-init + $(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.cli.yml up youdeploy-init @echo "Running BE server with the fake data generated..." @cd $(LOCAL_BE_GIT_PATH) && YD_API_TAG=${YD_API_TAG} API_LICENCE_KEY=${API_LICENCE_KEY} \ - $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE).yml -f $(DOCKER_COMPOSE).cli.yml up -d youdeploy-api + $(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.cli.yml up -d youdeploy-api .PHONY: local-e2e-test local-e2e-test: ## Launches local e2e tests. Note! Only for cycloid developers From cbd2915e57df83860a61123c6e40e0b97f8af37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 6 Jun 2024 16:29:34 +0200 Subject: [PATCH 48/98] misc: update devshell --- flake.lock | 16 ++++++++++------ flake.nix | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 79a8d67f..299b984e 100644 --- a/flake.lock +++ b/flake.lock @@ -20,14 +20,18 @@ }, "nixpkgs": { "locked": { - "lastModified": 1696748673, - "narHash": "sha256-UbPHrH4dKN/66EpfFpoG4St4XZYDX9YcMVRQGWzAUNA=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" + "lastModified": 1717196966, + "narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=", + "owner": "NixOs", + "repo": "nixpkgs", + "rev": "57610d2f8f0937f39dbd72251e9614b1561942d8", + "type": "github" }, "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" + "owner": "NixOs", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index 2ddc8f62..e1c78017 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,8 @@ { - description = "A basic dev shell for nix users"; + description = "A basic dev shell for nix/nixos users"; inputs = { - nixpkgs = { url = "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz"; }; + nixpkgs = { url = "github:NixOs/nixpkgs/nixos-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; }; @@ -23,7 +23,9 @@ gnumake # Prod is built using go 1.18 rn - go_1_18 + go_1_21 + + go-swagger ]); }; }); From 44eada1aea8c1151203ad8fbf12cddb19475586f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Mon, 10 Jun 2024 10:41:53 +0200 Subject: [PATCH 49/98] misc: add condition on direnv --- .envrc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.envrc b/.envrc index bbc2d75f..874cb16f 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1,4 @@ -watch_file flake.nix -use flake . -Lv --log-format raw +if has nix; then + watch_file flake.nix + use flake . -Lv --log-format raw +fi From 1cabe9e11faa5990e54b7219276ca4b908c34c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 10:33:06 +0200 Subject: [PATCH 50/98] func: bump go version to 1.22.4 --- docker-compose.yml | 2 +- flake.nix | 4 +--- go.mod | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c93e7b19..8a70bca4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: ############ yd-go: container_name: yd-go - image: cycloid/golang:1.14.4-r2 + image: cycloid/golang:1.22.4 volumes: - .:/go/src/github.com/cycloidio/cycloid-cli - $GOPATH/pkg/mod:/go/pkg/mod diff --git a/flake.nix b/flake.nix index e1c78017..13b31a19 100644 --- a/flake.nix +++ b/flake.nix @@ -22,9 +22,7 @@ # You packages here gnumake - # Prod is built using go 1.18 rn - go_1_21 - + go_1_22 go-swagger ]); }; diff --git a/go.mod b/go.mod index 8ac13551..30f08713 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cycloidio/cycloid-cli -go 1.21 +go 1.22 require ( dario.cat/mergo v1.0.0 From fc3a30cb3f173d4bcc89a26ae253bb520d1b43a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:38:54 +0200 Subject: [PATCH 51/98] misc: fix deprecated code --- cmd/cycloid/common/helpers.go | 4 ++-- e2e/helpers.go | 20 -------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index f308aae5..a0295dd9 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -106,7 +106,7 @@ func WithToken(t string) APIOptions { } type APIClient struct { - *client.API + *client.APIClient Config APIConfig } @@ -148,7 +148,7 @@ func NewAPI(opts ...APIOptions) *APIClient { // tr.DefaultAuthentication = httptransport.BearerToken("token") // api.SetTransport(tr) return &APIClient{ - API: api, + APIClient: api, Config: acfg, } diff --git a/e2e/helpers.go b/e2e/helpers.go index 8f725d49..dfd4801c 100644 --- a/e2e/helpers.go +++ b/e2e/helpers.go @@ -7,7 +7,6 @@ import ( "io" "os" "regexp" - "strings" "time" rootCmd "github.com/cycloidio/cycloid-cli/cmd" @@ -98,25 +97,6 @@ func executeCommand(args []string) (string, error) { return string(cmdOut), cmdErr } -func executeCommandWithStdin(args []string, stdin string) (string, error) { - cmd := rootCmd.NewRootCommand() - - buf := new(bytes.Buffer) - errBuf := new(bytes.Buffer) - cmd.SetOut(buf) - cmd.SetErr(errBuf) - - cmd.SetArgs(args) - cmd.SetIn(strings.NewReader(stdin)) - - cmdErr := cmd.Execute() - cmdOut, err := io.ReadAll(buf) - if err != nil { - panic(fmt.Sprintf("Unable to read command output buffer")) - } - return string(cmdOut), cmdErr -} - // AddNowTimestamp add a timestamp suffix to a string func AddNowTimestamp(txt string) string { return fmt.Sprintf(txt, NowTimestamp) From 8b9ba1ce6a2ca1076a543111fed7bbef1568f186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:39:55 +0200 Subject: [PATCH 52/98] func: update generated client with 0.31.0 go-swagger --- .../organization_projects_client.go | 40 ------------------- client/version | 1 + 2 files changed, 1 insertion(+), 40 deletions(-) create mode 100644 client/version diff --git a/client/client/organization_projects/organization_projects_client.go b/client/client/organization_projects/organization_projects_client.go index 5ace38d1..b0e0b22f 100644 --- a/client/client/organization_projects/organization_projects_client.go +++ b/client/client/organization_projects/organization_projects_client.go @@ -115,8 +115,6 @@ type ClientService interface { GetProject(params *GetProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectOK, error) - GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectConfigOK, error) - GetProjects(params *GetProjectsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectsOK, error) UpdateProject(params *UpdateProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateProjectOK, error) @@ -352,44 +350,6 @@ func (a *Client) GetProject(params *GetProjectParams, authInfo runtime.ClientAut return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } -/* -GetProjectConfig Fetch the current project's environment's configuration. -*/ -func (a *Client) GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectConfigOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetProjectConfigParams() - } - op := &runtime.ClientOperation{ - ID: "getProjectConfig", - Method: "GET", - PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/vnd.cycloid.io.v1+json", "application/x-www-form-urlencoded"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetProjectConfigReader{formats: a.formats}, - AuthInfo: authInfo, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetProjectConfigOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*GetProjectConfigDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - /* GetProjects Get list of projects of the organization. */ diff --git a/client/version b/client/version new file mode 100644 index 00000000..f40ebcb9 --- /dev/null +++ b/client/version @@ -0,0 +1 @@ +v5.0.40-saas From 214364e6f8a375aa0eb47a1c5908be41485e5fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 10:43:00 +0200 Subject: [PATCH 53/98] func: update go-swagger to 0.31.0 --- docker-compose.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8a70bca4..b9e5a7d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,4 @@ -version: '3' services: - ############ - # - # Tools - # - ############ yd-go: container_name: yd-go image: cycloid/golang:1.22.4 @@ -15,7 +9,7 @@ services: swagger: container_name: yd-swagger - image: quay.io/goswagger/swagger:v0.21.0 + image: quay.io/goswagger/swagger:v0.31.0 environment: - GOPATH=/go volumes: From a7fcecfb55d4befd061e6d06de06d53e36c394c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 10:43:26 +0200 Subject: [PATCH 54/98] breaking: update APIClient struct api type --- cmd/cycloid/common/helpers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index a0295dd9..f308aae5 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -106,7 +106,7 @@ func WithToken(t string) APIOptions { } type APIClient struct { - *client.APIClient + *client.API Config APIConfig } @@ -148,7 +148,7 @@ func NewAPI(opts ...APIOptions) *APIClient { // tr.DefaultAuthentication = httptransport.BearerToken("token") // api.SetTransport(tr) return &APIClient{ - APIClient: api, + API: api, Config: acfg, } From bae9d4c9ed79155836176515b71c810028efe393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 10:47:51 +0200 Subject: [PATCH 55/98] [ci skip]: add changelog --- changelog/unreleased/CLI-BREAKING-20240611-084737.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 changelog/unreleased/CLI-BREAKING-20240611-084737.yaml diff --git a/changelog/unreleased/CLI-BREAKING-20240611-084737.yaml b/changelog/unreleased/CLI-BREAKING-20240611-084737.yaml new file mode 100644 index 00000000..1fa30cd7 --- /dev/null +++ b/changelog/unreleased/CLI-BREAKING-20240611-084737.yaml @@ -0,0 +1,8 @@ +component: CLI +kind: BREAKING +body: Update go to 1.22.4 and go-swagger to 0.31.0 +time: 2024-06-11T08:47:37.363357202Z +custom: + DETAILS: "" + PR: "272" + TYPE: CLI From 0039595b7e91bffec7f21490bc5fa7d2080685e7 Mon Sep 17 00:00:00 2001 From: fhacloid <148750436+fhacloid@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:12:59 +0200 Subject: [PATCH 56/98] Delete changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml --- changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml diff --git a/changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml b/changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml deleted file mode 100644 index d874f2e7..00000000 --- a/changelog/unreleased/CLI-INTERNAL-20240606-142703.yaml +++ /dev/null @@ -1,8 +0,0 @@ -component: CLI -kind: INTERNAL -body: Update go version to 1.21 -time: 2024-06-06T14:27:03.879461344Z -custom: - DETAILS: "" - PR: "272" - TYPE: CLI From f9cabd3395d62b10e128fb8747bdae21b87c55fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 13:20:02 +0200 Subject: [PATCH 57/98] fix: add missed generated route from client --- .../organization_projects_client.go | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/client/client/organization_projects/organization_projects_client.go b/client/client/organization_projects/organization_projects_client.go index b0e0b22f..5ace38d1 100644 --- a/client/client/organization_projects/organization_projects_client.go +++ b/client/client/organization_projects/organization_projects_client.go @@ -115,6 +115,8 @@ type ClientService interface { GetProject(params *GetProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectOK, error) + GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectConfigOK, error) + GetProjects(params *GetProjectsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectsOK, error) UpdateProject(params *UpdateProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateProjectOK, error) @@ -350,6 +352,44 @@ func (a *Client) GetProject(params *GetProjectParams, authInfo runtime.ClientAut return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +GetProjectConfig Fetch the current project's environment's configuration. +*/ +func (a *Client) GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectConfigOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetProjectConfigParams() + } + op := &runtime.ClientOperation{ + ID: "getProjectConfig", + Method: "GET", + PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/vnd.cycloid.io.v1+json", "application/x-www-form-urlencoded"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetProjectConfigReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*GetProjectConfigOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetProjectConfigDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* GetProjects Get list of projects of the organization. */ From 18be3c8b53f54f0e8296a4eb410832af8ef4e5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 16:05:39 +0200 Subject: [PATCH 58/98] fix(create-env): fix tooltip for create-env --- cmd/cycloid/projects/create-env.go | 70 +++++++++++++++++++----------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 5a44c3ff..0ee81d80 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -23,28 +23,33 @@ func NewCreateEnvCommand() *cobra.Command { var cmd = &cobra.Command{ Use: "create-stackforms-env", Short: "create an environment within a project using StackForms.", - Long: ` -You can provide stackforms variables via files, env var and the --vars flag -The precedence order for variable provisioning is as follows: -- --var-file (-f) flag -- env vars CY_STACKFORMS_VAR -- --vars (-V) flag -- --extra-var (-x) flag + Long: `Create or update (with --update) an environment within a project using StackForms. ---vars accept json encoded values. +You can use the following ways to fill in the stackforms configuration (in the order of precedence): +1. --var-file (-f) flag -> accept any valid JSON file, if the filename is "-", read from stdin (can be set multiple times) +2. CY_STACKFORMS_VAR env var -> accept any valid JSON string (can be multiple json objects) +3. --json-vars (-j) flag -> accept any valid JSON string (can be set multiple times) +4. --var (-V) flag -> update a variable using a field=value syntax (e.g. -V section.group.key=value) -You can provide values fron stdin using the '--var-file -' flag. - -The output will be the generated configuration of the project. -`, +The output will be the generated configuration of the project.`, Example: ` # create 'prod' environment in 'my-project' -cy --org my-org project create-stackforms-env \ +cy project create-stackforms-env \ + --org my-org \ --project my-project \ --env prod \ --use-case usecase-1 \ --var-file vars.yml \ - --vars '{"myRaw": "vars"}'`, + --json-vars '{"myRaw": "vars"}' \ + --var section.group.key=value + +# Update a project with some values from another environement +# using -V to override some variables. +cy project get-env-config --org my-org --project my-project --env prod \ + | cy project create-stackforms-env --update \ + --project my-project --env staging --use-case aws \ + --var-file "-" \ + -V "pipeline.database.dump_version=staging"`, PreRunE: func(cmd *cobra.Command, args []string) error { internal.Warning(cmd.ErrOrStderr(), "This command will replace `cy project create-env` soon.\n"+ @@ -56,17 +61,16 @@ cy --org my-org project create-stackforms-env \ } common.WithFlagOrg(cmd) - cmd.PersistentFlags().StringP("project", "p", "", "the selected project") + cmd.PersistentFlags().StringP("project", "p", "", "project name") cmd.MarkFlagRequired("project") + cmd.PersistentFlags().StringP("env", "e", "", "environment name") + cmd.MarkFlagRequired("env") cmd.PersistentFlags().StringP("use-case", "u", "", "the selected use case of the stack") cmd.MarkFlagRequired("use-case") - cmd.PersistentFlags().StringP("env", "e", "", "the environment name of the stack") - cmd.MarkFlagRequired("env") cmd.PersistentFlags().StringArrayP("var-file", "f", nil, "path to a JSON file containing variables, can be '-' for stdin, can be set multiple times.") - cmd.PersistentFlags().StringArrayP("vars", "V", nil, "JSON string containing variables, can be set multiple times.") - cmd.PersistentFlags().StringToStringP("extra-var", "x", nil, "extra variable to be added to the environment in the -e key=value -e key=value format") - cmd.PersistentFlags().Bool("update", false, "Allow to override existing environment") - cmd.Flags().SortFlags = false + cmd.PersistentFlags().StringArrayP("json-vars", "j", nil, "JSON string containing variables, can be set multiple times.") + cmd.PersistentFlags().StringToStringP("var", "V", nil, `update a variable using a field=value syntax (e.g. -V section.group.key=value)`) + cmd.PersistentFlags().Bool("update", false, "allow to override existing environment") return cmd } @@ -126,7 +130,7 @@ func createEnv(cmd *cobra.Command, args []string) error { return err } - extraVar, err := cmd.Flags().GetStringToString("extra-var") + extraVar, err := cmd.Flags().GetStringToString("var") if err != nil { return err } @@ -192,7 +196,7 @@ func createEnv(cmd *cobra.Command, args []string) error { } // Get variables via CLI arguments --vars - cliVars, err := cmd.Flags().GetStringArray("vars") + cliVars, err := cmd.Flags().GetStringArray("json-vars") if err != nil { return err } @@ -226,6 +230,9 @@ func createEnv(cmd *cobra.Command, args []string) error { } // fetch the printer from the factory + if output == "table" { + output = "json" + } p, err := factory.GetPrinter(output) if err != nil { return errors.Wrap(err, "unable to get printer") @@ -286,6 +293,8 @@ func createEnv(cmd *cobra.Command, args []string) error { color = "default" } + // TODO: add the same color/icon as frontend for prod/prd staging/stg/preprod + // finally add the new environment envs = append(envs, &models.NewEnvironment{ // TODO: https://github.com/cycloidio/cycloid-cli/issues/67 @@ -305,7 +314,7 @@ func createEnv(cmd *cobra.Command, args []string) error { // Send the updateProject call // TODO: Add support for resource pool canonical in case of resource quotas - resp, err := m.UpdateProject(org, + _, err = m.UpdateProject(org, *projectData.Name, project, envs, @@ -317,5 +326,16 @@ func createEnv(cmd *cobra.Command, args []string) error { *projectData.UpdatedAt, ) - return printer.SmartPrint(p, resp, err, "", printer.Options{}, cmd.OutOrStdout()) + errMsg := "failed to send config accepted by backend, returning inputs instead." + config, err := m.GetProjectConfig(org, project, env) + if err != nil { + return printer.SmartPrint(p, inputs[0].Vars, errors.Wrap(err, errMsg), "", printer.Options{}, cmd.OutOrStdout()) + } + + formsConfig, err := common.ParseFormsConfig(config, usecase, true) + if err != nil { + return printer.SmartPrint(p, inputs[0].Vars, errors.Wrap(err, errMsg), "", printer.Options{}, cmd.OutOrStdout()) + } + + return printer.SmartPrint(p, formsConfig, nil, "", printer.Options{}, cmd.OutOrStdout()) } From d9881e6ce4ac30931c97b3555380422683663b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 16:05:57 +0200 Subject: [PATCH 59/98] misc: add default value in get project config --- cmd/cycloid/middleware/project.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cycloid/middleware/project.go b/cmd/cycloid/middleware/project.go index d6f13f9d..7a98982e 100644 --- a/cmd/cycloid/middleware/project.go +++ b/cmd/cycloid/middleware/project.go @@ -11,7 +11,6 @@ import ( ) func (m *middleware) ListProjects(org string) ([]*models.Project, error) { - params := organization_projects.NewGetProjectsParams() params.SetOrganizationCanonical(org) @@ -57,6 +56,7 @@ func (m *middleware) GetProjectConfig(org string, project string, env string) (* params.WithOrganizationCanonical(org) params.WithProjectCanonical(project) params.WithEnvironmentCanonical(env) + params.WithDefaults() resp, err := m.api.OrganizationProjects.GetProjectConfig(params, m.api.Credentials(&org)) if err != nil { From b7b615467c6523060bc5e22515464d65c426136b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 16:32:30 +0200 Subject: [PATCH 60/98] func: clean an add get-env command --- cmd/cycloid/projects/cmd.go | 2 -- ...ackforms-config-from-env.go => get-env.go} | 23 +++++++++---------- 2 files changed, 11 insertions(+), 14 deletions(-) rename cmd/cycloid/projects/{get-stackforms-config-from-env.go => get-env.go} (88%) diff --git a/cmd/cycloid/projects/cmd.go b/cmd/cycloid/projects/cmd.go index 9fe73b97..0504dfee 100644 --- a/cmd/cycloid/projects/cmd.go +++ b/cmd/cycloid/projects/cmd.go @@ -24,8 +24,6 @@ func NewCommands() *cobra.Command { NewCreateRawEnvCommand(), NewGetCommand(), NewGetEnvCommand(), - //NewGetStackformsConfigCommand(), // needs implementation - NewGetStackformsConfigFromEnvCommand(), ) return cmd diff --git a/cmd/cycloid/projects/get-stackforms-config-from-env.go b/cmd/cycloid/projects/get-env.go similarity index 88% rename from cmd/cycloid/projects/get-stackforms-config-from-env.go rename to cmd/cycloid/projects/get-env.go index e5364fe8..5bbe4cee 100644 --- a/cmd/cycloid/projects/get-stackforms-config-from-env.go +++ b/cmd/cycloid/projects/get-env.go @@ -12,12 +12,14 @@ import ( "github.com/spf13/cobra" ) -func NewGetStackformsConfigFromEnvCommand() *cobra.Command { +func NewGetEnvCommand() *cobra.Command { var cmd = &cobra.Command{ - Use: "get-env-config ", + Use: "get-env ", + Aliases: []string{ + "get-env-config", + }, Short: "Get the default stackforms config of a project's env", - Long: ` -This command will fetch the configuration of an environment in a project. + Long: `This command will fetch the configuration of an environment in a project. Output is in JSON by default. @@ -35,17 +37,14 @@ The values are generated as following: - First we get the current env value if exists (unless you set --default) - If no current value is present, we get the default -- If no default is set, we set a zeroed value in the correct type: ("", 0, [], {}) -`, - Example: ` -# Get the configuration as json (default) +- If no default is set, we set a zeroed value in the correct type: ("", 0, [], {})`, + Example: `# Get the configuration as json (default) cy --org my-org project get-env-config -p my-project-canonical -e my-env-canonical # Get the configuration as yaml -cy --org my-org project get-env-config my-project my-project use_case -o yaml -`, +cy --org my-org project get-env-config my-project my-project use_case -o yaml`, PreRunE: internal.CheckAPIAndCLIVersion, - RunE: getStackFormsConfigFromEnv, + RunE: getEnvConfig, Args: cobra.RangeArgs(0, 2), } @@ -60,7 +59,7 @@ cy --org my-org project get-env-config my-project my-project use_case -o yaml return cmd } -func getStackFormsConfigFromEnv(cmd *cobra.Command, args []string) error { +func getEnvConfig(cmd *cobra.Command, args []string) error { // Flags have precedence over args project, err := cmd.Flags().GetString("project") if len(args) >= 1 && project == "" { From 3d1c3d60332bea463ce4e7eea0a3d3eaa7ce1437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 16:32:45 +0200 Subject: [PATCH 61/98] fix: remove deprecated field in legacy command to keep it in help --- cmd/cycloid/projects/create-raw-env.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/cycloid/projects/create-raw-env.go b/cmd/cycloid/projects/create-raw-env.go index 4f653efc..a022702f 100644 --- a/cmd/cycloid/projects/create-raw-env.go +++ b/cmd/cycloid/projects/create-raw-env.go @@ -32,9 +32,12 @@ func NewCreateRawEnvCommand() *cobra.Command { --vars /my/pipeline/vars.yml \ --config /path/to/config=/path/in/config_repo `, - Deprecated: "This command will be changed to use stackforms in the future.\n" + - "If your still want to use this command as is, use `cy project create-env` instead.\n" + - "Please see https://github.com/cycloidio/cycloid-cli/issues/268 for more information.", + Hidden: false, + // TODO: Bring back deprecation when switch will be operated + // If we depreciate it, it will disappear from the help + //Deprecated: "This command will be changed to use stackforms in the future.\n" + + // "If your still want to use this command as is, use `cy project create-env` instead.\n" + + // "Please see https://github.com/cycloidio/cycloid-cli/issues/268 for more information.", PreRunE: func(cmd *cobra.Command, args []string) error { internal.Warning(cmd.ErrOrStderr(), "This command will be changed to use stackforms in the future.\n"+ From a10cb32ca17ad30b0b8b8858b0fa9ffce371e6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 16:33:07 +0200 Subject: [PATCH 62/98] fix(tests): fix expectation with new create-env ouput --- e2e/projects_test.go | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/e2e/projects_test.go b/e2e/projects_test.go index dbbfa172..ab5f804f 100644 --- a/e2e/projects_test.go +++ b/e2e/projects_test.go @@ -7,7 +7,6 @@ import ( "fmt" "testing" - "github.com/cycloidio/cycloid-cli/client/models" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -143,14 +142,14 @@ func TestProjects(t *testing.T) { "--project", "snowy", "--env", "sf-vars", "--use-case", "default", - "-V", `{"pipeline": {"config": {"message": "filledFromVars"}}}`, + "-j", `{"pipeline": {"config": {"message": "filledFromVars"}}}`, }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\": \"snowy") - var data models.Project + var data map[string]map[string]map[string]string err := json.Unmarshal([]byte(cmdOut), &data) assert.Nil(t, err) + assert.Equal(t, "filledFromVars", data["pipeline"]["config"]["message"]) }) t.Run("SuccessProjectGetStackformConfigVars", func(t *testing.T) { @@ -183,34 +182,36 @@ func TestProjects(t *testing.T) { "--project", "snowy", "--env", "sf-extra-vars", "--use-case", "default", - "-x", `pipeline.config.message=filledFromExtraVars`, + "-V", `pipeline.config.message=filledFromExtraVars`, }) assert.Nil(t, cmdErr) - require.Contains(t, cmdOut, "canonical\": \"snowy") - var data models.Project + var data map[string]map[string]map[string]string err := json.Unmarshal([]byte(cmdOut), &data) assert.Nil(t, err) + assert.Equal(t, "filledFromExtraVars", data["pipeline"]["config"]["message"]) }) - t.Run("SuccessProjectGetStackformConfigExtraVars", func(t *testing.T) { + // Extra vars + t.Run("SuccessProjectsCreateExtraVarsUpdate", func(t *testing.T) { cmdOut, cmdErr := executeCommand([]string{ "--output", "json", "--org", CY_TEST_ROOT_ORG, - "project", "get-env-config", - "-p", "snowy", "-e", "sf-extra-vars", + "project", + "create-stackforms-env", + "--project", "snowy", + "--env", "sf-extra-vars", + "--use-case", "default", + "-V", `pipeline.config.message=filledFromExtraVars`, + "-V", `pipeline.config.message=filledFromExtraVars2`, + "--update", }) assert.Nil(t, cmdErr) - - // Output should be in json by default - var data = make(map[string]map[string]map[string]any) + var data map[string]map[string]map[string]string err := json.Unmarshal([]byte(cmdOut), &data) - assert.NoError(t, err) - - message, ok := data["pipeline"]["config"]["message"] - assert.True(t, ok) - assert.Equal(t, "filledFromExtraVars", message) + assert.Nil(t, err) + assert.Equal(t, "filledFromExtraVars2", data["pipeline"]["config"]["message"]) }) t.Run("SuccessProjectsDelete", func(t *testing.T) { From 0c8201e699fa321e6d150c6240f2748c87eebb0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 16:39:06 +0200 Subject: [PATCH 63/98] fix(makefile): make wget replace current swagger.yml --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 60d421a3..9320c841 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,7 @@ generate-client-from-local: reset-old-client ## Generates client using docker an .PHONY: generate-client-from-docs generate-client-from-docs: reset-old-client ## Generates client using docker and swagger from docs (version -> latest-api) - @wget https://docs.cycloid.io/api/swagger.yml + @wget -O swagger.yml https://docs.cycloid.io/api/swagger.yml @export SWAGGER_VERSION=$$(python -c 'import yaml, sys; y = yaml.safe_load(sys.stdin); print(y["info"]["version"])' < swagger.yml); \ if [ -z "$$SWAGGER_VERSION" ]; then echo "Unable to read version from swagger"; exit 1; fi; \ $(DOCKER_COMPOSE) run $(SWAGGER_GENERATE) && \ From 3132617f82f4b9fe6c60114f0665b8be9a16067b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 16:53:25 +0200 Subject: [PATCH 64/98] func: update swagger with current develop --- .../organizations/get_summary_responses.go | 30 +++++++++---------- client/models/user_login.go | 8 ++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/client/client/organizations/get_summary_responses.go b/client/client/organizations/get_summary_responses.go index 0f720a84..c8d13ca1 100644 --- a/client/client/organizations/get_summary_responses.go +++ b/client/client/organizations/get_summary_responses.go @@ -303,16 +303,16 @@ swagger:model GetSummaryOKBody */ type GetSummaryOKBody struct { - // summary + // data // Required: true - Summary *models.Summary `json:"summary"` + Data *models.Summary `json:"data"` } // Validate validates this get summary o k body func (o *GetSummaryOKBody) Validate(formats strfmt.Registry) error { var res []error - if err := o.validateSummary(formats); err != nil { + if err := o.validateData(formats); err != nil { res = append(res, err) } @@ -322,18 +322,18 @@ func (o *GetSummaryOKBody) Validate(formats strfmt.Registry) error { return nil } -func (o *GetSummaryOKBody) validateSummary(formats strfmt.Registry) error { +func (o *GetSummaryOKBody) validateData(formats strfmt.Registry) error { - if err := validate.Required("getSummaryOK"+"."+"summary", "body", o.Summary); err != nil { + if err := validate.Required("getSummaryOK"+"."+"data", "body", o.Data); err != nil { return err } - if o.Summary != nil { - if err := o.Summary.Validate(formats); err != nil { + if o.Data != nil { + if err := o.Data.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getSummaryOK" + "." + "summary") + return ve.ValidateName("getSummaryOK" + "." + "data") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("getSummaryOK" + "." + "summary") + return ce.ValidateName("getSummaryOK" + "." + "data") } return err } @@ -346,7 +346,7 @@ func (o *GetSummaryOKBody) validateSummary(formats strfmt.Registry) error { func (o *GetSummaryOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error - if err := o.contextValidateSummary(ctx, formats); err != nil { + if err := o.contextValidateData(ctx, formats); err != nil { res = append(res, err) } @@ -356,15 +356,15 @@ func (o *GetSummaryOKBody) ContextValidate(ctx context.Context, formats strfmt.R return nil } -func (o *GetSummaryOKBody) contextValidateSummary(ctx context.Context, formats strfmt.Registry) error { +func (o *GetSummaryOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error { - if o.Summary != nil { + if o.Data != nil { - if err := o.Summary.ContextValidate(ctx, formats); err != nil { + if err := o.Data.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getSummaryOK" + "." + "summary") + return ve.ValidateName("getSummaryOK" + "." + "data") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("getSummaryOK" + "." + "summary") + return ce.ValidateName("getSummaryOK" + "." + "data") } return err } diff --git a/client/models/user_login.go b/client/models/user_login.go index 22b8a916..d0363140 100644 --- a/client/models/user_login.go +++ b/client/models/user_login.go @@ -20,7 +20,7 @@ import ( // Validate the user to access to the application. The user can login with the primary email address or with username. // // MinProperties: 2 -// MaxProperties: 2 +// MaxProperties: 3 // // swagger:model UserLogin type UserLogin struct { @@ -197,9 +197,9 @@ func (m *UserLogin) Validate(formats strfmt.Registry) error { return errors.TooFewProperties("", "body", 2) } - // maxProperties: 2 - if nprops > 2 { - return errors.TooManyProperties("", "body", 2) + // maxProperties: 3 + if nprops > 3 { + return errors.TooManyProperties("", "body", 3) } if err := m.validateEmail(formats); err != nil { From 36134cffb96fe0c87c475971ea6c81915120d41c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 16:54:33 +0200 Subject: [PATCH 65/98] misc(makefile): fix permissions madness with swagger container --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9320c841..9fcf2964 100644 --- a/Makefile +++ b/Makefile @@ -99,19 +99,18 @@ test: ## Run end to end tests .PHONY: delete-old-client reset-old-client: ## Resets old client folder - rm -rf ./client; \ - mkdir ./client + $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "rm -rf ./client" && mkdir -p client .PHONY: generate-client -generate-client: ## Generate client from file at SWAGGER_FILE path +generate-client: reset-old-client ## Generate client from file at SWAGGER_FILE path echo "Creating swagger files"; \ - rm -rf ./client; \ - mkdir ./client; - $(SWAGGER_GENERATE) && rm swagger.yml + $(SWAGGER_GENERATE) + $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "chown -R $(shell id -u):$(shell id -g) ./client" .PHONY: generate-client-from-local generate-client-from-local: reset-old-client ## Generates client using docker and local swagger (version -> v0.0-dev) $(DOCKER_COMPOSE) run $(SWAGGER_GENERATE) + $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "chown -R $(shell id -u):$(shell id -g) ./client" echo 'v0.0-dev' > client/version .PHONY: generate-client-from-docs @@ -124,6 +123,7 @@ generate-client-from-docs: reset-old-client ## Generates client using docker and echo "Please run the following git commands:"; \ echo "git add client" && \ echo "git commit -m 'Bump swagger client to version $$SWAGGER_VERSION'" + $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "chown -R $(shell id -u):$(shell id -g) ./client" .PHONY: ecr-connect ecr-connect: ## Login to ecr, requires aws cli installed From d2f52e9e07a6cde8bd4c13f1bed8f69d157bcdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 17:06:20 +0200 Subject: [PATCH 66/98] fix: correct some error messages --- cmd/cycloid/projects/create-env.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 0ee81d80..c33cdd2e 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -195,7 +195,7 @@ func createEnv(cmd *cobra.Command, args []string) error { } } - // Get variables via CLI arguments --vars + // Get variables via CLI arguments --json-vars cliVars, err := cmd.Flags().GetStringArray("json-vars") if err != nil { return err @@ -206,15 +206,15 @@ func createEnv(cmd *cobra.Command, args []string) error { var extractedVars = make(map[string]interface{}) err = json.Unmarshal([]byte(varInput), &extractedVars) if err != nil { - return fmt.Errorf("failed to parse var input '"+varInput+"' as JSON: %s", err) + return fmt.Errorf("failed to parse json-var input '"+varInput+"' as JSON: %s", err) } if err := mergo.Merge(&vars, extractedVars, mergo.WithOverride); err != nil { - return fmt.Errorf("failed to merge input vars from environment: %v", err) + return fmt.Errorf("failed to merge input vars from json-var input: %v\nerr: %v", extractedVars, err) } } - // Merge key/val from extraVar + // Merge key/val from --var for k, v := range extraVar { common.UpdateMapField(k, v, vars) } From 95f6199083b5b42aed140595d91f7b6bc7264bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 17:15:56 +0200 Subject: [PATCH 67/98] [ci skip]: add changelog --- changelog/unreleased/CLI-ADDED-20240612-151549.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 changelog/unreleased/CLI-ADDED-20240612-151549.yaml diff --git a/changelog/unreleased/CLI-ADDED-20240612-151549.yaml b/changelog/unreleased/CLI-ADDED-20240612-151549.yaml new file mode 100644 index 00000000..fb9dc548 --- /dev/null +++ b/changelog/unreleased/CLI-ADDED-20240612-151549.yaml @@ -0,0 +1,8 @@ +component: CLI +kind: ADDED +body: Add project creation and config fetch using stackforms via the CLI +time: 2024-06-12T15:15:49.798720082Z +custom: + DETAILS: Add a project creation and config fetch on a project using stackforms. + PR: "268" + TYPE: CLI From 69320e6cc94c5f72faeec694356bb080805b490a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Wed, 12 Jun 2024 17:18:57 +0200 Subject: [PATCH 68/98] [ci skip]: fix changelog --- changelog/unreleased/CLI-ADDED-20240612-151549.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog/unreleased/CLI-ADDED-20240612-151549.yaml b/changelog/unreleased/CLI-ADDED-20240612-151549.yaml index fb9dc548..9a898a6f 100644 --- a/changelog/unreleased/CLI-ADDED-20240612-151549.yaml +++ b/changelog/unreleased/CLI-ADDED-20240612-151549.yaml @@ -3,6 +3,8 @@ kind: ADDED body: Add project creation and config fetch using stackforms via the CLI time: 2024-06-12T15:15:49.798720082Z custom: - DETAILS: Add a project creation and config fetch on a project using stackforms. - PR: "268" + DETAILS: | + `cy project create-stackforms-env` command is now available and allows to create a env using stackforms + `cy project get-env` command is now available and allows to get a current environment stackforms configuration. + PR: "269" TYPE: CLI From 22c7d0b73a4c752a3bbc89dd7a5dba3c36d15844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:40:37 +0200 Subject: [PATCH 69/98] Bump swagger client to version v5.0.49-saas --- client/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/version b/client/version index f40ebcb9..d5209def 100644 --- a/client/version +++ b/client/version @@ -1 +1 @@ -v5.0.40-saas +v5.0.49-saas From 59e453acabaddf38a3c738d67e62d543f4da9113 Mon Sep 17 00:00:00 2001 From: cycloid-machine Date: Thu, 13 Jun 2024 11:38:01 +0000 Subject: [PATCH 70/98] [ci skip] v5.0.49-saas release --- changelog/unreleased/CLI-ADDED-20240612-151549.yaml | 10 ---------- changelog/unreleased/CLI-BREAKING-20240611-084737.yaml | 8 -------- 2 files changed, 18 deletions(-) delete mode 100644 changelog/unreleased/CLI-ADDED-20240612-151549.yaml delete mode 100644 changelog/unreleased/CLI-BREAKING-20240611-084737.yaml diff --git a/changelog/unreleased/CLI-ADDED-20240612-151549.yaml b/changelog/unreleased/CLI-ADDED-20240612-151549.yaml deleted file mode 100644 index 9a898a6f..00000000 --- a/changelog/unreleased/CLI-ADDED-20240612-151549.yaml +++ /dev/null @@ -1,10 +0,0 @@ -component: CLI -kind: ADDED -body: Add project creation and config fetch using stackforms via the CLI -time: 2024-06-12T15:15:49.798720082Z -custom: - DETAILS: | - `cy project create-stackforms-env` command is now available and allows to create a env using stackforms - `cy project get-env` command is now available and allows to get a current environment stackforms configuration. - PR: "269" - TYPE: CLI diff --git a/changelog/unreleased/CLI-BREAKING-20240611-084737.yaml b/changelog/unreleased/CLI-BREAKING-20240611-084737.yaml deleted file mode 100644 index 1fa30cd7..00000000 --- a/changelog/unreleased/CLI-BREAKING-20240611-084737.yaml +++ /dev/null @@ -1,8 +0,0 @@ -component: CLI -kind: BREAKING -body: Update go to 1.22.4 and go-swagger to 0.31.0 -time: 2024-06-11T08:47:37.363357202Z -custom: - DETAILS: "" - PR: "272" - TYPE: CLI From dcc2da89f6314d2824ca9a9ad6da2e92bd12e8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 13 Jun 2024 14:31:05 +0200 Subject: [PATCH 71/98] fix: fix makefile for ci --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9fcf2964..f56c5d24 100644 --- a/Makefile +++ b/Makefile @@ -101,11 +101,11 @@ test: ## Run end to end tests reset-old-client: ## Resets old client folder $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "rm -rf ./client" && mkdir -p client +# Used in CI, do not use docker compose here. .PHONY: generate-client generate-client: reset-old-client ## Generate client from file at SWAGGER_FILE path echo "Creating swagger files"; \ $(SWAGGER_GENERATE) - $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "chown -R $(shell id -u):$(shell id -g) ./client" .PHONY: generate-client-from-local generate-client-from-local: reset-old-client ## Generates client using docker and local swagger (version -> v0.0-dev) From 55ee36b71a49f644f4b38f4580f1fb5deac2254f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 13 Jun 2024 14:34:31 +0200 Subject: [PATCH 72/98] fix: fix version --- client/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/version b/client/version index d5209def..1d92c303 100644 --- a/client/version +++ b/client/version @@ -1 +1 @@ -v5.0.49-saas +v5.0.49 From ac467a2dcefcc145b2453dd37d37c352ebed4c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Thu, 13 Jun 2024 14:55:18 +0200 Subject: [PATCH 73/98] fix: add changelog --- changelog/unreleased/CLI-FIXED-20240613-125511.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 changelog/unreleased/CLI-FIXED-20240613-125511.yaml diff --git a/changelog/unreleased/CLI-FIXED-20240613-125511.yaml b/changelog/unreleased/CLI-FIXED-20240613-125511.yaml new file mode 100644 index 00000000..2f284cd1 --- /dev/null +++ b/changelog/unreleased/CLI-FIXED-20240613-125511.yaml @@ -0,0 +1,8 @@ +component: CLI +kind: FIXED +body: Fix version for release +time: 2024-06-13T12:55:11.766947309Z +custom: + DETAILS: "" + PR: "269" + TYPE: CLI From 933d1904e470d29fa26a8b2a80b8e6695458efe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 14:11:36 +0200 Subject: [PATCH 74/98] func: change api token env var to CY_API_TOKEN --- cmd/cycloid/common/helpers.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index f308aae5..f0064819 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -158,8 +158,16 @@ func (a *APIClient) Credentials(org *string) runtime.ClientAuthInfoWriter { var token = a.Config.Token if token == "" { // we first try to get the token from the env variable - token = os.Getenv("TOKEN") + var ok bool + token, ok = os.LookupEnv("CY_API_TOKEN") + if !ok { + token, ok = os.LookupEnv("TOKEN") + if ok { + fmt.Println("TOKEN env var is deprecated, please use CY_API_TOKEN instead") + } + } } + // if the token is not set with env variable we try to fetch // him from the config (if the user is logged) if len(token) == 0 { From ec6232d7d34548a07e2311695075e23bf90bab1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:25:55 +0200 Subject: [PATCH 75/98] func: make command to fill org via env var --- cmd/cycloid/apikey/delete.go | 31 ++++++++-------- cmd/cycloid/apikey/get.go | 31 ++++++++-------- cmd/cycloid/apikey/list.go | 30 ++++++++-------- cmd/cycloid/catalog-repositories/create.go | 2 +- cmd/cycloid/catalog-repositories/delete.go | 2 +- cmd/cycloid/catalog-repositories/get.go | 2 +- cmd/cycloid/catalog-repositories/list.go | 2 +- cmd/cycloid/catalog-repositories/refresh.go | 2 +- cmd/cycloid/catalog-repositories/update.go | 2 +- cmd/cycloid/common/flags.go | 18 ++++++++++ cmd/cycloid/common/helpers.go | 4 +-- cmd/cycloid/config-repositories/create.go | 4 +-- cmd/cycloid/config-repositories/delete.go | 2 +- cmd/cycloid/config-repositories/get.go | 2 +- cmd/cycloid/config-repositories/list.go | 2 +- cmd/cycloid/config-repositories/update.go | 2 +- cmd/cycloid/creds/create.go | 5 +-- cmd/cycloid/creds/delete.go | 2 +- cmd/cycloid/creds/get.go | 2 +- cmd/cycloid/creds/list.go | 2 +- cmd/cycloid/creds/update.go | 5 +-- cmd/cycloid/events/send.go | 6 ++-- .../external-backends/create_events.go | 4 +-- .../external-backends/create_infra_view.go | 14 ++++---- cmd/cycloid/external-backends/create_logs.go | 2 +- cmd/cycloid/external-backends/delete.go | 2 +- cmd/cycloid/external-backends/list.go | 4 +-- cmd/cycloid/infrapolicies/create.go | 2 +- cmd/cycloid/infrapolicies/delete.go | 2 +- cmd/cycloid/infrapolicies/get.go | 2 +- cmd/cycloid/infrapolicies/list.go | 2 +- cmd/cycloid/infrapolicies/update.go | 2 +- cmd/cycloid/infrapolicies/validate.go | 6 ++-- cmd/cycloid/kpis/create.go | 2 +- cmd/cycloid/kpis/delete.go | 2 +- cmd/cycloid/kpis/list.go | 2 +- cmd/cycloid/members/delete-invite.go | 2 +- cmd/cycloid/members/delete.go | 2 +- cmd/cycloid/members/get.go | 2 +- cmd/cycloid/members/invite.go | 2 +- cmd/cycloid/members/list-invites.go | 2 +- cmd/cycloid/members/list.go | 2 +- cmd/cycloid/members/update.go | 2 +- cmd/cycloid/organizations/create-children.go | 4 +-- cmd/cycloid/organizations/delete.go | 4 +-- cmd/cycloid/organizations/get.go | 3 +- cmd/cycloid/organizations/list-children.go | 3 +- cmd/cycloid/organizations/list-workers.go | 2 +- cmd/cycloid/organizations/update.go | 3 +- cmd/cycloid/pipelines/clear-task-cache.go | 3 +- cmd/cycloid/pipelines/diff.go | 8 ++--- cmd/cycloid/pipelines/get-job.go | 2 +- cmd/cycloid/pipelines/get.go | 4 +-- cmd/cycloid/pipelines/list-builds.go | 2 +- cmd/cycloid/pipelines/list-jobs.go | 3 +- cmd/cycloid/pipelines/list.go | 2 +- cmd/cycloid/pipelines/pause-job.go | 2 +- cmd/cycloid/pipelines/pause.go | 2 +- cmd/cycloid/pipelines/synced.go | 5 +-- cmd/cycloid/pipelines/trigger-build.go | 3 +- cmd/cycloid/pipelines/unpause-job.go | 2 +- cmd/cycloid/pipelines/unpause.go | 9 +++-- cmd/cycloid/pipelines/update.go | 9 ++--- cmd/cycloid/projects/cmd.go | 2 -- cmd/cycloid/projects/create-env.go | 3 +- cmd/cycloid/projects/create-raw-env.go | 2 +- cmd/cycloid/projects/create.go | 2 +- cmd/cycloid/projects/delete-env.go | 2 +- cmd/cycloid/projects/delete.go | 2 +- cmd/cycloid/projects/get-env.go | 3 +- cmd/cycloid/projects/get.go | 2 +- cmd/cycloid/projects/list.go | 5 +-- cmd/cycloid/roles/delete.go | 2 +- cmd/cycloid/roles/get.go | 2 +- cmd/cycloid/roles/list.go | 2 +- cmd/cycloid/stacks/get.go | 3 +- cmd/cycloid/stacks/list.go | 3 +- cmd/cycloid/stacks/validate-form.go | 3 +- cmd/cycloid/terracost/estimate.go | 36 +++++++++---------- 79 files changed, 188 insertions(+), 183 deletions(-) diff --git a/cmd/cycloid/apikey/delete.go b/cmd/cycloid/apikey/delete.go index d0c52973..e00053f8 100644 --- a/cmd/cycloid/apikey/delete.go +++ b/cmd/cycloid/apikey/delete.go @@ -22,21 +22,7 @@ func NewDeleteCommand() *cobra.Command { # delete the API key 'my-key' in the org my-org cy api-key delete --org my-org --canonical my-key `, - RunE: func(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") - if err != nil { - return fmt.Errorf("unable to get org flag: %w", err) - } - output, err := cmd.Flags().GetString("output") - if err != nil { - return fmt.Errorf("unable to get output flag: %w", err) - } - canonical, err := cmd.Flags().GetString("canonical") - if err != nil { - return fmt.Errorf("unable to get canonical flag: %w", err) - } - return remove(cmd, org, canonical, output) - }, + RunE: remove, } WithFlagCanonical(cmd) @@ -46,7 +32,20 @@ func NewDeleteCommand() *cobra.Command { // remove will send the DELETE request to the API in order to // delete a generated token -func remove(cmd *cobra.Command, org, canonical, output string) error { +func remove(cmd *cobra.Command, args []string) error { + org, err := common.GetOrg(cmd) + if err != nil { + return fmt.Errorf("unable to get org flag: %w", err) + } + output, err := cmd.Flags().GetString("output") + if err != nil { + return fmt.Errorf("unable to get output flag: %w", err) + } + canonical, err := cmd.Flags().GetString("canonical") + if err != nil { + return fmt.Errorf("unable to get canonical flag: %w", err) + } + api := common.NewAPI() m := middleware.NewMiddleware(api) diff --git a/cmd/cycloid/apikey/get.go b/cmd/cycloid/apikey/get.go index c4353481..9b960e16 100644 --- a/cmd/cycloid/apikey/get.go +++ b/cmd/cycloid/apikey/get.go @@ -22,21 +22,7 @@ func NewGetCommand() *cobra.Command { # get API key 'my-key' in the org my-org cy api-key get --org my-org --canonical my-key `, - RunE: func(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") - if err != nil { - return fmt.Errorf("unable to get org flag: %w", err) - } - output, err := cmd.Flags().GetString("output") - if err != nil { - return fmt.Errorf("unable to get output flag: %w", err) - } - canonical, err := cmd.Flags().GetString("canonical") - if err != nil { - return fmt.Errorf("unable to get canonical flag: %w", err) - } - return get(cmd, org, canonical, output) - }, + RunE: get, } WithFlagCanonical(cmd) @@ -46,7 +32,20 @@ func NewGetCommand() *cobra.Command { // get will send the GET request to the API in order to // get the generated token -func get(cmd *cobra.Command, org, canonical, output string) error { +func get(cmd *cobra.Command, args []string) error { + org, err := common.GetOrg(cmd) + if err != nil { + return fmt.Errorf("unable to get org flag: %w", err) + } + output, err := cmd.Flags().GetString("output") + if err != nil { + return fmt.Errorf("unable to get output flag: %w", err) + } + canonical, err := cmd.Flags().GetString("canonical") + if err != nil { + return fmt.Errorf("unable to get canonical flag: %w", err) + } + api := common.NewAPI() m := middleware.NewMiddleware(api) diff --git a/cmd/cycloid/apikey/list.go b/cmd/cycloid/apikey/list.go index ad9ba20e..fe93fdb7 100644 --- a/cmd/cycloid/apikey/list.go +++ b/cmd/cycloid/apikey/list.go @@ -19,35 +19,35 @@ func NewListCommand() *cobra.Command { Use: "list", Short: "list API keys", Example: ` - # list API keys in the org my-org - cy api-key list --org my-org +# list API keys in the org my-org +cy api-key list --org my-org `, - RunE: func(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") - if err != nil { - return fmt.Errorf("unable to get org flag: %w", err) - } - output, err := cmd.Flags().GetString("output") - if err != nil { - return fmt.Errorf("unable to get output flag: %w", err) - } - return list(cmd, org, output) - }, + RunE: list, } return cmd } -// list will send the GET request to the API in order to // list the generated tokens -func list(cmd *cobra.Command, org, output string) error { +func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) + org, err := cmd.Flags().GetString("org") + if err != nil { + return err + } + + output, err := cmd.Flags().GetString("output") + if err != nil { + return fmt.Errorf("unable to get output flag: %w", err) + } + // fetch the printer from the factory p, err := factory.GetPrinter(output) if err != nil { return errors.Wrap(err, "unable to get printer") } + keys, err := m.ListAPIKey(org) return printer.SmartPrint(p, keys, err, "unable to list API keys", printer.Options{}, cmd.OutOrStdout()) } diff --git a/cmd/cycloid/catalog-repositories/create.go b/cmd/cycloid/catalog-repositories/create.go index b21a4d7e..acb3c4d7 100644 --- a/cmd/cycloid/catalog-repositories/create.go +++ b/cmd/cycloid/catalog-repositories/create.go @@ -43,7 +43,7 @@ func createCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/delete.go b/cmd/cycloid/catalog-repositories/delete.go index 9af5a81c..e6345019 100644 --- a/cmd/cycloid/catalog-repositories/delete.go +++ b/cmd/cycloid/catalog-repositories/delete.go @@ -30,7 +30,7 @@ func deleteCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/get.go b/cmd/cycloid/catalog-repositories/get.go index e78822ad..91a2bb1e 100644 --- a/cmd/cycloid/catalog-repositories/get.go +++ b/cmd/cycloid/catalog-repositories/get.go @@ -29,7 +29,7 @@ func getCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/list.go b/cmd/cycloid/catalog-repositories/list.go index 9a5cada7..90bb0a34 100644 --- a/cmd/cycloid/catalog-repositories/list.go +++ b/cmd/cycloid/catalog-repositories/list.go @@ -28,7 +28,7 @@ func listCatalogRepositories(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/refresh.go b/cmd/cycloid/catalog-repositories/refresh.go index 74d75f9c..76238c9c 100644 --- a/cmd/cycloid/catalog-repositories/refresh.go +++ b/cmd/cycloid/catalog-repositories/refresh.go @@ -31,7 +31,7 @@ func refreshCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/update.go b/cmd/cycloid/catalog-repositories/update.go index b3e4c708..08801c42 100644 --- a/cmd/cycloid/catalog-repositories/update.go +++ b/cmd/cycloid/catalog-repositories/update.go @@ -36,7 +36,7 @@ func updateCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/common/flags.go b/cmd/cycloid/common/flags.go index 228da51d..9f96e01b 100644 --- a/cmd/cycloid/common/flags.go +++ b/cmd/cycloid/common/flags.go @@ -1,7 +1,12 @@ package common import ( + "fmt" + "os" + + "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/viper" ) var ( @@ -9,6 +14,19 @@ var ( idFlag uint32 ) +func GetOrg(cmd *cobra.Command) (org string, err error) { + org = viper.GetString("org") + if org == "" { + return "", errors.New("org is not set, use --org flag or CY_ORG env var") + } + + if viper.GetString("verbosity") == "debug" { + fmt.Fprintln(os.Stderr, "\033[1;34mdebug:\033[0m using org:", org) + } + + return org, nil +} + func WithFlagOrg(cmd *cobra.Command) string { flagName := "org" cmd.PersistentFlags().StringVar(&orgFlag, flagName, "", "Org cannonical name") diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index f0064819..6d2c3487 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -159,11 +159,11 @@ func (a *APIClient) Credentials(org *string) runtime.ClientAuthInfoWriter { if token == "" { // we first try to get the token from the env variable var ok bool - token, ok = os.LookupEnv("CY_API_TOKEN") + token, ok = os.LookupEnv("CY_API_KEY") if !ok { token, ok = os.LookupEnv("TOKEN") if ok { - fmt.Println("TOKEN env var is deprecated, please use CY_API_TOKEN instead") + fmt.Println("TOKEN env var is deprecated, please use CY_API_KEY instead") } } } diff --git a/cmd/cycloid/config-repositories/create.go b/cmd/cycloid/config-repositories/create.go index 3ed913ec..1a0c4b1e 100644 --- a/cmd/cycloid/config-repositories/create.go +++ b/cmd/cycloid/config-repositories/create.go @@ -23,8 +23,6 @@ func NewCreateCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } - // create --branch test --cred 105 --url "git@github.com:foo/bla.git" --name configname --default - common.RequiredFlag(common.WithFlagCred, cmd) common.RequiredFlag(WithFlagName, cmd) common.RequiredFlag(WithFlagBranch, cmd) @@ -38,7 +36,7 @@ func createConfigRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/config-repositories/delete.go b/cmd/cycloid/config-repositories/delete.go index ecd67fad..7fc61d99 100644 --- a/cmd/cycloid/config-repositories/delete.go +++ b/cmd/cycloid/config-repositories/delete.go @@ -32,7 +32,7 @@ func deleteConfigRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/config-repositories/get.go b/cmd/cycloid/config-repositories/get.go index 031066cb..905c55fd 100644 --- a/cmd/cycloid/config-repositories/get.go +++ b/cmd/cycloid/config-repositories/get.go @@ -31,7 +31,7 @@ func getConfigRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/config-repositories/list.go b/cmd/cycloid/config-repositories/list.go index ce290bc8..af84e56a 100644 --- a/cmd/cycloid/config-repositories/list.go +++ b/cmd/cycloid/config-repositories/list.go @@ -30,7 +30,7 @@ func listConfigRepositories(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/config-repositories/update.go b/cmd/cycloid/config-repositories/update.go index 82e2eae5..038c37c4 100644 --- a/cmd/cycloid/config-repositories/update.go +++ b/cmd/cycloid/config-repositories/update.go @@ -39,7 +39,7 @@ func updateConfigRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/creds/create.go b/cmd/cycloid/creds/create.go index 645b6b30..f225778e 100644 --- a/cmd/cycloid/creds/create.go +++ b/cmd/cycloid/creds/create.go @@ -3,6 +3,7 @@ package creds import ( "fmt" "io/ioutil" + "os" "strings" "github.com/pkg/errors" @@ -187,7 +188,7 @@ func create(cmd *cobra.Command, args []string) error { var rawCred *models.CredentialRaw credT := cmd.CalledAs() - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } @@ -226,7 +227,7 @@ func create(cmd *cobra.Command, args []string) error { return err } - sshKey, err := ioutil.ReadFile(sshKeyPath) + sshKey, err := os.ReadFile(sshKeyPath) if err != nil { return errors.Wrap(err, "unable to read SSH key") } diff --git a/cmd/cycloid/creds/delete.go b/cmd/cycloid/creds/delete.go index 41359993..b7a93513 100644 --- a/cmd/cycloid/creds/delete.go +++ b/cmd/cycloid/creds/delete.go @@ -31,7 +31,7 @@ func del(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/creds/get.go b/cmd/cycloid/creds/get.go index 2a151da3..0fcc750a 100644 --- a/cmd/cycloid/creds/get.go +++ b/cmd/cycloid/creds/get.go @@ -32,7 +32,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/creds/list.go b/cmd/cycloid/creds/list.go index d380677d..e2c1d0e5 100644 --- a/cmd/cycloid/creds/list.go +++ b/cmd/cycloid/creds/list.go @@ -31,7 +31,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/creds/update.go b/cmd/cycloid/creds/update.go index 879af8e8..5996eb7c 100644 --- a/cmd/cycloid/creds/update.go +++ b/cmd/cycloid/creds/update.go @@ -3,6 +3,7 @@ package creds import ( "fmt" "io/ioutil" + "os" "strings" "github.com/cycloidio/cycloid-cli/client/models" @@ -198,7 +199,7 @@ func update(cmd *cobra.Command, args []string) error { var rawCred *models.CredentialRaw credT := cmd.CalledAs() - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } @@ -237,7 +238,7 @@ func update(cmd *cobra.Command, args []string) error { return err } - sshKey, err := ioutil.ReadFile(sshKeyPath) + sshKey, err := os.ReadFile(sshKeyPath) if err != nil { return errors.Wrap(err, "unable to read SSH key") } diff --git a/cmd/cycloid/events/send.go b/cmd/cycloid/events/send.go index cc137b51..c17b7687 100644 --- a/cmd/cycloid/events/send.go +++ b/cmd/cycloid/events/send.go @@ -2,7 +2,7 @@ package events import ( "fmt" - "io/ioutil" + "os" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -58,7 +58,7 @@ func send(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } @@ -104,7 +104,7 @@ func send(cmd *cobra.Command, args []string) error { var msg string if messageFile != "" { - rawMsg, err := ioutil.ReadFile(messageFile) + rawMsg, err := os.ReadFile(messageFile) if err != nil { return errors.Wrap(err, "unable to read message file") } diff --git a/cmd/cycloid/external-backends/create_events.go b/cmd/cycloid/external-backends/create_events.go index 7383dc9f..024331a5 100644 --- a/cmd/cycloid/external-backends/create_events.go +++ b/cmd/cycloid/external-backends/create_events.go @@ -19,13 +19,13 @@ func createEvents(cmd *cobra.Command, args []string) error { var ( err error - org, cred string + cred string purpose = "events" ebC models.ExternalBackendConfiguration engine = cmd.CalledAs() ) - org, err = cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/external-backends/create_infra_view.go b/cmd/cycloid/external-backends/create_infra_view.go index 45cb78bd..f3cc1a32 100644 --- a/cmd/cycloid/external-backends/create_infra_view.go +++ b/cmd/cycloid/external-backends/create_infra_view.go @@ -18,19 +18,19 @@ func createInfraView(cmd *cobra.Command, args []string) error { m := middleware.NewMiddleware(api) var ( - purpose = "remote_tfstate" - err error - org, project, env string - ebC models.ExternalBackendConfiguration - engine = cmd.CalledAs() - defaultEB bool + purpose = "remote_tfstate" + err error + project, env string + ebC models.ExternalBackendConfiguration + engine = cmd.CalledAs() + defaultEB bool ) output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") } - org, err = cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/external-backends/create_logs.go b/cmd/cycloid/external-backends/create_logs.go index 1d4f4ae9..f06591cc 100644 --- a/cmd/cycloid/external-backends/create_logs.go +++ b/cmd/cycloid/external-backends/create_logs.go @@ -29,7 +29,7 @@ func createLogs(cmd *cobra.Command, args []string) error { if err != nil { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/external-backends/delete.go b/cmd/cycloid/external-backends/delete.go index 82aaa34e..6fff5d8f 100644 --- a/cmd/cycloid/external-backends/delete.go +++ b/cmd/cycloid/external-backends/delete.go @@ -32,7 +32,7 @@ func del(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/external-backends/list.go b/cmd/cycloid/external-backends/list.go index cb2fe4b6..e296f18e 100644 --- a/cmd/cycloid/external-backends/list.go +++ b/cmd/cycloid/external-backends/list.go @@ -34,8 +34,6 @@ func NewListCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - return cmd } @@ -43,7 +41,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/create.go b/cmd/cycloid/infrapolicies/create.go index 90077a26..9fafb8de 100644 --- a/cmd/cycloid/infrapolicies/create.go +++ b/cmd/cycloid/infrapolicies/create.go @@ -49,7 +49,7 @@ func create(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/delete.go b/cmd/cycloid/infrapolicies/delete.go index 8a5ea745..ecf65619 100644 --- a/cmd/cycloid/infrapolicies/delete.go +++ b/cmd/cycloid/infrapolicies/delete.go @@ -35,7 +35,7 @@ func delete(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/get.go b/cmd/cycloid/infrapolicies/get.go index b267293f..542837be 100644 --- a/cmd/cycloid/infrapolicies/get.go +++ b/cmd/cycloid/infrapolicies/get.go @@ -35,7 +35,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/list.go b/cmd/cycloid/infrapolicies/list.go index d4e89119..74f56424 100644 --- a/cmd/cycloid/infrapolicies/list.go +++ b/cmd/cycloid/infrapolicies/list.go @@ -36,7 +36,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/update.go b/cmd/cycloid/infrapolicies/update.go index 9bba2843..6d10f72e 100644 --- a/cmd/cycloid/infrapolicies/update.go +++ b/cmd/cycloid/infrapolicies/update.go @@ -50,7 +50,7 @@ func update(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/validate.go b/cmd/cycloid/infrapolicies/validate.go index 0686980d..07759b92 100644 --- a/cmd/cycloid/infrapolicies/validate.go +++ b/cmd/cycloid/infrapolicies/validate.go @@ -2,7 +2,7 @@ package infrapolicies import ( "fmt" - "io/ioutil" + "os" "github.com/spf13/cobra" @@ -35,7 +35,7 @@ func NewValidateCommand() *cobra.Command { // validate will send the GET request to the API in order to // validate the terraform Plan located in planPath func validate(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return fmt.Errorf("unable to validate org flag: %w", err) } @@ -56,7 +56,7 @@ func validate(cmd *cobra.Command, args []string) error { return fmt.Errorf("unable to get output flag: %w", err) } - plan, err := ioutil.ReadFile(planPath) + plan, err := os.ReadFile(planPath) if err != nil { return fmt.Errorf("unable to read terraform plan file: %w", err) } diff --git a/cmd/cycloid/kpis/create.go b/cmd/cycloid/kpis/create.go index 593f4b03..1ce183a1 100644 --- a/cmd/cycloid/kpis/create.go +++ b/cmd/cycloid/kpis/create.go @@ -44,7 +44,7 @@ func create(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/kpis/delete.go b/cmd/cycloid/kpis/delete.go index 378dd9a4..cfdd32d3 100644 --- a/cmd/cycloid/kpis/delete.go +++ b/cmd/cycloid/kpis/delete.go @@ -33,7 +33,7 @@ func delete(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/kpis/list.go b/cmd/cycloid/kpis/list.go index c1cd0e61..3da61fc7 100644 --- a/cmd/cycloid/kpis/list.go +++ b/cmd/cycloid/kpis/list.go @@ -33,7 +33,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/delete-invite.go b/cmd/cycloid/members/delete-invite.go index 6ba4e482..f38826e0 100644 --- a/cmd/cycloid/members/delete-invite.go +++ b/cmd/cycloid/members/delete-invite.go @@ -43,7 +43,7 @@ func deleteInvite(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/delete.go b/cmd/cycloid/members/delete.go index 2c30d2fd..18cfd3f5 100644 --- a/cmd/cycloid/members/delete.go +++ b/cmd/cycloid/members/delete.go @@ -39,7 +39,7 @@ func deleteMember(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/get.go b/cmd/cycloid/members/get.go index c28d6a72..93d2155c 100644 --- a/cmd/cycloid/members/get.go +++ b/cmd/cycloid/members/get.go @@ -44,7 +44,7 @@ func getMember(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/invite.go b/cmd/cycloid/members/invite.go index a7e59b92..547b6bb5 100644 --- a/cmd/cycloid/members/invite.go +++ b/cmd/cycloid/members/invite.go @@ -40,7 +40,7 @@ func inviteMember(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/list-invites.go b/cmd/cycloid/members/list-invites.go index feae7328..423c759d 100644 --- a/cmd/cycloid/members/list-invites.go +++ b/cmd/cycloid/members/list-invites.go @@ -42,7 +42,7 @@ func listInvites(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/list.go b/cmd/cycloid/members/list.go index 81c164a0..22823f29 100644 --- a/cmd/cycloid/members/list.go +++ b/cmd/cycloid/members/list.go @@ -42,7 +42,7 @@ func listMembers(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/update.go b/cmd/cycloid/members/update.go index b9f69ca3..e1cbd6ec 100644 --- a/cmd/cycloid/members/update.go +++ b/cmd/cycloid/members/update.go @@ -47,7 +47,7 @@ func updateConfigRepository(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/organizations/create-children.go b/cmd/cycloid/organizations/create-children.go index e38fd8a5..c30a0430 100644 --- a/cmd/cycloid/organizations/create-children.go +++ b/cmd/cycloid/organizations/create-children.go @@ -18,7 +18,6 @@ func NewCreateChildCommand() *cobra.Command { RunE: createChild, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) common.RequiredPersistentFlag(WithFlagParentOrganization, cmd) return cmd @@ -28,10 +27,11 @@ func createChild(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + porg, err := cmd.Flags().GetString("parent-org") if err != nil { return err diff --git a/cmd/cycloid/organizations/delete.go b/cmd/cycloid/organizations/delete.go index 399158e4..dda49147 100644 --- a/cmd/cycloid/organizations/delete.go +++ b/cmd/cycloid/organizations/delete.go @@ -24,8 +24,6 @@ func NewDeleteCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - return cmd } @@ -33,7 +31,7 @@ func del(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return errors.Wrap(err, "unable get org flag") } diff --git a/cmd/cycloid/organizations/get.go b/cmd/cycloid/organizations/get.go index c41bd49d..677470f1 100644 --- a/cmd/cycloid/organizations/get.go +++ b/cmd/cycloid/organizations/get.go @@ -22,7 +22,6 @@ func NewGetCommand() *cobra.Command { RunE: get, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } @@ -31,7 +30,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/organizations/list-children.go b/cmd/cycloid/organizations/list-children.go index 18ab8a2b..c00489ad 100644 --- a/cmd/cycloid/organizations/list-children.go +++ b/cmd/cycloid/organizations/list-children.go @@ -21,7 +21,6 @@ func NewListChildrensCommand() *cobra.Command { RunE: listChildrens, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } @@ -30,7 +29,7 @@ func listChildrens(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/organizations/list-workers.go b/cmd/cycloid/organizations/list-workers.go index e75bc1c3..6a4b038e 100644 --- a/cmd/cycloid/organizations/list-workers.go +++ b/cmd/cycloid/organizations/list-workers.go @@ -27,7 +27,7 @@ func listWorkers(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/organizations/update.go b/cmd/cycloid/organizations/update.go index b14d1d7f..8e062f7e 100644 --- a/cmd/cycloid/organizations/update.go +++ b/cmd/cycloid/organizations/update.go @@ -25,7 +25,6 @@ func NewUpdateCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) common.RequiredFlag(WithFlagName, cmd) return cmd @@ -40,7 +39,7 @@ func update(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return errors.Wrap(err, "unable get org flag") } diff --git a/cmd/cycloid/pipelines/clear-task-cache.go b/cmd/cycloid/pipelines/clear-task-cache.go index 4dbfb080..6086e83f 100644 --- a/cmd/cycloid/pipelines/clear-task-cache.go +++ b/cmd/cycloid/pipelines/clear-task-cache.go @@ -1,7 +1,6 @@ package pipelines import ( - "github.com/pkg/errors" "github.com/spf13/cobra" @@ -36,7 +35,7 @@ func cleartaskCache(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/diff.go b/cmd/cycloid/pipelines/diff.go index 4cb0afb3..d4fb53e4 100644 --- a/cmd/cycloid/pipelines/diff.go +++ b/cmd/cycloid/pipelines/diff.go @@ -2,7 +2,7 @@ package pipelines import ( "fmt" - "io/ioutil" + "io/os" "github.com/pkg/errors" @@ -38,7 +38,7 @@ func diff(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } @@ -69,13 +69,13 @@ func diff(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get printer") } - rawPipeline, err := ioutil.ReadFile(pipelinePath) + rawPipeline, err := os.ReadFile(pipelinePath) if err != nil { return fmt.Errorf("Pipeline file reading error : %s", err.Error()) } pipelineTemplate := string(rawPipeline) - rawVars, err := ioutil.ReadFile(varsPath) + rawVars, err := os.ReadFile(varsPath) if err != nil { return fmt.Errorf("Pipeline variables file reading error : %s", err.Error()) } diff --git a/cmd/cycloid/pipelines/get-job.go b/cmd/cycloid/pipelines/get-job.go index d664db75..55865527 100644 --- a/cmd/cycloid/pipelines/get-job.go +++ b/cmd/cycloid/pipelines/get-job.go @@ -34,7 +34,7 @@ func getJob(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/get.go b/cmd/cycloid/pipelines/get.go index 1e6f7310..17d3337f 100644 --- a/cmd/cycloid/pipelines/get.go +++ b/cmd/cycloid/pipelines/get.go @@ -23,8 +23,6 @@ func NewGetCommand() *cobra.Command { RunE: get, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - common.RequiredPersistentFlag(common.WithFlagProject, cmd) common.RequiredPersistentFlag(common.WithFlagEnv, cmd) @@ -35,7 +33,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/list-builds.go b/cmd/cycloid/pipelines/list-builds.go index 436904f4..e7502300 100644 --- a/cmd/cycloid/pipelines/list-builds.go +++ b/cmd/cycloid/pipelines/list-builds.go @@ -34,7 +34,7 @@ func listBuilds(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/list-jobs.go b/cmd/cycloid/pipelines/list-jobs.go index 70107820..39706f8f 100644 --- a/cmd/cycloid/pipelines/list-jobs.go +++ b/cmd/cycloid/pipelines/list-jobs.go @@ -33,10 +33,11 @@ func listJobs(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err diff --git a/cmd/cycloid/pipelines/list.go b/cmd/cycloid/pipelines/list.go index a96eaa12..aefb2930 100644 --- a/cmd/cycloid/pipelines/list.go +++ b/cmd/cycloid/pipelines/list.go @@ -26,7 +26,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/pause-job.go b/cmd/cycloid/pipelines/pause-job.go index 201861b7..d4093866 100644 --- a/cmd/cycloid/pipelines/pause-job.go +++ b/cmd/cycloid/pipelines/pause-job.go @@ -34,7 +34,7 @@ func pauseJob(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/pause.go b/cmd/cycloid/pipelines/pause.go index 43e1a91b..19feb1d9 100644 --- a/cmd/cycloid/pipelines/pause.go +++ b/cmd/cycloid/pipelines/pause.go @@ -33,7 +33,7 @@ func pause(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/synced.go b/cmd/cycloid/pipelines/synced.go index 315d2aec..7f0d8be2 100644 --- a/cmd/cycloid/pipelines/synced.go +++ b/cmd/cycloid/pipelines/synced.go @@ -25,8 +25,6 @@ func NewSyncedCommand() *cobra.Command { RunE: synced, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - common.RequiredPersistentFlag(common.WithFlagProject, cmd) common.RequiredPersistentFlag(common.WithFlagEnv, cmd) @@ -41,14 +39,17 @@ func synced(cmd *cobra.Command, args []string) error { if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err } + env, err := cmd.Flags().GetString("env") if err != nil { return err } + output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") diff --git a/cmd/cycloid/pipelines/trigger-build.go b/cmd/cycloid/pipelines/trigger-build.go index 9d9c2264..9688557f 100644 --- a/cmd/cycloid/pipelines/trigger-build.go +++ b/cmd/cycloid/pipelines/trigger-build.go @@ -34,10 +34,11 @@ func createBuild(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err diff --git a/cmd/cycloid/pipelines/unpause-job.go b/cmd/cycloid/pipelines/unpause-job.go index 71414634..a9d42353 100644 --- a/cmd/cycloid/pipelines/unpause-job.go +++ b/cmd/cycloid/pipelines/unpause-job.go @@ -34,7 +34,7 @@ func unpauseJob(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/unpause.go b/cmd/cycloid/pipelines/unpause.go index 80a11d72..b8f22d64 100644 --- a/cmd/cycloid/pipelines/unpause.go +++ b/cmd/cycloid/pipelines/unpause.go @@ -16,8 +16,8 @@ func NewUnpauseCommand() *cobra.Command { Use: "unpause", Short: "unpause a pipeline", Example: ` - # unpause pipeline my-project-env - cy --org my-org pipeline unpause --project my-project --env env +# unpause pipeline my-project-env +cy --org my-org pipeline unpause --project my-project --env env `, RunE: unpause, PreRunE: internal.CheckAPIAndCLIVersion, @@ -33,18 +33,21 @@ func unpause(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err } + env, err := cmd.Flags().GetString("env") if err != nil { return err } + output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") diff --git a/cmd/cycloid/pipelines/update.go b/cmd/cycloid/pipelines/update.go index b6cd441c..e45203bc 100644 --- a/cmd/cycloid/pipelines/update.go +++ b/cmd/cycloid/pipelines/update.go @@ -1,7 +1,7 @@ package pipelines import ( - "io/ioutil" + "os" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -40,10 +40,11 @@ func update(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err @@ -71,13 +72,13 @@ func update(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get printer") } - rawPipeline, err := ioutil.ReadFile(pipelinePath) + rawPipeline, err := os.ReadFile(pipelinePath) if err != nil { return errors.Wrap(err, "unable to read pipeline file") } pipeline := string(rawPipeline) - rawVars, err := ioutil.ReadFile(varsPath) + rawVars, err := os.ReadFile(varsPath) if err != nil { return errors.Wrap(err, "unable to read variables file") } diff --git a/cmd/cycloid/projects/cmd.go b/cmd/cycloid/projects/cmd.go index 0504dfee..78f51b9c 100644 --- a/cmd/cycloid/projects/cmd.go +++ b/cmd/cycloid/projects/cmd.go @@ -1,7 +1,6 @@ package projects import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -14,7 +13,6 @@ func NewCommands() *cobra.Command { }, Short: "Manage the projects", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewDeleteCommand(), NewCreateCommand(), diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index c33cdd2e..ebcf4c18 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -60,7 +60,6 @@ cy project get-env-config --org my-org --project my-project --env prod \ RunE: createEnv, } - common.WithFlagOrg(cmd) cmd.PersistentFlags().StringP("project", "p", "", "project name") cmd.MarkFlagRequired("project") cmd.PersistentFlags().StringP("env", "e", "", "environment name") @@ -81,7 +80,7 @@ func createEnv(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/create-raw-env.go b/cmd/cycloid/projects/create-raw-env.go index a022702f..74a276b3 100644 --- a/cmd/cycloid/projects/create-raw-env.go +++ b/cmd/cycloid/projects/create-raw-env.go @@ -63,7 +63,7 @@ func createRawEnv(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/create.go b/cmd/cycloid/projects/create.go index 7c624535..033c8525 100644 --- a/cmd/cycloid/projects/create.go +++ b/cmd/cycloid/projects/create.go @@ -53,7 +53,7 @@ func create(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/delete-env.go b/cmd/cycloid/projects/delete-env.go index c738ab3d..f51f86e6 100644 --- a/cmd/cycloid/projects/delete-env.go +++ b/cmd/cycloid/projects/delete-env.go @@ -32,7 +32,7 @@ func deleteEnv(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/delete.go b/cmd/cycloid/projects/delete.go index 0d6dbc1e..5051ede4 100644 --- a/cmd/cycloid/projects/delete.go +++ b/cmd/cycloid/projects/delete.go @@ -31,7 +31,7 @@ func del(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/get-env.go b/cmd/cycloid/projects/get-env.go index 5bbe4cee..8d2504b9 100644 --- a/cmd/cycloid/projects/get-env.go +++ b/cmd/cycloid/projects/get-env.go @@ -48,7 +48,6 @@ cy --org my-org project get-env-config my-project my-project use_case -o yaml`, Args: cobra.RangeArgs(0, 2), } - common.WithFlagOrg(cmd) cmd.Flags().StringP("project", "p", "", "specify the project") cmd.Flags().StringP("env", "e", "", "specify the env") cmd.Flags().BoolP("default", "d", false, "if set, will fetch the default value from the stack instead of the current ones.") @@ -85,7 +84,7 @@ func getEnvConfig(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/get.go b/cmd/cycloid/projects/get.go index e314d23e..acc2cf07 100644 --- a/cmd/cycloid/projects/get.go +++ b/cmd/cycloid/projects/get.go @@ -32,7 +32,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/list.go b/cmd/cycloid/projects/list.go index eb3eb8d7..7f05e7e4 100644 --- a/cmd/cycloid/projects/list.go +++ b/cmd/cycloid/projects/list.go @@ -29,10 +29,11 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { - return err + return errors.Wrap(err, "unable to get org") } + output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") diff --git a/cmd/cycloid/roles/delete.go b/cmd/cycloid/roles/delete.go index f6a6d0bf..c9d1443b 100644 --- a/cmd/cycloid/roles/delete.go +++ b/cmd/cycloid/roles/delete.go @@ -39,7 +39,7 @@ func deleteRole(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/roles/get.go b/cmd/cycloid/roles/get.go index e72c59df..8f10143c 100644 --- a/cmd/cycloid/roles/get.go +++ b/cmd/cycloid/roles/get.go @@ -44,7 +44,7 @@ func getRole(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/roles/list.go b/cmd/cycloid/roles/list.go index 0af97424..aeac294b 100644 --- a/cmd/cycloid/roles/list.go +++ b/cmd/cycloid/roles/list.go @@ -42,7 +42,7 @@ func listRoles(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/stacks/get.go b/cmd/cycloid/stacks/get.go index 3785ef59..f591829f 100644 --- a/cmd/cycloid/stacks/get.go +++ b/cmd/cycloid/stacks/get.go @@ -24,7 +24,6 @@ func NewGetCommand() *cobra.Command { RunE: get, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.Flags().StringVar(&refFlag, "ref", "", "referential of the stack") cmd.MarkFlagRequired("ref") @@ -36,7 +35,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/stacks/list.go b/cmd/cycloid/stacks/list.go index 76ac7a72..4ce05c57 100644 --- a/cmd/cycloid/stacks/list.go +++ b/cmd/cycloid/stacks/list.go @@ -22,7 +22,6 @@ func NewListCommand() *cobra.Command { RunE: list, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } @@ -31,7 +30,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/stacks/validate-form.go b/cmd/cycloid/stacks/validate-form.go index 6f88d7be..775d5fa5 100644 --- a/cmd/cycloid/stacks/validate-form.go +++ b/cmd/cycloid/stacks/validate-form.go @@ -24,7 +24,6 @@ func NewValidateFormCmd() *cobra.Command { RunE: validateForm, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) common.RequiredPersistentFlag(WithFlagForms, cmd) return cmd @@ -34,7 +33,7 @@ func validateForm(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/terracost/estimate.go b/cmd/cycloid/terracost/estimate.go index e2f170ab..a880c47b 100644 --- a/cmd/cycloid/terracost/estimate.go +++ b/cmd/cycloid/terracost/estimate.go @@ -2,7 +2,7 @@ package terracost import ( "fmt" - "io/ioutil" + "os" "github.com/spf13/cobra" @@ -16,29 +16,27 @@ import ( // of the cost estimation func NewEstimateCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "estimate", - RunE: func(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") - if err != nil { - return fmt.Errorf("unable to validate org flag: %w", err) - } - planPath, err := cmd.Flags().GetString("plan-path") - if err != nil { - return fmt.Errorf("unable to get plan path flag: %w", err) - } - output, err := cmd.Flags().GetString("output") - if err != nil { - return fmt.Errorf("unable to get output flag: %w", err) - } - return estimate(cmd, org, planPath, output) - }, + Use: "estimate", + RunE: estimate, } common.RequiredFlag(WithFlagPlanPath, cmd) return cmd } -func estimate(cmd *cobra.Command, org, planPath, output string) error { - plan, err := ioutil.ReadFile(planPath) +func estimate(cmd *cobra.Command, args []string) error { + org, err := common.GetOrg(cmd) + if err != nil { + return fmt.Errorf("unable to validate org flag: %w", err) + } + planPath, err := cmd.Flags().GetString("plan-path") + if err != nil { + return fmt.Errorf("unable to get plan path flag: %w", err) + } + output, err := cmd.Flags().GetString("output") + if err != nil { + return fmt.Errorf("unable to get output flag: %w", err) + } + plan, err := os.ReadFile(planPath) if err != nil { return fmt.Errorf("unable to read terraform plan file: %w", err) } From 711cfc708b3dcc4345262f03da0d036a43e297b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:26:18 +0200 Subject: [PATCH 76/98] func: allow setting API_KEY via env var for login --- cmd/cycloid/login/login.go | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index 21539443..bd4e7add 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -3,6 +3,7 @@ package login import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" @@ -20,23 +21,10 @@ func NewCommands() *cobra.Command { cy login --org my-org --api-key eyJhbGciOiJI... `, PreRunE: internal.CheckAPIAndCLIVersion, - RunE: func(cmd *cobra.Command, args []string) error { - - org, err := cmd.Flags().GetString("org") - if err != nil { - return errors.Wrap(err, "unable to get org flag") - } - apiKey, err := cmd.Flags().GetString("api-key") - if err != nil { - return errors.Wrap(err, "unable to get child flag") - } - - return login(org, apiKey) - }, + RunE: login, } - common.RequiredFlag(WithFlagAPIKey, cmd) - common.RequiredFlag(WithFlagOrg, cmd) + WithFlagAPIKey(cmd) cmd.AddCommand( NewListCommand(), @@ -45,10 +33,21 @@ func NewCommands() *cobra.Command { return cmd } -func login(org, key string) error { +func login(cmd *cobra.Command, args []string) error { + conf, _ := config.Read() // If err != nil, the file does not exist, we create it anyway + org, err := common.GetOrg(cmd) + if err != nil { + return errors.Wrap(err, "unable to get org flag") + } + + apiKey := viper.GetString("api-key") + if apiKey == "" { + return errors.Wrap(err, "apiKey not set or invalid") + } + // Check for a nil map. // This can be the case if the config file is empty if conf.Organizations == nil { @@ -56,7 +55,7 @@ func login(org, key string) error { } conf.Organizations[org] = config.Organization{ - Token: key, + Token: apiKey, } if err := config.Write(conf); err != nil { From 3ab0773fd251cc7b00b8ff0d25da49c75ffee0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:33:49 +0200 Subject: [PATCH 77/98] fix: remove last required org flags --- cmd/cycloid/apikey/cmd.go | 3 --- cmd/cycloid/catalog-repositories/cmd.go | 2 -- cmd/cycloid/config-repositories/cmd.go | 3 --- cmd/cycloid/creds/cmd.go | 2 -- cmd/cycloid/events/cmd.go | 3 --- cmd/cycloid/external-backends/cmd.go | 2 -- cmd/cycloid/infrapolicies/cmd.go | 5 +---- cmd/cycloid/login/common.go | 10 ++-------- cmd/cycloid/login/login.go | 2 ++ cmd/cycloid/members/cmd.go | 3 --- cmd/cycloid/pipelines/cmd.go | 3 --- cmd/cycloid/pipelines/diff.go | 2 +- cmd/cycloid/roles/cmd.go | 3 --- cmd/cycloid/terracost/cmd.go | 4 ---- 14 files changed, 6 insertions(+), 41 deletions(-) diff --git a/cmd/cycloid/apikey/cmd.go b/cmd/cycloid/apikey/cmd.go index e409f41b..ad3a59c9 100644 --- a/cmd/cycloid/apikey/cmd.go +++ b/cmd/cycloid/apikey/cmd.go @@ -2,8 +2,6 @@ package apikey import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) var ( @@ -24,7 +22,6 @@ func NewCommands() *cobra.Command { Example: example, Short: short, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand( NewDeleteCommand(), diff --git a/cmd/cycloid/catalog-repositories/cmd.go b/cmd/cycloid/catalog-repositories/cmd.go index e7f8a7ad..811c92a3 100644 --- a/cmd/cycloid/catalog-repositories/cmd.go +++ b/cmd/cycloid/catalog-repositories/cmd.go @@ -1,7 +1,6 @@ package catalogRepositories import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -15,7 +14,6 @@ func NewCommands() *cobra.Command { }, Short: "Manage the catalog repositories", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewCreateCommand(), NewUpdateCommand(), diff --git a/cmd/cycloid/config-repositories/cmd.go b/cmd/cycloid/config-repositories/cmd.go index 09edc295..93c59d94 100644 --- a/cmd/cycloid/config-repositories/cmd.go +++ b/cmd/cycloid/config-repositories/cmd.go @@ -2,8 +2,6 @@ package configRepositories import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) func NewCommands() *cobra.Command { @@ -15,7 +13,6 @@ func NewCommands() *cobra.Command { }, Short: "Manage the catalog repositories", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewCreateCommand(), NewUpdateCommand(), diff --git a/cmd/cycloid/creds/cmd.go b/cmd/cycloid/creds/cmd.go index fc6d7930..44ec7304 100644 --- a/cmd/cycloid/creds/cmd.go +++ b/cmd/cycloid/creds/cmd.go @@ -1,7 +1,6 @@ package creds import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -22,7 +21,6 @@ func NewCommands() *cobra.Command { NewDeleteCommand(), NewListCommand(), NewGetCommand()) - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } diff --git a/cmd/cycloid/events/cmd.go b/cmd/cycloid/events/cmd.go index d281e866..814362d5 100644 --- a/cmd/cycloid/events/cmd.go +++ b/cmd/cycloid/events/cmd.go @@ -1,7 +1,6 @@ package events import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -15,8 +14,6 @@ func NewCommands() *cobra.Command { Short: "Manage the events", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - cmd.AddCommand(NewSendCommand()) return cmd diff --git a/cmd/cycloid/external-backends/cmd.go b/cmd/cycloid/external-backends/cmd.go index 1d09b7ae..118c9b79 100644 --- a/cmd/cycloid/external-backends/cmd.go +++ b/cmd/cycloid/external-backends/cmd.go @@ -1,7 +1,6 @@ package externalBackends import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -14,7 +13,6 @@ func NewCommands() *cobra.Command { }, Short: "manage external backends", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewGetCommand(), NewDeleteCommand(), diff --git a/cmd/cycloid/infrapolicies/cmd.go b/cmd/cycloid/infrapolicies/cmd.go index fe8e0130..7d26c910 100644 --- a/cmd/cycloid/infrapolicies/cmd.go +++ b/cmd/cycloid/infrapolicies/cmd.go @@ -2,8 +2,6 @@ package infrapolicies import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) func NewCommands() *cobra.Command { @@ -18,13 +16,12 @@ func NewCommands() *cobra.Command { Short: "Manage the infraPolicies", } - common.RequiredFlag(common.WithFlagOrg, cmd) - cmd.AddCommand(NewValidateCommand(), NewUpdateCommand(), NewCreateCommand(), NewListCommand(), NewGetCommand(), NewDeleteCommand()) + return cmd } diff --git a/cmd/cycloid/login/common.go b/cmd/cycloid/login/common.go index f583bbde..940ce60f 100644 --- a/cmd/cycloid/login/common.go +++ b/cmd/cycloid/login/common.go @@ -3,8 +3,8 @@ package login import "github.com/spf13/cobra" var ( - apiKeyFlag string - orgFlag string + apiKeyFlag string + orgFlag string ) func WithFlagAPIKey(cmd *cobra.Command) string { @@ -12,9 +12,3 @@ func WithFlagAPIKey(cmd *cobra.Command) string { cmd.Flags().StringVar(&apiKeyFlag, flagName, "", "API key") return flagName } - -func WithFlagOrg(cmd *cobra.Command) string { - flagName := "org" - cmd.Flags().StringVar(&orgFlag, flagName, "", "Org cannonical name") - return flagName -} diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index bd4e7add..c70bc2ad 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -25,6 +25,7 @@ func NewCommands() *cobra.Command { } WithFlagAPIKey(cmd) + viper.BindPFlag("api-key", cmd.Flags().Lookup("api-key")) cmd.AddCommand( NewListCommand(), @@ -43,6 +44,7 @@ func login(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get org flag") } + // Get api key via env var or cli flag apiKey := viper.GetString("api-key") if apiKey == "" { return errors.Wrap(err, "apiKey not set or invalid") diff --git a/cmd/cycloid/members/cmd.go b/cmd/cycloid/members/cmd.go index 37a606bf..7489d215 100644 --- a/cmd/cycloid/members/cmd.go +++ b/cmd/cycloid/members/cmd.go @@ -2,8 +2,6 @@ package members import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) func NewCommands() *cobra.Command { @@ -22,7 +20,6 @@ func NewCommands() *cobra.Command { Short: short, Long: long, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewUpdateCommand(), NewDeleteCommand(), diff --git a/cmd/cycloid/pipelines/cmd.go b/cmd/cycloid/pipelines/cmd.go index 3d651ea6..461b0619 100644 --- a/cmd/cycloid/pipelines/cmd.go +++ b/cmd/cycloid/pipelines/cmd.go @@ -1,7 +1,6 @@ package pipelines import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -15,8 +14,6 @@ func NewCommands() *cobra.Command { Short: "Manage the pipelines", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - cmd.AddCommand(NewUnpauseJobCommand(), NewUpdateCommand(), NewGetJobCommand(), diff --git a/cmd/cycloid/pipelines/diff.go b/cmd/cycloid/pipelines/diff.go index d4fb53e4..050992c0 100644 --- a/cmd/cycloid/pipelines/diff.go +++ b/cmd/cycloid/pipelines/diff.go @@ -2,7 +2,7 @@ package pipelines import ( "fmt" - "io/os" + "os" "github.com/pkg/errors" diff --git a/cmd/cycloid/roles/cmd.go b/cmd/cycloid/roles/cmd.go index bae802e2..5da2e851 100644 --- a/cmd/cycloid/roles/cmd.go +++ b/cmd/cycloid/roles/cmd.go @@ -2,8 +2,6 @@ package roles import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) func NewCommands() *cobra.Command { @@ -22,7 +20,6 @@ func NewCommands() *cobra.Command { Short: short, Long: long, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewDeleteCommand(), NewListCommand(), diff --git a/cmd/cycloid/terracost/cmd.go b/cmd/cycloid/terracost/cmd.go index dabe4ca6..17eee9ad 100644 --- a/cmd/cycloid/terracost/cmd.go +++ b/cmd/cycloid/terracost/cmd.go @@ -2,8 +2,6 @@ package terracost import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) // NewCommands returns an implementation of Terracost commands @@ -17,8 +15,6 @@ func NewCommands() *cobra.Command { Short: "Use terracost feature", } - common.RequiredFlag(common.WithFlagOrg, cmd) - cmd.AddCommand(NewEstimateCommand()) return cmd } From 1aab90a600b8273e79cdee895ccb6a092d9d64e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 16:22:27 +0200 Subject: [PATCH 78/98] func: make login use CY_API_KEY env var as preference --- cmd/cycloid.go | 13 ++++++++++++- cmd/cycloid/common/helpers.go | 4 ++-- cmd/cycloid/login/common.go | 14 -------------- cmd/cycloid/login/login.go | 26 ++++++++++++++++++-------- 4 files changed, 32 insertions(+), 25 deletions(-) delete mode 100644 cmd/cycloid/login/common.go diff --git a/cmd/cycloid.go b/cmd/cycloid.go index 8b99c3c5..f1eb4ff0 100644 --- a/cmd/cycloid.go +++ b/cmd/cycloid.go @@ -47,7 +47,15 @@ func NewRootCommand() *cobra.Command { SilenceUsage: false, Use: "cy", Short: "Cycloid CLI", - Long: `Cy is a CLI for Cycloid framework. Learn more at https://www.cycloid.io/.`, + Long: `CLI tool to interact with Cycloid API. +Documentation at https://docs.beta.cycloid.io/reference/cli/ + +Environment: + +CY_API_URL -> Specify the HTTP url of Cycloid API to use, default https://http-api.cycloid.io +CY_ORG -> Set the current organization +CY_API_TOKEN -> Set the current API TOKEN +CY_VERBOSITY -> Set the verbosity level (debug, info, warning, error), default warning `, } rootCmd.PersistentFlags().StringVarP(&userOutput, "output", "o", "table", "The formatting style for command output: json|yaml|table") @@ -63,6 +71,9 @@ func NewRootCommand() *cobra.Command { rootCmd.PersistentFlags().Bool("insecure", false, "Decide to skip or not TLS verification") viper.BindPFlag("insecure", rootCmd.PersistentFlags().Lookup("insecure")) + rootCmd.PersistentFlags().String("org", "", "Specify the org to use. override CY_ORG env var. Required for all Org scoped endpoint.") + viper.BindPFlag("org", rootCmd.PersistentFlags().Lookup("org")) + // Remove usage on error, this is annoying in scripting rootCmd.SilenceUsage = true diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index 6d2c3487..f0064819 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -159,11 +159,11 @@ func (a *APIClient) Credentials(org *string) runtime.ClientAuthInfoWriter { if token == "" { // we first try to get the token from the env variable var ok bool - token, ok = os.LookupEnv("CY_API_KEY") + token, ok = os.LookupEnv("CY_API_TOKEN") if !ok { token, ok = os.LookupEnv("TOKEN") if ok { - fmt.Println("TOKEN env var is deprecated, please use CY_API_KEY instead") + fmt.Println("TOKEN env var is deprecated, please use CY_API_TOKEN instead") } } } diff --git a/cmd/cycloid/login/common.go b/cmd/cycloid/login/common.go deleted file mode 100644 index 940ce60f..00000000 --- a/cmd/cycloid/login/common.go +++ /dev/null @@ -1,14 +0,0 @@ -package login - -import "github.com/spf13/cobra" - -var ( - apiKeyFlag string - orgFlag string -) - -func WithFlagAPIKey(cmd *cobra.Command) string { - flagName := "api-key" - cmd.Flags().StringVar(&apiKeyFlag, flagName, "", "API key") - return flagName -} diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index c70bc2ad..3c37b8a9 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -8,6 +8,8 @@ import ( "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" "github.com/cycloidio/cycloid-cli/config" + "github.com/cycloidio/cycloid-cli/printer" + "github.com/cycloidio/cycloid-cli/printer/factory" ) // NewCommands returns the cobra command holding @@ -16,15 +18,14 @@ func NewCommands() *cobra.Command { cmd := &cobra.Command{ Use: "login", Short: "Login against the Cycloid console", - Example: `, - # Login in an org using api-key - cy login --org my-org --api-key eyJhbGciOiJI... -`, + Example: `# Login in an org using api-key +export CY_API_KEY=xxxx +cy login --org my-org`, PreRunE: internal.CheckAPIAndCLIVersion, RunE: login, } - WithFlagAPIKey(cmd) + cmd.Flags().String("api-key", "", "[deprecated] set the API key, use CY_API_KEY env var instead.") viper.BindPFlag("api-key", cmd.Flags().Lookup("api-key")) cmd.AddCommand( @@ -35,7 +36,6 @@ func NewCommands() *cobra.Command { } func login(cmd *cobra.Command, args []string) error { - conf, _ := config.Read() // If err != nil, the file does not exist, we create it anyway @@ -44,10 +44,20 @@ func login(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get org flag") } + p, err := factory.GetPrinter(viper.GetString("output")) + if err != nil { + return errors.Wrap(err, "unable to get printer") + } + // Get api key via env var or cli flag apiKey := viper.GetString("api-key") if apiKey == "" { - return errors.Wrap(err, "apiKey not set or invalid") + return printer.SmartPrint(p, apiKey, nil, "CY_API_KEY is not set or invalid", printer.Options{}, cmd.OutOrStderr()) + } + + // Warn user about deprecation + if cmd.Flags().Lookup("api-key").Changed { + internal.Warning(cmd.OutOrStderr(), "--api-key is deprecated, use CY_API_KEY env var instead") } // Check for a nil map. @@ -61,7 +71,7 @@ func login(cmd *cobra.Command, args []string) error { } if err := config.Write(conf); err != nil { - return errors.Wrap(err, "unable to save config") + return printer.SmartPrint(p, apiKey, err, "unable to write config file", printer.Options{}, cmd.OutOrStderr()) } return nil From e8b611766dc7300e38a7ea0ec55ef5541839eec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 11:23:48 +0200 Subject: [PATCH 79/98] fix: add proper error and nil handling in config read/write --- cmd/cycloid/login/login.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index e4521ade..681daf4d 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -46,9 +46,16 @@ func NewCommands() *cobra.Command { } func login(org, key string) error { + conf, err := config.Read() + if err != nil { + return errors.Wrap(err, "unable to read config") + } - // we save the new token and remove the previous one - conf, _ := config.Read() + // Check for a nil map. + // This can be the case if the config file is empty + if conf.Organizations == nil { + conf.Organizations = make(map[string]config.Organization) + } conf.Organizations[org] = config.Organization{ Token: key, From 257ca9b2f28fc54804d009c5530f8d40fb0090b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 11:24:08 +0200 Subject: [PATCH 80/98] fix: change config file permissions to 0600 --- config/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index a03ee743..2bc6ee3d 100644 --- a/config/config.go +++ b/config/config.go @@ -2,7 +2,7 @@ package config import ( "fmt" - "io/ioutil" + "os" "github.com/adrg/xdg" "github.com/pkg/errors" @@ -38,7 +38,7 @@ func Read() (*Config, error) { Organizations: make(map[string]Organization), }, errors.Wrap(err, "unable to find XDG config path") } - content, err := ioutil.ReadFile(configFilePath) + content, err := os.ReadFile(configFilePath) if err != nil { // we return an empty Config in case it's the first time we try to access // the config and it does not exist yet @@ -65,5 +65,5 @@ func Write(c *Config) error { return errors.Wrap(err, "unable to find XDG config path") } - return ioutil.WriteFile(configFilePath, content, 0644) + return os.WriteFile(configFilePath, content, 0600) } From 693d71775359c2ca948b5aace3c6124f738694ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 11:43:30 +0200 Subject: [PATCH 81/98] fix: error handling on config open --- cmd/cycloid/login/login.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index 681daf4d..21539443 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -46,10 +46,8 @@ func NewCommands() *cobra.Command { } func login(org, key string) error { - conf, err := config.Read() - if err != nil { - return errors.Wrap(err, "unable to read config") - } + conf, _ := config.Read() + // If err != nil, the file does not exist, we create it anyway // Check for a nil map. // This can be the case if the config file is empty From 562714a448356b069cfbe61ec409354f5aeea963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 16:24:58 +0200 Subject: [PATCH 82/98] misc: add nixos dev env shinanigan --- flake.lock | 16 ++++++---------- flake.nix | 6 +++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index 299b984e..79a8d67f 100644 --- a/flake.lock +++ b/flake.lock @@ -20,18 +20,14 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717196966, - "narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=", - "owner": "NixOs", - "repo": "nixpkgs", - "rev": "57610d2f8f0937f39dbd72251e9614b1561942d8", - "type": "github" + "lastModified": 1696748673, + "narHash": "sha256-UbPHrH4dKN/66EpfFpoG4St4XZYDX9YcMVRQGWzAUNA=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" }, "original": { - "owner": "NixOs", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" } }, "root": { diff --git a/flake.nix b/flake.nix index 13b31a19..4d0aea27 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "A basic dev shell for nix/nixos users"; inputs = { - nixpkgs = { url = "github:NixOs/nixpkgs/nixos-unstable"; }; + nixpkgs = { url = "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz"; }; flake-utils = { url = "github:numtide/flake-utils"; }; }; @@ -22,8 +22,8 @@ # You packages here gnumake - go_1_22 - go-swagger + # Prod is built using go 1.18 rn + go_1_18 ]); }; }); From 12d09326277918ca6b92376f0b11cd1a08207237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 16:25:38 +0200 Subject: [PATCH 83/98] func: update go version to 1.21 --- Makefile | 19 +++++++++---------- go.mod | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index e0decbe8..3a2bacdf 100644 --- a/Makefile +++ b/Makefile @@ -99,23 +99,24 @@ test: ## Run end to end tests .PHONY: delete-old-client reset-old-client: ## Resets old client folder - $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "rm -rf ./client" && mkdir -p client + rm -rf ./client; \ + mkdir ./client -# Used in CI, do not use docker compose here. .PHONY: generate-client -generate-client: reset-old-client ## Generate client from file at SWAGGER_FILE path +generate-client: ## Generate client from file at SWAGGER_FILE path echo "Creating swagger files"; \ - $(SWAGGER_GENERATE) + rm -rf ./client; \ + mkdir ./client; + $(SWAGGER_GENERATE) && rm swagger.yml .PHONY: generate-client-from-local generate-client-from-local: reset-old-client ## Generates client using docker and local swagger (version -> v0.0-dev) $(DOCKER_COMPOSE) run $(SWAGGER_GENERATE) - $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "chown -R $(shell id -u):$(shell id -g) ./client" echo 'v0.0-dev' > client/version .PHONY: generate-client-from-docs generate-client-from-docs: reset-old-client ## Generates client using docker and swagger from docs (version -> latest-api) - @wget -O swagger.yml https://docs.cycloid.io/api/swagger.yml + @wget https://docs.cycloid.io/api/swagger.yml @export SWAGGER_VERSION=$$(python -c 'import yaml, sys; y = yaml.safe_load(sys.stdin); print(y["info"]["version"])' < swagger.yml); \ if [ -z "$$SWAGGER_VERSION" ]; then echo "Unable to read version from swagger"; exit 1; fi; \ $(DOCKER_COMPOSE) run $(SWAGGER_GENERATE) && \ @@ -123,7 +124,6 @@ generate-client-from-docs: reset-old-client ## Generates client using docker and echo "Please run the following git commands:"; \ echo "git add client" && \ echo "git commit -m 'Bump swagger client to version $$SWAGGER_VERSION'" - $(DOCKER_COMPOSE) run --entrypoint /bin/sh swagger -c "chown -R $(shell id -u):$(shell id -g) ./client" .PHONY: ecr-connect ecr-connect: ## Login to ecr, requires aws cli installed @@ -137,10 +137,10 @@ start-local-be: ## Starts local BE instance. Note! Only for cycloid developers @echo "Generating fake data to be used in the tests..." @cd $(LOCAL_BE_GIT_PATH) && sed -i '/cost-explorer-es/d' config.yml @cd $(LOCAL_BE_GIT_PATH) && YD_API_TAG=${YD_API_TAG} API_LICENCE_KEY=${API_LICENCE_KEY} \ - $(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.cli.yml up youdeploy-init + $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE).yml -f $(DOCKER_COMPOSE).cli.yml up youdeploy-init @echo "Running BE server with the fake data generated..." @cd $(LOCAL_BE_GIT_PATH) && YD_API_TAG=${YD_API_TAG} API_LICENCE_KEY=${API_LICENCE_KEY} \ - $(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.cli.yml up -d youdeploy-api + $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE).yml -f $(DOCKER_COMPOSE).cli.yml up -d youdeploy-api .PHONY: local-e2e-test local-e2e-test: ## Launches local e2e tests. Note! Only for cycloid developers @@ -159,4 +159,3 @@ delete-local-be: ## Creates local BE instance and starts e2e tests. Note! Only f new-changelog-entry: ## Create a new entry for unreleased element @echo ${PATH} docker run -it -v $(CURDIR):/cycloid-cli -w /cycloid-cli cycloid/cycloid-toolkit changie new - diff --git a/go.mod b/go.mod index 30f08713..8ac13551 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cycloidio/cycloid-cli -go 1.22 +go 1.21 require ( dario.cat/mergo v1.0.0 From cd63328cbaa3335a672acbb078b90471b18fad70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 11 Jun 2024 10:33:06 +0200 Subject: [PATCH 84/98] func: bump go version to 1.22.4 --- flake.lock | 16 ++++++++++------ flake.nix | 6 +++--- go.mod | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 79a8d67f..b96a4f0e 100644 --- a/flake.lock +++ b/flake.lock @@ -20,14 +20,18 @@ }, "nixpkgs": { "locked": { - "lastModified": 1696748673, - "narHash": "sha256-UbPHrH4dKN/66EpfFpoG4St4XZYDX9YcMVRQGWzAUNA=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" + "lastModified": 1719848872, + "narHash": "sha256-H3+EC5cYuq+gQW8y0lSrrDZfH71LB4DAf+TDFyvwCNA=", + "owner": "NixOs", + "repo": "nixpkgs", + "rev": "00d80d13810dbfea8ab4ed1009b09100cca86ba8", + "type": "github" }, "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz" + "owner": "NixOs", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index 4d0aea27..13b31a19 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "A basic dev shell for nix/nixos users"; inputs = { - nixpkgs = { url = "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz"; }; + nixpkgs = { url = "github:NixOs/nixpkgs/nixos-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; }; @@ -22,8 +22,8 @@ # You packages here gnumake - # Prod is built using go 1.18 rn - go_1_18 + go_1_22 + go-swagger ]); }; }); diff --git a/go.mod b/go.mod index 8ac13551..30f08713 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cycloidio/cycloid-cli -go 1.21 +go 1.22 require ( dario.cat/mergo v1.0.0 From 10d8a61aaaa5b04d055a1b54e2cf4f5677a3d48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:38:54 +0200 Subject: [PATCH 85/98] misc: fix deprecated code --- cmd/cycloid/common/helpers.go | 4 ++-- e2e/helpers.go | 20 -------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index f94679e8..f435bb0f 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -106,7 +106,7 @@ func WithToken(t string) APIOptions { } type APIClient struct { - *client.API + *client.APIClient Config APIConfig } @@ -148,7 +148,7 @@ func NewAPI(opts ...APIOptions) *APIClient { // tr.DefaultAuthentication = httptransport.BearerToken("token") // api.SetTransport(tr) return &APIClient{ - API: api, + APIClient: api, Config: acfg, } diff --git a/e2e/helpers.go b/e2e/helpers.go index 8f725d49..dfd4801c 100644 --- a/e2e/helpers.go +++ b/e2e/helpers.go @@ -7,7 +7,6 @@ import ( "io" "os" "regexp" - "strings" "time" rootCmd "github.com/cycloidio/cycloid-cli/cmd" @@ -98,25 +97,6 @@ func executeCommand(args []string) (string, error) { return string(cmdOut), cmdErr } -func executeCommandWithStdin(args []string, stdin string) (string, error) { - cmd := rootCmd.NewRootCommand() - - buf := new(bytes.Buffer) - errBuf := new(bytes.Buffer) - cmd.SetOut(buf) - cmd.SetErr(errBuf) - - cmd.SetArgs(args) - cmd.SetIn(strings.NewReader(stdin)) - - cmdErr := cmd.Execute() - cmdOut, err := io.ReadAll(buf) - if err != nil { - panic(fmt.Sprintf("Unable to read command output buffer")) - } - return string(cmdOut), cmdErr -} - // AddNowTimestamp add a timestamp suffix to a string func AddNowTimestamp(txt string) string { return fmt.Sprintf(txt, NowTimestamp) From 8ec5a9f57b8933359f4fcc879c32a784dacf9c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:39:55 +0200 Subject: [PATCH 86/98] func: update generated client with 0.31.0 go-swagger --- .../organization_projects_client.go | 40 ------------------- client/version | 2 +- 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/client/client/organization_projects/organization_projects_client.go b/client/client/organization_projects/organization_projects_client.go index 5ace38d1..b0e0b22f 100644 --- a/client/client/organization_projects/organization_projects_client.go +++ b/client/client/organization_projects/organization_projects_client.go @@ -115,8 +115,6 @@ type ClientService interface { GetProject(params *GetProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectOK, error) - GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectConfigOK, error) - GetProjects(params *GetProjectsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectsOK, error) UpdateProject(params *UpdateProjectParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateProjectOK, error) @@ -352,44 +350,6 @@ func (a *Client) GetProject(params *GetProjectParams, authInfo runtime.ClientAut return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } -/* -GetProjectConfig Fetch the current project's environment's configuration. -*/ -func (a *Client) GetProjectConfig(params *GetProjectConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetProjectConfigOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetProjectConfigParams() - } - op := &runtime.ClientOperation{ - ID: "getProjectConfig", - Method: "GET", - PathPattern: "/organizations/{organization_canonical}/projects/{project_canonical}/environment/{environment_canonical}/config", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/vnd.cycloid.io.v1+json", "application/x-www-form-urlencoded"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetProjectConfigReader{formats: a.formats}, - AuthInfo: authInfo, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetProjectConfigOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*GetProjectConfigDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - /* GetProjects Get list of projects of the organization. */ diff --git a/client/version b/client/version index 1d92c303..f40ebcb9 100644 --- a/client/version +++ b/client/version @@ -1 +1 @@ -v5.0.49 +v5.0.40-saas From 5830be0efacce2092079b2c9fd6df527e6c6a404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:40:37 +0200 Subject: [PATCH 87/98] Bump swagger client to version v5.0.49-saas --- client/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/version b/client/version index f40ebcb9..d5209def 100644 --- a/client/version +++ b/client/version @@ -1 +1 @@ -v5.0.40-saas +v5.0.49-saas From 87e9a14d3ec093a10b1801d94168e9f6f2186f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 14:11:36 +0200 Subject: [PATCH 88/98] func: change api token env var to CY_API_TOKEN --- cmd/cycloid/common/helpers.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index f435bb0f..da9efc0d 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -158,8 +158,16 @@ func (a *APIClient) Credentials(org *string) runtime.ClientAuthInfoWriter { var token = a.Config.Token if token == "" { // we first try to get the token from the env variable - token = os.Getenv("TOKEN") + var ok bool + token, ok = os.LookupEnv("CY_API_TOKEN") + if !ok { + token, ok = os.LookupEnv("TOKEN") + if ok { + fmt.Println("TOKEN env var is deprecated, please use CY_API_TOKEN instead") + } + } } + // if the token is not set with env variable we try to fetch // him from the config (if the user is logged) if len(token) == 0 { From 11412a2dd82636b814c11e6375af25ebba8f927c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:25:55 +0200 Subject: [PATCH 89/98] func: make command to fill org via env var --- cmd/cycloid/apikey/delete.go | 31 ++++++++-------- cmd/cycloid/apikey/get.go | 31 ++++++++-------- cmd/cycloid/apikey/list.go | 30 ++++++++-------- cmd/cycloid/catalog-repositories/create.go | 2 +- cmd/cycloid/catalog-repositories/delete.go | 2 +- cmd/cycloid/catalog-repositories/get.go | 2 +- cmd/cycloid/catalog-repositories/list.go | 2 +- cmd/cycloid/catalog-repositories/refresh.go | 2 +- cmd/cycloid/catalog-repositories/update.go | 2 +- cmd/cycloid/common/flags.go | 18 ++++++++++ cmd/cycloid/common/helpers.go | 4 +-- cmd/cycloid/config-repositories/create.go | 4 +-- cmd/cycloid/config-repositories/delete.go | 2 +- cmd/cycloid/config-repositories/get.go | 2 +- cmd/cycloid/config-repositories/list.go | 2 +- cmd/cycloid/config-repositories/update.go | 2 +- cmd/cycloid/creds/create.go | 5 +-- cmd/cycloid/creds/delete.go | 2 +- cmd/cycloid/creds/get.go | 2 +- cmd/cycloid/creds/list.go | 2 +- cmd/cycloid/creds/update.go | 5 +-- cmd/cycloid/events/send.go | 6 ++-- .../external-backends/create_events.go | 4 +-- .../external-backends/create_infra_view.go | 14 ++++---- cmd/cycloid/external-backends/create_logs.go | 2 +- cmd/cycloid/external-backends/delete.go | 2 +- cmd/cycloid/external-backends/list.go | 4 +-- cmd/cycloid/infrapolicies/create.go | 2 +- cmd/cycloid/infrapolicies/delete.go | 2 +- cmd/cycloid/infrapolicies/get.go | 2 +- cmd/cycloid/infrapolicies/list.go | 2 +- cmd/cycloid/infrapolicies/update.go | 2 +- cmd/cycloid/infrapolicies/validate.go | 6 ++-- cmd/cycloid/kpis/create.go | 2 +- cmd/cycloid/kpis/delete.go | 2 +- cmd/cycloid/kpis/list.go | 2 +- cmd/cycloid/members/delete-invite.go | 2 +- cmd/cycloid/members/delete.go | 2 +- cmd/cycloid/members/get.go | 2 +- cmd/cycloid/members/invite.go | 2 +- cmd/cycloid/members/list-invites.go | 2 +- cmd/cycloid/members/list.go | 2 +- cmd/cycloid/members/update.go | 2 +- cmd/cycloid/organizations/create-children.go | 4 +-- cmd/cycloid/organizations/delete.go | 4 +-- cmd/cycloid/organizations/get.go | 3 +- cmd/cycloid/organizations/list-children.go | 3 +- cmd/cycloid/organizations/list-workers.go | 2 +- cmd/cycloid/organizations/update.go | 3 +- cmd/cycloid/pipelines/clear-task-cache.go | 3 +- cmd/cycloid/pipelines/diff.go | 8 ++--- cmd/cycloid/pipelines/get-job.go | 2 +- cmd/cycloid/pipelines/get.go | 4 +-- cmd/cycloid/pipelines/list-builds.go | 2 +- cmd/cycloid/pipelines/list-jobs.go | 3 +- cmd/cycloid/pipelines/list.go | 2 +- cmd/cycloid/pipelines/pause-job.go | 2 +- cmd/cycloid/pipelines/pause.go | 2 +- cmd/cycloid/pipelines/synced.go | 5 +-- cmd/cycloid/pipelines/trigger-build.go | 3 +- cmd/cycloid/pipelines/unpause-job.go | 2 +- cmd/cycloid/pipelines/unpause.go | 9 +++-- cmd/cycloid/pipelines/update.go | 9 ++--- cmd/cycloid/projects/cmd.go | 2 -- cmd/cycloid/projects/create-env.go | 3 +- cmd/cycloid/projects/create-raw-env.go | 2 +- cmd/cycloid/projects/create.go | 2 +- cmd/cycloid/projects/delete-env.go | 2 +- cmd/cycloid/projects/delete.go | 2 +- cmd/cycloid/projects/get-env.go | 3 +- cmd/cycloid/projects/get.go | 2 +- cmd/cycloid/projects/list.go | 5 +-- cmd/cycloid/roles/delete.go | 2 +- cmd/cycloid/roles/get.go | 2 +- cmd/cycloid/roles/list.go | 2 +- cmd/cycloid/stacks/get.go | 3 +- cmd/cycloid/stacks/list.go | 3 +- cmd/cycloid/stacks/validate-form.go | 3 +- cmd/cycloid/terracost/estimate.go | 36 +++++++++---------- 79 files changed, 188 insertions(+), 183 deletions(-) diff --git a/cmd/cycloid/apikey/delete.go b/cmd/cycloid/apikey/delete.go index d0c52973..e00053f8 100644 --- a/cmd/cycloid/apikey/delete.go +++ b/cmd/cycloid/apikey/delete.go @@ -22,21 +22,7 @@ func NewDeleteCommand() *cobra.Command { # delete the API key 'my-key' in the org my-org cy api-key delete --org my-org --canonical my-key `, - RunE: func(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") - if err != nil { - return fmt.Errorf("unable to get org flag: %w", err) - } - output, err := cmd.Flags().GetString("output") - if err != nil { - return fmt.Errorf("unable to get output flag: %w", err) - } - canonical, err := cmd.Flags().GetString("canonical") - if err != nil { - return fmt.Errorf("unable to get canonical flag: %w", err) - } - return remove(cmd, org, canonical, output) - }, + RunE: remove, } WithFlagCanonical(cmd) @@ -46,7 +32,20 @@ func NewDeleteCommand() *cobra.Command { // remove will send the DELETE request to the API in order to // delete a generated token -func remove(cmd *cobra.Command, org, canonical, output string) error { +func remove(cmd *cobra.Command, args []string) error { + org, err := common.GetOrg(cmd) + if err != nil { + return fmt.Errorf("unable to get org flag: %w", err) + } + output, err := cmd.Flags().GetString("output") + if err != nil { + return fmt.Errorf("unable to get output flag: %w", err) + } + canonical, err := cmd.Flags().GetString("canonical") + if err != nil { + return fmt.Errorf("unable to get canonical flag: %w", err) + } + api := common.NewAPI() m := middleware.NewMiddleware(api) diff --git a/cmd/cycloid/apikey/get.go b/cmd/cycloid/apikey/get.go index c4353481..9b960e16 100644 --- a/cmd/cycloid/apikey/get.go +++ b/cmd/cycloid/apikey/get.go @@ -22,21 +22,7 @@ func NewGetCommand() *cobra.Command { # get API key 'my-key' in the org my-org cy api-key get --org my-org --canonical my-key `, - RunE: func(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") - if err != nil { - return fmt.Errorf("unable to get org flag: %w", err) - } - output, err := cmd.Flags().GetString("output") - if err != nil { - return fmt.Errorf("unable to get output flag: %w", err) - } - canonical, err := cmd.Flags().GetString("canonical") - if err != nil { - return fmt.Errorf("unable to get canonical flag: %w", err) - } - return get(cmd, org, canonical, output) - }, + RunE: get, } WithFlagCanonical(cmd) @@ -46,7 +32,20 @@ func NewGetCommand() *cobra.Command { // get will send the GET request to the API in order to // get the generated token -func get(cmd *cobra.Command, org, canonical, output string) error { +func get(cmd *cobra.Command, args []string) error { + org, err := common.GetOrg(cmd) + if err != nil { + return fmt.Errorf("unable to get org flag: %w", err) + } + output, err := cmd.Flags().GetString("output") + if err != nil { + return fmt.Errorf("unable to get output flag: %w", err) + } + canonical, err := cmd.Flags().GetString("canonical") + if err != nil { + return fmt.Errorf("unable to get canonical flag: %w", err) + } + api := common.NewAPI() m := middleware.NewMiddleware(api) diff --git a/cmd/cycloid/apikey/list.go b/cmd/cycloid/apikey/list.go index ad9ba20e..fe93fdb7 100644 --- a/cmd/cycloid/apikey/list.go +++ b/cmd/cycloid/apikey/list.go @@ -19,35 +19,35 @@ func NewListCommand() *cobra.Command { Use: "list", Short: "list API keys", Example: ` - # list API keys in the org my-org - cy api-key list --org my-org +# list API keys in the org my-org +cy api-key list --org my-org `, - RunE: func(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") - if err != nil { - return fmt.Errorf("unable to get org flag: %w", err) - } - output, err := cmd.Flags().GetString("output") - if err != nil { - return fmt.Errorf("unable to get output flag: %w", err) - } - return list(cmd, org, output) - }, + RunE: list, } return cmd } -// list will send the GET request to the API in order to // list the generated tokens -func list(cmd *cobra.Command, org, output string) error { +func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) + org, err := cmd.Flags().GetString("org") + if err != nil { + return err + } + + output, err := cmd.Flags().GetString("output") + if err != nil { + return fmt.Errorf("unable to get output flag: %w", err) + } + // fetch the printer from the factory p, err := factory.GetPrinter(output) if err != nil { return errors.Wrap(err, "unable to get printer") } + keys, err := m.ListAPIKey(org) return printer.SmartPrint(p, keys, err, "unable to list API keys", printer.Options{}, cmd.OutOrStdout()) } diff --git a/cmd/cycloid/catalog-repositories/create.go b/cmd/cycloid/catalog-repositories/create.go index b21a4d7e..acb3c4d7 100644 --- a/cmd/cycloid/catalog-repositories/create.go +++ b/cmd/cycloid/catalog-repositories/create.go @@ -43,7 +43,7 @@ func createCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/delete.go b/cmd/cycloid/catalog-repositories/delete.go index 9af5a81c..e6345019 100644 --- a/cmd/cycloid/catalog-repositories/delete.go +++ b/cmd/cycloid/catalog-repositories/delete.go @@ -30,7 +30,7 @@ func deleteCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/get.go b/cmd/cycloid/catalog-repositories/get.go index e78822ad..91a2bb1e 100644 --- a/cmd/cycloid/catalog-repositories/get.go +++ b/cmd/cycloid/catalog-repositories/get.go @@ -29,7 +29,7 @@ func getCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/list.go b/cmd/cycloid/catalog-repositories/list.go index 9a5cada7..90bb0a34 100644 --- a/cmd/cycloid/catalog-repositories/list.go +++ b/cmd/cycloid/catalog-repositories/list.go @@ -28,7 +28,7 @@ func listCatalogRepositories(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/refresh.go b/cmd/cycloid/catalog-repositories/refresh.go index 74d75f9c..76238c9c 100644 --- a/cmd/cycloid/catalog-repositories/refresh.go +++ b/cmd/cycloid/catalog-repositories/refresh.go @@ -31,7 +31,7 @@ func refreshCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/catalog-repositories/update.go b/cmd/cycloid/catalog-repositories/update.go index b3e4c708..08801c42 100644 --- a/cmd/cycloid/catalog-repositories/update.go +++ b/cmd/cycloid/catalog-repositories/update.go @@ -36,7 +36,7 @@ func updateCatalogRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/common/flags.go b/cmd/cycloid/common/flags.go index 228da51d..9f96e01b 100644 --- a/cmd/cycloid/common/flags.go +++ b/cmd/cycloid/common/flags.go @@ -1,7 +1,12 @@ package common import ( + "fmt" + "os" + + "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/viper" ) var ( @@ -9,6 +14,19 @@ var ( idFlag uint32 ) +func GetOrg(cmd *cobra.Command) (org string, err error) { + org = viper.GetString("org") + if org == "" { + return "", errors.New("org is not set, use --org flag or CY_ORG env var") + } + + if viper.GetString("verbosity") == "debug" { + fmt.Fprintln(os.Stderr, "\033[1;34mdebug:\033[0m using org:", org) + } + + return org, nil +} + func WithFlagOrg(cmd *cobra.Command) string { flagName := "org" cmd.PersistentFlags().StringVar(&orgFlag, flagName, "", "Org cannonical name") diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index da9efc0d..906c509a 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -159,11 +159,11 @@ func (a *APIClient) Credentials(org *string) runtime.ClientAuthInfoWriter { if token == "" { // we first try to get the token from the env variable var ok bool - token, ok = os.LookupEnv("CY_API_TOKEN") + token, ok = os.LookupEnv("CY_API_KEY") if !ok { token, ok = os.LookupEnv("TOKEN") if ok { - fmt.Println("TOKEN env var is deprecated, please use CY_API_TOKEN instead") + fmt.Println("TOKEN env var is deprecated, please use CY_API_KEY instead") } } } diff --git a/cmd/cycloid/config-repositories/create.go b/cmd/cycloid/config-repositories/create.go index 3ed913ec..1a0c4b1e 100644 --- a/cmd/cycloid/config-repositories/create.go +++ b/cmd/cycloid/config-repositories/create.go @@ -23,8 +23,6 @@ func NewCreateCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } - // create --branch test --cred 105 --url "git@github.com:foo/bla.git" --name configname --default - common.RequiredFlag(common.WithFlagCred, cmd) common.RequiredFlag(WithFlagName, cmd) common.RequiredFlag(WithFlagBranch, cmd) @@ -38,7 +36,7 @@ func createConfigRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/config-repositories/delete.go b/cmd/cycloid/config-repositories/delete.go index ecd67fad..7fc61d99 100644 --- a/cmd/cycloid/config-repositories/delete.go +++ b/cmd/cycloid/config-repositories/delete.go @@ -32,7 +32,7 @@ func deleteConfigRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/config-repositories/get.go b/cmd/cycloid/config-repositories/get.go index 031066cb..905c55fd 100644 --- a/cmd/cycloid/config-repositories/get.go +++ b/cmd/cycloid/config-repositories/get.go @@ -31,7 +31,7 @@ func getConfigRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/config-repositories/list.go b/cmd/cycloid/config-repositories/list.go index ce290bc8..af84e56a 100644 --- a/cmd/cycloid/config-repositories/list.go +++ b/cmd/cycloid/config-repositories/list.go @@ -30,7 +30,7 @@ func listConfigRepositories(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/config-repositories/update.go b/cmd/cycloid/config-repositories/update.go index 82e2eae5..038c37c4 100644 --- a/cmd/cycloid/config-repositories/update.go +++ b/cmd/cycloid/config-repositories/update.go @@ -39,7 +39,7 @@ func updateConfigRepository(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/creds/create.go b/cmd/cycloid/creds/create.go index 645b6b30..f225778e 100644 --- a/cmd/cycloid/creds/create.go +++ b/cmd/cycloid/creds/create.go @@ -3,6 +3,7 @@ package creds import ( "fmt" "io/ioutil" + "os" "strings" "github.com/pkg/errors" @@ -187,7 +188,7 @@ func create(cmd *cobra.Command, args []string) error { var rawCred *models.CredentialRaw credT := cmd.CalledAs() - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } @@ -226,7 +227,7 @@ func create(cmd *cobra.Command, args []string) error { return err } - sshKey, err := ioutil.ReadFile(sshKeyPath) + sshKey, err := os.ReadFile(sshKeyPath) if err != nil { return errors.Wrap(err, "unable to read SSH key") } diff --git a/cmd/cycloid/creds/delete.go b/cmd/cycloid/creds/delete.go index 41359993..b7a93513 100644 --- a/cmd/cycloid/creds/delete.go +++ b/cmd/cycloid/creds/delete.go @@ -31,7 +31,7 @@ func del(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/creds/get.go b/cmd/cycloid/creds/get.go index 2a151da3..0fcc750a 100644 --- a/cmd/cycloid/creds/get.go +++ b/cmd/cycloid/creds/get.go @@ -32,7 +32,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/creds/list.go b/cmd/cycloid/creds/list.go index d380677d..e2c1d0e5 100644 --- a/cmd/cycloid/creds/list.go +++ b/cmd/cycloid/creds/list.go @@ -31,7 +31,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/creds/update.go b/cmd/cycloid/creds/update.go index 879af8e8..5996eb7c 100644 --- a/cmd/cycloid/creds/update.go +++ b/cmd/cycloid/creds/update.go @@ -3,6 +3,7 @@ package creds import ( "fmt" "io/ioutil" + "os" "strings" "github.com/cycloidio/cycloid-cli/client/models" @@ -198,7 +199,7 @@ func update(cmd *cobra.Command, args []string) error { var rawCred *models.CredentialRaw credT := cmd.CalledAs() - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } @@ -237,7 +238,7 @@ func update(cmd *cobra.Command, args []string) error { return err } - sshKey, err := ioutil.ReadFile(sshKeyPath) + sshKey, err := os.ReadFile(sshKeyPath) if err != nil { return errors.Wrap(err, "unable to read SSH key") } diff --git a/cmd/cycloid/events/send.go b/cmd/cycloid/events/send.go index cc137b51..c17b7687 100644 --- a/cmd/cycloid/events/send.go +++ b/cmd/cycloid/events/send.go @@ -2,7 +2,7 @@ package events import ( "fmt" - "io/ioutil" + "os" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -58,7 +58,7 @@ func send(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } @@ -104,7 +104,7 @@ func send(cmd *cobra.Command, args []string) error { var msg string if messageFile != "" { - rawMsg, err := ioutil.ReadFile(messageFile) + rawMsg, err := os.ReadFile(messageFile) if err != nil { return errors.Wrap(err, "unable to read message file") } diff --git a/cmd/cycloid/external-backends/create_events.go b/cmd/cycloid/external-backends/create_events.go index 7383dc9f..024331a5 100644 --- a/cmd/cycloid/external-backends/create_events.go +++ b/cmd/cycloid/external-backends/create_events.go @@ -19,13 +19,13 @@ func createEvents(cmd *cobra.Command, args []string) error { var ( err error - org, cred string + cred string purpose = "events" ebC models.ExternalBackendConfiguration engine = cmd.CalledAs() ) - org, err = cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/external-backends/create_infra_view.go b/cmd/cycloid/external-backends/create_infra_view.go index 45cb78bd..f3cc1a32 100644 --- a/cmd/cycloid/external-backends/create_infra_view.go +++ b/cmd/cycloid/external-backends/create_infra_view.go @@ -18,19 +18,19 @@ func createInfraView(cmd *cobra.Command, args []string) error { m := middleware.NewMiddleware(api) var ( - purpose = "remote_tfstate" - err error - org, project, env string - ebC models.ExternalBackendConfiguration - engine = cmd.CalledAs() - defaultEB bool + purpose = "remote_tfstate" + err error + project, env string + ebC models.ExternalBackendConfiguration + engine = cmd.CalledAs() + defaultEB bool ) output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") } - org, err = cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/external-backends/create_logs.go b/cmd/cycloid/external-backends/create_logs.go index 1d4f4ae9..f06591cc 100644 --- a/cmd/cycloid/external-backends/create_logs.go +++ b/cmd/cycloid/external-backends/create_logs.go @@ -29,7 +29,7 @@ func createLogs(cmd *cobra.Command, args []string) error { if err != nil { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/external-backends/delete.go b/cmd/cycloid/external-backends/delete.go index 82aaa34e..6fff5d8f 100644 --- a/cmd/cycloid/external-backends/delete.go +++ b/cmd/cycloid/external-backends/delete.go @@ -32,7 +32,7 @@ func del(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/external-backends/list.go b/cmd/cycloid/external-backends/list.go index cb2fe4b6..e296f18e 100644 --- a/cmd/cycloid/external-backends/list.go +++ b/cmd/cycloid/external-backends/list.go @@ -34,8 +34,6 @@ func NewListCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - return cmd } @@ -43,7 +41,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/create.go b/cmd/cycloid/infrapolicies/create.go index 90077a26..9fafb8de 100644 --- a/cmd/cycloid/infrapolicies/create.go +++ b/cmd/cycloid/infrapolicies/create.go @@ -49,7 +49,7 @@ func create(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/delete.go b/cmd/cycloid/infrapolicies/delete.go index 8a5ea745..ecf65619 100644 --- a/cmd/cycloid/infrapolicies/delete.go +++ b/cmd/cycloid/infrapolicies/delete.go @@ -35,7 +35,7 @@ func delete(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/get.go b/cmd/cycloid/infrapolicies/get.go index b267293f..542837be 100644 --- a/cmd/cycloid/infrapolicies/get.go +++ b/cmd/cycloid/infrapolicies/get.go @@ -35,7 +35,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/list.go b/cmd/cycloid/infrapolicies/list.go index d4e89119..74f56424 100644 --- a/cmd/cycloid/infrapolicies/list.go +++ b/cmd/cycloid/infrapolicies/list.go @@ -36,7 +36,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/update.go b/cmd/cycloid/infrapolicies/update.go index 9bba2843..6d10f72e 100644 --- a/cmd/cycloid/infrapolicies/update.go +++ b/cmd/cycloid/infrapolicies/update.go @@ -50,7 +50,7 @@ func update(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/infrapolicies/validate.go b/cmd/cycloid/infrapolicies/validate.go index 0686980d..07759b92 100644 --- a/cmd/cycloid/infrapolicies/validate.go +++ b/cmd/cycloid/infrapolicies/validate.go @@ -2,7 +2,7 @@ package infrapolicies import ( "fmt" - "io/ioutil" + "os" "github.com/spf13/cobra" @@ -35,7 +35,7 @@ func NewValidateCommand() *cobra.Command { // validate will send the GET request to the API in order to // validate the terraform Plan located in planPath func validate(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return fmt.Errorf("unable to validate org flag: %w", err) } @@ -56,7 +56,7 @@ func validate(cmd *cobra.Command, args []string) error { return fmt.Errorf("unable to get output flag: %w", err) } - plan, err := ioutil.ReadFile(planPath) + plan, err := os.ReadFile(planPath) if err != nil { return fmt.Errorf("unable to read terraform plan file: %w", err) } diff --git a/cmd/cycloid/kpis/create.go b/cmd/cycloid/kpis/create.go index 593f4b03..1ce183a1 100644 --- a/cmd/cycloid/kpis/create.go +++ b/cmd/cycloid/kpis/create.go @@ -44,7 +44,7 @@ func create(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/kpis/delete.go b/cmd/cycloid/kpis/delete.go index 378dd9a4..cfdd32d3 100644 --- a/cmd/cycloid/kpis/delete.go +++ b/cmd/cycloid/kpis/delete.go @@ -33,7 +33,7 @@ func delete(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/kpis/list.go b/cmd/cycloid/kpis/list.go index c1cd0e61..3da61fc7 100644 --- a/cmd/cycloid/kpis/list.go +++ b/cmd/cycloid/kpis/list.go @@ -33,7 +33,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/delete-invite.go b/cmd/cycloid/members/delete-invite.go index 6ba4e482..f38826e0 100644 --- a/cmd/cycloid/members/delete-invite.go +++ b/cmd/cycloid/members/delete-invite.go @@ -43,7 +43,7 @@ func deleteInvite(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/delete.go b/cmd/cycloid/members/delete.go index 2c30d2fd..18cfd3f5 100644 --- a/cmd/cycloid/members/delete.go +++ b/cmd/cycloid/members/delete.go @@ -39,7 +39,7 @@ func deleteMember(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/get.go b/cmd/cycloid/members/get.go index c28d6a72..93d2155c 100644 --- a/cmd/cycloid/members/get.go +++ b/cmd/cycloid/members/get.go @@ -44,7 +44,7 @@ func getMember(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/invite.go b/cmd/cycloid/members/invite.go index a7e59b92..547b6bb5 100644 --- a/cmd/cycloid/members/invite.go +++ b/cmd/cycloid/members/invite.go @@ -40,7 +40,7 @@ func inviteMember(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/list-invites.go b/cmd/cycloid/members/list-invites.go index feae7328..423c759d 100644 --- a/cmd/cycloid/members/list-invites.go +++ b/cmd/cycloid/members/list-invites.go @@ -42,7 +42,7 @@ func listInvites(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/list.go b/cmd/cycloid/members/list.go index 81c164a0..22823f29 100644 --- a/cmd/cycloid/members/list.go +++ b/cmd/cycloid/members/list.go @@ -42,7 +42,7 @@ func listMembers(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/members/update.go b/cmd/cycloid/members/update.go index b9f69ca3..e1cbd6ec 100644 --- a/cmd/cycloid/members/update.go +++ b/cmd/cycloid/members/update.go @@ -47,7 +47,7 @@ func updateConfigRepository(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/organizations/create-children.go b/cmd/cycloid/organizations/create-children.go index e38fd8a5..c30a0430 100644 --- a/cmd/cycloid/organizations/create-children.go +++ b/cmd/cycloid/organizations/create-children.go @@ -18,7 +18,6 @@ func NewCreateChildCommand() *cobra.Command { RunE: createChild, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) common.RequiredPersistentFlag(WithFlagParentOrganization, cmd) return cmd @@ -28,10 +27,11 @@ func createChild(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + porg, err := cmd.Flags().GetString("parent-org") if err != nil { return err diff --git a/cmd/cycloid/organizations/delete.go b/cmd/cycloid/organizations/delete.go index 399158e4..dda49147 100644 --- a/cmd/cycloid/organizations/delete.go +++ b/cmd/cycloid/organizations/delete.go @@ -24,8 +24,6 @@ func NewDeleteCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - return cmd } @@ -33,7 +31,7 @@ func del(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return errors.Wrap(err, "unable get org flag") } diff --git a/cmd/cycloid/organizations/get.go b/cmd/cycloid/organizations/get.go index c41bd49d..677470f1 100644 --- a/cmd/cycloid/organizations/get.go +++ b/cmd/cycloid/organizations/get.go @@ -22,7 +22,6 @@ func NewGetCommand() *cobra.Command { RunE: get, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } @@ -31,7 +30,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/organizations/list-children.go b/cmd/cycloid/organizations/list-children.go index 18ab8a2b..c00489ad 100644 --- a/cmd/cycloid/organizations/list-children.go +++ b/cmd/cycloid/organizations/list-children.go @@ -21,7 +21,6 @@ func NewListChildrensCommand() *cobra.Command { RunE: listChildrens, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } @@ -30,7 +29,7 @@ func listChildrens(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/organizations/list-workers.go b/cmd/cycloid/organizations/list-workers.go index e75bc1c3..6a4b038e 100644 --- a/cmd/cycloid/organizations/list-workers.go +++ b/cmd/cycloid/organizations/list-workers.go @@ -27,7 +27,7 @@ func listWorkers(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/organizations/update.go b/cmd/cycloid/organizations/update.go index b14d1d7f..8e062f7e 100644 --- a/cmd/cycloid/organizations/update.go +++ b/cmd/cycloid/organizations/update.go @@ -25,7 +25,6 @@ func NewUpdateCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) common.RequiredFlag(WithFlagName, cmd) return cmd @@ -40,7 +39,7 @@ func update(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return errors.Wrap(err, "unable get org flag") } diff --git a/cmd/cycloid/pipelines/clear-task-cache.go b/cmd/cycloid/pipelines/clear-task-cache.go index 4dbfb080..6086e83f 100644 --- a/cmd/cycloid/pipelines/clear-task-cache.go +++ b/cmd/cycloid/pipelines/clear-task-cache.go @@ -1,7 +1,6 @@ package pipelines import ( - "github.com/pkg/errors" "github.com/spf13/cobra" @@ -36,7 +35,7 @@ func cleartaskCache(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/diff.go b/cmd/cycloid/pipelines/diff.go index 4cb0afb3..d4fb53e4 100644 --- a/cmd/cycloid/pipelines/diff.go +++ b/cmd/cycloid/pipelines/diff.go @@ -2,7 +2,7 @@ package pipelines import ( "fmt" - "io/ioutil" + "io/os" "github.com/pkg/errors" @@ -38,7 +38,7 @@ func diff(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } @@ -69,13 +69,13 @@ func diff(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get printer") } - rawPipeline, err := ioutil.ReadFile(pipelinePath) + rawPipeline, err := os.ReadFile(pipelinePath) if err != nil { return fmt.Errorf("Pipeline file reading error : %s", err.Error()) } pipelineTemplate := string(rawPipeline) - rawVars, err := ioutil.ReadFile(varsPath) + rawVars, err := os.ReadFile(varsPath) if err != nil { return fmt.Errorf("Pipeline variables file reading error : %s", err.Error()) } diff --git a/cmd/cycloid/pipelines/get-job.go b/cmd/cycloid/pipelines/get-job.go index d664db75..55865527 100644 --- a/cmd/cycloid/pipelines/get-job.go +++ b/cmd/cycloid/pipelines/get-job.go @@ -34,7 +34,7 @@ func getJob(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/get.go b/cmd/cycloid/pipelines/get.go index 1e6f7310..17d3337f 100644 --- a/cmd/cycloid/pipelines/get.go +++ b/cmd/cycloid/pipelines/get.go @@ -23,8 +23,6 @@ func NewGetCommand() *cobra.Command { RunE: get, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - common.RequiredPersistentFlag(common.WithFlagProject, cmd) common.RequiredPersistentFlag(common.WithFlagEnv, cmd) @@ -35,7 +33,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/list-builds.go b/cmd/cycloid/pipelines/list-builds.go index 436904f4..e7502300 100644 --- a/cmd/cycloid/pipelines/list-builds.go +++ b/cmd/cycloid/pipelines/list-builds.go @@ -34,7 +34,7 @@ func listBuilds(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/list-jobs.go b/cmd/cycloid/pipelines/list-jobs.go index 70107820..39706f8f 100644 --- a/cmd/cycloid/pipelines/list-jobs.go +++ b/cmd/cycloid/pipelines/list-jobs.go @@ -33,10 +33,11 @@ func listJobs(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err diff --git a/cmd/cycloid/pipelines/list.go b/cmd/cycloid/pipelines/list.go index a96eaa12..aefb2930 100644 --- a/cmd/cycloid/pipelines/list.go +++ b/cmd/cycloid/pipelines/list.go @@ -26,7 +26,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/pause-job.go b/cmd/cycloid/pipelines/pause-job.go index 201861b7..d4093866 100644 --- a/cmd/cycloid/pipelines/pause-job.go +++ b/cmd/cycloid/pipelines/pause-job.go @@ -34,7 +34,7 @@ func pauseJob(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/pause.go b/cmd/cycloid/pipelines/pause.go index 43e1a91b..19feb1d9 100644 --- a/cmd/cycloid/pipelines/pause.go +++ b/cmd/cycloid/pipelines/pause.go @@ -33,7 +33,7 @@ func pause(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/synced.go b/cmd/cycloid/pipelines/synced.go index 315d2aec..7f0d8be2 100644 --- a/cmd/cycloid/pipelines/synced.go +++ b/cmd/cycloid/pipelines/synced.go @@ -25,8 +25,6 @@ func NewSyncedCommand() *cobra.Command { RunE: synced, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - common.RequiredPersistentFlag(common.WithFlagProject, cmd) common.RequiredPersistentFlag(common.WithFlagEnv, cmd) @@ -41,14 +39,17 @@ func synced(cmd *cobra.Command, args []string) error { if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err } + env, err := cmd.Flags().GetString("env") if err != nil { return err } + output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") diff --git a/cmd/cycloid/pipelines/trigger-build.go b/cmd/cycloid/pipelines/trigger-build.go index 9d9c2264..9688557f 100644 --- a/cmd/cycloid/pipelines/trigger-build.go +++ b/cmd/cycloid/pipelines/trigger-build.go @@ -34,10 +34,11 @@ func createBuild(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err diff --git a/cmd/cycloid/pipelines/unpause-job.go b/cmd/cycloid/pipelines/unpause-job.go index 71414634..a9d42353 100644 --- a/cmd/cycloid/pipelines/unpause-job.go +++ b/cmd/cycloid/pipelines/unpause-job.go @@ -34,7 +34,7 @@ func unpauseJob(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/pipelines/unpause.go b/cmd/cycloid/pipelines/unpause.go index 80a11d72..b8f22d64 100644 --- a/cmd/cycloid/pipelines/unpause.go +++ b/cmd/cycloid/pipelines/unpause.go @@ -16,8 +16,8 @@ func NewUnpauseCommand() *cobra.Command { Use: "unpause", Short: "unpause a pipeline", Example: ` - # unpause pipeline my-project-env - cy --org my-org pipeline unpause --project my-project --env env +# unpause pipeline my-project-env +cy --org my-org pipeline unpause --project my-project --env env `, RunE: unpause, PreRunE: internal.CheckAPIAndCLIVersion, @@ -33,18 +33,21 @@ func unpause(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err } + env, err := cmd.Flags().GetString("env") if err != nil { return err } + output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") diff --git a/cmd/cycloid/pipelines/update.go b/cmd/cycloid/pipelines/update.go index b6cd441c..e45203bc 100644 --- a/cmd/cycloid/pipelines/update.go +++ b/cmd/cycloid/pipelines/update.go @@ -1,7 +1,7 @@ package pipelines import ( - "io/ioutil" + "os" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -40,10 +40,11 @@ func update(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } + project, err := cmd.Flags().GetString("project") if err != nil { return err @@ -71,13 +72,13 @@ func update(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get printer") } - rawPipeline, err := ioutil.ReadFile(pipelinePath) + rawPipeline, err := os.ReadFile(pipelinePath) if err != nil { return errors.Wrap(err, "unable to read pipeline file") } pipeline := string(rawPipeline) - rawVars, err := ioutil.ReadFile(varsPath) + rawVars, err := os.ReadFile(varsPath) if err != nil { return errors.Wrap(err, "unable to read variables file") } diff --git a/cmd/cycloid/projects/cmd.go b/cmd/cycloid/projects/cmd.go index 0504dfee..78f51b9c 100644 --- a/cmd/cycloid/projects/cmd.go +++ b/cmd/cycloid/projects/cmd.go @@ -1,7 +1,6 @@ package projects import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -14,7 +13,6 @@ func NewCommands() *cobra.Command { }, Short: "Manage the projects", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewDeleteCommand(), NewCreateCommand(), diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 906b28dd..cb1cfac9 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -64,7 +64,6 @@ cy project get-env-config --org my-org --project my-project --env prod \ RunE: createEnv, } - common.WithFlagOrg(cmd) cmd.PersistentFlags().StringP("project", "p", "", "project name") cmd.MarkFlagRequired("project") cmd.PersistentFlags().StringP("env", "e", "", "environment name") @@ -86,7 +85,7 @@ func createEnv(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/create-raw-env.go b/cmd/cycloid/projects/create-raw-env.go index a022702f..74a276b3 100644 --- a/cmd/cycloid/projects/create-raw-env.go +++ b/cmd/cycloid/projects/create-raw-env.go @@ -63,7 +63,7 @@ func createRawEnv(cmd *cobra.Command, args []string) error { var err error - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/create.go b/cmd/cycloid/projects/create.go index 7c624535..033c8525 100644 --- a/cmd/cycloid/projects/create.go +++ b/cmd/cycloid/projects/create.go @@ -53,7 +53,7 @@ func create(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/delete-env.go b/cmd/cycloid/projects/delete-env.go index c738ab3d..f51f86e6 100644 --- a/cmd/cycloid/projects/delete-env.go +++ b/cmd/cycloid/projects/delete-env.go @@ -32,7 +32,7 @@ func deleteEnv(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/delete.go b/cmd/cycloid/projects/delete.go index 0d6dbc1e..5051ede4 100644 --- a/cmd/cycloid/projects/delete.go +++ b/cmd/cycloid/projects/delete.go @@ -31,7 +31,7 @@ func del(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/get-env.go b/cmd/cycloid/projects/get-env.go index d700a238..c5c0d776 100644 --- a/cmd/cycloid/projects/get-env.go +++ b/cmd/cycloid/projects/get-env.go @@ -48,7 +48,6 @@ cy --org my-org project get-env-config my-project my-project use_case -o yaml`, Args: cobra.RangeArgs(0, 2), } - common.WithFlagOrg(cmd) cmd.Flags().StringP("project", "p", "", "specify the project") cmd.Flags().StringP("env", "e", "", "specify the env") cmd.Flags().BoolP("default", "d", false, "if set, will fetch the default value from the stack instead of the current ones.") @@ -85,7 +84,7 @@ func getEnvConfig(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/get.go b/cmd/cycloid/projects/get.go index e314d23e..acc2cf07 100644 --- a/cmd/cycloid/projects/get.go +++ b/cmd/cycloid/projects/get.go @@ -32,7 +32,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/projects/list.go b/cmd/cycloid/projects/list.go index eb3eb8d7..7f05e7e4 100644 --- a/cmd/cycloid/projects/list.go +++ b/cmd/cycloid/projects/list.go @@ -29,10 +29,11 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { - return err + return errors.Wrap(err, "unable to get org") } + output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") diff --git a/cmd/cycloid/roles/delete.go b/cmd/cycloid/roles/delete.go index f6a6d0bf..c9d1443b 100644 --- a/cmd/cycloid/roles/delete.go +++ b/cmd/cycloid/roles/delete.go @@ -39,7 +39,7 @@ func deleteRole(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/roles/get.go b/cmd/cycloid/roles/get.go index e72c59df..8f10143c 100644 --- a/cmd/cycloid/roles/get.go +++ b/cmd/cycloid/roles/get.go @@ -44,7 +44,7 @@ func getRole(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/roles/list.go b/cmd/cycloid/roles/list.go index 0af97424..aeac294b 100644 --- a/cmd/cycloid/roles/list.go +++ b/cmd/cycloid/roles/list.go @@ -42,7 +42,7 @@ func listRoles(cmd *cobra.Command, args []string) error { return err } - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/stacks/get.go b/cmd/cycloid/stacks/get.go index 206bb468..6f8b4ebc 100644 --- a/cmd/cycloid/stacks/get.go +++ b/cmd/cycloid/stacks/get.go @@ -24,7 +24,6 @@ func NewGetCommand() *cobra.Command { RunE: get, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.Flags().StringVar(&refFlag, "ref", "", "referential of the stack") cmd.MarkFlagRequired("ref") @@ -36,7 +35,7 @@ func get(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/stacks/list.go b/cmd/cycloid/stacks/list.go index 76ac7a72..4ce05c57 100644 --- a/cmd/cycloid/stacks/list.go +++ b/cmd/cycloid/stacks/list.go @@ -22,7 +22,6 @@ func NewListCommand() *cobra.Command { RunE: list, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } @@ -31,7 +30,7 @@ func list(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/stacks/validate-form.go b/cmd/cycloid/stacks/validate-form.go index 6f88d7be..775d5fa5 100644 --- a/cmd/cycloid/stacks/validate-form.go +++ b/cmd/cycloid/stacks/validate-form.go @@ -24,7 +24,6 @@ func NewValidateFormCmd() *cobra.Command { RunE: validateForm, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) common.RequiredPersistentFlag(WithFlagForms, cmd) return cmd @@ -34,7 +33,7 @@ func validateForm(cmd *cobra.Command, args []string) error { api := common.NewAPI() m := middleware.NewMiddleware(api) - org, err := cmd.Flags().GetString("org") + org, err := common.GetOrg(cmd) if err != nil { return err } diff --git a/cmd/cycloid/terracost/estimate.go b/cmd/cycloid/terracost/estimate.go index e2f170ab..a880c47b 100644 --- a/cmd/cycloid/terracost/estimate.go +++ b/cmd/cycloid/terracost/estimate.go @@ -2,7 +2,7 @@ package terracost import ( "fmt" - "io/ioutil" + "os" "github.com/spf13/cobra" @@ -16,29 +16,27 @@ import ( // of the cost estimation func NewEstimateCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "estimate", - RunE: func(cmd *cobra.Command, args []string) error { - org, err := cmd.Flags().GetString("org") - if err != nil { - return fmt.Errorf("unable to validate org flag: %w", err) - } - planPath, err := cmd.Flags().GetString("plan-path") - if err != nil { - return fmt.Errorf("unable to get plan path flag: %w", err) - } - output, err := cmd.Flags().GetString("output") - if err != nil { - return fmt.Errorf("unable to get output flag: %w", err) - } - return estimate(cmd, org, planPath, output) - }, + Use: "estimate", + RunE: estimate, } common.RequiredFlag(WithFlagPlanPath, cmd) return cmd } -func estimate(cmd *cobra.Command, org, planPath, output string) error { - plan, err := ioutil.ReadFile(planPath) +func estimate(cmd *cobra.Command, args []string) error { + org, err := common.GetOrg(cmd) + if err != nil { + return fmt.Errorf("unable to validate org flag: %w", err) + } + planPath, err := cmd.Flags().GetString("plan-path") + if err != nil { + return fmt.Errorf("unable to get plan path flag: %w", err) + } + output, err := cmd.Flags().GetString("output") + if err != nil { + return fmt.Errorf("unable to get output flag: %w", err) + } + plan, err := os.ReadFile(planPath) if err != nil { return fmt.Errorf("unable to read terraform plan file: %w", err) } From d7510412543b5b0e409daad43ecc001a132c16f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:26:18 +0200 Subject: [PATCH 90/98] func: allow setting API_KEY via env var for login --- cmd/cycloid/login/login.go | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index 21539443..bd4e7add 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -3,6 +3,7 @@ package login import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" @@ -20,23 +21,10 @@ func NewCommands() *cobra.Command { cy login --org my-org --api-key eyJhbGciOiJI... `, PreRunE: internal.CheckAPIAndCLIVersion, - RunE: func(cmd *cobra.Command, args []string) error { - - org, err := cmd.Flags().GetString("org") - if err != nil { - return errors.Wrap(err, "unable to get org flag") - } - apiKey, err := cmd.Flags().GetString("api-key") - if err != nil { - return errors.Wrap(err, "unable to get child flag") - } - - return login(org, apiKey) - }, + RunE: login, } - common.RequiredFlag(WithFlagAPIKey, cmd) - common.RequiredFlag(WithFlagOrg, cmd) + WithFlagAPIKey(cmd) cmd.AddCommand( NewListCommand(), @@ -45,10 +33,21 @@ func NewCommands() *cobra.Command { return cmd } -func login(org, key string) error { +func login(cmd *cobra.Command, args []string) error { + conf, _ := config.Read() // If err != nil, the file does not exist, we create it anyway + org, err := common.GetOrg(cmd) + if err != nil { + return errors.Wrap(err, "unable to get org flag") + } + + apiKey := viper.GetString("api-key") + if apiKey == "" { + return errors.Wrap(err, "apiKey not set or invalid") + } + // Check for a nil map. // This can be the case if the config file is empty if conf.Organizations == nil { @@ -56,7 +55,7 @@ func login(org, key string) error { } conf.Organizations[org] = config.Organization{ - Token: key, + Token: apiKey, } if err := config.Write(conf); err != nil { From 75e4b3c1e2e737e69a4a451994472f8c28efc155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 15:33:49 +0200 Subject: [PATCH 91/98] fix: remove last required org flags --- cmd/cycloid/apikey/cmd.go | 3 --- cmd/cycloid/catalog-repositories/cmd.go | 2 -- cmd/cycloid/config-repositories/cmd.go | 3 --- cmd/cycloid/creds/cmd.go | 2 -- cmd/cycloid/events/cmd.go | 3 --- cmd/cycloid/external-backends/cmd.go | 2 -- cmd/cycloid/infrapolicies/cmd.go | 5 +---- cmd/cycloid/login/common.go | 10 ++-------- cmd/cycloid/login/login.go | 2 ++ cmd/cycloid/members/cmd.go | 3 --- cmd/cycloid/pipelines/cmd.go | 3 --- cmd/cycloid/pipelines/diff.go | 2 +- cmd/cycloid/roles/cmd.go | 3 --- cmd/cycloid/terracost/cmd.go | 4 ---- 14 files changed, 6 insertions(+), 41 deletions(-) diff --git a/cmd/cycloid/apikey/cmd.go b/cmd/cycloid/apikey/cmd.go index e409f41b..ad3a59c9 100644 --- a/cmd/cycloid/apikey/cmd.go +++ b/cmd/cycloid/apikey/cmd.go @@ -2,8 +2,6 @@ package apikey import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) var ( @@ -24,7 +22,6 @@ func NewCommands() *cobra.Command { Example: example, Short: short, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand( NewDeleteCommand(), diff --git a/cmd/cycloid/catalog-repositories/cmd.go b/cmd/cycloid/catalog-repositories/cmd.go index e7f8a7ad..811c92a3 100644 --- a/cmd/cycloid/catalog-repositories/cmd.go +++ b/cmd/cycloid/catalog-repositories/cmd.go @@ -1,7 +1,6 @@ package catalogRepositories import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -15,7 +14,6 @@ func NewCommands() *cobra.Command { }, Short: "Manage the catalog repositories", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewCreateCommand(), NewUpdateCommand(), diff --git a/cmd/cycloid/config-repositories/cmd.go b/cmd/cycloid/config-repositories/cmd.go index 09edc295..93c59d94 100644 --- a/cmd/cycloid/config-repositories/cmd.go +++ b/cmd/cycloid/config-repositories/cmd.go @@ -2,8 +2,6 @@ package configRepositories import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) func NewCommands() *cobra.Command { @@ -15,7 +13,6 @@ func NewCommands() *cobra.Command { }, Short: "Manage the catalog repositories", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewCreateCommand(), NewUpdateCommand(), diff --git a/cmd/cycloid/creds/cmd.go b/cmd/cycloid/creds/cmd.go index fc6d7930..44ec7304 100644 --- a/cmd/cycloid/creds/cmd.go +++ b/cmd/cycloid/creds/cmd.go @@ -1,7 +1,6 @@ package creds import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -22,7 +21,6 @@ func NewCommands() *cobra.Command { NewDeleteCommand(), NewListCommand(), NewGetCommand()) - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } diff --git a/cmd/cycloid/events/cmd.go b/cmd/cycloid/events/cmd.go index d281e866..814362d5 100644 --- a/cmd/cycloid/events/cmd.go +++ b/cmd/cycloid/events/cmd.go @@ -1,7 +1,6 @@ package events import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -15,8 +14,6 @@ func NewCommands() *cobra.Command { Short: "Manage the events", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - cmd.AddCommand(NewSendCommand()) return cmd diff --git a/cmd/cycloid/external-backends/cmd.go b/cmd/cycloid/external-backends/cmd.go index 1d09b7ae..118c9b79 100644 --- a/cmd/cycloid/external-backends/cmd.go +++ b/cmd/cycloid/external-backends/cmd.go @@ -1,7 +1,6 @@ package externalBackends import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -14,7 +13,6 @@ func NewCommands() *cobra.Command { }, Short: "manage external backends", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewGetCommand(), NewDeleteCommand(), diff --git a/cmd/cycloid/infrapolicies/cmd.go b/cmd/cycloid/infrapolicies/cmd.go index fe8e0130..7d26c910 100644 --- a/cmd/cycloid/infrapolicies/cmd.go +++ b/cmd/cycloid/infrapolicies/cmd.go @@ -2,8 +2,6 @@ package infrapolicies import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) func NewCommands() *cobra.Command { @@ -18,13 +16,12 @@ func NewCommands() *cobra.Command { Short: "Manage the infraPolicies", } - common.RequiredFlag(common.WithFlagOrg, cmd) - cmd.AddCommand(NewValidateCommand(), NewUpdateCommand(), NewCreateCommand(), NewListCommand(), NewGetCommand(), NewDeleteCommand()) + return cmd } diff --git a/cmd/cycloid/login/common.go b/cmd/cycloid/login/common.go index f583bbde..940ce60f 100644 --- a/cmd/cycloid/login/common.go +++ b/cmd/cycloid/login/common.go @@ -3,8 +3,8 @@ package login import "github.com/spf13/cobra" var ( - apiKeyFlag string - orgFlag string + apiKeyFlag string + orgFlag string ) func WithFlagAPIKey(cmd *cobra.Command) string { @@ -12,9 +12,3 @@ func WithFlagAPIKey(cmd *cobra.Command) string { cmd.Flags().StringVar(&apiKeyFlag, flagName, "", "API key") return flagName } - -func WithFlagOrg(cmd *cobra.Command) string { - flagName := "org" - cmd.Flags().StringVar(&orgFlag, flagName, "", "Org cannonical name") - return flagName -} diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index bd4e7add..c70bc2ad 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -25,6 +25,7 @@ func NewCommands() *cobra.Command { } WithFlagAPIKey(cmd) + viper.BindPFlag("api-key", cmd.Flags().Lookup("api-key")) cmd.AddCommand( NewListCommand(), @@ -43,6 +44,7 @@ func login(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get org flag") } + // Get api key via env var or cli flag apiKey := viper.GetString("api-key") if apiKey == "" { return errors.Wrap(err, "apiKey not set or invalid") diff --git a/cmd/cycloid/members/cmd.go b/cmd/cycloid/members/cmd.go index 37a606bf..7489d215 100644 --- a/cmd/cycloid/members/cmd.go +++ b/cmd/cycloid/members/cmd.go @@ -2,8 +2,6 @@ package members import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) func NewCommands() *cobra.Command { @@ -22,7 +20,6 @@ func NewCommands() *cobra.Command { Short: short, Long: long, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewUpdateCommand(), NewDeleteCommand(), diff --git a/cmd/cycloid/pipelines/cmd.go b/cmd/cycloid/pipelines/cmd.go index 3d651ea6..461b0619 100644 --- a/cmd/cycloid/pipelines/cmd.go +++ b/cmd/cycloid/pipelines/cmd.go @@ -1,7 +1,6 @@ package pipelines import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -15,8 +14,6 @@ func NewCommands() *cobra.Command { Short: "Manage the pipelines", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) - cmd.AddCommand(NewUnpauseJobCommand(), NewUpdateCommand(), NewGetJobCommand(), diff --git a/cmd/cycloid/pipelines/diff.go b/cmd/cycloid/pipelines/diff.go index d4fb53e4..050992c0 100644 --- a/cmd/cycloid/pipelines/diff.go +++ b/cmd/cycloid/pipelines/diff.go @@ -2,7 +2,7 @@ package pipelines import ( "fmt" - "io/os" + "os" "github.com/pkg/errors" diff --git a/cmd/cycloid/roles/cmd.go b/cmd/cycloid/roles/cmd.go index bae802e2..5da2e851 100644 --- a/cmd/cycloid/roles/cmd.go +++ b/cmd/cycloid/roles/cmd.go @@ -2,8 +2,6 @@ package roles import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) func NewCommands() *cobra.Command { @@ -22,7 +20,6 @@ func NewCommands() *cobra.Command { Short: short, Long: long, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewDeleteCommand(), NewListCommand(), diff --git a/cmd/cycloid/terracost/cmd.go b/cmd/cycloid/terracost/cmd.go index dabe4ca6..17eee9ad 100644 --- a/cmd/cycloid/terracost/cmd.go +++ b/cmd/cycloid/terracost/cmd.go @@ -2,8 +2,6 @@ package terracost import ( "github.com/spf13/cobra" - - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" ) // NewCommands returns an implementation of Terracost commands @@ -17,8 +15,6 @@ func NewCommands() *cobra.Command { Short: "Use terracost feature", } - common.RequiredFlag(common.WithFlagOrg, cmd) - cmd.AddCommand(NewEstimateCommand()) return cmd } From 0e3b8f8881c482f035808c55b8245f41e107ac83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 16:22:27 +0200 Subject: [PATCH 92/98] func: make login use CY_API_KEY env var as preference --- cmd/cycloid.go | 13 ++++++++++++- cmd/cycloid/common/helpers.go | 4 ++-- cmd/cycloid/login/common.go | 14 -------------- cmd/cycloid/login/login.go | 26 ++++++++++++++++++-------- 4 files changed, 32 insertions(+), 25 deletions(-) delete mode 100644 cmd/cycloid/login/common.go diff --git a/cmd/cycloid.go b/cmd/cycloid.go index 8b99c3c5..f1eb4ff0 100644 --- a/cmd/cycloid.go +++ b/cmd/cycloid.go @@ -47,7 +47,15 @@ func NewRootCommand() *cobra.Command { SilenceUsage: false, Use: "cy", Short: "Cycloid CLI", - Long: `Cy is a CLI for Cycloid framework. Learn more at https://www.cycloid.io/.`, + Long: `CLI tool to interact with Cycloid API. +Documentation at https://docs.beta.cycloid.io/reference/cli/ + +Environment: + +CY_API_URL -> Specify the HTTP url of Cycloid API to use, default https://http-api.cycloid.io +CY_ORG -> Set the current organization +CY_API_TOKEN -> Set the current API TOKEN +CY_VERBOSITY -> Set the verbosity level (debug, info, warning, error), default warning `, } rootCmd.PersistentFlags().StringVarP(&userOutput, "output", "o", "table", "The formatting style for command output: json|yaml|table") @@ -63,6 +71,9 @@ func NewRootCommand() *cobra.Command { rootCmd.PersistentFlags().Bool("insecure", false, "Decide to skip or not TLS verification") viper.BindPFlag("insecure", rootCmd.PersistentFlags().Lookup("insecure")) + rootCmd.PersistentFlags().String("org", "", "Specify the org to use. override CY_ORG env var. Required for all Org scoped endpoint.") + viper.BindPFlag("org", rootCmd.PersistentFlags().Lookup("org")) + // Remove usage on error, this is annoying in scripting rootCmd.SilenceUsage = true diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index 906c509a..da9efc0d 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -159,11 +159,11 @@ func (a *APIClient) Credentials(org *string) runtime.ClientAuthInfoWriter { if token == "" { // we first try to get the token from the env variable var ok bool - token, ok = os.LookupEnv("CY_API_KEY") + token, ok = os.LookupEnv("CY_API_TOKEN") if !ok { token, ok = os.LookupEnv("TOKEN") if ok { - fmt.Println("TOKEN env var is deprecated, please use CY_API_KEY instead") + fmt.Println("TOKEN env var is deprecated, please use CY_API_TOKEN instead") } } } diff --git a/cmd/cycloid/login/common.go b/cmd/cycloid/login/common.go deleted file mode 100644 index 940ce60f..00000000 --- a/cmd/cycloid/login/common.go +++ /dev/null @@ -1,14 +0,0 @@ -package login - -import "github.com/spf13/cobra" - -var ( - apiKeyFlag string - orgFlag string -) - -func WithFlagAPIKey(cmd *cobra.Command) string { - flagName := "api-key" - cmd.Flags().StringVar(&apiKeyFlag, flagName, "", "API key") - return flagName -} diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index c70bc2ad..3c37b8a9 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -8,6 +8,8 @@ import ( "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" "github.com/cycloidio/cycloid-cli/config" + "github.com/cycloidio/cycloid-cli/printer" + "github.com/cycloidio/cycloid-cli/printer/factory" ) // NewCommands returns the cobra command holding @@ -16,15 +18,14 @@ func NewCommands() *cobra.Command { cmd := &cobra.Command{ Use: "login", Short: "Login against the Cycloid console", - Example: `, - # Login in an org using api-key - cy login --org my-org --api-key eyJhbGciOiJI... -`, + Example: `# Login in an org using api-key +export CY_API_KEY=xxxx +cy login --org my-org`, PreRunE: internal.CheckAPIAndCLIVersion, RunE: login, } - WithFlagAPIKey(cmd) + cmd.Flags().String("api-key", "", "[deprecated] set the API key, use CY_API_KEY env var instead.") viper.BindPFlag("api-key", cmd.Flags().Lookup("api-key")) cmd.AddCommand( @@ -35,7 +36,6 @@ func NewCommands() *cobra.Command { } func login(cmd *cobra.Command, args []string) error { - conf, _ := config.Read() // If err != nil, the file does not exist, we create it anyway @@ -44,10 +44,20 @@ func login(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "unable to get org flag") } + p, err := factory.GetPrinter(viper.GetString("output")) + if err != nil { + return errors.Wrap(err, "unable to get printer") + } + // Get api key via env var or cli flag apiKey := viper.GetString("api-key") if apiKey == "" { - return errors.Wrap(err, "apiKey not set or invalid") + return printer.SmartPrint(p, apiKey, nil, "CY_API_KEY is not set or invalid", printer.Options{}, cmd.OutOrStderr()) + } + + // Warn user about deprecation + if cmd.Flags().Lookup("api-key").Changed { + internal.Warning(cmd.OutOrStderr(), "--api-key is deprecated, use CY_API_KEY env var instead") } // Check for a nil map. @@ -61,7 +71,7 @@ func login(cmd *cobra.Command, args []string) error { } if err := config.Write(conf); err != nil { - return errors.Wrap(err, "unable to save config") + return printer.SmartPrint(p, apiKey, err, "unable to write config file", printer.Options{}, cmd.OutOrStderr()) } return nil From c177fabd4c548ece0b77d5a0c8b6cb7b1bffea0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 16:41:48 +0200 Subject: [PATCH 93/98] fix: fix bad merge --- cmd/cycloid/common/helpers.go | 11 +---- cmd/cycloid/projects/create-env.go | 66 ++++++++++++++++++++++-------- 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/cmd/cycloid/common/helpers.go b/cmd/cycloid/common/helpers.go index f0064819..56fcf449 100644 --- a/cmd/cycloid/common/helpers.go +++ b/cmd/cycloid/common/helpers.go @@ -316,12 +316,7 @@ func EntityGetValue(entity *models.FormEntity, getCurrent bool) any { } } -func ParseFormsConfig(conf *models.ProjectEnvironmentConfig, useCase string, getCurrent bool) (vars map[string]map[string]map[string]any, err error) { - form, err := GetFormsUseCase(conf.Forms.UseCases, useCase) - if err != nil { - return nil, errors.Wrap(err, "failed to extract forms data from project config.") - } - +func ParseFormsConfig(form *models.FormUseCase, getCurrent bool) (vars map[string]map[string]map[string]any, err error) { vars = make(map[string]map[string]map[string]any) for _, section := range form.Sections { if section == nil { @@ -342,9 +337,7 @@ func ParseFormsConfig(conf *models.ProjectEnvironmentConfig, useCase string, get } value := EntityGetValue(varEntity, getCurrent) - // We have to strings.ToLower() the keys otherwise, it will not be - // recognized as input for a create-env - vars[strings.ToLower(*varEntity.Name)] = value + vars[*varEntity.Key] = value } groups[strings.ToLower(*group.Name)] = vars diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index ebcf4c18..0e5eef0e 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -15,6 +15,7 @@ import ( "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/cycloidio/cycloid-cli/cmd/cycloid/internal" "github.com/cycloidio/cycloid-cli/cmd/cycloid/middleware" + "github.com/cycloidio/cycloid-cli/cmd/cycloid/stacks" "github.com/cycloidio/cycloid-cli/printer" "github.com/cycloidio/cycloid-cli/printer/factory" ) @@ -25,6 +26,9 @@ func NewCreateEnvCommand() *cobra.Command { Short: "create an environment within a project using StackForms.", Long: `Create or update (with --update) an environment within a project using StackForms. +By default, the command will fetch the stack's default value for you to override. +You can cancel this with the --no-fetch-defaults flag + You can use the following ways to fill in the stackforms configuration (in the order of precedence): 1. --var-file (-f) flag -> accept any valid JSON file, if the filename is "-", read from stdin (can be set multiple times) 2. CY_STACKFORMS_VAR env var -> accept any valid JSON string (can be multiple json objects) @@ -60,6 +64,7 @@ cy project get-env-config --org my-org --project my-project --env prod \ RunE: createEnv, } + common.WithFlagOrg(cmd) cmd.PersistentFlags().StringP("project", "p", "", "project name") cmd.MarkFlagRequired("project") cmd.PersistentFlags().StringP("env", "e", "", "environment name") @@ -70,6 +75,7 @@ cy project get-env-config --org my-org --project my-project --env prod \ cmd.PersistentFlags().StringArrayP("json-vars", "j", nil, "JSON string containing variables, can be set multiple times.") cmd.PersistentFlags().StringToStringP("var", "V", nil, `update a variable using a field=value syntax (e.g. -V section.group.key=value)`) cmd.PersistentFlags().Bool("update", false, "allow to override existing environment") + cmd.PersistentFlags().Bool("no-fetch-defaults", false, "disable the fetching of the stacks default values") return cmd } @@ -85,13 +91,6 @@ func createEnv(cmd *cobra.Command, args []string) error { return err } - // Right now, in the way orgs are handled, there is a possibility - // of an empty org. - // TODO: Fix in another PR about orgs. - if org == "" { - return errors.New("org is empty, please specify an org with --org") - } - project, err := cmd.Flags().GetString("project") if err != nil { return err @@ -110,12 +109,12 @@ func createEnv(cmd *cobra.Command, args []string) error { return errors.New("env must be at least 2 characters long") } - usecase, err := cmd.Flags().GetString("use-case") + useCase, err := cmd.Flags().GetString("use-case") if err != nil { return err } - if usecase == "" { + if useCase == "" { return errors.New("use-case is empty, please specify an use-case with --use-case") } @@ -134,12 +133,43 @@ func createEnv(cmd *cobra.Command, args []string) error { return err } + noFetchDefault, err := cmd.Flags().GetBool("no-fetch-defaults") + if err != nil { + return err + } + // // Variable merge // - var vars = make(map[string]interface{}) + // We need the project data first to get the stack ref + projectData, err := m.GetProject(org, project) + if err != nil { + return err + } + + if !noFetchDefault { + // First we fetch the stack's default + stack, err := m.GetStackConfig(org, *projectData.ServiceCatalog.Ref) + if err != nil { + return errors.Wrap(err, "failed to retrieve stack's defaults values") + } + + data, err := stacks.ExtractFormsFromStackConfig(stack, useCase) + if err != nil { + return err + } + + defaultValues, err := common.ParseFormsConfig(data, false) + if err != nil { + return err + } + + // We merge default values first + mergo.Merge(&vars, defaultValues, mergo.WithOverride) + } + // Fetch vars from files and stdin for _, varFile := range varsFiles { internal.Debug("found var file", varFile) @@ -218,11 +248,6 @@ func createEnv(cmd *cobra.Command, args []string) error { common.UpdateMapField(k, v, vars) } - projectData, err := m.GetProject(org, project) - if err != nil { - return err - } - output, err := cmd.Flags().GetString("output") if err != nil { return errors.Wrap(err, "unable to get output flag") @@ -273,7 +298,7 @@ func createEnv(cmd *cobra.Command, args []string) error { // Infer icon and color based on usecase var cloudProviderCanonical, icon, color string - switch strings.ToLower(usecase) { + switch strings.ToLower(useCase) { case "aws": cloudProviderCanonical = "aws" icon = "mdi-aws" @@ -306,7 +331,7 @@ func createEnv(cmd *cobra.Command, args []string) error { inputs := []*models.FormInput{ { EnvironmentCanonical: &env, - UseCase: &usecase, + UseCase: &useCase, Vars: vars, }, } @@ -331,7 +356,12 @@ func createEnv(cmd *cobra.Command, args []string) error { return printer.SmartPrint(p, inputs[0].Vars, errors.Wrap(err, errMsg), "", printer.Options{}, cmd.OutOrStdout()) } - formsConfig, err := common.ParseFormsConfig(config, usecase, true) + form, err := common.GetFormsUseCase(config.Forms.UseCases, useCase) + if err != nil { + return errors.Wrap(err, "failed to extract forms data from project config.") + } + + formsConfig, err := common.ParseFormsConfig(form, true) if err != nil { return printer.SmartPrint(p, inputs[0].Vars, errors.Wrap(err, errMsg), "", printer.Options{}, cmd.OutOrStdout()) } From 01d67e1cc53b31ffa3a18c80385bd271cea70583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 17:32:42 +0200 Subject: [PATCH 94/98] fix(test): --api-key is not required anymore --- e2e/login_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/e2e/login_test.go b/e2e/login_test.go index fc3d7cfc..cfe8f7d1 100644 --- a/e2e/login_test.go +++ b/e2e/login_test.go @@ -1,9 +1,7 @@ -//go:build e2e -// +build e2e - package e2e import ( + "os" "testing" "github.com/stretchr/testify/assert" @@ -11,7 +9,7 @@ import ( ) func TestLogin(t *testing.T) { - t.Run("SuccessOrgLogin", func(t *testing.T) { + t.Run("SuccessOrgLoginLegacy", func(t *testing.T) { cmdOut, cmdErr := executeCommand([]string{ "login", "--org", CY_TEST_ROOT_ORG, @@ -22,13 +20,16 @@ func TestLogin(t *testing.T) { assert.Equal(t, "", cmdOut) }) - t.Run("ErrorMissingRequiredFlag", func(t *testing.T) { - _, cmdErr := executeCommand([]string{ + t.Run("SuccessOrgLogin", func(t *testing.T) { + err := os.Setenv("CY_API_KEY", CY_TEST_ROOT_API_KEY) + require.Nil(t, err) + + cmdOut, cmdErr := executeCommand([]string{ "login", "--org", CY_TEST_ROOT_ORG, }) - require.NotNil(t, cmdErr) - assert.Contains(t, string(cmdErr.Error()), "required flag(s) \"api-key\" not set") + require.Nil(t, cmdErr) + assert.Equal(t, "", cmdOut) }) } From 3e71994f368589ed968616419c6972743fabd5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 17:33:13 +0200 Subject: [PATCH 95/98] fix(tests): fix last org flags shinanigans --- cmd/cycloid/common/flags.go | 6 ------ cmd/cycloid/external-backends/delete.go | 1 - cmd/cycloid/kpis/cmd.go | 2 -- cmd/cycloid/login/login.go | 6 +++--- cmd/cycloid/organizations/list-workers.go | 1 - cmd/cycloid/projects/create-env.go | 1 - 6 files changed, 3 insertions(+), 14 deletions(-) diff --git a/cmd/cycloid/common/flags.go b/cmd/cycloid/common/flags.go index 9f96e01b..1c3b8c2d 100644 --- a/cmd/cycloid/common/flags.go +++ b/cmd/cycloid/common/flags.go @@ -27,12 +27,6 @@ func GetOrg(cmd *cobra.Command) (org string, err error) { return org, nil } -func WithFlagOrg(cmd *cobra.Command) string { - flagName := "org" - cmd.PersistentFlags().StringVar(&orgFlag, flagName, "", "Org cannonical name") - return flagName -} - func WithFlagProject(cmd *cobra.Command) string { flagName := "project" cmd.PersistentFlags().StringVar(&projectFlag, flagName, "", "Project cannonical name") diff --git a/cmd/cycloid/external-backends/delete.go b/cmd/cycloid/external-backends/delete.go index 6fff5d8f..1e31f873 100644 --- a/cmd/cycloid/external-backends/delete.go +++ b/cmd/cycloid/external-backends/delete.go @@ -23,7 +23,6 @@ func NewDeleteCommand() *cobra.Command { PreRunE: internal.CheckAPIAndCLIVersion, } common.RequiredFlag(common.WithFlagID, cmd) - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } diff --git a/cmd/cycloid/kpis/cmd.go b/cmd/cycloid/kpis/cmd.go index d612a8af..c2452ae3 100644 --- a/cmd/cycloid/kpis/cmd.go +++ b/cmd/cycloid/kpis/cmd.go @@ -1,7 +1,6 @@ package kpis import ( - "github.com/cycloidio/cycloid-cli/cmd/cycloid/common" "github.com/spf13/cobra" ) @@ -13,7 +12,6 @@ func NewCommands() *cobra.Command { }, Short: "Manage the kpis", } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) cmd.AddCommand(NewCreateCommand(), NewDeleteCommand(), diff --git a/cmd/cycloid/login/login.go b/cmd/cycloid/login/login.go index 3c37b8a9..f1e51de8 100644 --- a/cmd/cycloid/login/login.go +++ b/cmd/cycloid/login/login.go @@ -52,12 +52,12 @@ func login(cmd *cobra.Command, args []string) error { // Get api key via env var or cli flag apiKey := viper.GetString("api-key") if apiKey == "" { - return printer.SmartPrint(p, apiKey, nil, "CY_API_KEY is not set or invalid", printer.Options{}, cmd.OutOrStderr()) + return printer.SmartPrint(p, nil, nil, "CY_API_KEY is not set or invalid", printer.Options{}, cmd.OutOrStderr()) } // Warn user about deprecation if cmd.Flags().Lookup("api-key").Changed { - internal.Warning(cmd.OutOrStderr(), "--api-key is deprecated, use CY_API_KEY env var instead") + internal.Warning(cmd.ErrOrStderr(), "--api-key is deprecated, use CY_API_KEY env var instead") } // Check for a nil map. @@ -71,7 +71,7 @@ func login(cmd *cobra.Command, args []string) error { } if err := config.Write(conf); err != nil { - return printer.SmartPrint(p, apiKey, err, "unable to write config file", printer.Options{}, cmd.OutOrStderr()) + return printer.SmartPrint(p, nil, err, "unable to write config file", printer.Options{}, cmd.OutOrStderr()) } return nil diff --git a/cmd/cycloid/organizations/list-workers.go b/cmd/cycloid/organizations/list-workers.go index 6a4b038e..49ddd16b 100644 --- a/cmd/cycloid/organizations/list-workers.go +++ b/cmd/cycloid/organizations/list-workers.go @@ -18,7 +18,6 @@ func NewListWorkersCommand() *cobra.Command { RunE: listWorkers, PreRunE: internal.CheckAPIAndCLIVersion, } - common.RequiredPersistentFlag(common.WithFlagOrg, cmd) return cmd } diff --git a/cmd/cycloid/projects/create-env.go b/cmd/cycloid/projects/create-env.go index 0e5eef0e..9e6e15d1 100644 --- a/cmd/cycloid/projects/create-env.go +++ b/cmd/cycloid/projects/create-env.go @@ -64,7 +64,6 @@ cy project get-env-config --org my-org --project my-project --env prod \ RunE: createEnv, } - common.WithFlagOrg(cmd) cmd.PersistentFlags().StringP("project", "p", "", "project name") cmd.MarkFlagRequired("project") cmd.PersistentFlags().StringP("env", "e", "", "environment name") From 6103014a6a2b5e55cd540f28baa81175bfde47fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 17:33:28 +0200 Subject: [PATCH 96/98] misc: fix makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f56c5d24..67ef5d09 100644 --- a/Makefile +++ b/Makefile @@ -133,7 +133,7 @@ ecr-connect: ## Login to ecr, requires aws cli installed start-local-be: ## Starts local BE instance. Note! Only for cycloid developers @if [ ! -d ${LOCAL_BE_GIT_PATH} ]; then echo "Unable to find BE at LOCAL_BE_GIT_PATH"; exit 1; fi; @if [ -z "$$API_LICENCE_KEY" ]; then echo "API_LICENCE_KEY is not set"; exit 1; fi; \ - @echo "Starting Local BE..." + echo "Starting Local BE..." @echo "Generating fake data to be used in the tests..." @cd $(LOCAL_BE_GIT_PATH) && sed -i '/cost-explorer-es/d' config.yml @cd $(LOCAL_BE_GIT_PATH) && YD_API_TAG=${YD_API_TAG} API_LICENCE_KEY=${API_LICENCE_KEY} \ From 633baeeb0ac5a761b34ecb25d00b79a470745e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 17:41:54 +0200 Subject: [PATCH 97/98] misc: add changelog --- changelog/unreleased/CLI-BREAKING-20240702-154137.yaml | 9 +++++++++ changelog/unreleased/CLI-CHANGED-20240702-153738.yaml | 9 +++++++++ changelog/unreleased/CLI-FIXED-20240702-154027.yaml | 9 +++++++++ changelog/unreleased/CLI-SECURITY-20240702-153824.yaml | 8 ++++++++ changelog/unreleased/CLI-SECURITY-20240702-153935.yaml | 10 ++++++++++ 5 files changed, 45 insertions(+) create mode 100644 changelog/unreleased/CLI-BREAKING-20240702-154137.yaml create mode 100644 changelog/unreleased/CLI-CHANGED-20240702-153738.yaml create mode 100644 changelog/unreleased/CLI-FIXED-20240702-154027.yaml create mode 100644 changelog/unreleased/CLI-SECURITY-20240702-153824.yaml create mode 100644 changelog/unreleased/CLI-SECURITY-20240702-153935.yaml diff --git a/changelog/unreleased/CLI-BREAKING-20240702-154137.yaml b/changelog/unreleased/CLI-BREAKING-20240702-154137.yaml new file mode 100644 index 00000000..fa35081d --- /dev/null +++ b/changelog/unreleased/CLI-BREAKING-20240702-154137.yaml @@ -0,0 +1,9 @@ +component: CLI +kind: BREAKING +body: Env var TOKEN is replaced by CY_API_KEY for giving token via env var. +time: 2024-07-02T15:41:37.096071763Z +custom: + DETAILS: The old `TOKEN` env var still works but emits a warning. It will be removed + in a futur release. + PR: "273" + TYPE: CLI diff --git a/changelog/unreleased/CLI-CHANGED-20240702-153738.yaml b/changelog/unreleased/CLI-CHANGED-20240702-153738.yaml new file mode 100644 index 00000000..9b9baf0d --- /dev/null +++ b/changelog/unreleased/CLI-CHANGED-20240702-153738.yaml @@ -0,0 +1,9 @@ +component: CLI +kind: CHANGED +body: Allow to use CY_ORG env var to define the current org instead of --org flag +time: 2024-07-02T15:37:38.698172633Z +custom: + DETAILS: You can still use the --org flag, the CLI flag will have precedence over + the env var. + PR: "273" + TYPE: CLI diff --git a/changelog/unreleased/CLI-FIXED-20240702-154027.yaml b/changelog/unreleased/CLI-FIXED-20240702-154027.yaml new file mode 100644 index 00000000..b0bf9138 --- /dev/null +++ b/changelog/unreleased/CLI-FIXED-20240702-154027.yaml @@ -0,0 +1,9 @@ +component: CLI +kind: FIXED +body: --org flag is now global +time: 2024-07-02T15:40:27.815286561Z +custom: + DETAILS: This fixes inconsistency between commands, you can also set the org via + env vars now. + PR: "273" + TYPE: CLI diff --git a/changelog/unreleased/CLI-SECURITY-20240702-153824.yaml b/changelog/unreleased/CLI-SECURITY-20240702-153824.yaml new file mode 100644 index 00000000..95d759a7 --- /dev/null +++ b/changelog/unreleased/CLI-SECURITY-20240702-153824.yaml @@ -0,0 +1,8 @@ +component: CLI +kind: SECURITY +body: Make the configuration write as 0600 permissions in user home config +time: 2024-07-02T15:38:24.286288523Z +custom: + DETAILS: "" + PR: "273" + TYPE: CLI diff --git a/changelog/unreleased/CLI-SECURITY-20240702-153935.yaml b/changelog/unreleased/CLI-SECURITY-20240702-153935.yaml new file mode 100644 index 00000000..d0cf0705 --- /dev/null +++ b/changelog/unreleased/CLI-SECURITY-20240702-153935.yaml @@ -0,0 +1,10 @@ +component: CLI +kind: SECURITY +body: Allow to login using CY_API_TOKEN instead of providing the token via --api-token + flag +time: 2024-07-02T15:39:35.1456052Z +custom: + DETAILS: This will become the default way, using the flag will be deprecated in + the future. + PR: "273" + TYPE: CLI From 3b6e0933919018c32d33f10cee3b1dcf7ea5d07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BARRAS=20HAMPEL?= Date: Tue, 2 Jul 2024 17:43:58 +0200 Subject: [PATCH 98/98] misc: fix changelog pr number --- changelog/unreleased/CLI-BREAKING-20240702-154137.yaml | 2 +- changelog/unreleased/CLI-CHANGED-20240702-153738.yaml | 2 +- changelog/unreleased/CLI-FIXED-20240702-154027.yaml | 2 +- changelog/unreleased/CLI-SECURITY-20240702-153824.yaml | 2 +- changelog/unreleased/CLI-SECURITY-20240702-153935.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog/unreleased/CLI-BREAKING-20240702-154137.yaml b/changelog/unreleased/CLI-BREAKING-20240702-154137.yaml index fa35081d..031d2a20 100644 --- a/changelog/unreleased/CLI-BREAKING-20240702-154137.yaml +++ b/changelog/unreleased/CLI-BREAKING-20240702-154137.yaml @@ -5,5 +5,5 @@ time: 2024-07-02T15:41:37.096071763Z custom: DETAILS: The old `TOKEN` env var still works but emits a warning. It will be removed in a futur release. - PR: "273" + PR: "274" TYPE: CLI diff --git a/changelog/unreleased/CLI-CHANGED-20240702-153738.yaml b/changelog/unreleased/CLI-CHANGED-20240702-153738.yaml index 9b9baf0d..b4f6a3ee 100644 --- a/changelog/unreleased/CLI-CHANGED-20240702-153738.yaml +++ b/changelog/unreleased/CLI-CHANGED-20240702-153738.yaml @@ -5,5 +5,5 @@ time: 2024-07-02T15:37:38.698172633Z custom: DETAILS: You can still use the --org flag, the CLI flag will have precedence over the env var. - PR: "273" + PR: "274" TYPE: CLI diff --git a/changelog/unreleased/CLI-FIXED-20240702-154027.yaml b/changelog/unreleased/CLI-FIXED-20240702-154027.yaml index b0bf9138..a223db30 100644 --- a/changelog/unreleased/CLI-FIXED-20240702-154027.yaml +++ b/changelog/unreleased/CLI-FIXED-20240702-154027.yaml @@ -5,5 +5,5 @@ time: 2024-07-02T15:40:27.815286561Z custom: DETAILS: This fixes inconsistency between commands, you can also set the org via env vars now. - PR: "273" + PR: "274" TYPE: CLI diff --git a/changelog/unreleased/CLI-SECURITY-20240702-153824.yaml b/changelog/unreleased/CLI-SECURITY-20240702-153824.yaml index 95d759a7..30ff4dae 100644 --- a/changelog/unreleased/CLI-SECURITY-20240702-153824.yaml +++ b/changelog/unreleased/CLI-SECURITY-20240702-153824.yaml @@ -4,5 +4,5 @@ body: Make the configuration write as 0600 permissions in user home config time: 2024-07-02T15:38:24.286288523Z custom: DETAILS: "" - PR: "273" + PR: "274" TYPE: CLI diff --git a/changelog/unreleased/CLI-SECURITY-20240702-153935.yaml b/changelog/unreleased/CLI-SECURITY-20240702-153935.yaml index d0cf0705..db132caf 100644 --- a/changelog/unreleased/CLI-SECURITY-20240702-153935.yaml +++ b/changelog/unreleased/CLI-SECURITY-20240702-153935.yaml @@ -6,5 +6,5 @@ time: 2024-07-02T15:39:35.1456052Z custom: DETAILS: This will become the default way, using the flag will be deprecated in the future. - PR: "273" + PR: "274" TYPE: CLI