datacentred 0.1.1pre → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +11 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +2 -0
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile.lock +39 -2
- data/LICENSE +21 -0
- data/README.md +160 -2
- data/circle.yml +0 -2
- data/datacentred.gemspec +17 -14
- data/docs/Datacentred.html +537 -0
- data/docs/Datacentred/Errors.html +260 -0
- data/docs/Datacentred/Errors/Error.html +139 -0
- data/docs/Datacentred/Errors/NotFound.html +145 -0
- data/docs/Datacentred/Errors/Unauthorized.html +149 -0
- data/docs/Datacentred/Errors/UnprocessableEntity.html +145 -0
- data/docs/Datacentred/Model.html +128 -0
- data/docs/Datacentred/Model/Base.html +255 -0
- data/docs/Datacentred/Model/Project.html +1729 -0
- data/docs/Datacentred/Model/Role.html +1830 -0
- data/docs/Datacentred/Model/Usage.html +510 -0
- data/docs/Datacentred/Model/User.html +832 -0
- data/docs/Datacentred/Model/Version.html +451 -0
- data/docs/Datacentred/Project.html +142 -0
- data/docs/Datacentred/Request.html +128 -0
- data/docs/Datacentred/Request/Base.html +675 -0
- data/docs/Datacentred/Request/Projects.html +1286 -0
- data/docs/Datacentred/Request/Roles.html +1286 -0
- data/docs/Datacentred/Request/Usage.html +315 -0
- data/docs/Datacentred/Request/Users.html +841 -0
- data/docs/Datacentred/Request/Versions.html +258 -0
- data/docs/Datacentred/Response.html +410 -0
- data/docs/Datacentred/Role.html +142 -0
- data/docs/Datacentred/Usage.html +142 -0
- data/docs/Datacentred/User.html +142 -0
- data/docs/Datacentred/Version.html +142 -0
- data/docs/_index.html +349 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +492 -0
- data/docs/file.README.html +231 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +231 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +643 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/datacentred.rb +65 -12
- data/lib/datacentred/error.rb +37 -15
- data/lib/datacentred/model/base.rb +21 -0
- data/lib/datacentred/model/project.rb +90 -31
- data/lib/datacentred/model/role.rb +89 -31
- data/lib/datacentred/model/usage.rb +16 -9
- data/lib/datacentred/model/user.rb +54 -22
- data/lib/datacentred/model/version.rb +17 -8
- data/lib/datacentred/request/base.rb +68 -31
- data/lib/datacentred/request/projects.rb +92 -24
- data/lib/datacentred/request/roles.rb +92 -24
- data/lib/datacentred/request/usage.rb +10 -1
- data/lib/datacentred/request/users.rb +58 -15
- data/lib/datacentred/request/versions.rb +13 -1
- data/lib/datacentred/response.rb +6 -2
- data/test/integration/authorization_test.rb +30 -0
- data/test/integration/projects_test.rb +11 -11
- data/test/integration/roles_test.rb +17 -17
- data/test/integration/usage_test.rb +8 -8
- data/test/integration/users_test.rb +23 -19
- data/test/integration/versions_test.rb +1 -2
- data/test/test_helper.rb +8 -5
- data/test/vcr_cassettes/not_authorized.yml +57 -0
- data/test/vcr_cassettes/unexpected_error.yml +56 -0
- metadata +115 -9
@@ -1,14 +1,21 @@
|
|
1
1
|
module Datacentred
|
2
2
|
module Model
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
# Usage data for a given month/year.
|
4
|
+
#
|
5
|
+
# Data is updated every few hours for the current month.
|
6
|
+
#
|
7
|
+
# @attr [Time] last_updated_at
|
8
|
+
# @attr [[Hash]] projects
|
9
|
+
class Usage < Base
|
10
|
+
# Retrieve account usage data for a given year/month.
|
11
|
+
#
|
12
|
+
# @param [Integer] year The year.
|
13
|
+
# @param [Integer] month The month.
|
14
|
+
# @raise [Errors::NotFound] Raised if no usage data found for given year/month pair.
|
15
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
16
|
+
# @return [Usage] Usage for given year/month pair.
|
17
|
+
def self.find(year, month)
|
18
|
+
new Request::Usage.show year, month
|
12
19
|
end
|
13
20
|
end
|
14
21
|
end
|
@@ -1,31 +1,63 @@
|
|
1
1
|
module Datacentred
|
2
2
|
module Model
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
# A user on your DataCentred account.
|
4
|
+
#
|
5
|
+
# Users are team members with the ability to log into your DataCentred account.
|
6
|
+
#
|
7
|
+
# All users created in your DataCented account are backed by a corresponding user in OpenStack's identity service (Keystone).
|
8
|
+
class User < Base
|
9
|
+
class << self
|
10
|
+
# Create a new user.
|
11
|
+
#
|
12
|
+
# @param [Hash] params User attributes.
|
13
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes.
|
14
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
15
|
+
# @return [User] New user.
|
16
|
+
def create(params)
|
17
|
+
new Request::Users.create params
|
18
|
+
end
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
# List all available users.
|
21
|
+
#
|
22
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
23
|
+
# @return [[User]] A collection of all users on this account.
|
24
|
+
def all
|
25
|
+
Request::Users.list.map {|user| new user }
|
26
|
+
end
|
18
27
|
|
19
|
-
|
20
|
-
|
21
|
-
|
28
|
+
# Find a user by unique ID.
|
29
|
+
#
|
30
|
+
# @param [String] id The unique identifier for this user.
|
31
|
+
# @raise [Errors::NotFound] Raised if the user couldn't be found.
|
32
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
33
|
+
# @return [User] The user, if it exists.
|
34
|
+
def find(id)
|
35
|
+
new Request::Users.show id
|
36
|
+
end
|
22
37
|
|
23
|
-
|
24
|
-
|
25
|
-
|
38
|
+
# Update a user by unique ID.
|
39
|
+
#
|
40
|
+
# @param [String] id The unique identifier for this user.
|
41
|
+
# @param [Hash] params User attributes.
|
42
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes.
|
43
|
+
# @raise [Errors::NotFound] Raised if the user couldn't be found.
|
44
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
45
|
+
# @return [User] The updated user.
|
46
|
+
def update(id, params)
|
47
|
+
new Request::Users.update id, params
|
48
|
+
end
|
26
49
|
|
27
|
-
|
28
|
-
|
50
|
+
# Permanently remove the specified user.
|
51
|
+
#
|
52
|
+
# @param [String] id The unique identifier for this user.
|
53
|
+
# @raise [Errors::NotFound] Raised if the user couldn't be found.
|
54
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the specified user.
|
55
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
56
|
+
# @return [Boolean] Confirms the user was destroyed.
|
57
|
+
def destroy(id)
|
58
|
+
Request::Users.destroy id
|
59
|
+
true
|
60
|
+
end
|
29
61
|
end
|
30
62
|
end
|
31
63
|
end
|
@@ -1,13 +1,22 @@
|
|
1
1
|
module Datacentred
|
2
2
|
module Model
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
# An API version currently available for use.
|
4
|
+
#
|
5
|
+
# This method does not require authentication.
|
6
|
+
#
|
7
|
+
# An API version may be:
|
8
|
+
# * *CURRENT* - The latest supported version.
|
9
|
+
# * *SUPPORTED* - A supported older version.
|
10
|
+
# * *DEPRECATED* - Currently supported but soon to be retired.
|
11
|
+
#
|
12
|
+
# @attr [Integer] id
|
13
|
+
# @attr [String] status
|
14
|
+
class Version < Base
|
15
|
+
# List all available API versions
|
16
|
+
#
|
17
|
+
# @return [[Version]] Currently available versions of the API.
|
18
|
+
def self.all
|
19
|
+
Request::Versions.list.map {|version| new version }
|
11
20
|
end
|
12
21
|
end
|
13
22
|
end
|
@@ -1,46 +1,83 @@
|
|
1
1
|
module Datacentred
|
2
2
|
module Request
|
3
|
-
|
4
|
-
|
3
|
+
# Base class for all API requests.
|
4
|
+
#
|
5
|
+
# Uses the Faraday library for HTTP interactions.
|
5
6
|
class Base
|
7
|
+
class << self
|
8
|
+
# Access a resource via HTTP GET.
|
9
|
+
#
|
10
|
+
# @param [String] path Desired server path.
|
11
|
+
# @raise [Errors::Error] Raised if the server returns a non 2xx error code.
|
12
|
+
# @return [Object] Parsed server response body.
|
13
|
+
def get(path)
|
14
|
+
action :get, path
|
15
|
+
end
|
6
16
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
17
|
+
# Access a resource via HTTP POST.
|
18
|
+
#
|
19
|
+
# @param [String] path Desired server path.
|
20
|
+
# @param [Object] payload JSON serializable object.
|
21
|
+
# @raise [Errors::Error] Raised if the server returns a non 2xx error code.
|
22
|
+
# @return [Object] Parsed server response body.
|
23
|
+
def post(path, payload=nil)
|
24
|
+
action :post, path, payload
|
25
|
+
end
|
11
26
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
27
|
+
# Access a resource via HTTP PUT.
|
28
|
+
#
|
29
|
+
# @param [String] path Desired server path.
|
30
|
+
# @param [Object] payload JSON serializable object.
|
31
|
+
# @raise [Errors::Error] Raised if the server returns a non 2xx error code.
|
32
|
+
# @return [Object] Parsed server response body.
|
33
|
+
def put(path, payload=nil)
|
34
|
+
action :put, path, payload
|
35
|
+
end
|
16
36
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
37
|
+
# Access a resource via HTTP DELETE.
|
38
|
+
#
|
39
|
+
# @param [String] path Desired server path.
|
40
|
+
# @raise [Errors::Error] Raised if the server returns a non 2xx error code.
|
41
|
+
# @return [nil] Returns nil on success.
|
42
|
+
def delete(path)
|
43
|
+
action :delete, path
|
44
|
+
end
|
21
45
|
|
22
|
-
|
23
|
-
response = Datacentred::Response.new(conn.delete(url, payload))
|
24
|
-
response.body
|
25
|
-
end
|
46
|
+
private
|
26
47
|
|
27
|
-
|
48
|
+
def action(verb, path, payload=nil)
|
49
|
+
params = [path, payload&.to_json].compact
|
50
|
+
response = Datacentred::Response.new connection.send verb, *params
|
51
|
+
response.body
|
52
|
+
end
|
28
53
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
54
|
+
def connection
|
55
|
+
Faraday.new(url: base_url) do |faraday|
|
56
|
+
faraday.request :url_encoded
|
57
|
+
faraday.adapter Faraday.default_adapter
|
58
|
+
faraday.headers['Accept'] = "#{accept_type}; version=#{api_version}"
|
59
|
+
faraday.headers['Authorization'] = "Token token=#{credentials}"
|
60
|
+
faraday.headers['Content-Type'] = "application/json"
|
61
|
+
faraday.path_prefix = "/api/"
|
62
|
+
end
|
37
63
|
end
|
38
|
-
end
|
39
64
|
|
40
|
-
|
41
|
-
|
42
|
-
|
65
|
+
def accept_type
|
66
|
+
"application/vnd.datacentred.api+json"
|
67
|
+
end
|
68
|
+
|
69
|
+
def api_version
|
70
|
+
"1".freeze
|
71
|
+
end
|
43
72
|
|
73
|
+
def base_url
|
74
|
+
"https://my.datacentred.io"
|
75
|
+
end
|
76
|
+
|
77
|
+
def credentials
|
78
|
+
[Datacentred.access_key, Datacentred.secret_key].join ":"
|
79
|
+
end
|
80
|
+
end
|
44
81
|
end
|
45
82
|
end
|
46
83
|
end
|
@@ -1,37 +1,105 @@
|
|
1
1
|
module Datacentred
|
2
2
|
module Request
|
3
|
+
# RESTful API requests for the projects endpoints.
|
3
4
|
class Projects < Base
|
5
|
+
class << self
|
6
|
+
# Create a new project.
|
7
|
+
#
|
8
|
+
# POST /api/projects
|
9
|
+
#
|
10
|
+
# @param [Hash] params Project attributes.
|
11
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes.
|
12
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
13
|
+
# @return [Hash] New project.
|
14
|
+
def create(params)
|
15
|
+
post('projects', 'project' => params)['project']
|
16
|
+
end
|
4
17
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
18
|
+
# List all available projects.
|
19
|
+
#
|
20
|
+
# GET /api/projects
|
21
|
+
#
|
22
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
23
|
+
# @return [[Hash]] A collection of all projects on this account.
|
24
|
+
def list
|
25
|
+
get('projects')['projects']
|
26
|
+
end
|
12
27
|
|
13
|
-
|
14
|
-
|
15
|
-
|
28
|
+
# Find a project by unique ID.
|
29
|
+
#
|
30
|
+
# GET /api/projects/ead738d9f894bed9
|
31
|
+
#
|
32
|
+
# @param [String] id The unique identifier for this project.
|
33
|
+
# @raise [Errors::NotFound] Raised if the project couldn't be found.
|
34
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
35
|
+
# @return [Hash] The project, if it exists.
|
36
|
+
def show(id)
|
37
|
+
get("projects/#{id}")['project']
|
38
|
+
end
|
16
39
|
|
17
|
-
|
18
|
-
|
19
|
-
|
40
|
+
# Update a project by unique ID.
|
41
|
+
#
|
42
|
+
# PUT /api/projects/ead738d9f894bed9
|
43
|
+
#
|
44
|
+
# @param [String] id The unique identifier for this project.
|
45
|
+
# @param [Hash] params Project attributes.
|
46
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes.
|
47
|
+
# @raise [Errors::NotFound] Raised if the project could not be found.
|
48
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
49
|
+
# @return [Hash] The updated project.
|
50
|
+
def update(id, params)
|
51
|
+
put("projects/#{id}", 'project' => params)['project']
|
52
|
+
end
|
20
53
|
|
21
|
-
|
22
|
-
|
23
|
-
|
54
|
+
# Permanently remove the specified project.
|
55
|
+
#
|
56
|
+
# DELETE /api/projects/ead738d9f894bed9
|
57
|
+
#
|
58
|
+
# @param [String] id The unique identifier for this project.
|
59
|
+
# @raise [Errors::NotFound] Raised if the project couldn't be found.
|
60
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the specified project.
|
61
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
62
|
+
# @return [nil] Confirms the user was destroyed.
|
63
|
+
def destroy(id)
|
64
|
+
delete("projects/#{id}")
|
65
|
+
end
|
24
66
|
|
25
|
-
|
26
|
-
|
27
|
-
|
67
|
+
# List all users assigned to this project.
|
68
|
+
#
|
69
|
+
# GET /api/projects/ead738d9f894bed9/users
|
70
|
+
#
|
71
|
+
# @param [String] id The unique identifier for this project.
|
72
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
73
|
+
# @return [[Hash]] A collection of the project's users.
|
74
|
+
def list_users(id)
|
75
|
+
get("projects/#{id}/users")['users']
|
76
|
+
end
|
28
77
|
|
29
|
-
|
30
|
-
|
31
|
-
|
78
|
+
# Add a new user to this project, giving them access to it via OpenStack.
|
79
|
+
#
|
80
|
+
# PUT /api/projects/ead738d9f894bed9/users/82fa8de8f09102cc
|
81
|
+
#
|
82
|
+
# @param [String] project_id The unique identifier for this project.
|
83
|
+
# @param [String] user_id The unique identifier for this user.
|
84
|
+
# @raise [Errors::NotFound] Raised if the project or user couldn't be found.
|
85
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
86
|
+
# @return [nil] Confirms the user was added (or is already present).
|
87
|
+
def add_user(project_id, user_id)
|
88
|
+
put("projects/#{project_id}/users/#{user_id}")
|
89
|
+
end
|
32
90
|
|
33
|
-
|
34
|
-
|
91
|
+
# Remove user from this project, revoking their access to it on OpenStack.
|
92
|
+
#
|
93
|
+
# DELETE /api/projects/ead738d9f894bed9/users/82fa8de8f09102cc
|
94
|
+
#
|
95
|
+
# @param [String] project_id The unique identifier for this project.
|
96
|
+
# @param [String] user_id The unique identifier for this user.
|
97
|
+
# @raise [Errors::NotFound] Raised if project or user couldn't be found.
|
98
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
99
|
+
# @return [nil] Confirms that user was removed (or is already absent).
|
100
|
+
def remove_user(project_id, user_id)
|
101
|
+
delete("projects/#{project_id}/users/#{user_id}")
|
102
|
+
end
|
35
103
|
end
|
36
104
|
end
|
37
105
|
end
|
@@ -1,37 +1,105 @@
|
|
1
1
|
module Datacentred
|
2
2
|
module Request
|
3
|
+
# RESTful API requests for the roles endpoints.
|
3
4
|
class Roles < Base
|
5
|
+
class << self
|
6
|
+
# Create a new role.
|
7
|
+
#
|
8
|
+
# POST /api/roles
|
9
|
+
#
|
10
|
+
# @param [Hash] params Role attributes.
|
11
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes.
|
12
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
13
|
+
# @return [Hash] New role.
|
14
|
+
def create(params)
|
15
|
+
post('roles', 'role' => params)['role']
|
16
|
+
end
|
4
17
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
18
|
+
# List all available roles.
|
19
|
+
#
|
20
|
+
# GET /api/roles
|
21
|
+
#
|
22
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
23
|
+
# @return [[Hash]] A collection of all roles on this account.
|
24
|
+
def list
|
25
|
+
get('roles')['roles']
|
26
|
+
end
|
12
27
|
|
13
|
-
|
14
|
-
|
15
|
-
|
28
|
+
# Find a role by unique ID.
|
29
|
+
#
|
30
|
+
# GET /api/roles/ea894bed9d738d9f
|
31
|
+
#
|
32
|
+
# @param [String] id The unique identifier for this role.
|
33
|
+
# @raise [Errors::NotFound] Raised if the role couldn't be found.
|
34
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
35
|
+
# @return [Hash] The role, if it exists.
|
36
|
+
def show(id)
|
37
|
+
get("roles/#{id}")['role']
|
38
|
+
end
|
16
39
|
|
17
|
-
|
18
|
-
|
19
|
-
|
40
|
+
# Update a role by unique ID.
|
41
|
+
#
|
42
|
+
# PUT /api/roles/ea894bed9d738d9f
|
43
|
+
#
|
44
|
+
# @param [String] id The unique identifier for this role.
|
45
|
+
# @param [Hash] params Role attributes.
|
46
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes.
|
47
|
+
# @raise [Errors::NotFound] Raised if the role doesn't exist.
|
48
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
49
|
+
# @return [Hash] The updated role.
|
50
|
+
def update(id, params)
|
51
|
+
put("roles/#{id}", 'role' => params)['role']
|
52
|
+
end
|
20
53
|
|
21
|
-
|
22
|
-
|
23
|
-
|
54
|
+
# Permanently remove the specified role.
|
55
|
+
#
|
56
|
+
# DELETE /api/roles/ea894bed9d738d9f
|
57
|
+
#
|
58
|
+
# @param [String] id The unique identifier for this role.
|
59
|
+
# @raise [Errors::NotFound] Raised if the role couldn't be found.
|
60
|
+
# @raise [Errors::UnprocessableEntity] Raised if validations fail for the specifed role.
|
61
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
62
|
+
# @return [nil] Confirms the role was destroyed.
|
63
|
+
def destroy(id)
|
64
|
+
delete("roles/#{id}")
|
65
|
+
end
|
24
66
|
|
25
|
-
|
26
|
-
|
27
|
-
|
67
|
+
# List all users assigned to this role.
|
68
|
+
#
|
69
|
+
# GET /api/roles/ea894bed9d738d9f/users
|
70
|
+
#
|
71
|
+
# @param [String] role_id The unique identifier for this role.
|
72
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
73
|
+
# @return [[Hash]] A collection of the role's users.
|
74
|
+
def list_users(role_id)
|
75
|
+
get("roles/#{role_id}/users")['users']
|
76
|
+
end
|
28
77
|
|
29
|
-
|
30
|
-
|
31
|
-
|
78
|
+
# Add new user to this role, giving them the associated permissions.
|
79
|
+
#
|
80
|
+
# PUT /api/roles/ea894bed9d738d9f/users/82fa8de8f09102cc
|
81
|
+
#
|
82
|
+
# @param [String] role_id The unique identifier for this role.
|
83
|
+
# @param [String] user_id The unique identifier for this user.
|
84
|
+
# @raise [Errors::NotFound] Raised if the role or user couldn't be found.
|
85
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
86
|
+
# @return [nil] Confirms that user was added (or is already present).
|
87
|
+
def add_user(role_id, user_id)
|
88
|
+
put("roles/#{role_id}/users/#{user_id}")
|
89
|
+
end
|
32
90
|
|
33
|
-
|
34
|
-
|
91
|
+
# Remove user from this role, revoking the associated permissions.
|
92
|
+
#
|
93
|
+
# DELETE /api/roles/ea894bed9d738d9f/users/82fa8de8f09102cc
|
94
|
+
#
|
95
|
+
# @param [String] role_id The unique identifier for this role.
|
96
|
+
# @param [String] user_id The unique identifier for this user.
|
97
|
+
# @raise [Errors::NotFound] Raised if the role or user coundn't be found.
|
98
|
+
# @raise [Errors::Unauthorized] Raised if credentials aren't valid.
|
99
|
+
# @return [nil] Confirms that user was removed (or is already absent).
|
100
|
+
def remove_user(role_id, user_id)
|
101
|
+
delete("roles/#{role_id}/users/#{user_id}")
|
102
|
+
end
|
35
103
|
end
|
36
104
|
end
|
37
105
|
end
|