-
Notifications
You must be signed in to change notification settings - Fork 7
/
results.go
97 lines (81 loc) · 2.21 KB
/
results.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
package environments
import (
"github.com/huaweicloud/terraform-provider-hcs/huaweicloudstack/sdk/huaweicloud"
"github.com/huaweicloud/terraform-provider-hcs/huaweicloudstack/sdk/huaweicloud/pagination"
)
type commonResult struct {
golangsdk.Result
}
// CreateResult represents a result of the Create method.
type CreateResult struct {
commonResult
}
// UpdateResult represents a result of the Update method.
type UpdateResult struct {
commonResult
}
type Environment struct {
// Environment ID.
Id string `json:"id"`
// Environment name.
Name string `json:"name"`
// Description.
Description string `json:"remark"`
// Create time, in RFC-3339 format.
CreateTime string `json:"create_time"`
}
func (r commonResult) Extract() (*Environment, error) {
var s Environment
err := r.ExtractInto(&s)
return &s, err
}
// EnvironmentPage represents the response pages of the List method.
type EnvironmentPage struct {
pagination.SinglePageBase
}
func ExtractEnvironments(r pagination.Page) ([]Environment, error) {
var s []Environment
err := r.(EnvironmentPage).Result.ExtractIntoSlicePtr(&s, "envs")
return s, err
}
// DeleteResult represents a result of the Delete and DeleteVariable method.
type DeleteResult struct {
golangsdk.ErrResult
}
type VariableResult struct {
golangsdk.Result
}
// VariableCreateResult represents a result of the CreateVariable method.
type VariableCreateResult struct {
VariableResult
}
// VariableGetResult represents a result of the GetVariable operation.
type VariableGetResult struct {
VariableResult
}
type Variable struct {
// Environment variable ID.
Id string `json:"id"`
// Variable name.
Name string `json:"variable_name"`
// Variable value.
Value string `json:"variable_value"`
// API group ID.
GroupId string `json:"group_id"`
// Environment ID.
EnvId string `json:"env_id"`
}
func (r VariableResult) Extract() (*Variable, error) {
var s Variable
err := r.ExtractInto(&s)
return &s, err
}
// VariablePage represents the response pages of the List operation.
type VariablePage struct {
pagination.SinglePageBase
}
func ExtractVariables(r pagination.Page) ([]Variable, error) {
var s []Variable
err := r.(VariablePage).Result.ExtractIntoSlicePtr(&s, "variables")
return s, err
}