github.com/gophercloud/gophercloud@v1.11.0/openstack/clustering/v1/policies/doc.go (about) 1 /* 2 Package policies provides information and interaction with the policies through 3 the OpenStack Clustering service. 4 5 Example to List Policies 6 7 listOpts := policies.ListOpts{ 8 Limit: 2, 9 } 10 11 allPages, err := policies.List(clusteringClient, listOpts).AllPages() 12 if err != nil { 13 panic(err) 14 } 15 16 allPolicies, err := policies.ExtractPolicies(allPages) 17 if err != nil { 18 panic(err) 19 } 20 21 for _, policy := range allPolicies { 22 fmt.Printf("%+v\n", policy) 23 } 24 25 Example to Create a Policy 26 27 createOpts := policies.CreateOpts{ 28 Name: "new_policy", 29 Spec: policies.Spec{ 30 Description: "new policy description", 31 Properties: map[string]interface{}{ 32 "hooks": map[string]interface{}{ 33 "type": "zaqar", 34 "params": map[string]interface{}{ 35 "queue": "my_zaqar_queue", 36 }, 37 "timeout": 10, 38 }, 39 }, 40 Type: "senlin.policy.deletion", 41 Version: "1.1", 42 }, 43 } 44 45 createdPolicy, err := policies.Create(client, createOpts).Extract() 46 if err != nil { 47 panic(err) 48 } 49 50 Example to Get a Policy 51 52 policyName := "get_policy" 53 policyDetail, err := policies.Get(clusteringClient, policyName).Extract() 54 if err != nil { 55 panic(err) 56 } 57 58 fmt.Printf("%+v\n", policyDetail) 59 60 Example to Update a Policy 61 62 opts := policies.UpdateOpts{ 63 Name: "update_policy", 64 } 65 66 updatePolicy, err := policies.Update(client, opts).Extract() 67 if err != nil { 68 panic(err) 69 } 70 71 Example to Validate a Policy 72 73 opts := policies.ValidateOpts{ 74 Spec: policies.Spec{ 75 Description: "new policy description", 76 Properties: map[string]interface{}{ 77 "hooks": map[string]interface{}{ 78 "type": "zaqar", 79 "params": map[string]interface{}{ 80 "queue": "my_zaqar_queue", 81 }, 82 "timeout": 10, 83 }, 84 }, 85 Type: "senlin.policy.deletion", 86 Version: "1.1", 87 }, 88 } 89 90 validatePolicy, err := policies.Validate(client, opts).Extract() 91 if err != nil { 92 panic(err) 93 } 94 */ 95 package policies