From 5fee5e7301ba94e4a8566fa0a7d7acdff15d4093 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Fri, 1 Aug 2025 09:20:13 +0000 Subject: [PATCH] Generate mongodbflex --- .../mongodbflex/model_create_user_payload.go | 6 +- .../model_instance_response_user.go | 8 +- .../model_partial_update_user_payload.go | 8 +- .../mongodbflex/model_update_user_payload.go | 6 +- services/mongodbflex/model_user.go | 8 +- services/mongodbflex/model_user_role.go | 117 ++++++++++++++++++ services/mongodbflex/model_user_role_test.go | 11 ++ 7 files changed, 146 insertions(+), 18 deletions(-) create mode 100644 services/mongodbflex/model_user_role.go create mode 100644 services/mongodbflex/model_user_role_test.go diff --git a/services/mongodbflex/model_create_user_payload.go b/services/mongodbflex/model_create_user_payload.go index 3337c5f7c..4c13b3d7d 100644 --- a/services/mongodbflex/model_create_user_payload.go +++ b/services/mongodbflex/model_create_user_payload.go @@ -43,9 +43,9 @@ type CreateUserPayloadGetDatabaseRetType = string */ // isArray -type CreateUserPayloadGetRolesAttributeType = *[]string -type CreateUserPayloadGetRolesArgType = []string -type CreateUserPayloadGetRolesRetType = []string +type CreateUserPayloadGetRolesAttributeType = *[]UserRole +type CreateUserPayloadGetRolesArgType = []UserRole +type CreateUserPayloadGetRolesRetType = []UserRole func getCreateUserPayloadGetRolesAttributeTypeOk(arg CreateUserPayloadGetRolesAttributeType) (ret CreateUserPayloadGetRolesRetType, ok bool) { if arg == nil { diff --git a/services/mongodbflex/model_instance_response_user.go b/services/mongodbflex/model_instance_response_user.go index e6ea414f9..8ecf8f514 100644 --- a/services/mongodbflex/model_instance_response_user.go +++ b/services/mongodbflex/model_instance_response_user.go @@ -105,9 +105,9 @@ func setInstanceResponseUserGetPortAttributeType(arg *InstanceResponseUserGetPor */ // isArray -type InstanceResponseUserGetRolesAttributeType = *[]string -type InstanceResponseUserGetRolesArgType = []string -type InstanceResponseUserGetRolesRetType = []string +type InstanceResponseUserGetRolesAttributeType = *[]UserRole +type InstanceResponseUserGetRolesArgType = []UserRole +type InstanceResponseUserGetRolesRetType = []UserRole func getInstanceResponseUserGetRolesAttributeTypeOk(arg InstanceResponseUserGetRolesAttributeType) (ret InstanceResponseUserGetRolesRetType, ok bool) { if arg == nil { @@ -278,7 +278,7 @@ func (o *InstanceResponseUser) HasRoles() bool { return ok } -// SetRoles gets a reference to the given []string and assigns it to the Roles field. +// SetRoles gets a reference to the given []UserRole and assigns it to the Roles field. func (o *InstanceResponseUser) SetRoles(v InstanceResponseUserGetRolesRetType) { setInstanceResponseUserGetRolesAttributeType(&o.Roles, v) } diff --git a/services/mongodbflex/model_partial_update_user_payload.go b/services/mongodbflex/model_partial_update_user_payload.go index b756dae87..09e20aff1 100644 --- a/services/mongodbflex/model_partial_update_user_payload.go +++ b/services/mongodbflex/model_partial_update_user_payload.go @@ -43,9 +43,9 @@ type PartialUpdateUserPayloadGetDatabaseRetType = string */ // isArray -type PartialUpdateUserPayloadGetRolesAttributeType = *[]string -type PartialUpdateUserPayloadGetRolesArgType = []string -type PartialUpdateUserPayloadGetRolesRetType = []string +type PartialUpdateUserPayloadGetRolesAttributeType = *[]UserRole +type PartialUpdateUserPayloadGetRolesArgType = []UserRole +type PartialUpdateUserPayloadGetRolesRetType = []UserRole func getPartialUpdateUserPayloadGetRolesAttributeTypeOk(arg PartialUpdateUserPayloadGetRolesAttributeType) (ret PartialUpdateUserPayloadGetRolesRetType, ok bool) { if arg == nil { @@ -122,7 +122,7 @@ func (o *PartialUpdateUserPayload) HasRoles() bool { return ok } -// SetRoles gets a reference to the given []string and assigns it to the Roles field. +// SetRoles gets a reference to the given []UserRole and assigns it to the Roles field. func (o *PartialUpdateUserPayload) SetRoles(v PartialUpdateUserPayloadGetRolesRetType) { setPartialUpdateUserPayloadGetRolesAttributeType(&o.Roles, v) } diff --git a/services/mongodbflex/model_update_user_payload.go b/services/mongodbflex/model_update_user_payload.go index 1b20facee..0cfc5e176 100644 --- a/services/mongodbflex/model_update_user_payload.go +++ b/services/mongodbflex/model_update_user_payload.go @@ -43,9 +43,9 @@ type UpdateUserPayloadGetDatabaseRetType = string */ // isArray -type UpdateUserPayloadGetRolesAttributeType = *[]string -type UpdateUserPayloadGetRolesArgType = []string -type UpdateUserPayloadGetRolesRetType = []string +type UpdateUserPayloadGetRolesAttributeType = *[]UserRole +type UpdateUserPayloadGetRolesArgType = []UserRole +type UpdateUserPayloadGetRolesRetType = []UserRole func getUpdateUserPayloadGetRolesAttributeTypeOk(arg UpdateUserPayloadGetRolesAttributeType) (ret UpdateUserPayloadGetRolesRetType, ok bool) { if arg == nil { diff --git a/services/mongodbflex/model_user.go b/services/mongodbflex/model_user.go index 0157714c7..28ca719e4 100644 --- a/services/mongodbflex/model_user.go +++ b/services/mongodbflex/model_user.go @@ -126,9 +126,9 @@ func setUserGetPortAttributeType(arg *UserGetPortAttributeType, val UserGetPortR */ // isArray -type UserGetRolesAttributeType = *[]string -type UserGetRolesArgType = []string -type UserGetRolesRetType = []string +type UserGetRolesAttributeType = *[]UserRole +type UserGetRolesArgType = []UserRole +type UserGetRolesRetType = []UserRole func getUserGetRolesAttributeTypeOk(arg UserGetRolesAttributeType) (ret UserGetRolesRetType, ok bool) { if arg == nil { @@ -345,7 +345,7 @@ func (o *User) HasRoles() bool { return ok } -// SetRoles gets a reference to the given []string and assigns it to the Roles field. +// SetRoles gets a reference to the given []UserRole and assigns it to the Roles field. func (o *User) SetRoles(v UserGetRolesRetType) { setUserGetRolesAttributeType(&o.Roles, v) } diff --git a/services/mongodbflex/model_user_role.go b/services/mongodbflex/model_user_role.go new file mode 100644 index 000000000..0c03a20a1 --- /dev/null +++ b/services/mongodbflex/model_user_role.go @@ -0,0 +1,117 @@ +/* +STACKIT MongoDB Service API + +This is the documentation for the STACKIT MongoDB Flex Service API + +API version: 2.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package mongodbflex + +import ( + "encoding/json" + "fmt" +) + +// UserRole The user role for the instance. +type UserRole string + +// List of user.role +const ( + USERROLE_READ_ANY_DATABASE UserRole = "readAnyDatabase" + USERROLE_READ_WRITE_ANY_DATABASE UserRole = "readWriteAnyDatabase" + USERROLE_STACKIT_ADMIN UserRole = "stackitAdmin" +) + +// All allowed values of UserRole enum +var AllowedUserRoleEnumValues = []UserRole{ + "readAnyDatabase", + "readWriteAnyDatabase", + "stackitAdmin", +} + +func (v *UserRole) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue string + if value == zeroValue { + return nil + } + enumTypeValue := UserRole(value) + for _, existing := range AllowedUserRoleEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid UserRole", value) +} + +// NewUserRoleFromValue returns a pointer to a valid UserRole +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewUserRoleFromValue(v string) (*UserRole, error) { + ev := UserRole(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for UserRole: valid values are %v", v, AllowedUserRoleEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v UserRole) IsValid() bool { + for _, existing := range AllowedUserRoleEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to user.role value +func (v UserRole) Ptr() *UserRole { + return &v +} + +type NullableUserRole struct { + value *UserRole + isSet bool +} + +func (v NullableUserRole) Get() *UserRole { + return v.value +} + +func (v *NullableUserRole) Set(val *UserRole) { + v.value = val + v.isSet = true +} + +func (v NullableUserRole) IsSet() bool { + return v.isSet +} + +func (v *NullableUserRole) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUserRole(val *UserRole) *NullableUserRole { + return &NullableUserRole{value: val, isSet: true} +} + +func (v NullableUserRole) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUserRole) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/mongodbflex/model_user_role_test.go b/services/mongodbflex/model_user_role_test.go new file mode 100644 index 000000000..e3129995f --- /dev/null +++ b/services/mongodbflex/model_user_role_test.go @@ -0,0 +1,11 @@ +/* +STACKIT MongoDB Service API + +This is the documentation for the STACKIT MongoDB Flex Service API + +API version: 2.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package mongodbflex