AccelByte Codegen SDK
This repository contains AccelByte platform SDKs generated from OpenAPI specs.
Golang SDKs generated using go-swagger
.
Generate SDK from OpenAPI spec
Golang SDK
- Go to one of directory in
justice-go-sdk-clients/<service_name>-sdk
- Execute
make gen-client
, this command will lookup OpenAPI file <service-name>-swagger.json
and template located in pkg/utils/swagger-templates/client
so make sure both files are exist.
Generate sdk
- Go to one of directory in
justice-go-sdk-clients/<service_name>-sdk
- Execute
make gen-client
- make sure
package.json
have these configurations:
...,
"main": "dist/index.js",
"scripts": {
...,
"build": "npx babel src -d dist",
"postinstall": "yarn run build"
},
...
- build the package
yarn run build
Publish module
We use lerna to wrap all of sdk into one module. Please refer to lerna's documentation on how to publish the module.
Using the SDK
Golang SDK
Following list is the available SDKs:
Basic SDK is SDK to communicate with Basic service. Basic service responsible to manage user profile, namespace, language.
IAM SDK able to communicate with IAM service. IAM service responsible to authenticate and authorize users, manage users, manage roles and permission, manage clients.
Platform service is responsible to manage commerce like items, stores, entitlement, etc.
Cloudsave SDK is SDK to communicate with cloudsave service. Cloudsave service handle read and write player records and game records.
Lobby SDK is SDK to communicate with lobby service. Lobby service is service responsible to manage lobby related service like, friends management, chat, notification, etc. Currently, only http rest API covered in this SDK.
Group SDK is responsible to have the group to gather players into one place to interact with each other.
Social SDK is responsible for managing communication with social service. Social service functionality includes game profile management, cloud storage, and dynamic statistic.
In this docs, we will use iam-sdk
for sample usage.
The SDK contains 2 directory, iamclient
and iamclientmodels
. iamclient
contains the logic to make request and iamclientmodels
contains the models like request and response models.
To include the SDK to your project, add following in your go.mod
:
replace (
github.com/AccelByte/accelbyte-go-sdk/services-api => path/to/justice-go-sdk
github.com/AccelByte/accelbyte-go-sdk/basic-sdk => path/to/basic-sdk
github.com/AccelByte/accelbyte-go-sdk/cloudsave-sdk => path/to/cloudsave-sdk
github.com/AccelByte/accelbyte-go-sdk/iam-sdk => path/to/iam-sdk
github.com/AccelByte/accelbyte-go-sdk/lobby-sdk => path/to/lobby-sdk
github.com/AccelByte/accelbyte-go-sdk/platform-sdk => path/to/platform-sdk
)
require (
github.com/AccelByte/accelbyte-go-sdk/services-api v1.0.0
)
To use this SDK, client must create a struct that implement following interface:
ConfigRepository
: A repository that responsible to store configuration.
TokenRepository
: A repository that responsible to store access token.
There are several authorization methods to make request:
No authorization is used for public endpoint, like /iam/v3/public/namespaces/{namespace}/users
, Following is sample code to create request without authorization.
IamService.Users.PublicCreateUserV3(param, nil)
IamService.OAuth20.TokenRevocationV3(param, client.BasicAuth(clientId, clientSecret))
- Bearer token authorization
IamService.Users.AdminAddUserRoleV3(param, client.BearerToken(accessToken))
Lobby Websocket SDK
Justice SDK includes websocket SDK used to connect client to justice lobby service. Following is the list of features that using websocket as communication:
To use websocket SDK client should implements connectionutils/ConnectionManager
interface. ConnectionManager
manages websocket connection that save, get and close the websocket connection. In other words, client should maintain websocket connection using ConnectionManager
.
To use websocket SDK, connection should keep alive.