-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpacePlatformMigration.go
61 lines (50 loc) · 1.57 KB
/
SpacePlatformMigration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package platform
import (
"encoding/json"
"fmt"
"github.com/ao-space/platform-sdk-go/utils"
"github.com/jinzhu/copier"
"net/http"
"net/url"
)
type SpacePlatformMigrationRequest struct {
NetworkClientId string `json:"networkClientId"`
UserInfos []UserMigrationInfo `json:"userInfos"`
}
type UserMigrationInfo struct {
UserId string `json:"userId"`
UserDomain string `json:"userDomain"`
UserType string `json:"userType"`
ClientInfos []ClientInfo `json:"clientInfos"`
}
type ClientInfo struct {
ClientUUID string `json:"clientUUID"`
ClientType string `json:"clientType"`
}
type SpacePlatformMigrationResponse struct {
BoxUUID string `json:"boxUUID"`
NetworkClient netWorkClient `json:"netWorkClient"`
UserInfos []UserMigrationInfo `json:"userInfos"`
}
func (c *Client) SpacePlatformMigration(input *SpacePlatformMigrationRequest) (*SpacePlatformMigrationResponse, error) {
if !c.IsAvailable(uriSpacePlatformMigration, http.MethodPost) {
return nil, fmt.Errorf("the ability is not available: [%v] %v ", http.MethodPost, uriSpacePlatformMigration)
}
path := fmt.Sprintf("/platform/boxes/%v/migration", c.BoxUUID)
URL := new(url.URL)
copier.Copy(URL, c.BaseURL)
URL = URL.JoinPath(path)
op := new(Operation)
op.SetOperation(http.MethodPost, URL)
requestBody, _ := json.Marshal(input)
resp, err := c.Send(op, requestBody)
if err != nil {
return nil, err
}
output := new(SpacePlatformMigrationResponse)
err = utils.GetBody(resp, output)
if err != nil {
return nil, err
}
return output, nil
}