# README
Go API client for openapi
The Kable API allows developers to manage customers and API keys and record events about their API.
API Host and Environments
Kable is accessible in Live and Test environments for authentication and metering of client API requests. You will have separate API keys to access each environment.
You should only use Kable's Live environment for your own production data. All other configured environments should use Kable's Test environment.
API Protocols and Headers
All requests to the Kable API are made over HTTPS TLS v1.2+ to ensure security. Calls made over HTTP will fail. Any requests without proper authentication will also fail.
The Kable API uses standard JSON for requests and responses. Be sure to set both the Content-Type
and Accept
headers on each request to application/json.
Each Kable API response includes a requestId
as the X-REQUEST-ID
response header. The requestId
is included regardless whether the API request succeeded or failed. You can use this requestId to help with debugging or when contacting support regarding a specific API call.
API Keys
There are two types of API keys on Kable.
Kable Keys
Kable Keys are the keys you, the Kable customer, use to interact with Kable. These keys help us ensure that only you are interacting with Kable on your behalf. You can find your keys on the Company page of the dashboard after you sign up.
Kable Keys should be included in every request to the Kable API. You must provide your client ID as the KABLE-CLIENT-ID
header and your secret key as the KABLE-CLIENT-SECRET
header on each request to Kable. If you are using a language-specific Kable library, you will initialize the SDK using these keys.
Customer Keys
Customer Keys are the keys your customers use to interact with your API. Customer Keys are authenticated by Kable when a customer makes a request to your API if you use Kable's authentication services. Customers must provide their client ID (defined as clientId
when you create the customer) as the X-CLIENT-ID
header and their secret key as the X-API-KEY
header on each request to your API that Kable is to authenticate.
API Versioning
All Kable endpoints are versioned. After the host, each API can be found at /api/vX/...
where X is the API version.
We strive to ensure that changes to the Kable API are backward compatible. Sometimes, though, we must break from older design paradigms to make the product better. When this happens, a new version of the API is released.
The current version of Kable is v1.
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: 1.2.1
- 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/openapi"
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 https://live.kable.io/api/v1
Class | Method | HTTP request | Description |
---|---|---|---|
CustomersApi | AddCustomerPaymentMethod | Post /customers/{customerId}/payment_methods/add | add a customer payment method |
CustomersApi | AddCustomerPlans | Post /customers/{customerId}/plans/add | add a plan(s) to a customer |
CustomersApi | CancelCustomer | Post /customers/{customerId}/cancel | cancel a customer |
CustomersApi | CreateCustomer | Post /customers/create | create a customer |
CustomersApi | GetAllCustomers | Get /customers | get all customers |
CustomersApi | GetCustomer | Get /customers/{customerId} | get customer |
CustomersApi | RemoveCustomerPlans | Post /customers/{customerId}/plans/remove | remove a plan(s) from a customer |
CustomersApi | UpdateCustomer | Post /customers/{customerId}/update | update a customer |
DimensionsApi | GetAllDimensions | Get /dimensions | get all dimensions |
DimensionsApi | GetDimension | Get /dimensions/{dimensionId} | get dimension |
EventsApi | CreateEvents | Post /events/create | record events |
KeysApi | CreateKey | Post /keys/create | create a customer API key |
KeysApi | RevokeKey | Post /keys/revoke | revoke a customer API key(s) |
PlansApi | GetAllPlans | Get /plans | get all plans |
PlansApi | GetPlan | Get /plans/{planId} | get plan |
TokensApi | CreateToken | Post /tokens/create | create a token |
UsageApi | GetUsage | Post /usage/get | get usage metrics |
Documentation For Models
- AddCustomerPaymentMethod200Response
- AddCustomerPaymentMethodRequest
- AddCustomerPlansRequest
- CreateCustomer200Response
- CreateCustomerRequest
- CreateKey200Response
- CreateKeyRequest
- CreateToken200Response
- CreateTokenRequest
- Customer
- CustomerPlan
- Dimension
- Event
- GetUsageRequest
- Key
- Plan
- RevokeKeyRequest
- UpdateCustomerRequest
- UsageMetricInterval
- UsageMetricResponse
Documentation For Authorization
Endpoints do not require authorization.
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