-
Notifications
You must be signed in to change notification settings - Fork 7
/
results.go
47 lines (40 loc) · 1.52 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
package instances
import (
"github.com/huaweicloud/terraform-provider-hcs/huaweicloudstack/sdk/huaweicloud"
"github.com/huaweicloud/terraform-provider-hcs/huaweicloudstack/sdk/huaweicloud/pagination"
)
// Instance is a struct which represents all the infromation of a instance
type Instance struct {
ID string `json:"instance_id"`
Name string `json:"instance_name"`
GroupID string `json:"scaling_group_id"`
GroupName string `json:"scaling_group_name"`
LifeCycleStatus string `json:"life_cycle_state"`
HealthStatus string `json:"health_status"`
ConfigurationName string `json:"scaling_configuration_name"`
ConfigurationID string `json:"scaling_configuration_id"`
CreateTime string `json:"create_time"`
Protected bool `json:"protect_from_scaling_down"`
}
// InstancePage is a struct which can do the page function
type InstancePage struct {
pagination.SinglePageBase
}
// IsEmpty returns true if a instances number equal to 0.
func (r InstancePage) IsEmpty() (bool, error) {
groups, err := r.Extract()
return len(groups) == 0, err
}
func (r InstancePage) Extract() ([]Instance, error) {
var instances []Instance
err := r.Result.ExtractIntoSlicePtr(&instances, "scaling_group_instances")
return instances, err
}
// DeleteResult is a struct which contains the result of deletion instance
type DeleteResult struct {
golangsdk.ErrResult
}
// BatchResult is a struct which contains the result of batch operations
type BatchResult struct {
golangsdk.ErrResult
}