-
Notifications
You must be signed in to change notification settings - Fork 8
/
gateway.go
65 lines (50 loc) · 1.74 KB
/
gateway.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
package request
import (
"fmt"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
)
const gatewayBaseURL string = "/gateway"
type GetGatewaysRequest struct {
Filters []QueryFilter
}
func (r *GetGatewaysRequest) RequestURL() string {
if len(r.Filters) == 0 {
return gatewayBaseURL
}
return fmt.Sprintf("%s?%s", gatewayBaseURL, encodeQueryFilters(r.Filters))
}
type GetGatewayRequest struct {
UUID string
}
func (r *GetGatewayRequest) RequestURL() string {
return fmt.Sprintf("%s/%s", gatewayBaseURL, r.UUID)
}
type GatewayRouter struct {
UUID string `json:"uuid,omitempty"`
}
type CreateGatewayRequest struct {
Name string `json:"name,omitempty"`
Zone string `json:"zone,omitempty"`
Features []upcloud.GatewayFeature `json:"features,omitempty"`
Routers []GatewayRouter `json:"routers,omitempty"`
Labels []upcloud.Label `json:"labels,omitempty"`
ConfiguredStatus upcloud.GatewayConfiguredStatus `json:"configured_status,omitempty"`
}
func (r *CreateGatewayRequest) RequestURL() string {
return gatewayBaseURL
}
type ModifyGatewayRequest struct {
UUID string `json:"-"`
Name string `json:"name,omitempty"`
ConfiguredStatus upcloud.GatewayConfiguredStatus `json:"configured_status,omitempty"`
Labels []upcloud.Label `json:"labels,omitempty"`
}
func (r *ModifyGatewayRequest) RequestURL() string {
return fmt.Sprintf("%s/%s", gatewayBaseURL, r.UUID)
}
type DeleteGatewayRequest struct {
UUID string
}
func (r *DeleteGatewayRequest) RequestURL() string {
return fmt.Sprintf("%s/%s", gatewayBaseURL, r.UUID)
}