This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
result.go
115 lines (94 loc) · 2.63 KB
/
result.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package servers
import (
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers"
"github.com/huaweicloud/golangsdk/openstack/iec/v1/common"
)
// GetResult contains the server result
type GetResult struct {
golangsdk.Result
}
type ServerDetail struct {
Server *Server `json:"server"`
}
// Server IEC服务实例的对外呈现结构
type Server struct {
cloudservers.CloudServer
CommonFiled
}
//CommonFiled is common filed
type CommonFiled struct {
ServerID string `json:"origin_server_id,omitempty"`
EdgeCloudID string `json:"edgecloud_id,omitempty"`
EdgeCloudName string `json:"edgecloud_name,omitempty"`
Location common.GeoLocation `json:"geolocation"`
Operator common.Operator `json:"operator"`
DomainID string `json:"domain_id"`
}
// ExtractServerDetail 输出边缘实例详情
func (r GetResult) ExtractServerDetail() (ServerDetail, error) {
var serverDetail ServerDetail
err := r.ExtractInto(&serverDetail)
return serverDetail, err
}
// UpdateResult contains the update result
type UpdateResult struct {
golangsdk.Result
}
// ExtractUpdateToServer extract CloudServer struct from UpdateResult
func (r UpdateResult) ExtractUpdateToServer() (interface{}, error) {
var updateServer Server
err := r.ExtractInto(&updateServer)
return &updateServer, err
}
type commonResult struct {
golangsdk.Result
}
type CreateResult struct {
commonResult
}
type JobExecResult struct {
commonResult
}
// Job 执行创建/删除接口时返回的jobid结构
type Job struct {
// job id of create image
Id string `json:"job_id"`
}
func (r commonResult) ExtractJob() (Job, error) {
var j Job
err := r.ExtractInto(&j)
return j, err
}
// ServerIDs is a serverIds structure returned when you create a server
type ServerIDs struct {
IDs []string `json:"server_ids"`
}
//ExtractServer is used to extract server struct in response
func (r commonResult) ExtractServer() (ServerIDs, error) {
var s ServerIDs
err := r.ExtractInto(&s)
return s, err
}
//CreateCloudServerResponse is a structure for creating server return values
type CreateCloudServerResponse struct {
Job Job
ServerIDs ServerIDs
}
// DeleteResult is the response from a Delete operation. Call its ExtractErr
// method to determine if the call succeeded or failed.
type DeleteResult struct {
golangsdk.ErrResult
}
type Servers struct {
Servers []Server `json:"servers"`
Count int `json:"count"`
}
type ListResult struct {
commonResult
}
func (r ListResult) Extract() (*Servers, error) {
var entity Servers
err := r.ExtractInto(&entity)
return &entity, err
}