github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/identity/v2/users/doc.go (about) 1 /* 2 Package users provides information and interaction with the users API 3 resource for the OpenStack Identity Service. 4 5 Example to List Users 6 7 allPages, err := users.List(identityClient).AllPages() 8 if err != nil { 9 panic(err) 10 } 11 12 allUsers, err := users.ExtractUsers(allPages) 13 if err != nil { 14 panic(err) 15 } 16 17 for _, user := range allUsers { 18 fmt.Printf("%+v\n", user) 19 } 20 21 Example to Create a User 22 23 createOpts := users.CreateOpts{ 24 Name: "name", 25 TenantID: "c39e3de9be2d4c779f1dfd6abacc176d", 26 Enabled: golangsdk.Enabled, 27 } 28 29 user, err := users.Create(identityClient, createOpts).Extract() 30 if err != nil { 31 panic(err) 32 } 33 34 Example to Update a User 35 36 userID := "9fe2ff9ee4384b1894a90878d3e92bab" 37 38 updateOpts := users.UpdateOpts{ 39 Name: "new_name", 40 Enabled: golangsdk.Disabled, 41 } 42 43 user, err := users.Update(identityClient, userID, updateOpts).Extract() 44 if err != nil { 45 panic(err) 46 } 47 48 Example to Delete a User 49 50 userID := "9fe2ff9ee4384b1894a90878d3e92bab" 51 err := users.Delete(identityClient, userID).ExtractErr() 52 if err != nil { 53 panic(err) 54 } 55 56 Example to List a User's Roles 57 58 tenantID := "1d8b6120dcc640fda4fc9194ffc80273" 59 userID := "c39e3de9be2d4c779f1dfd6abacc176d" 60 61 allPages, err := users.ListRoles(identityClient, tenantID, userID).AllPages() 62 if err != nil { 63 panic(err) 64 } 65 66 allRoles, err := users.ExtractRoles(allPages) 67 if err != nil { 68 panic(err) 69 } 70 71 for _, role := range allRoles { 72 fmt.Printf("%+v\n", role) 73 } 74 */ 75 package users