From 41b8cfe765404fdd380e4d12719cb314746a1389 Mon Sep 17 00:00:00 2001 From: Lajos Date: Tue, 13 Oct 2020 14:47:33 +0200 Subject: [PATCH] replace --- api_feature_flag_setting_values_ext.go | 388 +++++++++++++++++++++++++ 1 file changed, 388 insertions(+) diff --git a/api_feature_flag_setting_values_ext.go b/api_feature_flag_setting_values_ext.go index 7c0917c..523c10d 100644 --- a/api_feature_flag_setting_values_ext.go +++ b/api_feature_flag_setting_values_ext.go @@ -758,3 +758,391 @@ func (a *FeatureFlagSettingValuesApiService) UpdateSettingValueFloat(ctx context return localVarReturnValue, localVarHttpResponse, nil } + +/* +FeatureFlagSettingValuesApiService Replace value +This endpoint replaces the whole value of a Feature Flag or Setting in a specified Environment. Only the `value`, `rolloutRules` and `percentageRules` attributes are modifiable by this endpoint. **Important:** As this endpoint is doing a complete replace, it's important to set every other attribute that you don't want to change in its original state. Not listing one means that it will reset. For example: We have the following resource. ``` { \"rolloutPercentageItems\": [ { \"percentage\": 30, \"value\": true }, { \"percentage\": 70, \"value\": false } ], \"rolloutRules\": [], \"value\": false } ``` If we send a replace request body as below: ``` { \"value\": true } ``` Then besides that the default value is set to `true`, all the Percentage Rules are deleted. So we get a response like this: ``` { \"rolloutPercentageItems\": [], \"rolloutRules\": [], \"value\": true } ``` + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param body + * @param environmentId The identifier of the Environment. + * @param settingId The id of the Setting. + * @param optional nil or *FeatureFlagSettingValuesApiReplaceSettingValueOpts - Optional Parameters: + * @param "Reason" (optional.String) - The reason note for the Audit Log if the Product's \"Config changes require a reason\" preference is turned on. +@return SettingValueModel +*/ + +func (a *FeatureFlagSettingValuesApiService) ReplaceSettingValueBool(ctx context.Context, body UpdateSettingValueModelBool, environmentId string, settingId int32, localVarOptionals *FeatureFlagSettingValuesApiReplaceSettingValueOpts) (SettingValueModelBool, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue SettingValueModelBool + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/environments/{environmentId}/settings/{settingId}/value" + localVarPath = strings.Replace(localVarPath, "{"+"environmentId"+"}", fmt.Sprintf("%v", environmentId), -1) + localVarPath = strings.Replace(localVarPath, "{"+"settingId"+"}", fmt.Sprintf("%v", settingId), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Reason.IsSet() { + localVarQueryParams.Add("reason", parameterToString(localVarOptionals.Reason.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "text/json", "application/_*+json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/hal+json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v SettingValueModel + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +FeatureFlagSettingValuesApiService Replace value +This endpoint replaces the whole value of a Feature Flag or Setting in a specified Environment. Only the `value`, `rolloutRules` and `percentageRules` attributes are modifiable by this endpoint. **Important:** As this endpoint is doing a complete replace, it's important to set every other attribute that you don't want to change in its original state. Not listing one means that it will reset. For example: We have the following resource. ``` { \"rolloutPercentageItems\": [ { \"percentage\": 30, \"value\": true }, { \"percentage\": 70, \"value\": false } ], \"rolloutRules\": [], \"value\": false } ``` If we send a replace request body as below: ``` { \"value\": true } ``` Then besides that the default value is set to `true`, all the Percentage Rules are deleted. So we get a response like this: ``` { \"rolloutPercentageItems\": [], \"rolloutRules\": [], \"value\": true } ``` + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param body + * @param environmentId The identifier of the Environment. + * @param settingId The id of the Setting. + * @param optional nil or *FeatureFlagSettingValuesApiReplaceSettingValueOpts - Optional Parameters: + * @param "Reason" (optional.String) - The reason note for the Audit Log if the Product's \"Config changes require a reason\" preference is turned on. +@return SettingValueModel +*/ + +func (a *FeatureFlagSettingValuesApiService) ReplaceSettingValueString(ctx context.Context, body UpdateSettingValueModelString, environmentId string, settingId int32, localVarOptionals *FeatureFlagSettingValuesApiReplaceSettingValueOpts) (SettingValueModelString, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue SettingValueModelString + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/environments/{environmentId}/settings/{settingId}/value" + localVarPath = strings.Replace(localVarPath, "{"+"environmentId"+"}", fmt.Sprintf("%v", environmentId), -1) + localVarPath = strings.Replace(localVarPath, "{"+"settingId"+"}", fmt.Sprintf("%v", settingId), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Reason.IsSet() { + localVarQueryParams.Add("reason", parameterToString(localVarOptionals.Reason.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "text/json", "application/_*+json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/hal+json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v SettingValueModel + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +FeatureFlagSettingValuesApiService Replace value +This endpoint replaces the whole value of a Feature Flag or Setting in a specified Environment. Only the `value`, `rolloutRules` and `percentageRules` attributes are modifiable by this endpoint. **Important:** As this endpoint is doing a complete replace, it's important to set every other attribute that you don't want to change in its original state. Not listing one means that it will reset. For example: We have the following resource. ``` { \"rolloutPercentageItems\": [ { \"percentage\": 30, \"value\": true }, { \"percentage\": 70, \"value\": false } ], \"rolloutRules\": [], \"value\": false } ``` If we send a replace request body as below: ``` { \"value\": true } ``` Then besides that the default value is set to `true`, all the Percentage Rules are deleted. So we get a response like this: ``` { \"rolloutPercentageItems\": [], \"rolloutRules\": [], \"value\": true } ``` + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param body + * @param environmentId The identifier of the Environment. + * @param settingId The id of the Setting. + * @param optional nil or *FeatureFlagSettingValuesApiReplaceSettingValueOpts - Optional Parameters: + * @param "Reason" (optional.String) - The reason note for the Audit Log if the Product's \"Config changes require a reason\" preference is turned on. +@return SettingValueModel +*/ + +func (a *FeatureFlagSettingValuesApiService) ReplaceSettingValueInt(ctx context.Context, body UpdateSettingValueModelInt, environmentId string, settingId int32, localVarOptionals *FeatureFlagSettingValuesApiReplaceSettingValueOpts) (SettingValueModelInt, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue SettingValueModelInt + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/environments/{environmentId}/settings/{settingId}/value" + localVarPath = strings.Replace(localVarPath, "{"+"environmentId"+"}", fmt.Sprintf("%v", environmentId), -1) + localVarPath = strings.Replace(localVarPath, "{"+"settingId"+"}", fmt.Sprintf("%v", settingId), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Reason.IsSet() { + localVarQueryParams.Add("reason", parameterToString(localVarOptionals.Reason.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "text/json", "application/_*+json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/hal+json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v SettingValueModel + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +FeatureFlagSettingValuesApiService Replace value +This endpoint replaces the whole value of a Feature Flag or Setting in a specified Environment. Only the `value`, `rolloutRules` and `percentageRules` attributes are modifiable by this endpoint. **Important:** As this endpoint is doing a complete replace, it's important to set every other attribute that you don't want to change in its original state. Not listing one means that it will reset. For example: We have the following resource. ``` { \"rolloutPercentageItems\": [ { \"percentage\": 30, \"value\": true }, { \"percentage\": 70, \"value\": false } ], \"rolloutRules\": [], \"value\": false } ``` If we send a replace request body as below: ``` { \"value\": true } ``` Then besides that the default value is set to `true`, all the Percentage Rules are deleted. So we get a response like this: ``` { \"rolloutPercentageItems\": [], \"rolloutRules\": [], \"value\": true } ``` + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param body + * @param environmentId The identifier of the Environment. + * @param settingId The id of the Setting. + * @param optional nil or *FeatureFlagSettingValuesApiReplaceSettingValueOpts - Optional Parameters: + * @param "Reason" (optional.String) - The reason note for the Audit Log if the Product's \"Config changes require a reason\" preference is turned on. +@return SettingValueModel +*/ + +func (a *FeatureFlagSettingValuesApiService) ReplaceSettingValueFloat(ctx context.Context, body UpdateSettingValueModelFloat, environmentId string, settingId int32, localVarOptionals *FeatureFlagSettingValuesApiReplaceSettingValueOpts) (SettingValueModelFloat, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue SettingValueModelFloat + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/environments/{environmentId}/settings/{settingId}/value" + localVarPath = strings.Replace(localVarPath, "{"+"environmentId"+"}", fmt.Sprintf("%v", environmentId), -1) + localVarPath = strings.Replace(localVarPath, "{"+"settingId"+"}", fmt.Sprintf("%v", settingId), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Reason.IsSet() { + localVarQueryParams.Add("reason", parameterToString(localVarOptionals.Reason.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "text/json", "application/_*+json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/hal+json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &body + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v SettingValueModel + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +}