It is a convenient SDK to use OPTiM Cloud IoT OS(CIOS) in Go language.
This SDK uses OpenAPI and is generated in code. OpenAPI will be split at a later date, but is now included in the code. It is imperfect.
go get -u github.com/optim-corp/cios-golang-sdk
- If you want to use Prod Client
client = ciossdk.NewCiosClient(ciossdk.CiosClientConfig{
Debug: true,
AutoRefresh: true,
Urls: sdkmodel.ProdUrls(),
})
- If you want to use Pre Client
client = ciossdk.NewCiosClient(ciossdk.CiosClientConfig{
Debug: true,
AutoRefresh: true,
Urls: sdkmodel.PreUrls(),
})
- If you want to use Custom URL
client = ciossdk.NewCiosClient(ciossdk.CiosClientConfig{
Debug: true,
AutoRefresh: true,
Urls: ciossdk.CIOSUrl{
MessagingUrl: " https://",
LocationUrl: " https://",
AccountsUrl: " https://",
StorageUrl: " https://",
IamUrl: " https://",
AuthUrl: " https://",
VideoStreamingUrl: " https://",
DeviceManagementUrl: " https://",
DeviceMonitoringUrl: " https://",
DeviceAssetManagementUrl: " https://",
},
})
OAuthClientType | is Suppoted |
---|---|
Web | ✅ |
Client | ✅ |
Device | ✅ |
Native | ❌ |
- Client Auth
- client id
- client secret
- request scope
client = ciossdk.NewCiosClient(ciossdk.CiosClientConfig{
AuthConfig: ClientAuthConf(
"clientID",
"clientSecret",
"scope",
),
})
- Refresh Token Auth
- client id
- client secret
- refresh token
- request scope
client = ciossdk.NewCiosClient(ciossdk.CiosClientConfig{
AuthConfig: RefreshTokenAuth(
"clientID",
"clientSecret",
"refreshToken",
"scope",
),
})
- Device Auth
- client id
- client secret
- assertion
- request scope
client = ciossdk.NewCiosClient(ciossdk.CiosClientConfig{
AuthConfig: DeviceAuthConf(
"clientID",
"clientSecret",
"assertion",
"scope",
),
})
The refresh token will only be executed once if the request fails.
- Channel API
- DataStore API
- Get a Channel for DataStore
- Get Channels for DataStore
- Get a Object
- Get latest Object
- Get latest Object on Channels
- Get Objects info (max limit 1000)
- Get Objects info no limit
- Get Objects info unlimited
- Parse latest Object
- Parse latest Object on channels
- Get Stream first (websocket)
- Get Stream (max limit 1000) (websocket)
- Get Stream no limit (websocket)
- Get Stream unlimited (websocket)
- Parse Stream no limit (websocket)
- Parse Stream unlimited (websocket)
- Parse Stream first (websocket)
- Delete a Object
- Delete Objects on Channel
- Messaging API
package ciossdk_mock has mock interface
var client = ciossdk.NewCiosClient()
type MockBucket struct {
ciossdk_mock.NoImplementFileStorage
}
func (*MockBucket) GetBuckets(ctx ciosctx.RequestCtx, request cios.ApiGetBucketsRequest) (cios.MultipleBucket, *_nethttp.Response, error) {
return cios.MultipleBucket{}, nil, nil
}
func Test_sampleGetBucket(t *testing.T) {
mock := &ciossdk_mock.MockClient{}
mock.SetFileStorage(&MockBucket{})
client = mock
....
}
If you have any issues or questions, please raise them on Github issues.
Copyright (c) 2021 OPTiM Corporation https://www.optim.co.jp/