diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b776c478..4356f7973 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,11 +36,15 @@ - **Feature:** Add new `ClusterErrorCode` types: `CLUSTERERRORCODE_INFRA_SNA_NETWORK_NOT_FOUND`, `CLUSTERERRORCODE_FETCHING_ERRORS_NOT_POSSIBLE` - [v0.26.0](services/ske/CHANGELOG.md#v0260) - Add `required:"true"` tags to model structs -- `git`: [v0.6.0](services/git/CHANGELOG.md#v060) - - **Feature:** Add support for `Flavors` for STACKIT git instance - - **Feature:** Add support for `Acl` for STACKIT git instance - - `projectId` and `instanceId` strings must have a length of 36 characters now (previously was only limited to a maximum of 36 characters) - - Add `required:"true"` tags to model structs +- `git`: + - [v0.7.0](services/git/CHANGELOG.md#v070) + - **Feature:** Add `Sku` field to `Flavors` model + - **Feature:** Add enums `CreateInstancePayloadFlavor` for `Flavor` field in `CreateInstancePayload` + - [v0.6.0](services/git/CHANGELOG.md#v060) + - **Feature:** Add support for `Flavors` for STACKIT git instance + - **Feature:** Add support for `Acl` for STACKIT git instance + - `projectId` and `instanceId` strings must have a length of 36 characters now (previously was only limited to a maximum of 36 characters) + - Add `required:"true"` tags to model structs - `serverupdate`: [v1.2.0](services/serverupdate/CHANGELOG.md#v120) - Add `required:"true"` tags to model structs - `serverbackup`: [v1.3.0](services/serverbackup/CHANGELOG.md#v130) diff --git a/services/git/CHANGELOG.md b/services/git/CHANGELOG.md index a36111759..5d88e06d7 100644 --- a/services/git/CHANGELOG.md +++ b/services/git/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.7.0 +- **Feature:** Add `Sku` field to `Flavors` model +- **Feature:** Add enums `CreateInstancePayloadFlavor` for `Flavor` field in `CreateInstancePayload` + ## v0.6.0 - **Feature:** Add support for `Flavors` for STACKIT git instance - **Feature:** Add support for `Acl` for STACKIT git instance diff --git a/services/git/VERSION b/services/git/VERSION index e07d136c7..e7f5d1aa6 100644 --- a/services/git/VERSION +++ b/services/git/VERSION @@ -1 +1 @@ -v0.6.0 \ No newline at end of file +v0.7.0 \ No newline at end of file diff --git a/services/git/api_default.go b/services/git/api_default.go index e8a844ad5..d18b9c364 100644 --- a/services/git/api_default.go +++ b/services/git/api_default.go @@ -85,7 +85,7 @@ type DefaultApi interface { @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId The STACKIT portal project UUID the STACKIT Git instance is part of. + @param projectId Project identifier. @return ApiListFlavorsRequest */ ListFlavors(ctx context.Context, projectId string) ApiListFlavorsRequest @@ -93,7 +93,7 @@ type DefaultApi interface { ListFlavorsExecute executes the request @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId The STACKIT portal project UUID the STACKIT Git instance is part of. + @param projectId Project identifier. @return ListFlavors */ @@ -685,6 +685,9 @@ func (r ListFlavorsRequest) Execute() (*ListFlavors, error) { localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, fmt.Errorf("projectId must have at least 36 elements") + } if strlen(r.projectId) > 36 { return localVarReturnValue, fmt.Errorf("projectId must have less than 36 elements") } @@ -738,6 +741,17 @@ func (r ListFlavorsRequest) Execute() (*ListFlavors, error) { Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 400 { + var v GenericErrorResponse + err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } if localVarHTTPResponse.StatusCode == 401 { var v UnauthorizedResponse err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) @@ -750,7 +764,7 @@ func (r ListFlavorsRequest) Execute() (*ListFlavors, error) { return localVarReturnValue, newErr } if localVarHTTPResponse.StatusCode == 500 { - var v InternalServerErrorResponse + var v GenericErrorResponse err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { newErr.ErrorMessage = err.Error() @@ -781,7 +795,7 @@ ListFlavors: Returns the details for the given STACKIT Git flavors. Provides detailed information about possible Git Flavors. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId The STACKIT portal project UUID the STACKIT Git instance is part of. + @param projectId Project identifier. @return ApiListFlavorsRequest */ func (a *APIClient) ListFlavors(ctx context.Context, projectId string) ApiListFlavorsRequest { diff --git a/services/git/model_create_instance_payload.go b/services/git/model_create_instance_payload.go index a65a9fa8d..3a1e20ed6 100644 --- a/services/git/model_create_instance_payload.go +++ b/services/git/model_create_instance_payload.go @@ -12,6 +12,7 @@ package git import ( "encoding/json" + "fmt" ) // checks if the CreateInstancePayload type satisfies the MappedNullable interface at compile time @@ -41,8 +42,114 @@ func setCreateInstancePayloadGetAclAttributeType(arg *CreateInstancePayloadGetAc types and functions for flavor */ -// isNotNullableString -type CreateInstancePayloadGetFlavorAttributeType = *string +// isEnum + +// CreateInstancePayloadFlavor Desired instance flavor. Must be one of the defined enum values +// value type for enums +type CreateInstancePayloadFlavor string + +// List of Flavor +const ( + CREATEINSTANCEPAYLOADFLAVOR__10 CreateInstancePayloadFlavor = "git-10" + CREATEINSTANCEPAYLOADFLAVOR__100 CreateInstancePayloadFlavor = "git-100" +) + +// All allowed values of CreateInstancePayload enum +var AllowedCreateInstancePayloadFlavorEnumValues = []CreateInstancePayloadFlavor{ + "git-10", + "git-100", +} + +func (v *CreateInstancePayloadFlavor) 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 CreateInstancePayloadFlavor + 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 := CreateInstancePayloadFlavor(value) + for _, existing := range AllowedCreateInstancePayloadFlavorEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid CreateInstancePayload", value) +} + +// NewCreateInstancePayloadFlavorFromValue returns a pointer to a valid CreateInstancePayloadFlavor +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewCreateInstancePayloadFlavorFromValue(v CreateInstancePayloadFlavor) (*CreateInstancePayloadFlavor, error) { + ev := CreateInstancePayloadFlavor(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for CreateInstancePayloadFlavor: valid values are %v", v, AllowedCreateInstancePayloadFlavorEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v CreateInstancePayloadFlavor) IsValid() bool { + for _, existing := range AllowedCreateInstancePayloadFlavorEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FlavorFlavor value +func (v CreateInstancePayloadFlavor) Ptr() *CreateInstancePayloadFlavor { + return &v +} + +type NullableCreateInstancePayloadFlavor struct { + value *CreateInstancePayloadFlavor + isSet bool +} + +func (v NullableCreateInstancePayloadFlavor) Get() *CreateInstancePayloadFlavor { + return v.value +} + +func (v *NullableCreateInstancePayloadFlavor) Set(val *CreateInstancePayloadFlavor) { + v.value = val + v.isSet = true +} + +func (v NullableCreateInstancePayloadFlavor) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateInstancePayloadFlavor) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateInstancePayloadFlavor(val *CreateInstancePayloadFlavor) *NullableCreateInstancePayloadFlavor { + return &NullableCreateInstancePayloadFlavor{value: val, isSet: true} +} + +func (v NullableCreateInstancePayloadFlavor) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateInstancePayloadFlavor) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type CreateInstancePayloadGetFlavorAttributeType = *CreateInstancePayloadFlavor +type CreateInstancePayloadGetFlavorArgType = CreateInstancePayloadFlavor +type CreateInstancePayloadGetFlavorRetType = CreateInstancePayloadFlavor func getCreateInstancePayloadGetFlavorAttributeTypeOk(arg CreateInstancePayloadGetFlavorAttributeType) (ret CreateInstancePayloadGetFlavorRetType, ok bool) { if arg == nil { @@ -55,9 +162,6 @@ func setCreateInstancePayloadGetFlavorAttributeType(arg *CreateInstancePayloadGe *arg = &val } -type CreateInstancePayloadGetFlavorArgType = string -type CreateInstancePayloadGetFlavorRetType = string - /* types and functions for name */ @@ -79,11 +183,11 @@ func setCreateInstancePayloadGetNameAttributeType(arg *CreateInstancePayloadGetN type CreateInstancePayloadGetNameArgType = string type CreateInstancePayloadGetNameRetType = string -// CreateInstancePayload Instance creation configuration options. +// CreateInstancePayload Request a STACKIT Git instance to be created with these properties. type CreateInstancePayload struct { // Restricted ACL for instance access. Acl CreateInstancePayloadGetAclAttributeType `json:"acl,omitempty"` - // Instance flavor. Defaults to git-100 if not specified. + // Desired instance flavor. Must be one of the defined enum values Flavor CreateInstancePayloadGetFlavorAttributeType `json:"flavor,omitempty"` // A user chosen name to distinguish multiple STACKIT Git instances. // REQUIRED @@ -107,8 +211,6 @@ func NewCreateInstancePayload(name CreateInstancePayloadGetNameArgType) *CreateI // but it doesn't guarantee that properties required by API are set func NewCreateInstancePayloadWithDefaults() *CreateInstancePayload { this := CreateInstancePayload{} - var flavor string = "git-100" - this.Flavor = &flavor return &this } diff --git a/services/git/model_create_instance_payload_test.go b/services/git/model_create_instance_payload_test.go index e39c866ed..f0259f88f 100644 --- a/services/git/model_create_instance_payload_test.go +++ b/services/git/model_create_instance_payload_test.go @@ -9,3 +9,50 @@ API version: 1beta.0.4 // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package git + +import ( + "testing" +) + +// isEnum + +func TestCreateInstancePayloadFlavor_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(`"git-10"`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 2`, + args: args{ + src: []byte(`"git-100"`), + }, + wantErr: false, + }, + { + name: "fail", + args: args{ + src: []byte("\"FOOBAR\""), + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := CreateInstancePayloadFlavor("") + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/services/git/model_flavor.go b/services/git/model_flavor.go index 99e0298e9..aae5b2000 100644 --- a/services/git/model_flavor.go +++ b/services/git/model_flavor.go @@ -209,6 +209,27 @@ func setFlavorGetIdAttributeType(arg *FlavorGetIdAttributeType, val FlavorGetIdR type FlavorGetIdArgType = string type FlavorGetIdRetType = string +/* + types and functions for sku +*/ + +// isNotNullableString +type FlavorGetSkuAttributeType = *string + +func getFlavorGetSkuAttributeTypeOk(arg FlavorGetSkuAttributeType) (ret FlavorGetSkuRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setFlavorGetSkuAttributeType(arg *FlavorGetSkuAttributeType, val FlavorGetSkuRetType) { + *arg = &val +} + +type FlavorGetSkuArgType = string +type FlavorGetSkuRetType = string + // Flavor Describes a STACKIT Git Flavor. type Flavor struct { // Defines the flavor availability. @@ -223,6 +244,9 @@ type Flavor struct { // Flavor id. // REQUIRED Id FlavorGetIdAttributeType `json:"id" required:"true"` + // SAP article number. + // REQUIRED + Sku FlavorGetSkuAttributeType `json:"sku" required:"true"` } type _Flavor Flavor @@ -231,12 +255,13 @@ type _Flavor Flavor // 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 NewFlavor(availability FlavorGetAvailabilityArgType, description FlavorGetDescriptionArgType, displayName FlavorGetDisplayNameArgType, id FlavorGetIdArgType) *Flavor { +func NewFlavor(availability FlavorGetAvailabilityArgType, description FlavorGetDescriptionArgType, displayName FlavorGetDisplayNameArgType, id FlavorGetIdArgType, sku FlavorGetSkuArgType) *Flavor { this := Flavor{} setFlavorGetAvailabilityAttributeType(&this.Availability, availability) setFlavorGetDescriptionAttributeType(&this.Description, description) setFlavorGetDisplayNameAttributeType(&this.DisplayName, displayName) setFlavorGetIdAttributeType(&this.Id, id) + setFlavorGetSkuAttributeType(&this.Sku, sku) return &this } @@ -316,6 +341,23 @@ func (o *Flavor) SetId(v FlavorGetIdRetType) { setFlavorGetIdAttributeType(&o.Id, v) } +// GetSku returns the Sku field value +func (o *Flavor) GetSku() (ret FlavorGetSkuRetType) { + ret, _ = o.GetSkuOk() + return ret +} + +// GetSkuOk returns a tuple with the Sku field value +// and a boolean to check if the value has been set. +func (o *Flavor) GetSkuOk() (ret FlavorGetSkuRetType, ok bool) { + return getFlavorGetSkuAttributeTypeOk(o.Sku) +} + +// SetSku sets field value +func (o *Flavor) SetSku(v FlavorGetSkuRetType) { + setFlavorGetSkuAttributeType(&o.Sku, v) +} + func (o Flavor) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if val, ok := getFlavorGetAvailabilityAttributeTypeOk(o.Availability); ok { @@ -330,6 +372,9 @@ func (o Flavor) ToMap() (map[string]interface{}, error) { if val, ok := getFlavorGetIdAttributeTypeOk(o.Id); ok { toSerialize["Id"] = val } + if val, ok := getFlavorGetSkuAttributeTypeOk(o.Sku); ok { + toSerialize["Sku"] = val + } return toSerialize, nil } diff --git a/services/git/model_instance.go b/services/git/model_instance.go index 77387b97e..587308921 100644 --- a/services/git/model_instance.go +++ b/services/git/model_instance.go @@ -170,7 +170,7 @@ type InstanceGetNameRetType = string // isEnum -// InstanceState Indicate the readiness state of the instance. +// InstanceState The current state of the STACKIT Git instance. // value type for enums type InstanceState string @@ -338,7 +338,7 @@ func setInstanceGetVersionAttributeType(arg *InstanceGetVersionAttributeType, va type InstanceGetVersionArgType = string type InstanceGetVersionRetType = string -// Instance Information about an Instance. +// Instance Describes a STACKIT Git instance. type Instance struct { // Restricted ACL for instance access. // REQUIRED @@ -349,25 +349,25 @@ type Instance struct { // How many bytes of Object Storage is consumed. Read Only. // REQUIRED ConsumedObjectStorage InstanceGetConsumedObjectStorageAttributeType `json:"consumed_object_storage" required:"true"` - // Instance creation timestamp in RFC3339 format. + // The date and time the creation of the STACKIT Git instance was triggered. // REQUIRED Created InstanceGetCreatedAttributeType `json:"created" required:"true"` - // Instance flavor. + // Desired instance flavor. Must be one of the defined enum values // REQUIRED Flavor InstanceGetFlavorAttributeType `json:"flavor" required:"true"` - // Instance identifier. + // A auto generated unique id which identifies the STACKIT Git instances. // REQUIRED Id InstanceGetIdAttributeType `json:"id" required:"true"` - // Instance name. + // A user chosen name to distinguish multiple STACKIT Git instances. // REQUIRED Name InstanceGetNameAttributeType `json:"name" required:"true"` - // Indicate the readiness state of the instance. + // The current state of the STACKIT Git instance. // REQUIRED State InstanceGetStateAttributeType `json:"state" required:"true"` - // Instance url. + // The URL for reaching the STACKIT Git instance. // REQUIRED Url InstanceGetUrlAttributeType `json:"url" required:"true"` - // STACKIT Git version indicator. + // The current version of STACKIT Git deployed to the instance. // REQUIRED Version InstanceGetVersionAttributeType `json:"version" required:"true"` } diff --git a/services/git/model_list_instances.go b/services/git/model_list_instances.go index 031b90bb8..193fb2536 100644 --- a/services/git/model_list_instances.go +++ b/services/git/model_list_instances.go @@ -37,7 +37,7 @@ func setListInstancesGetInstancesAttributeType(arg *ListInstancesGetInstancesAtt *arg = &val } -// ListInstances List of Instances. +// ListInstances A list of STACKIT Git instances. type ListInstances struct { // REQUIRED Instances ListInstancesGetInstancesAttributeType `json:"instances" required:"true"`