diff --git a/services/resourcemanager/model_container_search_result.go b/services/resourcemanager/model_container_search_result.go new file mode 100644 index 000000000..82cf38321 --- /dev/null +++ b/services/resourcemanager/model_container_search_result.go @@ -0,0 +1,462 @@ +/* +Resource Manager API + +API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package resourcemanager + +import ( + "encoding/json" + "fmt" +) + +// checks if the ContainerSearchResult type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ContainerSearchResult{} + +/* + types and functions for containerId +*/ + +// isNotNullableString +type ContainerSearchResultGetContainerIdAttributeType = *string + +func getContainerSearchResultGetContainerIdAttributeTypeOk(arg ContainerSearchResultGetContainerIdAttributeType) (ret ContainerSearchResultGetContainerIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContainerSearchResultGetContainerIdAttributeType(arg *ContainerSearchResultGetContainerIdAttributeType, val ContainerSearchResultGetContainerIdRetType) { + *arg = &val +} + +type ContainerSearchResultGetContainerIdArgType = string +type ContainerSearchResultGetContainerIdRetType = string + +/* + types and functions for containerType +*/ + +// isEnum + +// ContainerSearchResultContainerType Resource container type. +// value type for enums +type ContainerSearchResultContainerType string + +// List of ContainerType +const ( + CONTAINERSEARCHRESULTCONTAINER_TYPE_PROJECT ContainerSearchResultContainerType = "PROJECT" + CONTAINERSEARCHRESULTCONTAINER_TYPE_FOLDER ContainerSearchResultContainerType = "FOLDER" +) + +// All allowed values of ContainerSearchResult enum +var AllowedContainerSearchResultContainerTypeEnumValues = []ContainerSearchResultContainerType{ + "PROJECT", + "FOLDER", +} + +func (v *ContainerSearchResultContainerType) UnmarshalJSON(src []byte) error { + // use a type alias to prevent infinite recursion during unmarshal, + // see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers + type TmpJson ContainerSearchResultContainerType + var value TmpJson + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue TmpJson + if value == zeroValue { + return nil + } + enumTypeValue := ContainerSearchResultContainerType(value) + for _, existing := range AllowedContainerSearchResultContainerTypeEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid ContainerSearchResult", value) +} + +// NewContainerSearchResultContainerTypeFromValue returns a pointer to a valid ContainerSearchResultContainerType +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewContainerSearchResultContainerTypeFromValue(v ContainerSearchResultContainerType) (*ContainerSearchResultContainerType, error) { + ev := ContainerSearchResultContainerType(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for ContainerSearchResultContainerType: valid values are %v", v, AllowedContainerSearchResultContainerTypeEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v ContainerSearchResultContainerType) IsValid() bool { + for _, existing := range AllowedContainerSearchResultContainerTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ContainerTypeContainerType value +func (v ContainerSearchResultContainerType) Ptr() *ContainerSearchResultContainerType { + return &v +} + +type NullableContainerSearchResultContainerType struct { + value *ContainerSearchResultContainerType + isSet bool +} + +func (v NullableContainerSearchResultContainerType) Get() *ContainerSearchResultContainerType { + return v.value +} + +func (v *NullableContainerSearchResultContainerType) Set(val *ContainerSearchResultContainerType) { + v.value = val + v.isSet = true +} + +func (v NullableContainerSearchResultContainerType) IsSet() bool { + return v.isSet +} + +func (v *NullableContainerSearchResultContainerType) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableContainerSearchResultContainerType(val *ContainerSearchResultContainerType) *NullableContainerSearchResultContainerType { + return &NullableContainerSearchResultContainerType{value: val, isSet: true} +} + +func (v NullableContainerSearchResultContainerType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableContainerSearchResultContainerType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type ContainerSearchResultGetContainerTypeAttributeType = *ContainerSearchResultContainerType +type ContainerSearchResultGetContainerTypeArgType = ContainerSearchResultContainerType +type ContainerSearchResultGetContainerTypeRetType = ContainerSearchResultContainerType + +func getContainerSearchResultGetContainerTypeAttributeTypeOk(arg ContainerSearchResultGetContainerTypeAttributeType) (ret ContainerSearchResultGetContainerTypeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContainerSearchResultGetContainerTypeAttributeType(arg *ContainerSearchResultGetContainerTypeAttributeType, val ContainerSearchResultGetContainerTypeRetType) { + *arg = &val +} + +/* + types and functions for id +*/ + +// isNotNullableString +type ContainerSearchResultGetIdAttributeType = *string + +func getContainerSearchResultGetIdAttributeTypeOk(arg ContainerSearchResultGetIdAttributeType) (ret ContainerSearchResultGetIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContainerSearchResultGetIdAttributeType(arg *ContainerSearchResultGetIdAttributeType, val ContainerSearchResultGetIdRetType) { + *arg = &val +} + +type ContainerSearchResultGetIdArgType = string +type ContainerSearchResultGetIdRetType = string + +/* + types and functions for lifecycleState +*/ + +// isEnumRef +type ContainerSearchResultGetLifecycleStateAttributeType = *LifecycleState +type ContainerSearchResultGetLifecycleStateArgType = LifecycleState +type ContainerSearchResultGetLifecycleStateRetType = LifecycleState + +func getContainerSearchResultGetLifecycleStateAttributeTypeOk(arg ContainerSearchResultGetLifecycleStateAttributeType) (ret ContainerSearchResultGetLifecycleStateRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContainerSearchResultGetLifecycleStateAttributeType(arg *ContainerSearchResultGetLifecycleStateAttributeType, val ContainerSearchResultGetLifecycleStateRetType) { + *arg = &val +} + +/* + types and functions for name +*/ + +// isNotNullableString +type ContainerSearchResultGetNameAttributeType = *string + +func getContainerSearchResultGetNameAttributeTypeOk(arg ContainerSearchResultGetNameAttributeType) (ret ContainerSearchResultGetNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContainerSearchResultGetNameAttributeType(arg *ContainerSearchResultGetNameAttributeType, val ContainerSearchResultGetNameRetType) { + *arg = &val +} + +type ContainerSearchResultGetNameArgType = string +type ContainerSearchResultGetNameRetType = string + +/* + types and functions for organizationId +*/ + +// isNotNullableString +type ContainerSearchResultGetOrganizationIdAttributeType = *string + +func getContainerSearchResultGetOrganizationIdAttributeTypeOk(arg ContainerSearchResultGetOrganizationIdAttributeType) (ret ContainerSearchResultGetOrganizationIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setContainerSearchResultGetOrganizationIdAttributeType(arg *ContainerSearchResultGetOrganizationIdAttributeType, val ContainerSearchResultGetOrganizationIdRetType) { + *arg = &val +} + +type ContainerSearchResultGetOrganizationIdArgType = string +type ContainerSearchResultGetOrganizationIdRetType = string + +// ContainerSearchResult struct for ContainerSearchResult +type ContainerSearchResult struct { + // Globally unique user-friendly identifier. + // REQUIRED + ContainerId ContainerSearchResultGetContainerIdAttributeType `json:"containerId" required:"true"` + // Resource container type. + // REQUIRED + ContainerType ContainerSearchResultGetContainerTypeAttributeType `json:"containerType" required:"true"` + // Globally unique identifier. + // REQUIRED + Id ContainerSearchResultGetIdAttributeType `json:"id" required:"true"` + LifecycleState ContainerSearchResultGetLifecycleStateAttributeType `json:"lifecycleState,omitempty"` + // Resource container name. + // REQUIRED + Name ContainerSearchResultGetNameAttributeType `json:"name" required:"true"` + // Id of the organization the container is in. + OrganizationId ContainerSearchResultGetOrganizationIdAttributeType `json:"organizationId,omitempty"` +} + +type _ContainerSearchResult ContainerSearchResult + +// NewContainerSearchResult instantiates a new ContainerSearchResult object +// 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 NewContainerSearchResult(containerId ContainerSearchResultGetContainerIdArgType, containerType ContainerSearchResultGetContainerTypeArgType, id ContainerSearchResultGetIdArgType, name ContainerSearchResultGetNameArgType) *ContainerSearchResult { + this := ContainerSearchResult{} + setContainerSearchResultGetContainerIdAttributeType(&this.ContainerId, containerId) + setContainerSearchResultGetContainerTypeAttributeType(&this.ContainerType, containerType) + setContainerSearchResultGetIdAttributeType(&this.Id, id) + setContainerSearchResultGetNameAttributeType(&this.Name, name) + return &this +} + +// NewContainerSearchResultWithDefaults instantiates a new ContainerSearchResult object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewContainerSearchResultWithDefaults() *ContainerSearchResult { + this := ContainerSearchResult{} + return &this +} + +// GetContainerId returns the ContainerId field value +func (o *ContainerSearchResult) GetContainerId() (ret ContainerSearchResultGetContainerIdRetType) { + ret, _ = o.GetContainerIdOk() + return ret +} + +// GetContainerIdOk returns a tuple with the ContainerId field value +// and a boolean to check if the value has been set. +func (o *ContainerSearchResult) GetContainerIdOk() (ret ContainerSearchResultGetContainerIdRetType, ok bool) { + return getContainerSearchResultGetContainerIdAttributeTypeOk(o.ContainerId) +} + +// SetContainerId sets field value +func (o *ContainerSearchResult) SetContainerId(v ContainerSearchResultGetContainerIdRetType) { + setContainerSearchResultGetContainerIdAttributeType(&o.ContainerId, v) +} + +// GetContainerType returns the ContainerType field value +func (o *ContainerSearchResult) GetContainerType() (ret ContainerSearchResultGetContainerTypeRetType) { + ret, _ = o.GetContainerTypeOk() + return ret +} + +// GetContainerTypeOk returns a tuple with the ContainerType field value +// and a boolean to check if the value has been set. +func (o *ContainerSearchResult) GetContainerTypeOk() (ret ContainerSearchResultGetContainerTypeRetType, ok bool) { + return getContainerSearchResultGetContainerTypeAttributeTypeOk(o.ContainerType) +} + +// SetContainerType sets field value +func (o *ContainerSearchResult) SetContainerType(v ContainerSearchResultGetContainerTypeRetType) { + setContainerSearchResultGetContainerTypeAttributeType(&o.ContainerType, v) +} + +// GetId returns the Id field value +func (o *ContainerSearchResult) GetId() (ret ContainerSearchResultGetIdRetType) { + ret, _ = o.GetIdOk() + return ret +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *ContainerSearchResult) GetIdOk() (ret ContainerSearchResultGetIdRetType, ok bool) { + return getContainerSearchResultGetIdAttributeTypeOk(o.Id) +} + +// SetId sets field value +func (o *ContainerSearchResult) SetId(v ContainerSearchResultGetIdRetType) { + setContainerSearchResultGetIdAttributeType(&o.Id, v) +} + +// GetLifecycleState returns the LifecycleState field value if set, zero value otherwise. +func (o *ContainerSearchResult) GetLifecycleState() (res ContainerSearchResultGetLifecycleStateRetType) { + res, _ = o.GetLifecycleStateOk() + return +} + +// GetLifecycleStateOk returns a tuple with the LifecycleState field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerSearchResult) GetLifecycleStateOk() (ret ContainerSearchResultGetLifecycleStateRetType, ok bool) { + return getContainerSearchResultGetLifecycleStateAttributeTypeOk(o.LifecycleState) +} + +// HasLifecycleState returns a boolean if a field has been set. +func (o *ContainerSearchResult) HasLifecycleState() bool { + _, ok := o.GetLifecycleStateOk() + return ok +} + +// SetLifecycleState gets a reference to the given LifecycleState and assigns it to the LifecycleState field. +func (o *ContainerSearchResult) SetLifecycleState(v ContainerSearchResultGetLifecycleStateRetType) { + setContainerSearchResultGetLifecycleStateAttributeType(&o.LifecycleState, v) +} + +// GetName returns the Name field value +func (o *ContainerSearchResult) GetName() (ret ContainerSearchResultGetNameRetType) { + ret, _ = o.GetNameOk() + return ret +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ContainerSearchResult) GetNameOk() (ret ContainerSearchResultGetNameRetType, ok bool) { + return getContainerSearchResultGetNameAttributeTypeOk(o.Name) +} + +// SetName sets field value +func (o *ContainerSearchResult) SetName(v ContainerSearchResultGetNameRetType) { + setContainerSearchResultGetNameAttributeType(&o.Name, v) +} + +// GetOrganizationId returns the OrganizationId field value if set, zero value otherwise. +func (o *ContainerSearchResult) GetOrganizationId() (res ContainerSearchResultGetOrganizationIdRetType) { + res, _ = o.GetOrganizationIdOk() + return +} + +// GetOrganizationIdOk returns a tuple with the OrganizationId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerSearchResult) GetOrganizationIdOk() (ret ContainerSearchResultGetOrganizationIdRetType, ok bool) { + return getContainerSearchResultGetOrganizationIdAttributeTypeOk(o.OrganizationId) +} + +// HasOrganizationId returns a boolean if a field has been set. +func (o *ContainerSearchResult) HasOrganizationId() bool { + _, ok := o.GetOrganizationIdOk() + return ok +} + +// SetOrganizationId gets a reference to the given string and assigns it to the OrganizationId field. +func (o *ContainerSearchResult) SetOrganizationId(v ContainerSearchResultGetOrganizationIdRetType) { + setContainerSearchResultGetOrganizationIdAttributeType(&o.OrganizationId, v) +} + +func (o ContainerSearchResult) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getContainerSearchResultGetContainerIdAttributeTypeOk(o.ContainerId); ok { + toSerialize["ContainerId"] = val + } + if val, ok := getContainerSearchResultGetContainerTypeAttributeTypeOk(o.ContainerType); ok { + toSerialize["ContainerType"] = val + } + if val, ok := getContainerSearchResultGetIdAttributeTypeOk(o.Id); ok { + toSerialize["Id"] = val + } + if val, ok := getContainerSearchResultGetLifecycleStateAttributeTypeOk(o.LifecycleState); ok { + toSerialize["LifecycleState"] = val + } + if val, ok := getContainerSearchResultGetNameAttributeTypeOk(o.Name); ok { + toSerialize["Name"] = val + } + if val, ok := getContainerSearchResultGetOrganizationIdAttributeTypeOk(o.OrganizationId); ok { + toSerialize["OrganizationId"] = val + } + return toSerialize, nil +} + +type NullableContainerSearchResult struct { + value *ContainerSearchResult + isSet bool +} + +func (v NullableContainerSearchResult) Get() *ContainerSearchResult { + return v.value +} + +func (v *NullableContainerSearchResult) Set(val *ContainerSearchResult) { + v.value = val + v.isSet = true +} + +func (v NullableContainerSearchResult) IsSet() bool { + return v.isSet +} + +func (v *NullableContainerSearchResult) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableContainerSearchResult(val *ContainerSearchResult) *NullableContainerSearchResult { + return &NullableContainerSearchResult{value: val, isSet: true} +} + +func (v NullableContainerSearchResult) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableContainerSearchResult) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/resourcemanager/model_container_search_result_test.go b/services/resourcemanager/model_container_search_result_test.go new file mode 100644 index 000000000..8ce1ffb78 --- /dev/null +++ b/services/resourcemanager/model_container_search_result_test.go @@ -0,0 +1,58 @@ +/* +Resource Manager API + +API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + +API version: 2.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package resourcemanager + +import ( + "testing" +) + +// isEnum + +func TestContainerSearchResultContainerType_UnmarshalJSON(t *testing.T) { + type args struct { + src []byte + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: `success - possible enum value no. 1`, + args: args{ + src: []byte(`"PROJECT"`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 2`, + args: args{ + src: []byte(`"FOLDER"`), + }, + wantErr: false, + }, + { + name: "fail", + args: args{ + src: []byte("\"FOOBAR\""), + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := ContainerSearchResultContainerType("") + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +}