forked from gophercloud/gophercloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
96 lines (78 loc) · 1.86 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
/*
Package policies provides information and interaction with the policies through
the OpenStack Clustering service.
Example to List Policies
listOpts := policies.ListOpts{
Limit: 2,
}
allPages, err := policies.List(clusteringClient, listOpts).AllPages()
if err != nil {
panic(err)
}
allPolicies, err := policies.ExtractPolicies(allPages)
if err != nil {
panic(err)
}
for _, policy := range allPolicies {
fmt.Printf("%+v\n", policy)
}
Example to Create a Policy
opts := policies.CreateOpts{
Name: "new_policy",
Spec: policies.Spec{
Description: "new policy description",
Properties: map[string]interface{}{
"hooks": map[string]interface{}{
"type": "zaqar",
"params": map[string]interface{}{
"queue": "my_zaqar_queue",
},
"timeout": 10,
},
},
Type: "senlin.policy.deletion",
Version: "1.1",
},
}
createdPolicy, err := policies.Create(client, opts).Extract()
if err != nil {
panic(err)
}
Example to Get a Policy
policyName := "get_policy"
policyDetail, err := policies.Get(clusteringClient, policyName).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", policyDetail)
Example to Update a Policy
opts := policies.UpdateOpts{
Name: "update_policy",
}
updatePolicy, err := policies.Update(client, opts).Extract()
if err != nil {
panic(err)
}
Example to Validate a Policy
opts := policies.ValidateOpts{
Spec: policies.Spec{
Description: "new policy description",
Properties: map[string]interface{}{
"hooks": map[string]interface{}{
"type": "zaqar",
"params": map[string]interface{}{
"queue": "my_zaqar_queue",
},
"timeout": 10,
},
},
Type: "senlin.policy.deletion",
Version: "1.1",
},
}
validatePolicy, err := policies.Validate(client, opts).Extract()
if err != nil {
panic(err)
}
*/
package policies