github.com/safedep/dry@v0.0.0-20241016050132-a15651f0548b/apiguard/tykgen/api_batch_requests.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 ) 20 21 // Linger please 22 var ( 23 _ context.Context 24 ) 25 26 type BatchRequestsApiService service 27 /* 28 BatchRequestsApiService Run batch request 29 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 30 * @param listenPath API listen path 31 @return ApiStatusMessage 32 */ 33 func (a *BatchRequestsApiService) Batch(ctx context.Context, listenPath string) (ApiStatusMessage, *http.Response, error) { 34 var ( 35 localVarHttpMethod = strings.ToUpper("Post") 36 localVarPostBody interface{} 37 localVarFileName string 38 localVarFileBytes []byte 39 localVarReturnValue ApiStatusMessage 40 ) 41 42 // create path and map variables 43 localVarPath := a.client.cfg.BasePath + "/{listen_path}/tyk/batch" 44 localVarPath = strings.Replace(localVarPath, "{"+"listen_path"+"}", fmt.Sprintf("%v", listenPath), -1) 45 46 localVarHeaderParams := make(map[string]string) 47 localVarQueryParams := url.Values{} 48 localVarFormParams := url.Values{} 49 50 // to determine the Content-Type header 51 localVarHttpContentTypes := []string{} 52 53 // set Content-Type header 54 localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 55 if localVarHttpContentType != "" { 56 localVarHeaderParams["Content-Type"] = localVarHttpContentType 57 } 58 59 // to determine the Accept header 60 localVarHttpHeaderAccepts := []string{"application/json"} 61 62 // set Accept header 63 localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 64 if localVarHttpHeaderAccept != "" { 65 localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 66 } 67 if ctx != nil { 68 // API Key Authentication 69 if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { 70 var key string 71 if auth.Prefix != "" { 72 key = auth.Prefix + " " + auth.Key 73 } else { 74 key = auth.Key 75 } 76 localVarHeaderParams["X-Tyk-Authorization"] = key 77 78 } 79 } 80 r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 81 if err != nil { 82 return localVarReturnValue, nil, err 83 } 84 85 localVarHttpResponse, err := a.client.callAPI(r) 86 if err != nil || localVarHttpResponse == nil { 87 return localVarReturnValue, localVarHttpResponse, err 88 } 89 90 localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 91 localVarHttpResponse.Body.Close() 92 if err != nil { 93 return localVarReturnValue, localVarHttpResponse, err 94 } 95 96 if localVarHttpResponse.StatusCode < 300 { 97 // If we succeed, return the data, otherwise pass on to decode error. 98 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 99 if err == nil { 100 return localVarReturnValue, localVarHttpResponse, err 101 } 102 } 103 104 if localVarHttpResponse.StatusCode >= 300 { 105 newErr := GenericSwaggerError{ 106 body: localVarBody, 107 error: localVarHttpResponse.Status, 108 } 109 if localVarHttpResponse.StatusCode == 200 { 110 var v ApiStatusMessage 111 err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 112 if err != nil { 113 newErr.error = err.Error() 114 return localVarReturnValue, localVarHttpResponse, newErr 115 } 116 newErr.model = v 117 return localVarReturnValue, localVarHttpResponse, newErr 118 } 119 return localVarReturnValue, localVarHttpResponse, newErr 120 } 121 122 return localVarReturnValue, localVarHttpResponse, nil 123 }