modulepackage
0.0.0-20231204070321-7e6df26960ff
Repository: https://github.com/ao-space/platform-sdk-go.git
Documentation: pkg.go.dev
# README
English | 简体中文
platform-sdk-go
Introduction
Golang version SDK for accessing the fundamental services on the Ao.Space platform.
Installation
-
Install using
go get
go get github.com/ao-space/platform-sdk-go/v2
-
Import into your code
import "github.com/ao-space/platform-sdk-go/v2"
Quick Start
Each interface has a corresponding Request structure and a Response structure. For example, the ObtainBoxRegKey
interface has corresponding request and response structures named ObtainBoxRegKeyRequest
and ObtainBoxRegKeyResponse
, respectively.
Below is an example of how to use the SDK for obtaining an access token.
package main
import (
"fmt"
"github.com/ao-space/platform-sdk-go/utils"
"github.com/ao-space/platform-sdk-go/v2"
)
func main() {
// Create a client: specify the Host of the platform's fundamental
// service and optionally set the transport manually
client := platform.NewClientWithHost(platform.AoSpaceDomain, nil)
// Optionally set the request ID for the most recent request
client.SetRequestId("XXXXX")
// Request parameters
input := &platform.ObtainBoxRegKeyRequest{
BoxUUID: "XXXXX",
ServiceIds: []string{"XXXXX"},
}
response, err := client.ObtainBoxRegKey(input)
if err != nil {
panic(err)
}
fmt.Println(utils.ToString(response))
}
Documentation
SDK Functionality Examples
-
Obtain Box_Reg_Key
- Used to authenticate the identity of the device on the space platform and generate
box_reg_keys
.
client = platform.NewClientWithHost("XXXXXX", nil) resp, err := client.ObtainBoxRegKey(&platform.ObtainBoxRegKeyRequest{ BoxUUID: "XXXXX", ServiceIds: []string{"XXXXX"}, }) if err != nil { fmt.Println(err) return } fmt.Println(resp)
- Used to authenticate the identity of the device on the space platform and generate
-
Register Device
- Register AO.space device, and the space platform assigns network client information to it
resp, err := client.RegisterDevice() if err != nil { fmt.Println(err) return } fmt.Println(resp)
-
Delete Device
- Delete the registration information of AO.space device, including user registration information, client registration information, network resources, etc
err := client.DeleteDevice() if err != nil { fmt.Println(err) return }
-
Register User
- Register users and synchronize their binding clients
resp, err := client.RegisterUser(&platform.RegisterUserRequest{ UserID: "XXX", // User ID Subdomain: "XXX", //The subdomain name specified by the user UserType: "XXX", //User type (administrator, member), value: user_admin、user_member ClientUUID: "XXX", //The UUID of the client }) if err != nil { fmt.Println(err) return } fmt.Println(resp)
-
Generate User Domain Name
- Generate the user's subdomain name, and the subdomain name is unique globally
resp, err := client.GenerateUserDomain(&platform.GenerateUserDomainRequest{ EffectiveTime: "XXX", //Validity period, in seconds, up to 7 days }) if err != nil { fmt.Println(err) return } fmt.Println(resp)
-
Modify User Domain Name
- Modify the user's subdomain name, still retaining the user's historical subdomain name
resp, err := client.ModifyUserDomain(&platform.ModifyUserDomainRequest{ UserId: "XXX", Subdomain: "XXX", }) if err != nil { fmt.Println(err) return } fmt.Println(resp)
-
Delete User
- Delete user registration information, including client registration information, etc
err := client.DeleteUser("your userId") if err != nil { fmt.Println(err) return }
-
Register Client
- Register Client
resp, err := client.RegisterClient(&platform.RegisterClientRequest{ UserId: "XXX", ClientUUID: "XXX", ClientType: "XXX", //客户端类型(绑定、扫码授权),取值:client_bind、client_auth }) if err != nil { fmt.Println(err) return } fmt.Println(resp)
-
Delete Client
- Delete client registration information
err := client.DeleteClient(&platform.DeleteClientRequest{ UserId: "XXX", ClientUUID: "XXX", }) if err != nil { fmt.Println(err) return }
-
Space Platform Migration
- Used to migrate AO.space device data to the new space platform
resp, err := client.SpacePlatformMigration(&platform.SpacePlatformMigrationRequest{ NetworkClientId: "XXX", UserInfos: []platform.UserMigrationInfo{ platform.UserMigrationInfo{ UserId: "XXX", UserDomain: "XXX", UserType: "XXX", ClientInfos: []platform.ClientInfo{ platform.ClientInfo{ ClientUUID: "XXX", ClientType: "XXX", }, }, }, }, }) if err != nil { fmt.Println(err) return }
-
Space Platform Migration Out
- Used for domain name redirection on old space platforms
resp, err := client.SpacePlatformMigrationOut(&platform.SpacePlatformMigrationOutRequest{ UserDomainRouteInfos: []platform.UserDomainRouteInfo{ platform.UserDomainRouteInfo{ UserId: "XXX", UserDomainRedirect: "XXX", //Redirected user domain name }, }})
API Reference
# Functions
NewClientWithHost Host 是服务所在主机 transport 是连接池相关的配置.
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author