Skip to main content

Generate SDK

It's time to generate a SDK to use Arbitrium as a library in your code . With Arbitrium, we decide to use Swagger. With Swagger, it's easy to generate an Arbritium SDK for any developper that might need it. Let's have a quick tutorial that show you how to generate a SDK.

Using our dashboard#

Go on our dashboard#

Go on our dashboard and click on SDK.

img

Choose your language and download your kit#

You can choose your language client side and download it. This code is autogenerated.

img

Using Swagger editor#

Get Arbitrium's OpenAPI specification#

Go on our API's page and click on Download right next to Download OpenAPI specification:

img

Swagger editor#

Now, go to Swagger editor and copy/paste the OpenAPI specification. You should see our API on the right side of the page.

img

Generate a SDK#

Now, we can generate a sdk. Click on Generate Client

img

Select your prgramming languange and use it!

img

How to use it#

Go#

In your Go project, create a folder named swagger and copy the generated SDK inside it. Your project structure should look like this.

img

You will need to add a dependency. You can do it by running this command

go get golang.org/x/oauth2

To use the sdk you will need a swagger configuration and an auth context.

Here's an example of a deployment

// Creating Arbitrium deploy request
payload := swagger.DeployModel{
AppName: appName, // Your application's name
VersionName: appVersion, // Your version's name
IpList: ips, // A list of users IP
}
// API configuration
configuration := swagger.NewConfiguration()
configuration.BasePath = arbitriumAPI // The API base URL
// Creating a client
client := swagger.NewAPIClient(configuration)
// Auth context
auth := context.WithValue(context.Background(), swagger.ContextAPIKey, swagger.APIKey{
Key: apiToken, // Your Arbitrium token
Prefix: "token",
})
// Deploying
request, _, err := client.V1Api.Deploy(auth, payload)
if err != nil {
log.Printf("Could not deploy game server, err: %v", err.Error())
return "", err
}