github.com/safedep/dry@v0.0.0-20241016050132-a15651f0548b/apiguard/tykgen/api_organisation_quotas.go (about)

     1  
     2  /*
     3   * Tyk Gateway API
     4   *
     5   * The Tyk Gateway API is the primary means for integrating your application with the Tyk API Gateway system. This API is very small, and has no granular permissions system. It is intended to be used purely for internal automation and integration.  **Warning: Under no circumstances should outside parties be granted access to this API.**  The Tyk Gateway API is capable of:  * Managing session objects (key generation) * Managing and listing policies * Managing and listing API Definitions (only when not using the Dashboard) * Hot reloads / reloading a cluster configuration * OAuth client creation (only when not using the Dashboard)   In order to use the Gateway API, you'll need to set the `secret` parameter in your tyk.conf file.  The shared secret you set should then be sent along as a header with each Gateway API Request in order for it to be successful:  ``` x-tyk-authorization: <your-secret> ``` <br/> <b>The Tyk Gateway API is subsumed by the Tyk Dashboard API in Pro installations.</b>
     6   *
     7   * API version: 5.5.0
     8   * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
     9   */
    10  package swagger
    11  
    12  import (
    13  	"context"
    14  	"io/ioutil"
    15  	"net/http"
    16  	"net/url"
    17  	"strings"
    18  	"fmt"
    19  	"github.com/antihax/optional"
    20  )
    21  
    22  // Linger please
    23  var (
    24  	_ context.Context
    25  )
    26  
    27  type OrganisationQuotasApiService service
    28  /*
    29  OrganisationQuotasApiService Create an organisation key
    30  This work similar to Keys API except that Key ID is always equals Organisation ID
    31   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
    32   * @param keyID The Key ID
    33   * @param optional nil or *OrganisationQuotasApiAddOrgKeyOpts - Optional Parameters:
    34       * @param "Body" (optional.Interface of SessionState) - 
    35  @return ApiModifyKeySuccess
    36  */
    37  
    38  type OrganisationQuotasApiAddOrgKeyOpts struct {
    39      Body optional.Interface
    40  }
    41  
    42  func (a *OrganisationQuotasApiService) AddOrgKey(ctx context.Context, keyID string, localVarOptionals *OrganisationQuotasApiAddOrgKeyOpts) (ApiModifyKeySuccess, *http.Response, error) {
    43  	var (
    44  		localVarHttpMethod = strings.ToUpper("Post")
    45  		localVarPostBody   interface{}
    46  		localVarFileName   string
    47  		localVarFileBytes  []byte
    48  		localVarReturnValue ApiModifyKeySuccess
    49  	)
    50  
    51  	// create path and map variables
    52  	localVarPath := a.client.cfg.BasePath + "/tyk/org/keys/{keyID}"
    53  	localVarPath = strings.Replace(localVarPath, "{"+"keyID"+"}", fmt.Sprintf("%v", keyID), -1)
    54  
    55  	localVarHeaderParams := make(map[string]string)
    56  	localVarQueryParams := url.Values{}
    57  	localVarFormParams := url.Values{}
    58  
    59  	// to determine the Content-Type header
    60  	localVarHttpContentTypes := []string{"application/json"}
    61  
    62  	// set Content-Type header
    63  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
    64  	if localVarHttpContentType != "" {
    65  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
    66  	}
    67  
    68  	// to determine the Accept header
    69  	localVarHttpHeaderAccepts := []string{"application/json"}
    70  
    71  	// set Accept header
    72  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
    73  	if localVarHttpHeaderAccept != "" {
    74  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
    75  	}
    76  	// body params
    77  	if localVarOptionals != nil && localVarOptionals.Body.IsSet() {
    78  		
    79  		localVarOptionalBody:= localVarOptionals.Body.Value()
    80  		localVarPostBody = &localVarOptionalBody
    81  	}
    82  	if ctx != nil {
    83  		// API Key Authentication
    84  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
    85  			var key string
    86  			if auth.Prefix != "" {
    87  				key = auth.Prefix + " " + auth.Key
    88  			} else {
    89  				key = auth.Key
    90  			}
    91  			localVarHeaderParams["X-Tyk-Authorization"] = key
    92  			
    93  		}
    94  	}
    95  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
    96  	if err != nil {
    97  		return localVarReturnValue, nil, err
    98  	}
    99  
   100  	localVarHttpResponse, err := a.client.callAPI(r)
   101  	if err != nil || localVarHttpResponse == nil {
   102  		return localVarReturnValue, localVarHttpResponse, err
   103  	}
   104  
   105  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   106  	localVarHttpResponse.Body.Close()
   107  	if err != nil {
   108  		return localVarReturnValue, localVarHttpResponse, err
   109  	}
   110  
   111  	if localVarHttpResponse.StatusCode < 300 {
   112  		// If we succeed, return the data, otherwise pass on to decode error.
   113  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   114  		if err == nil { 
   115  			return localVarReturnValue, localVarHttpResponse, err
   116  		}
   117  	}
   118  
   119  	if localVarHttpResponse.StatusCode >= 300 {
   120  		newErr := GenericSwaggerError{
   121  			body: localVarBody,
   122  			error: localVarHttpResponse.Status,
   123  		}
   124  		if localVarHttpResponse.StatusCode == 200 {
   125  			var v ApiModifyKeySuccess
   126  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   127  				if err != nil {
   128  					newErr.error = err.Error()
   129  					return localVarReturnValue, localVarHttpResponse, newErr
   130  				}
   131  				newErr.model = v
   132  				return localVarReturnValue, localVarHttpResponse, newErr
   133  		}
   134  		return localVarReturnValue, localVarHttpResponse, newErr
   135  	}
   136  
   137  	return localVarReturnValue, localVarHttpResponse, nil
   138  }
   139  /*
   140  OrganisationQuotasApiService Delete Organisation Key
   141  Deleting a key will remove all limits from organisation. It does not affects regualar keys created within organisation.
   142   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   143   * @param keyID The Key ID
   144  @return ApiStatusMessage
   145  */
   146  func (a *OrganisationQuotasApiService) DeleteOrgKey(ctx context.Context, keyID string) (ApiStatusMessage, *http.Response, error) {
   147  	var (
   148  		localVarHttpMethod = strings.ToUpper("Delete")
   149  		localVarPostBody   interface{}
   150  		localVarFileName   string
   151  		localVarFileBytes  []byte
   152  		localVarReturnValue ApiStatusMessage
   153  	)
   154  
   155  	// create path and map variables
   156  	localVarPath := a.client.cfg.BasePath + "/tyk/org/keys/{keyID}"
   157  	localVarPath = strings.Replace(localVarPath, "{"+"keyID"+"}", fmt.Sprintf("%v", keyID), -1)
   158  
   159  	localVarHeaderParams := make(map[string]string)
   160  	localVarQueryParams := url.Values{}
   161  	localVarFormParams := url.Values{}
   162  
   163  	// to determine the Content-Type header
   164  	localVarHttpContentTypes := []string{}
   165  
   166  	// set Content-Type header
   167  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   168  	if localVarHttpContentType != "" {
   169  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   170  	}
   171  
   172  	// to determine the Accept header
   173  	localVarHttpHeaderAccepts := []string{"application/json"}
   174  
   175  	// set Accept header
   176  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   177  	if localVarHttpHeaderAccept != "" {
   178  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   179  	}
   180  	if ctx != nil {
   181  		// API Key Authentication
   182  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   183  			var key string
   184  			if auth.Prefix != "" {
   185  				key = auth.Prefix + " " + auth.Key
   186  			} else {
   187  				key = auth.Key
   188  			}
   189  			localVarHeaderParams["X-Tyk-Authorization"] = key
   190  			
   191  		}
   192  	}
   193  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   194  	if err != nil {
   195  		return localVarReturnValue, nil, err
   196  	}
   197  
   198  	localVarHttpResponse, err := a.client.callAPI(r)
   199  	if err != nil || localVarHttpResponse == nil {
   200  		return localVarReturnValue, localVarHttpResponse, err
   201  	}
   202  
   203  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   204  	localVarHttpResponse.Body.Close()
   205  	if err != nil {
   206  		return localVarReturnValue, localVarHttpResponse, err
   207  	}
   208  
   209  	if localVarHttpResponse.StatusCode < 300 {
   210  		// If we succeed, return the data, otherwise pass on to decode error.
   211  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   212  		if err == nil { 
   213  			return localVarReturnValue, localVarHttpResponse, err
   214  		}
   215  	}
   216  
   217  	if localVarHttpResponse.StatusCode >= 300 {
   218  		newErr := GenericSwaggerError{
   219  			body: localVarBody,
   220  			error: localVarHttpResponse.Status,
   221  		}
   222  		if localVarHttpResponse.StatusCode == 200 {
   223  			var v ApiStatusMessage
   224  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   225  				if err != nil {
   226  					newErr.error = err.Error()
   227  					return localVarReturnValue, localVarHttpResponse, newErr
   228  				}
   229  				newErr.model = v
   230  				return localVarReturnValue, localVarHttpResponse, newErr
   231  		}
   232  		return localVarReturnValue, localVarHttpResponse, newErr
   233  	}
   234  
   235  	return localVarReturnValue, localVarHttpResponse, nil
   236  }
   237  /*
   238  OrganisationQuotasApiService Get an Organisation Key
   239  Get session info about specified orgnanisation key. Should return up to date rate limit and quota usage numbers.
   240   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   241   * @param keyID The Key ID
   242  @return SessionState
   243  */
   244  func (a *OrganisationQuotasApiService) GetOrgKey(ctx context.Context, keyID string) (SessionState, *http.Response, error) {
   245  	var (
   246  		localVarHttpMethod = strings.ToUpper("Get")
   247  		localVarPostBody   interface{}
   248  		localVarFileName   string
   249  		localVarFileBytes  []byte
   250  		localVarReturnValue SessionState
   251  	)
   252  
   253  	// create path and map variables
   254  	localVarPath := a.client.cfg.BasePath + "/tyk/org/keys/{keyID}"
   255  	localVarPath = strings.Replace(localVarPath, "{"+"keyID"+"}", fmt.Sprintf("%v", keyID), -1)
   256  
   257  	localVarHeaderParams := make(map[string]string)
   258  	localVarQueryParams := url.Values{}
   259  	localVarFormParams := url.Values{}
   260  
   261  	// to determine the Content-Type header
   262  	localVarHttpContentTypes := []string{}
   263  
   264  	// set Content-Type header
   265  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   266  	if localVarHttpContentType != "" {
   267  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   268  	}
   269  
   270  	// to determine the Accept header
   271  	localVarHttpHeaderAccepts := []string{"application/json"}
   272  
   273  	// set Accept header
   274  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   275  	if localVarHttpHeaderAccept != "" {
   276  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   277  	}
   278  	if ctx != nil {
   279  		// API Key Authentication
   280  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   281  			var key string
   282  			if auth.Prefix != "" {
   283  				key = auth.Prefix + " " + auth.Key
   284  			} else {
   285  				key = auth.Key
   286  			}
   287  			localVarHeaderParams["X-Tyk-Authorization"] = key
   288  			
   289  		}
   290  	}
   291  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   292  	if err != nil {
   293  		return localVarReturnValue, nil, err
   294  	}
   295  
   296  	localVarHttpResponse, err := a.client.callAPI(r)
   297  	if err != nil || localVarHttpResponse == nil {
   298  		return localVarReturnValue, localVarHttpResponse, err
   299  	}
   300  
   301  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   302  	localVarHttpResponse.Body.Close()
   303  	if err != nil {
   304  		return localVarReturnValue, localVarHttpResponse, err
   305  	}
   306  
   307  	if localVarHttpResponse.StatusCode < 300 {
   308  		// If we succeed, return the data, otherwise pass on to decode error.
   309  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   310  		if err == nil { 
   311  			return localVarReturnValue, localVarHttpResponse, err
   312  		}
   313  	}
   314  
   315  	if localVarHttpResponse.StatusCode >= 300 {
   316  		newErr := GenericSwaggerError{
   317  			body: localVarBody,
   318  			error: localVarHttpResponse.Status,
   319  		}
   320  		if localVarHttpResponse.StatusCode == 200 {
   321  			var v SessionState
   322  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   323  				if err != nil {
   324  					newErr.error = err.Error()
   325  					return localVarReturnValue, localVarHttpResponse, newErr
   326  				}
   327  				newErr.model = v
   328  				return localVarReturnValue, localVarHttpResponse, newErr
   329  		}
   330  		return localVarReturnValue, localVarHttpResponse, newErr
   331  	}
   332  
   333  	return localVarReturnValue, localVarHttpResponse, nil
   334  }
   335  /*
   336  OrganisationQuotasApiService List Organisation Keys
   337  You can now set rate limits at the organisation level by using the following fields - allowance and rate. These are the number of allowed requests for the specified per value, and need to be set to the same value. If you don&#x27;t want to have organisation level rate limiting, set &#x27;rate&#x27; or &#x27;per&#x27; to zero, or don&#x27;t add them to your request.
   338   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   339  @return InlineResponse2002
   340  */
   341  func (a *OrganisationQuotasApiService) ListOrgKeys(ctx context.Context) (InlineResponse2002, *http.Response, error) {
   342  	var (
   343  		localVarHttpMethod = strings.ToUpper("Get")
   344  		localVarPostBody   interface{}
   345  		localVarFileName   string
   346  		localVarFileBytes  []byte
   347  		localVarReturnValue InlineResponse2002
   348  	)
   349  
   350  	// create path and map variables
   351  	localVarPath := a.client.cfg.BasePath + "/tyk/org/keys"
   352  
   353  	localVarHeaderParams := make(map[string]string)
   354  	localVarQueryParams := url.Values{}
   355  	localVarFormParams := url.Values{}
   356  
   357  	// to determine the Content-Type header
   358  	localVarHttpContentTypes := []string{}
   359  
   360  	// set Content-Type header
   361  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   362  	if localVarHttpContentType != "" {
   363  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   364  	}
   365  
   366  	// to determine the Accept header
   367  	localVarHttpHeaderAccepts := []string{"application/json"}
   368  
   369  	// set Accept header
   370  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   371  	if localVarHttpHeaderAccept != "" {
   372  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   373  	}
   374  	if ctx != nil {
   375  		// API Key Authentication
   376  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   377  			var key string
   378  			if auth.Prefix != "" {
   379  				key = auth.Prefix + " " + auth.Key
   380  			} else {
   381  				key = auth.Key
   382  			}
   383  			localVarHeaderParams["X-Tyk-Authorization"] = key
   384  			
   385  		}
   386  	}
   387  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   388  	if err != nil {
   389  		return localVarReturnValue, nil, err
   390  	}
   391  
   392  	localVarHttpResponse, err := a.client.callAPI(r)
   393  	if err != nil || localVarHttpResponse == nil {
   394  		return localVarReturnValue, localVarHttpResponse, err
   395  	}
   396  
   397  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   398  	localVarHttpResponse.Body.Close()
   399  	if err != nil {
   400  		return localVarReturnValue, localVarHttpResponse, err
   401  	}
   402  
   403  	if localVarHttpResponse.StatusCode < 300 {
   404  		// If we succeed, return the data, otherwise pass on to decode error.
   405  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   406  		if err == nil { 
   407  			return localVarReturnValue, localVarHttpResponse, err
   408  		}
   409  	}
   410  
   411  	if localVarHttpResponse.StatusCode >= 300 {
   412  		newErr := GenericSwaggerError{
   413  			body: localVarBody,
   414  			error: localVarHttpResponse.Status,
   415  		}
   416  		if localVarHttpResponse.StatusCode == 200 {
   417  			var v InlineResponse2002
   418  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   419  				if err != nil {
   420  					newErr.error = err.Error()
   421  					return localVarReturnValue, localVarHttpResponse, newErr
   422  				}
   423  				newErr.model = v
   424  				return localVarReturnValue, localVarHttpResponse, newErr
   425  		}
   426  		return localVarReturnValue, localVarHttpResponse, newErr
   427  	}
   428  
   429  	return localVarReturnValue, localVarHttpResponse, nil
   430  }
   431  /*
   432  OrganisationQuotasApiService Update Organisation Key
   433  This work similar to Keys API except that Key ID is always equals Organisation ID  For Gateway v2.6.0 onwards, you can now set rate limits at the organisation level by using the following fields - allowance and rate. These are the number of allowed requests for the specified per value, and need to be set to the same value. If you don&#x27;t want to have organisation level rate limiting, set &#x60;rate&#x60; or &#x60;per&#x60; to zero, or don&#x27;t add them to your request.
   434   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   435   * @param keyID The Key ID
   436   * @param optional nil or *OrganisationQuotasApiUpdateOrgKeyOpts - Optional Parameters:
   437       * @param "Body" (optional.Interface of SessionState) - 
   438       * @param "ResetQuota" (optional.String) -  Adding the &#x60;reset_quota&#x60; parameter and setting it to 1, will cause Tyk reset the organisations quota in the live quota manager, it is recommended to use this mechanism to reset organisation-level access if a monthly subscription is in place.
   439  @return ApiModifyKeySuccess
   440  */
   441  
   442  type OrganisationQuotasApiUpdateOrgKeyOpts struct {
   443      Body optional.Interface
   444      ResetQuota optional.String
   445  }
   446  
   447  func (a *OrganisationQuotasApiService) UpdateOrgKey(ctx context.Context, keyID string, localVarOptionals *OrganisationQuotasApiUpdateOrgKeyOpts) (ApiModifyKeySuccess, *http.Response, error) {
   448  	var (
   449  		localVarHttpMethod = strings.ToUpper("Put")
   450  		localVarPostBody   interface{}
   451  		localVarFileName   string
   452  		localVarFileBytes  []byte
   453  		localVarReturnValue ApiModifyKeySuccess
   454  	)
   455  
   456  	// create path and map variables
   457  	localVarPath := a.client.cfg.BasePath + "/tyk/org/keys/{keyID}"
   458  	localVarPath = strings.Replace(localVarPath, "{"+"keyID"+"}", fmt.Sprintf("%v", keyID), -1)
   459  
   460  	localVarHeaderParams := make(map[string]string)
   461  	localVarQueryParams := url.Values{}
   462  	localVarFormParams := url.Values{}
   463  
   464  	if localVarOptionals != nil && localVarOptionals.ResetQuota.IsSet() {
   465  		localVarQueryParams.Add("reset_quota", parameterToString(localVarOptionals.ResetQuota.Value(), ""))
   466  	}
   467  	// to determine the Content-Type header
   468  	localVarHttpContentTypes := []string{"application/json"}
   469  
   470  	// set Content-Type header
   471  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   472  	if localVarHttpContentType != "" {
   473  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   474  	}
   475  
   476  	// to determine the Accept header
   477  	localVarHttpHeaderAccepts := []string{"application/json"}
   478  
   479  	// set Accept header
   480  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   481  	if localVarHttpHeaderAccept != "" {
   482  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   483  	}
   484  	// body params
   485  	if localVarOptionals != nil && localVarOptionals.Body.IsSet() {
   486  		
   487  		localVarOptionalBody:= localVarOptionals.Body.Value()
   488  		localVarPostBody = &localVarOptionalBody
   489  	}
   490  	if ctx != nil {
   491  		// API Key Authentication
   492  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   493  			var key string
   494  			if auth.Prefix != "" {
   495  				key = auth.Prefix + " " + auth.Key
   496  			} else {
   497  				key = auth.Key
   498  			}
   499  			localVarHeaderParams["X-Tyk-Authorization"] = key
   500  			
   501  		}
   502  	}
   503  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   504  	if err != nil {
   505  		return localVarReturnValue, nil, err
   506  	}
   507  
   508  	localVarHttpResponse, err := a.client.callAPI(r)
   509  	if err != nil || localVarHttpResponse == nil {
   510  		return localVarReturnValue, localVarHttpResponse, err
   511  	}
   512  
   513  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   514  	localVarHttpResponse.Body.Close()
   515  	if err != nil {
   516  		return localVarReturnValue, localVarHttpResponse, err
   517  	}
   518  
   519  	if localVarHttpResponse.StatusCode < 300 {
   520  		// If we succeed, return the data, otherwise pass on to decode error.
   521  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   522  		if err == nil { 
   523  			return localVarReturnValue, localVarHttpResponse, err
   524  		}
   525  	}
   526  
   527  	if localVarHttpResponse.StatusCode >= 300 {
   528  		newErr := GenericSwaggerError{
   529  			body: localVarBody,
   530  			error: localVarHttpResponse.Status,
   531  		}
   532  		if localVarHttpResponse.StatusCode == 200 {
   533  			var v ApiModifyKeySuccess
   534  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   535  				if err != nil {
   536  					newErr.error = err.Error()
   537  					return localVarReturnValue, localVarHttpResponse, newErr
   538  				}
   539  				newErr.model = v
   540  				return localVarReturnValue, localVarHttpResponse, newErr
   541  		}
   542  		return localVarReturnValue, localVarHttpResponse, newErr
   543  	}
   544  
   545  	return localVarReturnValue, localVarHttpResponse, nil
   546  }