/
doc.go
77 lines (59 loc) · 1.6 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
/*
Package policies provides information and interaction with the policies API
resource for the OpenStack Identity service.
Example to List Policies
listOpts := policies.ListOpts{
Type: "application/json",
}
allPages, err := policies.List(identityClient, 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
createOpts := policies.CreateOpts{
Type: "application/json",
Blob: []byte("{'foobar_user': 'role:compute-user'}"),
Extra: map[string]interface{}{
"description": "policy for foobar_user",
},
}
policy, err := policies.Create(identityClient, createOpts).Extract()
if err != nil {
panic(err)
}
Example to Get a Policy
policyID := "0fe36e73809d46aeae6705c39077b1b3"
policy, err := policies.Get(identityClient, policyID).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", policy)
Example to Update a Policy
policyID := "0fe36e73809d46aeae6705c39077b1b3"
updateOpts := policies.UpdateOpts{
Type: "application/json",
Blob: []byte("{'foobar_user': 'role:compute-user'}"),
Extra: map[string]interface{}{
"description": "policy for foobar_user",
},
}
policy, err := policies.Update(identityClient, policyID, updateOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", policy)
Example to Delete a Policy
policyID := "0fe36e73809d46aeae6705c39077b1b3"
err := policies.Delete(identityClient, policyID).ExtractErr()
if err != nil {
panic(err)
}
*/
package policies