rs_user_policy 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
data/bin/rs_user_policy
CHANGED
@@ -89,7 +89,7 @@ end
|
|
89
89
|
# Populate the user_assignments with extra bits..
|
90
90
|
user_collection.users.each do |user|
|
91
91
|
user_hash = user.to_hash
|
92
|
-
user_hash.delete(
|
92
|
+
user_hash.delete("permissions")
|
93
93
|
user_assignments[user.email].merge!(user_hash)
|
94
94
|
end
|
95
95
|
|
@@ -124,7 +124,7 @@ net_new_users.each do |net_new_user_email|
|
|
124
124
|
net_new_user_href = api_user.href
|
125
125
|
net_new_user = UserResourceDetailMock.new(net_new_user_email, net_new_user_href)
|
126
126
|
user_assignments[net_new_user_email].delete("create")
|
127
|
-
rescue RightApi::
|
127
|
+
rescue RightApi::ApiError => e
|
128
128
|
log.error("Failed to create a user with the following properties.\n Properties: #{JSON.pretty_generate(user_create_params)}\n Error: #{e}")
|
129
129
|
next
|
130
130
|
end
|
@@ -166,7 +166,7 @@ begin
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|
169
|
-
rescue RightApi::
|
169
|
+
rescue RightApi::ApiError => e
|
170
170
|
log.fatal("A RightScale API exception occurred - #{e}")
|
171
171
|
end
|
172
172
|
|
@@ -44,7 +44,7 @@ module RsUserPolicy
|
|
44
44
|
|
45
45
|
# Destroys all passed in permissions with the specified client.
|
46
46
|
# This method handles deleting permissions in the appropriate order to avoid the dreaded;
|
47
|
-
# RightApi::
|
47
|
+
# RightApi::ApiError: Error: HTTP Code: 422, Response body: A user must have the observer role.
|
48
48
|
# TODO: Handle a 422 resulting from calling delete too quickly and attempting to remove "observer" when other deletes have not been committed
|
49
49
|
#
|
50
50
|
# @param [Array<RightApi::ResourceDetail>] permissions
|
@@ -53,7 +53,7 @@ module RsUserPolicy
|
|
53
53
|
# @param [RightApi::Client] client
|
54
54
|
# An active RightApi::Client instance for the account referenced in account_href
|
55
55
|
#
|
56
|
-
# @raise [RightApi::
|
56
|
+
# @raise [RightApi::ApiError] If an unrecoverable API error has occurred.
|
57
57
|
#
|
58
58
|
# @return [Hash] A hash where the keys are the permission hrefs destroyed, and the values are the role_title of those permissions
|
59
59
|
def self.destroy_permissions(permissions, client)
|
@@ -67,7 +67,7 @@ module RsUserPolicy
|
|
67
67
|
|
68
68
|
# Creates all the passed in permissions using the supplied client.
|
69
69
|
# This method handles creating permissions with "observer" first in order to avoide the dreaded;
|
70
|
-
# RightApi::
|
70
|
+
# RightApi::ApiError: Error: HTTP Code: 422, Response body: A user must have the observer role.
|
71
71
|
#
|
72
72
|
# @param [Hash] permissions
|
73
73
|
# A hash where the key is a RightScale API User href, and the value is a hash where the key is the permission role_title that the user should be granted, and the value is nil.
|
@@ -75,7 +75,7 @@ module RsUserPolicy
|
|
75
75
|
# @param [RightApi::Client] client
|
76
76
|
# An active RightApi::Client instance for the account referenced in account_href
|
77
77
|
#
|
78
|
-
# @raise [RightApi::
|
78
|
+
# @raise [RightApi::ApiError] If an unrecoverable API error has occurred.
|
79
79
|
#
|
80
80
|
# @return [Hash] The permissions input hash, where the nil values have been replaced with the href of the permission which was created.
|
81
81
|
#
|
data/lib/rs_user_policy/user.rb
CHANGED
@@ -36,10 +36,10 @@ module RsUserPolicy
|
|
36
36
|
# Converts this object to a hash which can be serialized
|
37
37
|
def to_hash()
|
38
38
|
rethash = {
|
39
|
-
|
39
|
+
"permissions" => @permissions
|
40
40
|
}
|
41
41
|
(@user.attributes - [:links]).each do |attr_sym|
|
42
|
-
rethash[attr_sym.
|
42
|
+
rethash[attr_sym.to_s] = @user.send(attr_sym.to_s)
|
43
43
|
end
|
44
44
|
rethash
|
45
45
|
end
|
@@ -69,7 +69,7 @@ module RsUserPolicy
|
|
69
69
|
# @param [Hash] options Optional parameters
|
70
70
|
# @option options [Bool] :dry_run If true, no API calls will be made, but the return value will contain the actions which would have been taken
|
71
71
|
#
|
72
|
-
# @raise [RightApi::
|
72
|
+
# @raise [RightApi::ApiError] If an unrecoverable API error has occurred.
|
73
73
|
#
|
74
74
|
# @return [Hash] A hash where the keys are the permission hrefs destroyed, and the keys are the role_title of those permissions
|
75
75
|
def clear_permissions(account_href, client, options={})
|
@@ -96,7 +96,7 @@ module RsUserPolicy
|
|
96
96
|
# @param [Hash] options Optional parameters
|
97
97
|
# @option options [Bool] :dry_run If true, no API calls will be made, but the return value will contain the actions which would have been taken
|
98
98
|
#
|
99
|
-
# @raise [RightApi::
|
99
|
+
# @raise [RightApi::ApiError] If an unrecoverable API error has occurred.
|
100
100
|
#
|
101
101
|
# @return [Hash,Hash] A tuple where two hashes are returned. The keys of the hashes are the href of the permission, and the values are the role_title of the permission. The first hash is the permissions removed, and the second hash is the permissions added
|
102
102
|
def set_api_permissions(permissions, account_href, client, options={})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs_user_policy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -16,17 +16,17 @@ dependencies:
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.5.
|
21
|
+
version: 1.5.10
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.5.
|
29
|
+
version: 1.5.10
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: trollop
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
segments:
|
82
82
|
- 0
|
83
|
-
hash:
|
83
|
+
hash: 710974494852960112
|
84
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
85
|
none: false
|
86
86
|
requirements:
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
segments:
|
91
91
|
- 0
|
92
|
-
hash:
|
92
|
+
hash: 710974494852960112
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
95
|
rubygems_version: 1.8.24
|