github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/identity/v2/tenants/doc.go (about) 1 /* 2 Package tenants provides information and interaction with the 3 tenants API resource for the OpenStack Identity service. 4 5 See http://developer.openstack.org/api-ref-identity-v2.html#identity-auth-v2 6 and http://developer.openstack.org/api-ref-identity-v2.html#admin-tenants 7 for more information. 8 9 Example to List Tenants 10 11 listOpts := tenants.ListOpts{ 12 Limit: 2, 13 } 14 15 allPages, err := tenants.List(identityClient, listOpts).AllPages() 16 if err != nil { 17 panic(err) 18 } 19 20 allTenants, err := tenants.ExtractTenants(allPages) 21 if err != nil { 22 panic(err) 23 } 24 25 for _, tenant := range allTenants { 26 fmt.Printf("%+v\n", tenant) 27 } 28 29 Example to Create a Tenant 30 31 createOpts := tenants.CreateOpts{ 32 Name: "tenant_name", 33 Description: "this is a tenant", 34 Enabled: golangsdk.Enabled, 35 } 36 37 tenant, err := tenants.Create(identityClient, createOpts).Extract() 38 if err != nil { 39 panic(err) 40 } 41 42 Example to Update a Tenant 43 44 tenantID := "e6db6ed6277c461a853458589063b295" 45 46 updateOpts := tenants.UpdateOpts{ 47 Description: "this is a new description", 48 Enabled: golangsdk.Disabled, 49 } 50 51 tenant, err := tenants.Update(identityClient, tenantID, updateOpts).Extract() 52 if err != nil { 53 panic(err) 54 } 55 56 Example to Delete a Tenant 57 58 tenantID := "e6db6ed6277c461a853458589063b295" 59 60 err := tenants.Delete(identitYClient, tenantID).ExtractErr() 61 if err != nil { 62 panic(err) 63 } 64 */ 65 package tenants