-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathautoscaling_group.go
107 lines (82 loc) · 3.11 KB
/
autoscaling_group.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
package paperspace
import (
"fmt"
)
type AutoscalingGroup struct {
ID string `json:"id"`
Name string `json:"name"`
Min int `json:"min"`
Max int `json:"max"`
Current int `json:"current"`
ClusterID string `json:"clusterId"`
MachineType string `json:"machineType"`
TemplateID string `json:"templateId"`
ScriptID string `json:"startupScriptId"`
NetworkID string `json:"networkId"`
Nodes []Machine `json:"nodes"`
}
type AutoscalingGroupCreateParams struct {
RequestParams
Name string `json:"name"`
Min int `json:"min"`
Max int `json:"max"`
ClusterID string `json:"clusterId"`
MachineType string `json:"machineType"`
TemplateID string `json:"templateId"`
ScriptID string `json:"startupScriptId,omitempty"`
NetworkID string `json:"networkId"`
}
type AutoscalingGroupDeleteParams struct {
RequestParams
}
type AutoscalingGroupGetParams struct {
RequestParams
IncludeNodes bool `json:"includeNodes,omitempty"`
}
type AutoscalingGroupListParams struct {
RequestParams
Filter Filter `json:"filter,omitempty"`
IncludeNodes bool `json:"includeNodes,omitempty"`
}
type AutoscalingGroupUpdateAttributeParams struct {
Name string `json:"name,omitempty"`
Min *int `json:"min,omitempty"`
Max *int `json:"max,omitempty"`
Current *int `json:"current,omitempty"`
MachineType string `json:"machineType,omitempty"`
TemplateID string `json:"templateId,omitempty"`
ScriptID string `json:"startupScriptId,omitempty"`
NetworkID string `json:"networkId,omitempty"`
}
type AutoscalingGroupUpdateParams struct {
RequestParams
Attributes AutoscalingGroupUpdateAttributeParams `json:"attributes,omitempty"`
}
func (c Client) CreateAutoscalingGroup(params AutoscalingGroupCreateParams) (AutoscalingGroup, error) {
autoscalingGroup := AutoscalingGroup{}
url := fmt.Sprintf("/autoscalingGroups")
_, err := c.Request("POST", url, params, &autoscalingGroup, params.RequestParams)
return autoscalingGroup, err
}
func (c Client) GetAutoscalingGroup(id string, params AutoscalingGroupGetParams) (AutoscalingGroup, error) {
autoscalingGroup := AutoscalingGroup{}
url := fmt.Sprintf("/autoscalingGroups/%s", id)
_, err := c.Request("GET", url, params, &autoscalingGroup, params.RequestParams)
return autoscalingGroup, err
}
func (c Client) GetAutoscalingGroups(params AutoscalingGroupListParams) ([]AutoscalingGroup, error) {
var autoscalingGroups []AutoscalingGroup
url := fmt.Sprintf("/autoscalingGroups")
_, err := c.Request("GET", url, params, &autoscalingGroups, params.RequestParams)
return autoscalingGroups, err
}
func (c Client) UpdateAutoscalingGroup(id string, params AutoscalingGroupUpdateParams) error {
url := fmt.Sprintf("/autoscalingGroups/%s", id)
_, err := c.Request("PATCH", url, params, nil, params.RequestParams)
return err
}
func (c Client) DeleteAutoscalingGroup(id string, params AutoscalingGroupDeleteParams) error {
url := fmt.Sprintf("/autoscalingGroups/%s", id)
_, err := c.Request("DELETE", url, nil, nil, params.RequestParams)
return err
}