dsl struct tags; wip
diff --git a/openstack/identity/v2/extensions/admin/roles/requests.go b/openstack/identity/v2/extensions/admin/roles/requests.go
index 891ab62..d80c53f 100644
--- a/openstack/identity/v2/extensions/admin/roles/requests.go
+++ b/openstack/identity/v2/extensions/admin/roles/requests.go
@@ -8,26 +8,25 @@
// List is the operation responsible for listing all available global roles
// that a user can adopt.
func List(client *gophercloud.ServiceClient) pagination.Pager {
- createPage := func(r pagination.PageResult) pagination.Page {
+ return pagination.NewPager(client, rootURL(client), func(r pagination.PageResult) pagination.Page {
return RolePage{pagination.SinglePageBase(r)}
- }
- return pagination.NewPager(client, rootURL(client), createPage)
+ })
}
-// AddUserRole is the operation responsible for assigning a particular role to
+// AddUser is the operation responsible for assigning a particular role to
// a user. This is confined to the scope of the user's tenant - so the tenant
// ID is a required argument.
-func AddUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
- var result UserRoleResult
- _, result.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
- return result
+func AddUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
+ var r UserRoleResult
+ _, r.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
+ return r
}
-// DeleteUserRole is the operation responsible for deleting a particular role
+// DeleteUser is the operation responsible for deleting a particular role
// from a user. This is confined to the scope of the user's tenant - so the
// tenant ID is a required argument.
-func DeleteUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
- var result UserRoleResult
- _, result.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
- return result
+func DeleteUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
+ var r UserRoleResult
+ _, r.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
+ return r
}
diff --git a/openstack/identity/v2/extensions/admin/roles/requests_test.go b/openstack/identity/v2/extensions/admin/roles/requests_test.go
index af809a5..cf3402d 100644
--- a/openstack/identity/v2/extensions/admin/roles/requests_test.go
+++ b/openstack/identity/v2/extensions/admin/roles/requests_test.go
@@ -41,24 +41,24 @@
th.AssertEquals(t, 1, count)
}
-func TestAddUserRole(t *testing.T) {
+func TestAddUser(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
MockAddUserRoleResponse(t)
- err := AddUserRole(client.ServiceClient(), "{tenant_id}", "{user_id}", "{role_id}").ExtractErr()
+ err := AddUser(client.ServiceClient(), "{tenant_id}", "{user_id}", "{role_id}").ExtractErr()
th.AssertNoErr(t, err)
}
-func TestDeleteUserRole(t *testing.T) {
+func TestDeleteUser(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
MockDeleteUserRoleResponse(t)
- err := DeleteUserRole(client.ServiceClient(), "{tenant_id}", "{user_id}", "{role_id}").ExtractErr()
+ err := DeleteUser(client.ServiceClient(), "{tenant_id}", "{user_id}", "{role_id}").ExtractErr()
th.AssertNoErr(t, err)
}
diff --git a/openstack/identity/v2/extensions/delegate.go b/openstack/identity/v2/extensions/delegate.go
index 4b2c6a7..cf6cc81 100644
--- a/openstack/identity/v2/extensions/delegate.go
+++ b/openstack/identity/v2/extensions/delegate.go
@@ -14,23 +14,19 @@
// IsEmpty returns true if the current page contains at least one Extension.
func (page ExtensionPage) IsEmpty() (bool, error) {
is, err := ExtractExtensions(page)
- if err != nil {
- return true, err
- }
- return len(is) == 0, nil
+ return len(is) == 0, err
}
// ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the
// elements into a slice of Extension structs.
func ExtractExtensions(page pagination.Page) ([]common.Extension, error) {
- r := page.(ExtensionPage)
// Identity v2 adds an intermediate "values" object.
var s struct {
Extensions struct {
Values []common.Extension `json:"values"`
} `json:"extensions"`
}
- err := r.ExtractInto(&s)
+ err := page.(ExtensionPage).ExtractInto(&s)
return s.Extensions.Values, err
}