Skip to content

alphadose/tyk-go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for openapi

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>

The Tyk Gateway API is subsumed by the Tyk Dashboard API in Pro installations.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 3.2.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/GIT_USER_ID/GIT_REPO_ID"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
APIsApi CreateApi Post /tyk/apis
APIsApi DeleteApi Delete /tyk/apis/{apiID}
APIsApi GetApi Get /tyk/apis/{apiID}
APIsApi ListApis Get /tyk/apis
APIsApi UpdateApi Put /tyk/apis/{apiID}
BatchRequestsApi Batch Post /{listen_path}/tyk/batch Run batch request
CacheInvalidationApi InvalidateCache Delete /tyk/cache/{apiID} Invalidate cache
CertsApi AddCert Post /tyk/certs Add a certificate
CertsApi DeleteCerts Delete /tyk/certs Delete Certificate
CertsApi ListCerts Get /tyk/certs List Certificates
HealthCheckingApi Hello Get /tyk/hello Check the Health of the Gateway
HealthCheckingApi HelloAPI Get /tyk/{listenPath}/hello Check the Health of the API
HotReloadApi HotReload Get /tyk/reload/ Hot-reload a single node
HotReloadApi HotReloadGroup Get /tyk/reload/group Hot-reload a Tyk group
KeysApi AddKey Post /tyk/keys Create a key
KeysApi CreateCustomKey Post /tyk/keys/{keyID} Create Custom Key / Import Key
KeysApi DeleteKey Delete /tyk/keys/{keyID} Delete Key
KeysApi GetKey Get /tyk/keys/{keyID} Get a Key
KeysApi ListKeys Get /tyk/keys List Keys
KeysApi UpdateKey Put /tyk/keys/{keyID} Update Key
OAuthApi AuthorizeClient Post /tyk/oauth/authorize-client/ Authorize client
OAuthApi CreateOAuthClient Post /tyk/oauth/clients/create Create new OAuth client
OAuthApi DeleteOAuthClient Delete /tyk/oauth/clients/{apiID}/{keyName} Delete OAuth client
OAuthApi GetOAuthClient Get /tyk/oauth/clients/{apiID}/{keyName} Get OAuth client
OAuthApi GetOAuthClientTokens Get /tyk/oauth/clients/{apiID}/{keyName}/tokens List tokens
OAuthApi InvalidateOAuthRefresh Delete /tyk/oauth/refresh/{keyName} Invalidate OAuth refresh token
OAuthApi ListOAuthClients Get /tyk/oauth/clients/{apiID} List oAuth clients
OAuthApi RevokeAllTokens Post /tyk/oauth/revoke_all revoke all client's tokens
OAuthApi RevokeSingleToken Post /tyk/oauth/revoke revoke token
OAuthApi UpdateoAuthClient Put /tyk/oauth/clients/{apiID} Update OAuth metadata and Policy ID
OrganisationQuotasApi AddOrgKey Post /tyk/org/keys/{keyID} Create an organisation key
OrganisationQuotasApi DeleteOrgKey Delete /tyk/org/keys/{keyID} Delete Organisation Key
OrganisationQuotasApi GetOrgKey Get /tyk/org/keys/{keyID} Get an Organisation Key
OrganisationQuotasApi ListOrgKeys Get /tyk/org/keys List Organisation Keys
OrganisationQuotasApi UpdateOrgKey Put /tyk/org/keys/{keyID} Update Organisation Key
PoliciesApi AddPolicy Post /tyk/policies Create a Policy
PoliciesApi DeletePolicy Delete /tyk/policies/{polID} Delete a Policy
PoliciesApi GetPolicy Get /tyk/policies/{polID} Get a Policy
PoliciesApi ListPolicies Get /tyk/policies List Policies
PoliciesApi UpdatePolicy Put /tyk/policies/{polID} Update a Policy
SchemaApi GetSchema Get /tyk/schema

Documentation For Models

Documentation For Authorization

api_key

  • Type: API key
  • API key parameter name: X-Tyk-Authorization
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: X-Tyk-Authorization and passed in as the auth context for each request.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

About

Golang SDK for Tyk's API

Resources

Stars

Watchers

Forks

Packages

No packages published