github.com/gophercloud/gophercloud@v1.11.0/openstack/identity/v2/extensions/admin/roles/requests.go (about) 1 package roles 2 3 import ( 4 "github.com/gophercloud/gophercloud" 5 "github.com/gophercloud/gophercloud/pagination" 6 ) 7 8 // List is the operation responsible for listing all available global roles 9 // that a user can adopt. 10 func List(client *gophercloud.ServiceClient) pagination.Pager { 11 return pagination.NewPager(client, rootURL(client), func(r pagination.PageResult) pagination.Page { 12 return RolePage{pagination.SinglePageBase(r)} 13 }) 14 } 15 16 // AddUser is the operation responsible for assigning a particular role to 17 // a user. This is confined to the scope of the user's tenant - so the tenant 18 // ID is a required argument. 19 func AddUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) (r UserRoleResult) { 20 resp, err := client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, &gophercloud.RequestOpts{ 21 OkCodes: []int{200, 201}, 22 }) 23 _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) 24 return 25 } 26 27 // DeleteUser is the operation responsible for deleting a particular role 28 // from a user. This is confined to the scope of the user's tenant - so the 29 // tenant ID is a required argument. 30 func DeleteUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) (r UserRoleResult) { 31 resp, err := client.Delete(userRoleURL(client, tenantID, userID, roleID), nil) 32 _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) 33 return 34 }