github.com/safedep/dry@v0.0.0-20241016050132-a15651f0548b/apiguard/tykgen/api_apis.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 APIsApiService service
    28  /*
    29  APIsApiService
    30  Create API  A single Tyk node can have its API Definitions queried, deleted and updated remotely. This functionality enables you to remotely update your Tyk definitions without having to manage the files manually.
    31   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
    32   * @param optional nil or *APIsApiCreateApiOpts - Optional Parameters:
    33       * @param "Body" (optional.Interface of ApiDefinition) - 
    34       * @param "BaseApiId" (optional.String) -  The base API which the new version will be linked to.
    35       * @param "BaseApiVersionName" (optional.String) -  The version name of the base API while creating the first version. This doesn&#x27;t have to be sent for the next versions but if it is set, it will override base API version name.
    36       * @param "NewVersionName" (optional.String) -  The version name of the created version.
    37       * @param "SetDefault" (optional.Bool) -  If true, the new version is set as default version.
    38  @return ApiModifyKeySuccess
    39  */
    40  
    41  type APIsApiCreateApiOpts struct {
    42      Body optional.Interface
    43      BaseApiId optional.String
    44      BaseApiVersionName optional.String
    45      NewVersionName optional.String
    46      SetDefault optional.Bool
    47  }
    48  
    49  func (a *APIsApiService) CreateApi(ctx context.Context, localVarOptionals *APIsApiCreateApiOpts) (ApiModifyKeySuccess, *http.Response, error) {
    50  	var (
    51  		localVarHttpMethod = strings.ToUpper("Post")
    52  		localVarPostBody   interface{}
    53  		localVarFileName   string
    54  		localVarFileBytes  []byte
    55  		localVarReturnValue ApiModifyKeySuccess
    56  	)
    57  
    58  	// create path and map variables
    59  	localVarPath := a.client.cfg.BasePath + "/tyk/apis"
    60  
    61  	localVarHeaderParams := make(map[string]string)
    62  	localVarQueryParams := url.Values{}
    63  	localVarFormParams := url.Values{}
    64  
    65  	if localVarOptionals != nil && localVarOptionals.BaseApiId.IsSet() {
    66  		localVarQueryParams.Add("base_api_id", parameterToString(localVarOptionals.BaseApiId.Value(), ""))
    67  	}
    68  	if localVarOptionals != nil && localVarOptionals.BaseApiVersionName.IsSet() {
    69  		localVarQueryParams.Add("base_api_version_name", parameterToString(localVarOptionals.BaseApiVersionName.Value(), ""))
    70  	}
    71  	if localVarOptionals != nil && localVarOptionals.NewVersionName.IsSet() {
    72  		localVarQueryParams.Add("new_version_name", parameterToString(localVarOptionals.NewVersionName.Value(), ""))
    73  	}
    74  	if localVarOptionals != nil && localVarOptionals.SetDefault.IsSet() {
    75  		localVarQueryParams.Add("set_default", parameterToString(localVarOptionals.SetDefault.Value(), ""))
    76  	}
    77  	// to determine the Content-Type header
    78  	localVarHttpContentTypes := []string{"application/json"}
    79  
    80  	// set Content-Type header
    81  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
    82  	if localVarHttpContentType != "" {
    83  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
    84  	}
    85  
    86  	// to determine the Accept header
    87  	localVarHttpHeaderAccepts := []string{"application/json"}
    88  
    89  	// set Accept header
    90  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
    91  	if localVarHttpHeaderAccept != "" {
    92  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
    93  	}
    94  	// body params
    95  	if localVarOptionals != nil && localVarOptionals.Body.IsSet() {
    96  		
    97  		localVarOptionalBody:= localVarOptionals.Body.Value()
    98  		localVarPostBody = &localVarOptionalBody
    99  	}
   100  	if ctx != nil {
   101  		// API Key Authentication
   102  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   103  			var key string
   104  			if auth.Prefix != "" {
   105  				key = auth.Prefix + " " + auth.Key
   106  			} else {
   107  				key = auth.Key
   108  			}
   109  			localVarHeaderParams["X-Tyk-Authorization"] = key
   110  			
   111  		}
   112  	}
   113  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   114  	if err != nil {
   115  		return localVarReturnValue, nil, err
   116  	}
   117  
   118  	localVarHttpResponse, err := a.client.callAPI(r)
   119  	if err != nil || localVarHttpResponse == nil {
   120  		return localVarReturnValue, localVarHttpResponse, err
   121  	}
   122  
   123  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   124  	localVarHttpResponse.Body.Close()
   125  	if err != nil {
   126  		return localVarReturnValue, localVarHttpResponse, err
   127  	}
   128  
   129  	if localVarHttpResponse.StatusCode < 300 {
   130  		// If we succeed, return the data, otherwise pass on to decode error.
   131  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   132  		if err == nil { 
   133  			return localVarReturnValue, localVarHttpResponse, err
   134  		}
   135  	}
   136  
   137  	if localVarHttpResponse.StatusCode >= 300 {
   138  		newErr := GenericSwaggerError{
   139  			body: localVarBody,
   140  			error: localVarHttpResponse.Status,
   141  		}
   142  		if localVarHttpResponse.StatusCode == 200 {
   143  			var v ApiModifyKeySuccess
   144  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   145  				if err != nil {
   146  					newErr.error = err.Error()
   147  					return localVarReturnValue, localVarHttpResponse, newErr
   148  				}
   149  				newErr.model = v
   150  				return localVarReturnValue, localVarHttpResponse, newErr
   151  		}
   152  		if localVarHttpResponse.StatusCode == 400 {
   153  			var v ApiStatusMessage
   154  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   155  				if err != nil {
   156  					newErr.error = err.Error()
   157  					return localVarReturnValue, localVarHttpResponse, newErr
   158  				}
   159  				newErr.model = v
   160  				return localVarReturnValue, localVarHttpResponse, newErr
   161  		}
   162  		return localVarReturnValue, localVarHttpResponse, newErr
   163  	}
   164  
   165  	return localVarReturnValue, localVarHttpResponse, nil
   166  }
   167  /*
   168  APIsApiService
   169  Deleting an API definition will remove the file from the file store, the API definition will NOT be unloaded, a separate reload request will need to be made to disable the API endpoint.
   170   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   171   * @param apiID The API ID
   172  @return ApiStatusMessage
   173  */
   174  func (a *APIsApiService) DeleteApi(ctx context.Context, apiID string) (ApiStatusMessage, *http.Response, error) {
   175  	var (
   176  		localVarHttpMethod = strings.ToUpper("Delete")
   177  		localVarPostBody   interface{}
   178  		localVarFileName   string
   179  		localVarFileBytes  []byte
   180  		localVarReturnValue ApiStatusMessage
   181  	)
   182  
   183  	// create path and map variables
   184  	localVarPath := a.client.cfg.BasePath + "/tyk/apis/{apiID}"
   185  	localVarPath = strings.Replace(localVarPath, "{"+"apiID"+"}", fmt.Sprintf("%v", apiID), -1)
   186  
   187  	localVarHeaderParams := make(map[string]string)
   188  	localVarQueryParams := url.Values{}
   189  	localVarFormParams := url.Values{}
   190  
   191  	// to determine the Content-Type header
   192  	localVarHttpContentTypes := []string{}
   193  
   194  	// set Content-Type header
   195  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   196  	if localVarHttpContentType != "" {
   197  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   198  	}
   199  
   200  	// to determine the Accept header
   201  	localVarHttpHeaderAccepts := []string{"application/json"}
   202  
   203  	// set Accept header
   204  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   205  	if localVarHttpHeaderAccept != "" {
   206  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   207  	}
   208  	if ctx != nil {
   209  		// API Key Authentication
   210  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   211  			var key string
   212  			if auth.Prefix != "" {
   213  				key = auth.Prefix + " " + auth.Key
   214  			} else {
   215  				key = auth.Key
   216  			}
   217  			localVarHeaderParams["X-Tyk-Authorization"] = key
   218  			
   219  		}
   220  	}
   221  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   222  	if err != nil {
   223  		return localVarReturnValue, nil, err
   224  	}
   225  
   226  	localVarHttpResponse, err := a.client.callAPI(r)
   227  	if err != nil || localVarHttpResponse == nil {
   228  		return localVarReturnValue, localVarHttpResponse, err
   229  	}
   230  
   231  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   232  	localVarHttpResponse.Body.Close()
   233  	if err != nil {
   234  		return localVarReturnValue, localVarHttpResponse, err
   235  	}
   236  
   237  	if localVarHttpResponse.StatusCode < 300 {
   238  		// If we succeed, return the data, otherwise pass on to decode error.
   239  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   240  		if err == nil { 
   241  			return localVarReturnValue, localVarHttpResponse, err
   242  		}
   243  	}
   244  
   245  	if localVarHttpResponse.StatusCode >= 300 {
   246  		newErr := GenericSwaggerError{
   247  			body: localVarBody,
   248  			error: localVarHttpResponse.Status,
   249  		}
   250  		if localVarHttpResponse.StatusCode == 200 {
   251  			var v ApiStatusMessage
   252  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   253  				if err != nil {
   254  					newErr.error = err.Error()
   255  					return localVarReturnValue, localVarHttpResponse, newErr
   256  				}
   257  				newErr.model = v
   258  				return localVarReturnValue, localVarHttpResponse, newErr
   259  		}
   260  		if localVarHttpResponse.StatusCode == 400 {
   261  			var v ApiStatusMessage
   262  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   263  				if err != nil {
   264  					newErr.error = err.Error()
   265  					return localVarReturnValue, localVarHttpResponse, newErr
   266  				}
   267  				newErr.model = v
   268  				return localVarReturnValue, localVarHttpResponse, newErr
   269  		}
   270  		return localVarReturnValue, localVarHttpResponse, newErr
   271  	}
   272  
   273  	return localVarReturnValue, localVarHttpResponse, nil
   274  }
   275  /*
   276  APIsApiService
   277  Get API definition Only if used without the Tyk Dashboard
   278   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   279   * @param apiID The API ID
   280  @return ApiDefinition
   281  */
   282  func (a *APIsApiService) GetApi(ctx context.Context, apiID string) (ApiDefinition, *http.Response, error) {
   283  	var (
   284  		localVarHttpMethod = strings.ToUpper("Get")
   285  		localVarPostBody   interface{}
   286  		localVarFileName   string
   287  		localVarFileBytes  []byte
   288  		localVarReturnValue ApiDefinition
   289  	)
   290  
   291  	// create path and map variables
   292  	localVarPath := a.client.cfg.BasePath + "/tyk/apis/{apiID}"
   293  	localVarPath = strings.Replace(localVarPath, "{"+"apiID"+"}", fmt.Sprintf("%v", apiID), -1)
   294  
   295  	localVarHeaderParams := make(map[string]string)
   296  	localVarQueryParams := url.Values{}
   297  	localVarFormParams := url.Values{}
   298  
   299  	// to determine the Content-Type header
   300  	localVarHttpContentTypes := []string{}
   301  
   302  	// set Content-Type header
   303  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   304  	if localVarHttpContentType != "" {
   305  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   306  	}
   307  
   308  	// to determine the Accept header
   309  	localVarHttpHeaderAccepts := []string{"application/json"}
   310  
   311  	// set Accept header
   312  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   313  	if localVarHttpHeaderAccept != "" {
   314  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   315  	}
   316  	if ctx != nil {
   317  		// API Key Authentication
   318  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   319  			var key string
   320  			if auth.Prefix != "" {
   321  				key = auth.Prefix + " " + auth.Key
   322  			} else {
   323  				key = auth.Key
   324  			}
   325  			localVarHeaderParams["X-Tyk-Authorization"] = key
   326  			
   327  		}
   328  	}
   329  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   330  	if err != nil {
   331  		return localVarReturnValue, nil, err
   332  	}
   333  
   334  	localVarHttpResponse, err := a.client.callAPI(r)
   335  	if err != nil || localVarHttpResponse == nil {
   336  		return localVarReturnValue, localVarHttpResponse, err
   337  	}
   338  
   339  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   340  	localVarHttpResponse.Body.Close()
   341  	if err != nil {
   342  		return localVarReturnValue, localVarHttpResponse, err
   343  	}
   344  
   345  	if localVarHttpResponse.StatusCode < 300 {
   346  		// If we succeed, return the data, otherwise pass on to decode error.
   347  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   348  		if err == nil { 
   349  			return localVarReturnValue, localVarHttpResponse, err
   350  		}
   351  	}
   352  
   353  	if localVarHttpResponse.StatusCode >= 300 {
   354  		newErr := GenericSwaggerError{
   355  			body: localVarBody,
   356  			error: localVarHttpResponse.Status,
   357  		}
   358  		if localVarHttpResponse.StatusCode == 200 {
   359  			var v ApiDefinition
   360  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   361  				if err != nil {
   362  					newErr.error = err.Error()
   363  					return localVarReturnValue, localVarHttpResponse, newErr
   364  				}
   365  				newErr.model = v
   366  				return localVarReturnValue, localVarHttpResponse, newErr
   367  		}
   368  		return localVarReturnValue, localVarHttpResponse, newErr
   369  	}
   370  
   371  	return localVarReturnValue, localVarHttpResponse, nil
   372  }
   373  /*
   374  APIsApiService
   375  Listing versions of an OAS API
   376   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   377   * @param apiID The API ID
   378   * @param optional nil or *APIsApiListApiVersionsOpts - Optional Parameters:
   379       * @param "SearchText" (optional.String) -  Search for API version name
   380       * @param "AccessType" (optional.String) -  Filter for internal or external API versions
   381  @return InlineResponse200
   382  */
   383  
   384  type APIsApiListApiVersionsOpts struct {
   385      SearchText optional.String
   386      AccessType optional.String
   387  }
   388  
   389  func (a *APIsApiService) ListApiVersions(ctx context.Context, apiID string, localVarOptionals *APIsApiListApiVersionsOpts) (InlineResponse200, *http.Response, error) {
   390  	var (
   391  		localVarHttpMethod = strings.ToUpper("Get")
   392  		localVarPostBody   interface{}
   393  		localVarFileName   string
   394  		localVarFileBytes  []byte
   395  		localVarReturnValue InlineResponse200
   396  	)
   397  
   398  	// create path and map variables
   399  	localVarPath := a.client.cfg.BasePath + "/tyk/apis/{apiID}/versions"
   400  	localVarPath = strings.Replace(localVarPath, "{"+"apiID"+"}", fmt.Sprintf("%v", apiID), -1)
   401  
   402  	localVarHeaderParams := make(map[string]string)
   403  	localVarQueryParams := url.Values{}
   404  	localVarFormParams := url.Values{}
   405  
   406  	if localVarOptionals != nil && localVarOptionals.SearchText.IsSet() {
   407  		localVarQueryParams.Add("searchText", parameterToString(localVarOptionals.SearchText.Value(), ""))
   408  	}
   409  	if localVarOptionals != nil && localVarOptionals.AccessType.IsSet() {
   410  		localVarQueryParams.Add("accessType", parameterToString(localVarOptionals.AccessType.Value(), ""))
   411  	}
   412  	// to determine the Content-Type header
   413  	localVarHttpContentTypes := []string{}
   414  
   415  	// set Content-Type header
   416  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   417  	if localVarHttpContentType != "" {
   418  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   419  	}
   420  
   421  	// to determine the Accept header
   422  	localVarHttpHeaderAccepts := []string{"application/json"}
   423  
   424  	// set Accept header
   425  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   426  	if localVarHttpHeaderAccept != "" {
   427  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   428  	}
   429  	if ctx != nil {
   430  		// API Key Authentication
   431  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   432  			var key string
   433  			if auth.Prefix != "" {
   434  				key = auth.Prefix + " " + auth.Key
   435  			} else {
   436  				key = auth.Key
   437  			}
   438  			localVarHeaderParams["X-Tyk-Authorization"] = key
   439  			
   440  		}
   441  	}
   442  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   443  	if err != nil {
   444  		return localVarReturnValue, nil, err
   445  	}
   446  
   447  	localVarHttpResponse, err := a.client.callAPI(r)
   448  	if err != nil || localVarHttpResponse == nil {
   449  		return localVarReturnValue, localVarHttpResponse, err
   450  	}
   451  
   452  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   453  	localVarHttpResponse.Body.Close()
   454  	if err != nil {
   455  		return localVarReturnValue, localVarHttpResponse, err
   456  	}
   457  
   458  	if localVarHttpResponse.StatusCode < 300 {
   459  		// If we succeed, return the data, otherwise pass on to decode error.
   460  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   461  		if err == nil { 
   462  			return localVarReturnValue, localVarHttpResponse, err
   463  		}
   464  	}
   465  
   466  	if localVarHttpResponse.StatusCode >= 300 {
   467  		newErr := GenericSwaggerError{
   468  			body: localVarBody,
   469  			error: localVarHttpResponse.Status,
   470  		}
   471  		if localVarHttpResponse.StatusCode == 200 {
   472  			var v InlineResponse200
   473  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   474  				if err != nil {
   475  					newErr.error = err.Error()
   476  					return localVarReturnValue, localVarHttpResponse, newErr
   477  				}
   478  				newErr.model = v
   479  				return localVarReturnValue, localVarHttpResponse, newErr
   480  		}
   481  		return localVarReturnValue, localVarHttpResponse, newErr
   482  	}
   483  
   484  	return localVarReturnValue, localVarHttpResponse, nil
   485  }
   486  /*
   487  APIsApiService
   488  List APIs  Only if used without the Tyk Dashboard
   489   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   490  @return []ApiDefinition
   491  */
   492  func (a *APIsApiService) ListApis(ctx context.Context) ([]ApiDefinition, *http.Response, error) {
   493  	var (
   494  		localVarHttpMethod = strings.ToUpper("Get")
   495  		localVarPostBody   interface{}
   496  		localVarFileName   string
   497  		localVarFileBytes  []byte
   498  		localVarReturnValue []ApiDefinition
   499  	)
   500  
   501  	// create path and map variables
   502  	localVarPath := a.client.cfg.BasePath + "/tyk/apis"
   503  
   504  	localVarHeaderParams := make(map[string]string)
   505  	localVarQueryParams := url.Values{}
   506  	localVarFormParams := url.Values{}
   507  
   508  	// to determine the Content-Type header
   509  	localVarHttpContentTypes := []string{}
   510  
   511  	// set Content-Type header
   512  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   513  	if localVarHttpContentType != "" {
   514  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   515  	}
   516  
   517  	// to determine the Accept header
   518  	localVarHttpHeaderAccepts := []string{"application/json"}
   519  
   520  	// set Accept header
   521  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   522  	if localVarHttpHeaderAccept != "" {
   523  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   524  	}
   525  	if ctx != nil {
   526  		// API Key Authentication
   527  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   528  			var key string
   529  			if auth.Prefix != "" {
   530  				key = auth.Prefix + " " + auth.Key
   531  			} else {
   532  				key = auth.Key
   533  			}
   534  			localVarHeaderParams["X-Tyk-Authorization"] = key
   535  			
   536  		}
   537  	}
   538  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   539  	if err != nil {
   540  		return localVarReturnValue, nil, err
   541  	}
   542  
   543  	localVarHttpResponse, err := a.client.callAPI(r)
   544  	if err != nil || localVarHttpResponse == nil {
   545  		return localVarReturnValue, localVarHttpResponse, err
   546  	}
   547  
   548  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   549  	localVarHttpResponse.Body.Close()
   550  	if err != nil {
   551  		return localVarReturnValue, localVarHttpResponse, err
   552  	}
   553  
   554  	if localVarHttpResponse.StatusCode < 300 {
   555  		// If we succeed, return the data, otherwise pass on to decode error.
   556  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   557  		if err == nil { 
   558  			return localVarReturnValue, localVarHttpResponse, err
   559  		}
   560  	}
   561  
   562  	if localVarHttpResponse.StatusCode >= 300 {
   563  		newErr := GenericSwaggerError{
   564  			body: localVarBody,
   565  			error: localVarHttpResponse.Status,
   566  		}
   567  		if localVarHttpResponse.StatusCode == 200 {
   568  			var v []ApiDefinition
   569  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   570  				if err != nil {
   571  					newErr.error = err.Error()
   572  					return localVarReturnValue, localVarHttpResponse, newErr
   573  				}
   574  				newErr.model = v
   575  				return localVarReturnValue, localVarHttpResponse, newErr
   576  		}
   577  		return localVarReturnValue, localVarHttpResponse, newErr
   578  	}
   579  
   580  	return localVarReturnValue, localVarHttpResponse, nil
   581  }
   582  /*
   583  APIsApiService
   584  Updating an API definition uses the same signature an object as a &#x60;POST&#x60;, however it will first ensure that the API ID that is being updated is the same as the one in the object being &#x60;PUT&#x60;.   Updating will completely replace the file descriptor and will not change an API Definition that has already been loaded, the hot-reload endpoint will need to be called to push the new definition to live. 
   585   * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
   586   * @param apiID The API ID
   587   * @param optional nil or *APIsApiUpdateApiOpts - Optional Parameters:
   588       * @param "Body" (optional.Interface of ApiDefinition) - 
   589  @return ApiModifyKeySuccess
   590  */
   591  
   592  type APIsApiUpdateApiOpts struct {
   593      Body optional.Interface
   594  }
   595  
   596  func (a *APIsApiService) UpdateApi(ctx context.Context, apiID string, localVarOptionals *APIsApiUpdateApiOpts) (ApiModifyKeySuccess, *http.Response, error) {
   597  	var (
   598  		localVarHttpMethod = strings.ToUpper("Put")
   599  		localVarPostBody   interface{}
   600  		localVarFileName   string
   601  		localVarFileBytes  []byte
   602  		localVarReturnValue ApiModifyKeySuccess
   603  	)
   604  
   605  	// create path and map variables
   606  	localVarPath := a.client.cfg.BasePath + "/tyk/apis/{apiID}"
   607  	localVarPath = strings.Replace(localVarPath, "{"+"apiID"+"}", fmt.Sprintf("%v", apiID), -1)
   608  
   609  	localVarHeaderParams := make(map[string]string)
   610  	localVarQueryParams := url.Values{}
   611  	localVarFormParams := url.Values{}
   612  
   613  	// to determine the Content-Type header
   614  	localVarHttpContentTypes := []string{"application/json"}
   615  
   616  	// set Content-Type header
   617  	localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
   618  	if localVarHttpContentType != "" {
   619  		localVarHeaderParams["Content-Type"] = localVarHttpContentType
   620  	}
   621  
   622  	// to determine the Accept header
   623  	localVarHttpHeaderAccepts := []string{"application/json"}
   624  
   625  	// set Accept header
   626  	localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
   627  	if localVarHttpHeaderAccept != "" {
   628  		localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
   629  	}
   630  	// body params
   631  	if localVarOptionals != nil && localVarOptionals.Body.IsSet() {
   632  		
   633  		localVarOptionalBody:= localVarOptionals.Body.Value()
   634  		localVarPostBody = &localVarOptionalBody
   635  	}
   636  	if ctx != nil {
   637  		// API Key Authentication
   638  		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
   639  			var key string
   640  			if auth.Prefix != "" {
   641  				key = auth.Prefix + " " + auth.Key
   642  			} else {
   643  				key = auth.Key
   644  			}
   645  			localVarHeaderParams["X-Tyk-Authorization"] = key
   646  			
   647  		}
   648  	}
   649  	r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
   650  	if err != nil {
   651  		return localVarReturnValue, nil, err
   652  	}
   653  
   654  	localVarHttpResponse, err := a.client.callAPI(r)
   655  	if err != nil || localVarHttpResponse == nil {
   656  		return localVarReturnValue, localVarHttpResponse, err
   657  	}
   658  
   659  	localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
   660  	localVarHttpResponse.Body.Close()
   661  	if err != nil {
   662  		return localVarReturnValue, localVarHttpResponse, err
   663  	}
   664  
   665  	if localVarHttpResponse.StatusCode < 300 {
   666  		// If we succeed, return the data, otherwise pass on to decode error.
   667  		err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   668  		if err == nil { 
   669  			return localVarReturnValue, localVarHttpResponse, err
   670  		}
   671  	}
   672  
   673  	if localVarHttpResponse.StatusCode >= 300 {
   674  		newErr := GenericSwaggerError{
   675  			body: localVarBody,
   676  			error: localVarHttpResponse.Status,
   677  		}
   678  		if localVarHttpResponse.StatusCode == 200 {
   679  			var v ApiModifyKeySuccess
   680  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   681  				if err != nil {
   682  					newErr.error = err.Error()
   683  					return localVarReturnValue, localVarHttpResponse, newErr
   684  				}
   685  				newErr.model = v
   686  				return localVarReturnValue, localVarHttpResponse, newErr
   687  		}
   688  		if localVarHttpResponse.StatusCode == 400 {
   689  			var v ApiStatusMessage
   690  			err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
   691  				if err != nil {
   692  					newErr.error = err.Error()
   693  					return localVarReturnValue, localVarHttpResponse, newErr
   694  				}
   695  				newErr.model = v
   696  				return localVarReturnValue, localVarHttpResponse, newErr
   697  		}
   698  		return localVarReturnValue, localVarHttpResponse, newErr
   699  	}
   700  
   701  	return localVarReturnValue, localVarHttpResponse, nil
   702  }