-
Notifications
You must be signed in to change notification settings - Fork 6
/
doc.go
141 lines (105 loc) · 3.05 KB
/
doc.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
Package routes contains functionality for working with ECL Managed Load Balancer resources.
Example to list routes
listOpts := routes.ListOpts{}
allPages, err := routes.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
panic(err)
}
allRoutes, err := routes.ExtractRoutes(allPages)
if err != nil {
panic(err)
}
for _, route := range allRoutes {
fmt.Printf("%+v\n", route)
}
Example to create a route
var tags map[string]interface{}
tagsJson := `{"key":"value"}`
err := json.Unmarshal([]byte(tagsJson), &tags)
if err != nil {
panic(err)
}
createOpts := routes.CreateOpts{
Name: "route",
Description: "description",
Tags: tags,
DestinationCidr: "172.16.0.0/24",
NextHopIPAddress: "192.168.0.254",
LoadBalancerID: "67fea379-cff0-4191-9175-de7d6941a040",
}
route, err := routes.Create(managedLoadBalancerClient, createOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", route)
Example to show a route
showOpts := routes.ShowOpts{}
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
route, err := routes.Show(managedLoadBalancerClient, id, showOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", route)
Example to update a route
name := "route"
description := "description"
var tags map[string]interface{}
tagsJson := `{"key":"value"}`
err := json.Unmarshal([]byte(tagsJson), &tags)
if err != nil {
panic(err)
}
updateOpts := routes.UpdateOpts{
Name: &name,
Description: &description,
Tags: &tags,
}
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
route, err := routes.Update(managedLoadBalancerClient, updateOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", route)
Example to delete a route
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
err := routes.Delete(managedLoadBalancerClient, id).ExtractErr()
if err != nil {
panic(err)
}
Example to create staged route configurations
createStagedOpts := routes.CreateStagedOpts{
NextHopIPAddress: "192.168.0.254",
}
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
routeConfigurations, err := routes.CreateStaged(managedLoadBalancerClient, id, createStagedOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", routeConfigurations)
Example to show staged route configurations
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
routeConfigurations, err := routes.ShowStaged(managedLoadBalancerClient, id).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", routeConfigurations)
Example to update staged route configurations
nextHopIPAddress := "192.168.0.254"
updateStagedOpts := routes.UpdateStagedOpts{
NextHopIPAddress: &nextHopIPAddress,
}
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
routeConfigurations, err := routes.UpdateStaged(managedLoadBalancerClient, updateStagedOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", routeConfigurations)
Example to cancel staged route configurations
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
err := routes.CancelStaged(managedLoadBalancerClient, id).ExtractErr()
if err != nil {
panic(err)
}
*/
package routes