diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b3342840..40d3a3d36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Release (2024-XX-XX) +- `serverupdate`: [v0.2.0](services/serverupdate/CHANGELOG.md#v020-2024-11-26) + - **Feature:** Add support for managing `UpdatePolicy` resources - `dns`: [v0.12.0](services/dns/CHANGELOG.md#v0120-2024-11-20) - **Feature:** New models `ZoneModelsImportRecordModel` and `ZoneModelsImportZoneJson` - `serverbackup`: [v0.3.0](services/serverbackup/CHANGELOG.md#v030-2024-11-20) diff --git a/services/serverupdate/CHANGELOG.md b/services/serverupdate/CHANGELOG.md index b126f850d..635354a1d 100644 --- a/services/serverupdate/CHANGELOG.md +++ b/services/serverupdate/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.0 (2024-11-26) + +- **Feature:** Add support for managing `UpdatePolicy` resources + ## v0.1.0 (2024-11-20) - Manage your STACKIT Server Updates: `Update`, `UpdateSchedule`, `BackupProperties` diff --git a/services/serverupdate/api_default.go b/services/serverupdate/api_default.go index d2f9a3587..5facd4b3c 100644 --- a/services/serverupdate/api_default.go +++ b/services/serverupdate/api_default.go @@ -141,8 +141,8 @@ func (r ApiCreateUpdateRequest) Execute() (*Update, error) { CreateUpdate: create update @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @return ApiCreateUpdateRequest */ func (a *APIClient) CreateUpdate(ctx context.Context, projectId string, serverId string) ApiCreateUpdateRequest { @@ -280,8 +280,8 @@ func (r ApiCreateUpdateScheduleRequest) Execute() (*UpdateSchedule, error) { CreateUpdateSchedule: create update schedule @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @return ApiCreateUpdateScheduleRequest */ func (a *APIClient) CreateUpdateSchedule(ctx context.Context, projectId string, serverId string) ApiCreateUpdateScheduleRequest { @@ -402,8 +402,8 @@ func (r ApiDeleteUpdateScheduleRequest) Execute() error { DeleteUpdateSchedule: delete update schedule @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @param scheduleId update schedule id @return ApiDeleteUpdateScheduleRequest */ @@ -525,8 +525,8 @@ func (r ApiDisableServiceRequest) Execute() error { DisableService: disable update service @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @return ApiDisableServiceRequest */ func (a *APIClient) DisableService(ctx context.Context, projectId string, serverId string) ApiDisableServiceRequest { @@ -648,8 +648,8 @@ func (r ApiDisableServiceResourceRequest) Execute() error { DisableServiceResource: disable update service @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @return ApiDisableServiceResourceRequest */ func (a *APIClient) DisableServiceResource(ctx context.Context, projectId string, serverId string) ApiDisableServiceResourceRequest { @@ -776,8 +776,8 @@ func (r ApiEnableServiceRequest) Execute() error { EnableService: enable update service @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @return ApiEnableServiceRequest */ func (a *APIClient) EnableService(ctx context.Context, projectId string, serverId string) ApiEnableServiceRequest { @@ -907,8 +907,8 @@ func (r ApiEnableServiceResourceRequest) Execute() error { EnableServiceResource: enable update service @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @return ApiEnableServiceResourceRequest */ func (a *APIClient) EnableServiceResource(ctx context.Context, projectId string, serverId string) ApiEnableServiceResourceRequest { @@ -1040,8 +1040,8 @@ func (r ApiGetUpdateRequest) Execute() (*Update, error) { GetUpdate: get update @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @param updateId id of the update @return ApiGetUpdateRequest */ @@ -1176,8 +1176,8 @@ func (r ApiGetUpdateScheduleRequest) Execute() (*UpdateSchedule, error) { GetUpdateSchedule: get single update schedule details @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @param scheduleId update schedule id @return ApiGetUpdateScheduleRequest */ @@ -1202,6 +1202,121 @@ func (a *APIClient) GetUpdateScheduleExecute(ctx context.Context, projectId stri return r.Execute() } +type ApiListUpdatePoliciesRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string +} + +func (r ApiListUpdatePoliciesRequest) Execute() (*GetUpdatePoliciesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetUpdatePoliciesResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListUpdatePolicies") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/update-policies" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +ListUpdatePolicies: get list of update policies + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId project id + @return ApiListUpdatePoliciesRequest +*/ +func (a *APIClient) ListUpdatePolicies(ctx context.Context, projectId string) ApiListUpdatePoliciesRequest { + return ApiListUpdatePoliciesRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } +} + +func (a *APIClient) ListUpdatePoliciesExecute(ctx context.Context, projectId string) (*GetUpdatePoliciesResponse, error) { + r := ApiListUpdatePoliciesRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + } + return r.Execute() +} + type ApiListUpdateSchedulesRequest struct { ctx context.Context apiService *DefaultApiService @@ -1310,8 +1425,8 @@ func (r ApiListUpdateSchedulesRequest) Execute() (*GetUpdateSchedulesResponse, e ListUpdateSchedules: get list of update schedules @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @return ApiListUpdateSchedulesRequest */ func (a *APIClient) ListUpdateSchedules(ctx context.Context, projectId string, serverId string) ApiListUpdateSchedulesRequest { @@ -1441,8 +1556,8 @@ func (r ApiListUpdatesRequest) Execute() (*GetUpdatesListResponse, error) { ListUpdates: get list of updates @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @return ApiListUpdatesRequest */ func (a *APIClient) ListUpdates(ctx context.Context, projectId string, serverId string) ApiListUpdatesRequest { @@ -1582,8 +1697,8 @@ func (r ApiUpdateUpdateScheduleRequest) Execute() (*UpdateSchedule, error) { UpdateUpdateSchedule: update update schedule @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId portal project id - @param serverId openstack server id + @param projectId project id + @param serverId server id @param scheduleId update schedule id @return ApiUpdateUpdateScheduleRequest */ diff --git a/services/serverupdate/api_default_test.go b/services/serverupdate/api_default_test.go index e2c399d76..41d3752c4 100644 --- a/services/serverupdate/api_default_test.go +++ b/services/serverupdate/api_default_test.go @@ -497,6 +497,58 @@ func Test_serverupdate_DefaultApiService(t *testing.T) { } }) + t.Run("Test DefaultApiService ListUpdatePolicies", func(t *testing.T) { + path := "/v1/projects/{projectId}/update-policies" + projectIdValue := "projectId" + path = strings.Replace(path, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { + data := GetUpdatePoliciesResponse{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for serverupdate_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := "projectId" + + resp, reqErr := apiClient.ListUpdatePolicies(context.Background(), projectId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if resp == nil { + t.Fatalf("response not present") + } + }) + t.Run("Test DefaultApiService ListUpdateSchedules", func(t *testing.T) { path := "/v1/projects/{projectId}/servers/{serverId}/update-schedules" projectIdValue := "projectId" diff --git a/services/serverupdate/model_create_update_schedule_payload.go b/services/serverupdate/model_create_update_schedule_payload.go index 18162c7f0..ddf8afec8 100644 --- a/services/serverupdate/model_create_update_schedule_payload.go +++ b/services/serverupdate/model_create_update_schedule_payload.go @@ -22,8 +22,7 @@ type CreateUpdateSchedulePayload struct { // REQUIRED Enabled *bool `json:"enabled"` // Can be cast to int32 without loss of precision. - // REQUIRED - Id *int64 `json:"id"` + Id *int64 `json:"id,omitempty"` // Can be cast to int32 without loss of precision. // REQUIRED MaintenanceWindow *int64 `json:"maintenanceWindow"` @@ -39,10 +38,9 @@ type _CreateUpdateSchedulePayload CreateUpdateSchedulePayload // 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 NewCreateUpdateSchedulePayload(enabled *bool, id *int64, maintenanceWindow *int64, name *string, rrule *string) *CreateUpdateSchedulePayload { +func NewCreateUpdateSchedulePayload(enabled *bool, maintenanceWindow *int64, name *string, rrule *string) *CreateUpdateSchedulePayload { this := CreateUpdateSchedulePayload{} this.Enabled = enabled - this.Id = id this.MaintenanceWindow = maintenanceWindow this.Name = name this.Rrule = rrule @@ -81,26 +79,34 @@ func (o *CreateUpdateSchedulePayload) SetEnabled(v *bool) { o.Enabled = v } -// GetId returns the Id field value +// GetId returns the Id field value if set, zero value otherwise. func (o *CreateUpdateSchedulePayload) GetId() *int64 { - if o == nil { + if o == nil || IsNil(o.Id) { var ret *int64 return ret } - return o.Id } -// GetIdOk returns a tuple with the Id field value +// GetIdOk returns a tuple with the Id field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *CreateUpdateSchedulePayload) GetIdOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.Id) { return nil, false } return o.Id, true } -// SetId sets field value +// HasId returns a boolean if a field has been set. +func (o *CreateUpdateSchedulePayload) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given int64 and assigns it to the Id field. func (o *CreateUpdateSchedulePayload) SetId(v *int64) { o.Id = v } @@ -180,7 +186,9 @@ func (o *CreateUpdateSchedulePayload) SetRrule(v *string) { func (o CreateUpdateSchedulePayload) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} toSerialize["enabled"] = o.Enabled - toSerialize["id"] = o.Id + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } toSerialize["maintenanceWindow"] = o.MaintenanceWindow toSerialize["name"] = o.Name toSerialize["rrule"] = o.Rrule diff --git a/services/serverupdate/model_get_update_policies_response.go b/services/serverupdate/model_get_update_policies_response.go new file mode 100644 index 000000000..4e33eb703 --- /dev/null +++ b/services/serverupdate/model_get_update_policies_response.go @@ -0,0 +1,116 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the GetUpdatePoliciesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetUpdatePoliciesResponse{} + +// GetUpdatePoliciesResponse struct for GetUpdatePoliciesResponse +type GetUpdatePoliciesResponse struct { + Items *[]UpdatePolicy `json:"items,omitempty"` +} + +// NewGetUpdatePoliciesResponse instantiates a new GetUpdatePoliciesResponse 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 NewGetUpdatePoliciesResponse() *GetUpdatePoliciesResponse { + this := GetUpdatePoliciesResponse{} + return &this +} + +// NewGetUpdatePoliciesResponseWithDefaults instantiates a new GetUpdatePoliciesResponse 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 NewGetUpdatePoliciesResponseWithDefaults() *GetUpdatePoliciesResponse { + this := GetUpdatePoliciesResponse{} + return &this +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *GetUpdatePoliciesResponse) GetItems() *[]UpdatePolicy { + if o == nil || IsNil(o.Items) { + var ret *[]UpdatePolicy + return ret + } + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetUpdatePoliciesResponse) GetItemsOk() (*[]UpdatePolicy, bool) { + if o == nil || IsNil(o.Items) { + return nil, false + } + return o.Items, true +} + +// HasItems returns a boolean if a field has been set. +func (o *GetUpdatePoliciesResponse) HasItems() bool { + if o != nil && !IsNil(o.Items) { + return true + } + + return false +} + +// SetItems gets a reference to the given []UpdatePolicy and assigns it to the Items field. +func (o *GetUpdatePoliciesResponse) SetItems(v *[]UpdatePolicy) { + o.Items = v +} + +func (o GetUpdatePoliciesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Items) { + toSerialize["items"] = o.Items + } + return toSerialize, nil +} + +type NullableGetUpdatePoliciesResponse struct { + value *GetUpdatePoliciesResponse + isSet bool +} + +func (v NullableGetUpdatePoliciesResponse) Get() *GetUpdatePoliciesResponse { + return v.value +} + +func (v *NullableGetUpdatePoliciesResponse) Set(val *GetUpdatePoliciesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetUpdatePoliciesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetUpdatePoliciesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetUpdatePoliciesResponse(val *GetUpdatePoliciesResponse) *NullableGetUpdatePoliciesResponse { + return &NullableGetUpdatePoliciesResponse{value: val, isSet: true} +} + +func (v NullableGetUpdatePoliciesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetUpdatePoliciesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_update_policy.go b/services/serverupdate/model_update_policy.go new file mode 100644 index 000000000..58cfd6ef6 --- /dev/null +++ b/services/serverupdate/model_update_policy.go @@ -0,0 +1,332 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the UpdatePolicy type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdatePolicy{} + +// UpdatePolicy struct for UpdatePolicy +type UpdatePolicy struct { + Default *bool `json:"default,omitempty"` + Description *string `json:"description,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Id *string `json:"id,omitempty"` + MaintenanceWindow *int64 `json:"maintenanceWindow,omitempty"` + Name *string `json:"name,omitempty"` + Rrule *string `json:"rrule,omitempty"` +} + +// NewUpdatePolicy instantiates a new UpdatePolicy 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 NewUpdatePolicy() *UpdatePolicy { + this := UpdatePolicy{} + return &this +} + +// NewUpdatePolicyWithDefaults instantiates a new UpdatePolicy 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 NewUpdatePolicyWithDefaults() *UpdatePolicy { + this := UpdatePolicy{} + return &this +} + +// GetDefault returns the Default field value if set, zero value otherwise. +func (o *UpdatePolicy) GetDefault() *bool { + if o == nil || IsNil(o.Default) { + var ret *bool + return ret + } + return o.Default +} + +// GetDefaultOk returns a tuple with the Default field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdatePolicy) GetDefaultOk() (*bool, bool) { + if o == nil || IsNil(o.Default) { + return nil, false + } + return o.Default, true +} + +// HasDefault returns a boolean if a field has been set. +func (o *UpdatePolicy) HasDefault() bool { + if o != nil && !IsNil(o.Default) { + return true + } + + return false +} + +// SetDefault gets a reference to the given bool and assigns it to the Default field. +func (o *UpdatePolicy) SetDefault(v *bool) { + o.Default = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *UpdatePolicy) GetDescription() *string { + if o == nil || IsNil(o.Description) { + var ret *string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdatePolicy) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *UpdatePolicy) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *UpdatePolicy) SetDescription(v *string) { + o.Description = v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *UpdatePolicy) GetEnabled() *bool { + if o == nil || IsNil(o.Enabled) { + var ret *bool + return ret + } + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdatePolicy) GetEnabledOk() (*bool, bool) { + if o == nil || IsNil(o.Enabled) { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *UpdatePolicy) HasEnabled() bool { + if o != nil && !IsNil(o.Enabled) { + return true + } + + return false +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *UpdatePolicy) SetEnabled(v *bool) { + o.Enabled = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *UpdatePolicy) GetId() *string { + if o == nil || IsNil(o.Id) { + var ret *string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdatePolicy) GetIdOk() (*string, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *UpdatePolicy) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *UpdatePolicy) SetId(v *string) { + o.Id = v +} + +// GetMaintenanceWindow returns the MaintenanceWindow field value if set, zero value otherwise. +func (o *UpdatePolicy) GetMaintenanceWindow() *int64 { + if o == nil || IsNil(o.MaintenanceWindow) { + var ret *int64 + return ret + } + return o.MaintenanceWindow +} + +// GetMaintenanceWindowOk returns a tuple with the MaintenanceWindow field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdatePolicy) GetMaintenanceWindowOk() (*int64, bool) { + if o == nil || IsNil(o.MaintenanceWindow) { + return nil, false + } + return o.MaintenanceWindow, true +} + +// HasMaintenanceWindow returns a boolean if a field has been set. +func (o *UpdatePolicy) HasMaintenanceWindow() bool { + if o != nil && !IsNil(o.MaintenanceWindow) { + return true + } + + return false +} + +// SetMaintenanceWindow gets a reference to the given int64 and assigns it to the MaintenanceWindow field. +func (o *UpdatePolicy) SetMaintenanceWindow(v *int64) { + o.MaintenanceWindow = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *UpdatePolicy) GetName() *string { + if o == nil || IsNil(o.Name) { + var ret *string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdatePolicy) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *UpdatePolicy) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *UpdatePolicy) SetName(v *string) { + o.Name = v +} + +// GetRrule returns the Rrule field value if set, zero value otherwise. +func (o *UpdatePolicy) GetRrule() *string { + if o == nil || IsNil(o.Rrule) { + var ret *string + return ret + } + return o.Rrule +} + +// GetRruleOk returns a tuple with the Rrule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdatePolicy) GetRruleOk() (*string, bool) { + if o == nil || IsNil(o.Rrule) { + return nil, false + } + return o.Rrule, true +} + +// HasRrule returns a boolean if a field has been set. +func (o *UpdatePolicy) HasRrule() bool { + if o != nil && !IsNil(o.Rrule) { + return true + } + + return false +} + +// SetRrule gets a reference to the given string and assigns it to the Rrule field. +func (o *UpdatePolicy) SetRrule(v *string) { + o.Rrule = v +} + +func (o UpdatePolicy) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Default) { + toSerialize["default"] = o.Default + } + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + if !IsNil(o.Enabled) { + toSerialize["enabled"] = o.Enabled + } + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } + if !IsNil(o.MaintenanceWindow) { + toSerialize["maintenanceWindow"] = o.MaintenanceWindow + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Rrule) { + toSerialize["rrule"] = o.Rrule + } + return toSerialize, nil +} + +type NullableUpdatePolicy struct { + value *UpdatePolicy + isSet bool +} + +func (v NullableUpdatePolicy) Get() *UpdatePolicy { + return v.value +} + +func (v *NullableUpdatePolicy) Set(val *UpdatePolicy) { + v.value = val + v.isSet = true +} + +func (v NullableUpdatePolicy) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdatePolicy) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdatePolicy(val *UpdatePolicy) *NullableUpdatePolicy { + return &NullableUpdatePolicy{value: val, isSet: true} +} + +func (v NullableUpdatePolicy) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdatePolicy) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_update_schedule.go b/services/serverupdate/model_update_schedule.go index 8ee0e6fe7..e279dfcb6 100644 --- a/services/serverupdate/model_update_schedule.go +++ b/services/serverupdate/model_update_schedule.go @@ -22,8 +22,7 @@ type UpdateSchedule struct { // REQUIRED Enabled *bool `json:"enabled"` // Can be cast to int32 without loss of precision. - // REQUIRED - Id *int64 `json:"id"` + Id *int64 `json:"id,omitempty"` // Can be cast to int32 without loss of precision. // REQUIRED MaintenanceWindow *int64 `json:"maintenanceWindow"` @@ -39,10 +38,9 @@ type _UpdateSchedule UpdateSchedule // 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 NewUpdateSchedule(enabled *bool, id *int64, maintenanceWindow *int64, name *string, rrule *string) *UpdateSchedule { +func NewUpdateSchedule(enabled *bool, maintenanceWindow *int64, name *string, rrule *string) *UpdateSchedule { this := UpdateSchedule{} this.Enabled = enabled - this.Id = id this.MaintenanceWindow = maintenanceWindow this.Name = name this.Rrule = rrule @@ -81,26 +79,34 @@ func (o *UpdateSchedule) SetEnabled(v *bool) { o.Enabled = v } -// GetId returns the Id field value +// GetId returns the Id field value if set, zero value otherwise. func (o *UpdateSchedule) GetId() *int64 { - if o == nil { + if o == nil || IsNil(o.Id) { var ret *int64 return ret } - return o.Id } -// GetIdOk returns a tuple with the Id field value +// GetIdOk returns a tuple with the Id field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *UpdateSchedule) GetIdOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.Id) { return nil, false } return o.Id, true } -// SetId sets field value +// HasId returns a boolean if a field has been set. +func (o *UpdateSchedule) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given int64 and assigns it to the Id field. func (o *UpdateSchedule) SetId(v *int64) { o.Id = v } @@ -180,7 +186,9 @@ func (o *UpdateSchedule) SetRrule(v *string) { func (o UpdateSchedule) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} toSerialize["enabled"] = o.Enabled - toSerialize["id"] = o.Id + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } toSerialize["maintenanceWindow"] = o.MaintenanceWindow toSerialize["name"] = o.Name toSerialize["rrule"] = o.Rrule diff --git a/services/serverupdate/model_update_update_schedule_payload.go b/services/serverupdate/model_update_update_schedule_payload.go index 20d2c6cb8..0d823cdc7 100644 --- a/services/serverupdate/model_update_update_schedule_payload.go +++ b/services/serverupdate/model_update_update_schedule_payload.go @@ -22,8 +22,7 @@ type UpdateUpdateSchedulePayload struct { // REQUIRED Enabled *bool `json:"enabled"` // Can be cast to int32 without loss of precision. - // REQUIRED - Id *int64 `json:"id"` + Id *int64 `json:"id,omitempty"` // Can be cast to int32 without loss of precision. // REQUIRED MaintenanceWindow *int64 `json:"maintenanceWindow"` @@ -39,10 +38,9 @@ type _UpdateUpdateSchedulePayload UpdateUpdateSchedulePayload // 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 NewUpdateUpdateSchedulePayload(enabled *bool, id *int64, maintenanceWindow *int64, name *string, rrule *string) *UpdateUpdateSchedulePayload { +func NewUpdateUpdateSchedulePayload(enabled *bool, maintenanceWindow *int64, name *string, rrule *string) *UpdateUpdateSchedulePayload { this := UpdateUpdateSchedulePayload{} this.Enabled = enabled - this.Id = id this.MaintenanceWindow = maintenanceWindow this.Name = name this.Rrule = rrule @@ -81,26 +79,34 @@ func (o *UpdateUpdateSchedulePayload) SetEnabled(v *bool) { o.Enabled = v } -// GetId returns the Id field value +// GetId returns the Id field value if set, zero value otherwise. func (o *UpdateUpdateSchedulePayload) GetId() *int64 { - if o == nil { + if o == nil || IsNil(o.Id) { var ret *int64 return ret } - return o.Id } -// GetIdOk returns a tuple with the Id field value +// GetIdOk returns a tuple with the Id field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *UpdateUpdateSchedulePayload) GetIdOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.Id) { return nil, false } return o.Id, true } -// SetId sets field value +// HasId returns a boolean if a field has been set. +func (o *UpdateUpdateSchedulePayload) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given int64 and assigns it to the Id field. func (o *UpdateUpdateSchedulePayload) SetId(v *int64) { o.Id = v } @@ -180,7 +186,9 @@ func (o *UpdateUpdateSchedulePayload) SetRrule(v *string) { func (o UpdateUpdateSchedulePayload) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} toSerialize["enabled"] = o.Enabled - toSerialize["id"] = o.Id + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } toSerialize["maintenanceWindow"] = o.MaintenanceWindow toSerialize["name"] = o.Name toSerialize["rrule"] = o.Rrule