github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/identity/v2/extensions/admin/roles/requests.go (about)

     1  package roles
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/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 *golangsdk.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 *golangsdk.ServiceClient, tenantID, userID, roleID string) (r UserRoleResult) {
    20  	_, r.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, &golangsdk.RequestOpts{
    21  		OkCodes: []int{200, 201},
    22  	})
    23  	return
    24  }
    25  
    26  // DeleteUser is the operation responsible for deleting a particular role
    27  // from a user. This is confined to the scope of the user's tenant - so the
    28  // tenant ID is a required argument.
    29  func DeleteUser(client *golangsdk.ServiceClient, tenantID, userID, roleID string) (r UserRoleResult) {
    30  	_, r.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
    31  	return
    32  }