From f77e0a73315e393f9534e89a8ad067cfbf5d9c65 Mon Sep 17 00:00:00 2001 From: "L.Dongming" Date: Tue, 5 Nov 2024 13:20:01 +0800 Subject: [PATCH] chore: set engineOptions acountOption.privileges and ParameterOption->versions not required --- .generator/schemas/adminapi.yaml | 2 - .generator/schemas/openapi.yaml | 2 - api/kbcloud/admin/model_account_option.go | 41 +++++++++++---------- api/kbcloud/admin/model_parameter_option.go | 31 +++++++++------- api/kbcloud/model_account_option.go | 41 +++++++++++---------- api/kbcloud/model_parameter_option.go | 31 +++++++++------- 6 files changed, 78 insertions(+), 70 deletions(-) diff --git a/.generator/schemas/adminapi.yaml b/.generator/schemas/adminapi.yaml index 5d9530bb..b6d604ff 100644 --- a/.generator/schemas/adminapi.yaml +++ b/.generator/schemas/adminapi.yaml @@ -17191,7 +17191,6 @@ components: type: object required: - enabled - - privileges - accountNamePattern - create - resetPassword @@ -17535,7 +17534,6 @@ components: required: - component - configs - - versions - exportTpl - family - defaultTplName diff --git a/.generator/schemas/openapi.yaml b/.generator/schemas/openapi.yaml index f5aa9169..57d1a73b 100644 --- a/.generator/schemas/openapi.yaml +++ b/.generator/schemas/openapi.yaml @@ -13108,7 +13108,6 @@ components: type: object required: - enabled - - privileges - accountNamePattern - create - resetPassword @@ -13452,7 +13451,6 @@ components: required: - component - configs - - versions - exportTpl - family - defaultTplName diff --git a/api/kbcloud/admin/model_account_option.go b/api/kbcloud/admin/model_account_option.go index 9e684b92..e1f97725 100644 --- a/api/kbcloud/admin/model_account_option.go +++ b/api/kbcloud/admin/model_account_option.go @@ -12,7 +12,7 @@ import ( type AccountOption struct { Enabled bool `json:"enabled"` - Privileges []string `json:"privileges"` + Privileges []string `json:"privileges,omitempty"` AccountNamePattern string `json:"accountNamePattern"` Create bool `json:"create"` ResetPassword bool `json:"resetPassword"` @@ -26,10 +26,9 @@ type AccountOption struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed. -func NewAccountOption(enabled bool, privileges []string, accountNamePattern string, create bool, resetPassword bool, delete bool) *AccountOption { +func NewAccountOption(enabled bool, accountNamePattern string, create bool, resetPassword bool, delete bool) *AccountOption { this := AccountOption{} this.Enabled = enabled - this.Privileges = privileges this.AccountNamePattern = accountNamePattern this.Create = create this.ResetPassword = resetPassword @@ -68,25 +67,30 @@ func (o *AccountOption) SetEnabled(v bool) { o.Enabled = v } -// GetPrivileges returns the Privileges field value. +// GetPrivileges returns the Privileges field value if set, zero value otherwise. func (o *AccountOption) GetPrivileges() []string { - if o == nil { + if o == nil || o.Privileges == nil { var ret []string return ret } return o.Privileges } -// GetPrivilegesOk returns a tuple with the Privileges field value +// GetPrivilegesOk returns a tuple with the Privileges field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *AccountOption) GetPrivilegesOk() (*[]string, bool) { - if o == nil { + if o == nil || o.Privileges == nil { return nil, false } return &o.Privileges, true } -// SetPrivileges sets field value. +// HasPrivileges returns a boolean if a field has been set. +func (o *AccountOption) HasPrivileges() bool { + return o != nil && o.Privileges != nil +} + +// SetPrivileges gets a reference to the given []string and assigns it to the Privileges field. func (o *AccountOption) SetPrivileges(v []string) { o.Privileges = v } @@ -190,7 +194,9 @@ func (o AccountOption) MarshalJSON() ([]byte, error) { return common.Marshal(o.UnparsedObject) } toSerialize["enabled"] = o.Enabled - toSerialize["privileges"] = o.Privileges + if o.Privileges != nil { + toSerialize["privileges"] = o.Privileges + } toSerialize["accountNamePattern"] = o.AccountNamePattern toSerialize["create"] = o.Create toSerialize["resetPassword"] = o.ResetPassword @@ -205,12 +211,12 @@ func (o AccountOption) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *AccountOption) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Enabled *bool `json:"enabled"` - Privileges *[]string `json:"privileges"` - AccountNamePattern *string `json:"accountNamePattern"` - Create *bool `json:"create"` - ResetPassword *bool `json:"resetPassword"` - Delete *bool `json:"delete"` + Enabled *bool `json:"enabled"` + Privileges []string `json:"privileges,omitempty"` + AccountNamePattern *string `json:"accountNamePattern"` + Create *bool `json:"create"` + ResetPassword *bool `json:"resetPassword"` + Delete *bool `json:"delete"` }{} if err = common.Unmarshal(bytes, &all); err != nil { return common.Unmarshal(bytes, &o.UnparsedObject) @@ -218,9 +224,6 @@ func (o *AccountOption) UnmarshalJSON(bytes []byte) (err error) { if all.Enabled == nil { return fmt.Errorf("required field enabled missing") } - if all.Privileges == nil { - return fmt.Errorf("required field privileges missing") - } if all.AccountNamePattern == nil { return fmt.Errorf("required field accountNamePattern missing") } @@ -240,7 +243,7 @@ func (o *AccountOption) UnmarshalJSON(bytes []byte) (err error) { return err } o.Enabled = *all.Enabled - o.Privileges = *all.Privileges + o.Privileges = all.Privileges o.AccountNamePattern = *all.AccountNamePattern o.Create = *all.Create o.ResetPassword = *all.ResetPassword diff --git a/api/kbcloud/admin/model_parameter_option.go b/api/kbcloud/admin/model_parameter_option.go index 49b03b1b..78d2440f 100644 --- a/api/kbcloud/admin/model_parameter_option.go +++ b/api/kbcloud/admin/model_parameter_option.go @@ -14,7 +14,7 @@ type ParameterOption struct { Component string `json:"component"` Configs []ParameterConfig `json:"configs"` // deprecated - Versions []string `json:"versions"` + Versions []string `json:"versions,omitempty"` ExportTpl bool `json:"exportTpl"` // a alias with major version. Family string `json:"family"` @@ -32,11 +32,10 @@ type ParameterOption struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed. -func NewParameterOption(component string, configs []ParameterConfig, versions []string, exportTpl bool, family string, defaultTplName string, defaultTplDescription LocalizedDescription) *ParameterOption { +func NewParameterOption(component string, configs []ParameterConfig, exportTpl bool, family string, defaultTplName string, defaultTplDescription LocalizedDescription) *ParameterOption { this := ParameterOption{} this.Component = component this.Configs = configs - this.Versions = versions this.ExportTpl = exportTpl this.Family = family this.DefaultTplName = defaultTplName @@ -102,25 +101,30 @@ func (o *ParameterOption) SetConfigs(v []ParameterConfig) { o.Configs = v } -// GetVersions returns the Versions field value. +// GetVersions returns the Versions field value if set, zero value otherwise. func (o *ParameterOption) GetVersions() []string { - if o == nil { + if o == nil || o.Versions == nil { var ret []string return ret } return o.Versions } -// GetVersionsOk returns a tuple with the Versions field value +// GetVersionsOk returns a tuple with the Versions field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *ParameterOption) GetVersionsOk() (*[]string, bool) { - if o == nil { + if o == nil || o.Versions == nil { return nil, false } return &o.Versions, true } -// SetVersions sets field value. +// HasVersions returns a boolean if a field has been set. +func (o *ParameterOption) HasVersions() bool { + return o != nil && o.Versions != nil +} + +// SetVersions gets a reference to the given []string and assigns it to the Versions field. func (o *ParameterOption) SetVersions(v []string) { o.Versions = v } @@ -281,7 +285,9 @@ func (o ParameterOption) MarshalJSON() ([]byte, error) { } toSerialize["component"] = o.Component toSerialize["configs"] = o.Configs - toSerialize["versions"] = o.Versions + if o.Versions != nil { + toSerialize["versions"] = o.Versions + } toSerialize["exportTpl"] = o.ExportTpl toSerialize["family"] = o.Family if o.MajorVersion != nil { @@ -304,7 +310,7 @@ func (o *ParameterOption) UnmarshalJSON(bytes []byte) (err error) { all := struct { Component *string `json:"component"` Configs *[]ParameterConfig `json:"configs"` - Versions *[]string `json:"versions"` + Versions []string `json:"versions,omitempty"` ExportTpl *bool `json:"exportTpl"` Family *string `json:"family"` MajorVersion *string `json:"majorVersion,omitempty"` @@ -321,9 +327,6 @@ func (o *ParameterOption) UnmarshalJSON(bytes []byte) (err error) { if all.Configs == nil { return fmt.Errorf("required field configs missing") } - if all.Versions == nil { - return fmt.Errorf("required field versions missing") - } if all.ExportTpl == nil { return fmt.Errorf("required field exportTpl missing") } @@ -346,7 +349,7 @@ func (o *ParameterOption) UnmarshalJSON(bytes []byte) (err error) { hasInvalidField := false o.Component = *all.Component o.Configs = *all.Configs - o.Versions = *all.Versions + o.Versions = all.Versions o.ExportTpl = *all.ExportTpl o.Family = *all.Family o.MajorVersion = all.MajorVersion diff --git a/api/kbcloud/model_account_option.go b/api/kbcloud/model_account_option.go index cf6317c4..21b84287 100644 --- a/api/kbcloud/model_account_option.go +++ b/api/kbcloud/model_account_option.go @@ -12,7 +12,7 @@ import ( type AccountOption struct { Enabled bool `json:"enabled"` - Privileges []string `json:"privileges"` + Privileges []string `json:"privileges,omitempty"` AccountNamePattern string `json:"accountNamePattern"` Create bool `json:"create"` ResetPassword bool `json:"resetPassword"` @@ -26,10 +26,9 @@ type AccountOption struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed. -func NewAccountOption(enabled bool, privileges []string, accountNamePattern string, create bool, resetPassword bool, delete bool) *AccountOption { +func NewAccountOption(enabled bool, accountNamePattern string, create bool, resetPassword bool, delete bool) *AccountOption { this := AccountOption{} this.Enabled = enabled - this.Privileges = privileges this.AccountNamePattern = accountNamePattern this.Create = create this.ResetPassword = resetPassword @@ -68,25 +67,30 @@ func (o *AccountOption) SetEnabled(v bool) { o.Enabled = v } -// GetPrivileges returns the Privileges field value. +// GetPrivileges returns the Privileges field value if set, zero value otherwise. func (o *AccountOption) GetPrivileges() []string { - if o == nil { + if o == nil || o.Privileges == nil { var ret []string return ret } return o.Privileges } -// GetPrivilegesOk returns a tuple with the Privileges field value +// GetPrivilegesOk returns a tuple with the Privileges field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *AccountOption) GetPrivilegesOk() (*[]string, bool) { - if o == nil { + if o == nil || o.Privileges == nil { return nil, false } return &o.Privileges, true } -// SetPrivileges sets field value. +// HasPrivileges returns a boolean if a field has been set. +func (o *AccountOption) HasPrivileges() bool { + return o != nil && o.Privileges != nil +} + +// SetPrivileges gets a reference to the given []string and assigns it to the Privileges field. func (o *AccountOption) SetPrivileges(v []string) { o.Privileges = v } @@ -190,7 +194,9 @@ func (o AccountOption) MarshalJSON() ([]byte, error) { return common.Marshal(o.UnparsedObject) } toSerialize["enabled"] = o.Enabled - toSerialize["privileges"] = o.Privileges + if o.Privileges != nil { + toSerialize["privileges"] = o.Privileges + } toSerialize["accountNamePattern"] = o.AccountNamePattern toSerialize["create"] = o.Create toSerialize["resetPassword"] = o.ResetPassword @@ -205,12 +211,12 @@ func (o AccountOption) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *AccountOption) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Enabled *bool `json:"enabled"` - Privileges *[]string `json:"privileges"` - AccountNamePattern *string `json:"accountNamePattern"` - Create *bool `json:"create"` - ResetPassword *bool `json:"resetPassword"` - Delete *bool `json:"delete"` + Enabled *bool `json:"enabled"` + Privileges []string `json:"privileges,omitempty"` + AccountNamePattern *string `json:"accountNamePattern"` + Create *bool `json:"create"` + ResetPassword *bool `json:"resetPassword"` + Delete *bool `json:"delete"` }{} if err = common.Unmarshal(bytes, &all); err != nil { return common.Unmarshal(bytes, &o.UnparsedObject) @@ -218,9 +224,6 @@ func (o *AccountOption) UnmarshalJSON(bytes []byte) (err error) { if all.Enabled == nil { return fmt.Errorf("required field enabled missing") } - if all.Privileges == nil { - return fmt.Errorf("required field privileges missing") - } if all.AccountNamePattern == nil { return fmt.Errorf("required field accountNamePattern missing") } @@ -240,7 +243,7 @@ func (o *AccountOption) UnmarshalJSON(bytes []byte) (err error) { return err } o.Enabled = *all.Enabled - o.Privileges = *all.Privileges + o.Privileges = all.Privileges o.AccountNamePattern = *all.AccountNamePattern o.Create = *all.Create o.ResetPassword = *all.ResetPassword diff --git a/api/kbcloud/model_parameter_option.go b/api/kbcloud/model_parameter_option.go index 35b9a0bf..aa1753f7 100644 --- a/api/kbcloud/model_parameter_option.go +++ b/api/kbcloud/model_parameter_option.go @@ -14,7 +14,7 @@ type ParameterOption struct { Component string `json:"component"` Configs []ParameterConfig `json:"configs"` // deprecated - Versions []string `json:"versions"` + Versions []string `json:"versions,omitempty"` ExportTpl bool `json:"exportTpl"` // a alias with major version. Family string `json:"family"` @@ -32,11 +32,10 @@ type ParameterOption struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed. -func NewParameterOption(component string, configs []ParameterConfig, versions []string, exportTpl bool, family string, defaultTplName string, defaultTplDescription LocalizedDescription) *ParameterOption { +func NewParameterOption(component string, configs []ParameterConfig, exportTpl bool, family string, defaultTplName string, defaultTplDescription LocalizedDescription) *ParameterOption { this := ParameterOption{} this.Component = component this.Configs = configs - this.Versions = versions this.ExportTpl = exportTpl this.Family = family this.DefaultTplName = defaultTplName @@ -102,25 +101,30 @@ func (o *ParameterOption) SetConfigs(v []ParameterConfig) { o.Configs = v } -// GetVersions returns the Versions field value. +// GetVersions returns the Versions field value if set, zero value otherwise. func (o *ParameterOption) GetVersions() []string { - if o == nil { + if o == nil || o.Versions == nil { var ret []string return ret } return o.Versions } -// GetVersionsOk returns a tuple with the Versions field value +// GetVersionsOk returns a tuple with the Versions field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *ParameterOption) GetVersionsOk() (*[]string, bool) { - if o == nil { + if o == nil || o.Versions == nil { return nil, false } return &o.Versions, true } -// SetVersions sets field value. +// HasVersions returns a boolean if a field has been set. +func (o *ParameterOption) HasVersions() bool { + return o != nil && o.Versions != nil +} + +// SetVersions gets a reference to the given []string and assigns it to the Versions field. func (o *ParameterOption) SetVersions(v []string) { o.Versions = v } @@ -281,7 +285,9 @@ func (o ParameterOption) MarshalJSON() ([]byte, error) { } toSerialize["component"] = o.Component toSerialize["configs"] = o.Configs - toSerialize["versions"] = o.Versions + if o.Versions != nil { + toSerialize["versions"] = o.Versions + } toSerialize["exportTpl"] = o.ExportTpl toSerialize["family"] = o.Family if o.MajorVersion != nil { @@ -304,7 +310,7 @@ func (o *ParameterOption) UnmarshalJSON(bytes []byte) (err error) { all := struct { Component *string `json:"component"` Configs *[]ParameterConfig `json:"configs"` - Versions *[]string `json:"versions"` + Versions []string `json:"versions,omitempty"` ExportTpl *bool `json:"exportTpl"` Family *string `json:"family"` MajorVersion *string `json:"majorVersion,omitempty"` @@ -321,9 +327,6 @@ func (o *ParameterOption) UnmarshalJSON(bytes []byte) (err error) { if all.Configs == nil { return fmt.Errorf("required field configs missing") } - if all.Versions == nil { - return fmt.Errorf("required field versions missing") - } if all.ExportTpl == nil { return fmt.Errorf("required field exportTpl missing") } @@ -346,7 +349,7 @@ func (o *ParameterOption) UnmarshalJSON(bytes []byte) (err error) { hasInvalidField := false o.Component = *all.Component o.Configs = *all.Configs - o.Versions = *all.Versions + o.Versions = all.Versions o.ExportTpl = *all.ExportTpl o.Family = *all.Family o.MajorVersion = all.MajorVersion