diff --git a/services/git/api_default.go b/services/git/api_default.go index 8fdb19ca5..3e7fae492 100644 --- a/services/git/api_default.go +++ b/services/git/api_default.go @@ -186,7 +186,7 @@ type ApiListRunnerLabelsRequest interface { } type ApiPatchInstanceRequest interface { - PatchOperation(patchOperation []PatchOperation) ApiPatchInstanceRequest + PatchInstancePayload(patchInstancePayload PatchInstancePayload) ApiPatchInstanceRequest Execute() (*Instance, error) } @@ -1183,15 +1183,15 @@ func (a *APIClient) ListRunnerLabelsExecute(ctx context.Context, projectId strin } type PatchInstanceRequest struct { - ctx context.Context - apiService *DefaultApiService - projectId string - instanceId string - patchOperation *[]PatchOperation + ctx context.Context + apiService *DefaultApiService + projectId string + instanceId string + patchInstancePayload *PatchInstancePayload } -func (r PatchInstanceRequest) PatchOperation(patchOperation []PatchOperation) ApiPatchInstanceRequest { - r.patchOperation = &patchOperation +func (r PatchInstanceRequest) PatchInstancePayload(patchInstancePayload PatchInstancePayload) ApiPatchInstanceRequest { + r.patchInstancePayload = &patchInstancePayload return r } @@ -1231,12 +1231,12 @@ func (r PatchInstanceRequest) Execute() (*Instance, error) { if strlen(r.instanceId) > 36 { return localVarReturnValue, fmt.Errorf("instanceId must have less than 36 elements") } - if r.patchOperation == nil { - return localVarReturnValue, fmt.Errorf("patchOperation is required and must be specified") + if r.patchInstancePayload == nil { + return localVarReturnValue, fmt.Errorf("patchInstancePayload is required and must be specified") } // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json-patch+json"} + localVarHTTPContentTypes := []string{"application/json", "application/json-patch+json"} // set Content-Type header localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) @@ -1253,7 +1253,7 @@ func (r PatchInstanceRequest) Execute() (*Instance, error) { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } // body params - localVarPostBody = r.patchOperation + localVarPostBody = r.patchInstancePayload req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) if err != nil { return localVarReturnValue, err diff --git a/services/git/api_default_test.go b/services/git/api_default_test.go index 2de3a78b3..d4077721d 100644 --- a/services/git/api_default_test.go +++ b/services/git/api_default_test.go @@ -380,9 +380,9 @@ func Test_git_DefaultApiService(t *testing.T) { projectId := projectIdValue instanceId := instanceIdValue - patchOperation := []PatchOperation{} + patchInstancePayload := PatchInstancePayload{} - resp, reqErr := apiClient.PatchInstance(context.Background(), projectId, instanceId).PatchOperation(patchOperation).Execute() + resp, reqErr := apiClient.PatchInstance(context.Background(), projectId, instanceId).PatchInstancePayload(patchInstancePayload).Execute() if reqErr != nil { t.Fatalf("error in call: %v", reqErr) diff --git a/services/git/model_create_instance_payload.go b/services/git/model_create_instance_payload.go index 3c722d067..408be85f5 100644 --- a/services/git/model_create_instance_payload.go +++ b/services/git/model_create_instance_payload.go @@ -12,7 +12,6 @@ package git import ( "encoding/json" - "fmt" ) // checks if the CreateInstancePayload type satisfies the MappedNullable interface at compile time @@ -42,114 +41,10 @@ func setCreateInstancePayloadGetAclAttributeType(arg *CreateInstancePayloadGetAc types and functions for flavor */ -// 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 +// isEnumRef +type CreateInstancePayloadGetFlavorAttributeType = *InstanceFlavor +type CreateInstancePayloadGetFlavorArgType = InstanceFlavor +type CreateInstancePayloadGetFlavorRetType = InstanceFlavor func getCreateInstancePayloadGetFlavorAttributeTypeOk(arg CreateInstancePayloadGetFlavorAttributeType) (ret CreateInstancePayloadGetFlavorRetType, ok bool) { if arg == nil { @@ -186,8 +81,7 @@ type CreateInstancePayloadGetNameRetType = string // CreateInstancePayload Request a STACKIT Git instance to be created with these properties. type CreateInstancePayload struct { // A list of CIDR network addresses that are allowed to access the instance. - Acl CreateInstancePayloadGetAclAttributeType `json:"acl,omitempty"` - // Desired instance flavor. Must be one of the defined enum values + Acl CreateInstancePayloadGetAclAttributeType `json:"acl,omitempty"` Flavor CreateInstancePayloadGetFlavorAttributeType `json:"flavor,omitempty"` // A user chosen name to distinguish multiple STACKIT Git instances. // REQUIRED @@ -255,7 +149,7 @@ func (o *CreateInstancePayload) HasFlavor() bool { return ok } -// SetFlavor gets a reference to the given string and assigns it to the Flavor field. +// SetFlavor gets a reference to the given InstanceFlavor and assigns it to the Flavor field. func (o *CreateInstancePayload) SetFlavor(v CreateInstancePayloadGetFlavorRetType) { setCreateInstancePayloadGetFlavorAttributeType(&o.Flavor, v) } diff --git a/services/git/model_create_instance_payload_test.go b/services/git/model_create_instance_payload_test.go index f0259f88f..e39c866ed 100644 --- a/services/git/model_create_instance_payload_test.go +++ b/services/git/model_create_instance_payload_test.go @@ -9,50 +9,3 @@ 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_instance_flavor.go b/services/git/model_instance_flavor.go new file mode 100644 index 000000000..4439a8c76 --- /dev/null +++ b/services/git/model_instance_flavor.go @@ -0,0 +1,115 @@ +/* +STACKIT Git API + +STACKIT Git management API. + +API version: 1beta.0.4 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package git + +import ( + "encoding/json" + "fmt" +) + +// InstanceFlavor Desired instance flavor. Must be one of the defined enum values. +type InstanceFlavor string + +// List of InstanceFlavor +const ( + INSTANCEFLAVOR__10 InstanceFlavor = "git-10" + INSTANCEFLAVOR__100 InstanceFlavor = "git-100" +) + +// All allowed values of InstanceFlavor enum +var AllowedInstanceFlavorEnumValues = []InstanceFlavor{ + "git-10", + "git-100", +} + +func (v *InstanceFlavor) 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 := InstanceFlavor(value) + for _, existing := range AllowedInstanceFlavorEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid InstanceFlavor", value) +} + +// NewInstanceFlavorFromValue returns a pointer to a valid InstanceFlavor +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewInstanceFlavorFromValue(v string) (*InstanceFlavor, error) { + ev := InstanceFlavor(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for InstanceFlavor: valid values are %v", v, AllowedInstanceFlavorEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v InstanceFlavor) IsValid() bool { + for _, existing := range AllowedInstanceFlavorEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to InstanceFlavor value +func (v InstanceFlavor) Ptr() *InstanceFlavor { + return &v +} + +type NullableInstanceFlavor struct { + value *InstanceFlavor + isSet bool +} + +func (v NullableInstanceFlavor) Get() *InstanceFlavor { + return v.value +} + +func (v *NullableInstanceFlavor) Set(val *InstanceFlavor) { + v.value = val + v.isSet = true +} + +func (v NullableInstanceFlavor) IsSet() bool { + return v.isSet +} + +func (v *NullableInstanceFlavor) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInstanceFlavor(val *InstanceFlavor) *NullableInstanceFlavor { + return &NullableInstanceFlavor{value: val, isSet: true} +} + +func (v NullableInstanceFlavor) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInstanceFlavor) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/git/model_instance_flavor_test.go b/services/git/model_instance_flavor_test.go new file mode 100644 index 000000000..e39c866ed --- /dev/null +++ b/services/git/model_instance_flavor_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Git API + +STACKIT Git management API. + +API version: 1beta.0.4 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package git diff --git a/services/git/model_patch_instance_payload.go b/services/git/model_patch_instance_payload.go new file mode 100644 index 000000000..87e9c3aa4 --- /dev/null +++ b/services/git/model_patch_instance_payload.go @@ -0,0 +1,129 @@ +/* +STACKIT Git API + +STACKIT Git management API. + +API version: 1beta.0.4 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package git + +import ( + "encoding/json" +) + +// checks if the PatchInstancePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchInstancePayload{} + +/* + types and functions for acl +*/ + +// isArray +type PatchInstancePayloadGetAclAttributeType = *[]string +type PatchInstancePayloadGetAclArgType = *[]string +type PatchInstancePayloadGetAclRetType = *[]string + +func getPatchInstancePayloadGetAclAttributeTypeOk(arg PatchInstancePayloadGetAclAttributeType) (ret PatchInstancePayloadGetAclRetType, ok bool) { + if arg == nil { + return nil, false + } + return arg, true +} + +func setPatchInstancePayloadGetAclAttributeType(arg *PatchInstancePayloadGetAclAttributeType, val PatchInstancePayloadGetAclRetType) { + *arg = val +} + +// PatchInstancePayload Properties to patch on an instance. All fields are optional. +type PatchInstancePayload struct { + // A list of CIDR network addresses that are allowed to access the instance. + Acl PatchInstancePayloadGetAclAttributeType `json:"acl,omitempty"` +} + +// NewPatchInstancePayload instantiates a new PatchInstancePayload 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 NewPatchInstancePayload() *PatchInstancePayload { + this := PatchInstancePayload{} + return &this +} + +// NewPatchInstancePayloadWithDefaults instantiates a new PatchInstancePayload 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 NewPatchInstancePayloadWithDefaults() *PatchInstancePayload { + this := PatchInstancePayload{} + return &this +} + +// GetAcl returns the Acl field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *PatchInstancePayload) GetAcl() (res PatchInstancePayloadGetAclRetType) { + res, _ = o.GetAclOk() + return +} + +// GetAclOk returns a tuple with the Acl field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *PatchInstancePayload) GetAclOk() (ret PatchInstancePayloadGetAclRetType, ok bool) { + return getPatchInstancePayloadGetAclAttributeTypeOk(o.Acl) +} + +// HasAcl returns a boolean if a field has been set. +func (o *PatchInstancePayload) HasAcl() bool { + _, ok := o.GetAclOk() + return ok +} + +// SetAcl gets a reference to the given []string and assigns it to the Acl field. +func (o *PatchInstancePayload) SetAcl(v PatchInstancePayloadGetAclRetType) { + setPatchInstancePayloadGetAclAttributeType(&o.Acl, v) +} + +func (o PatchInstancePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getPatchInstancePayloadGetAclAttributeTypeOk(o.Acl); ok { + toSerialize["Acl"] = val + } + return toSerialize, nil +} + +type NullablePatchInstancePayload struct { + value *PatchInstancePayload + isSet bool +} + +func (v NullablePatchInstancePayload) Get() *PatchInstancePayload { + return v.value +} + +func (v *NullablePatchInstancePayload) Set(val *PatchInstancePayload) { + v.value = val + v.isSet = true +} + +func (v NullablePatchInstancePayload) IsSet() bool { + return v.isSet +} + +func (v *NullablePatchInstancePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePatchInstancePayload(val *PatchInstancePayload) *NullablePatchInstancePayload { + return &NullablePatchInstancePayload{value: val, isSet: true} +} + +func (v NullablePatchInstancePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePatchInstancePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/git/model_patch_instance_payload_test.go b/services/git/model_patch_instance_payload_test.go new file mode 100644 index 000000000..e39c866ed --- /dev/null +++ b/services/git/model_patch_instance_payload_test.go @@ -0,0 +1,11 @@ +/* +STACKIT Git API + +STACKIT Git management API. + +API version: 1beta.0.4 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package git