cios-golang-sdk

module
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: Apache-2.0

README

OPTiM Cloud IoT OS Golang SDK (0.4.2)

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.

Instration

go get -u github.com/optim-corp/cios-golang-sdk

Usage

Initialization
  • 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://",
    },
})
Authentication
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.

Document

Authorization
Account
FileStorage
Pub/Sub
Device
Video
Geography
Collection (WIP)
License
Contract

How to test client

package ciossdk_mock has mock interface

Usage
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
    ....
}

How to Support

If you have any issues or questions, please raise them on Github issues.

LICENSE

The Apache-2.0 License

Copyright (c) 2021 OPTiM Corporation https://www.optim.co.jp/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL