github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/rbacpolicies/doc.go (about) 1 /* 2 Package rbacpolicies contains functionality for working with Neutron RBAC Policies. 3 Role-Based Access Control (RBAC) policy framework enables both operators 4 and users to grant access to resources for specific projects. 5 6 Sharing an object with a specific project is accomplished by creating a 7 policy entry that permits the target project the access_as_shared action 8 on that object. 9 10 To make a network available as an external network for specific projects 11 rather than all projects, use the access_as_external action. 12 If a network is marked as external during creation, it now implicitly creates 13 a wildcard RBAC policy granting everyone access to preserve previous behavior 14 before this feature was added. 15 16 Example to Create a RBAC Policy 17 18 createOpts := rbacpolicies.CreateOpts{ 19 Action: rbacpolicies.ActionAccessShared, 20 ObjectType: "network", 21 TargetTenant: "6e547a3bcfe44702889fdeff3c3520c3", 22 ObjectID: "240d22bf-bd17-4238-9758-25f72610ecdc" 23 } 24 25 rbacPolicy, err := rbacpolicies.Create(rbacClient, createOpts).Extract() 26 if err != nil { 27 panic(err) 28 } 29 30 Example to List RBAC Policies 31 32 listOpts := rbacpolicies.ListOpts{ 33 TenantID: "a99e9b4e620e4db09a2dfb6e42a01e66", 34 } 35 36 allPages, err := rbacpolicies.List(rbacClient, listOpts).AllPages() 37 if err != nil { 38 panic(err) 39 } 40 41 allRBACPolicies, err := rbacpolicies.ExtractRBACPolicies(allPages) 42 if err != nil { 43 panic(err) 44 } 45 46 for _, rbacpolicy := range allRBACPolicies { 47 fmt.Printf("%+v", rbacpolicy) 48 } 49 50 Example to Delete a RBAC Policy 51 52 rbacPolicyID := "94fe107f-da78-4d92-a9d7-5611b06dad8d" 53 err := rbacpolicies.Delete(rbacClient, rbacPolicyID).ExtractErr() 54 if err != nil { 55 panic(err) 56 } 57 58 Example to Get RBAC Policy by ID 59 60 rbacPolicyID := "94fe107f-da78-4d92-a9d7-5611b06dad8d" 61 rbacpolicy, err := rbacpolicies.Get(rbacClient, rbacPolicyID).Extract() 62 if err != nil { 63 panic(err) 64 } 65 fmt.Printf("%+v", rbacpolicy) 66 67 Example to Update a RBAC Policy 68 69 rbacPolicyID := "570b0306-afb5-4d3b-ab47-458fdc16baaa" 70 updateOpts := rbacpolicies.UpdateOpts{ 71 TargetTenant: "9d766060b6354c9e8e2da44cab0e8f38", 72 } 73 rbacPolicy, err := rbacpolicies.Update(rbacClient, rbacPolicyID, updateOpts).Extract() 74 if err != nil { 75 panic(err) 76 } 77 78 */ 79 package rbacpolicies