runcible 1.2.0 → 1.3.0

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.
Files changed (43) hide show
  1. data/Gemfile +2 -1
  2. data/README.md +1 -1
  3. data/Rakefile +16 -10
  4. data/lib/runcible.rb +1 -1
  5. data/lib/runcible/base.rb +24 -29
  6. data/lib/runcible/extensions/consumer.rb +25 -26
  7. data/lib/runcible/extensions/consumer_group.rb +10 -13
  8. data/lib/runcible/extensions/distribution.rb +0 -2
  9. data/lib/runcible/extensions/docker_image.rb +0 -1
  10. data/lib/runcible/extensions/errata.rb +0 -3
  11. data/lib/runcible/extensions/package_category.rb +0 -3
  12. data/lib/runcible/extensions/package_group.rb +0 -2
  13. data/lib/runcible/extensions/puppet_module.rb +0 -3
  14. data/lib/runcible/extensions/repository.rb +88 -72
  15. data/lib/runcible/extensions/rpm.rb +3 -5
  16. data/lib/runcible/extensions/unit.rb +10 -13
  17. data/lib/runcible/extensions/yum_repo_metadata_file.rb +0 -3
  18. data/lib/runcible/instance.rb +22 -28
  19. data/lib/runcible/models/distributor.rb +4 -5
  20. data/lib/runcible/models/docker_distributor.rb +4 -4
  21. data/lib/runcible/models/docker_importer.rb +2 -2
  22. data/lib/runcible/models/export_distributor.rb +1 -1
  23. data/lib/runcible/models/importer.rb +3 -6
  24. data/lib/runcible/models/iso_distributor.rb +3 -3
  25. data/lib/runcible/models/iso_importer.rb +1 -1
  26. data/lib/runcible/models/nodes_http_distributor.rb +0 -1
  27. data/lib/runcible/models/puppet_distributor.rb +2 -2
  28. data/lib/runcible/models/yum_clone_distributor.rb +3 -4
  29. data/lib/runcible/models/yum_distributor.rb +7 -7
  30. data/lib/runcible/models/yum_importer.rb +17 -17
  31. data/lib/runcible/resources/consumer.rb +17 -20
  32. data/lib/runcible/resources/consumer_group.rb +13 -15
  33. data/lib/runcible/resources/content.rb +10 -10
  34. data/lib/runcible/resources/event_notifier.rb +5 -9
  35. data/lib/runcible/resources/repository.rb +23 -23
  36. data/lib/runcible/resources/repository_group.rb +5 -7
  37. data/lib/runcible/resources/repository_schedule.rb +5 -7
  38. data/lib/runcible/resources/role.rb +5 -8
  39. data/lib/runcible/resources/task.rb +10 -13
  40. data/lib/runcible/resources/unit.rb +3 -6
  41. data/lib/runcible/resources/user.rb +7 -10
  42. data/lib/runcible/version.rb +1 -1
  43. metadata +2 -2
@@ -27,22 +27,21 @@ module Runcible
27
27
  module Resources
28
28
  # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/consumer/group/index.html
29
29
  class ConsumerGroup < Runcible::Base
30
-
31
30
  # Generates the API path for Consumer Groups
32
31
  #
33
32
  # @param [String] id the ID of the consumer group
34
- # @return [String] the consumer group path, may contain the id if passed
35
- def path(id=nil)
36
- groups = "consumer_groups/"
33
+ # @return [String] the consumer group path, may contain the id if passed
34
+ def path(id = nil)
35
+ groups = 'consumer_groups/'
37
36
  id.nil? ? groups : groups + "#{id}/"
38
37
  end
39
-
38
+
40
39
  # Creates a Consumer Group
41
40
  #
42
41
  # @param [String] id the ID of the consumer
43
42
  # @param [Hash] optional container for all optional parameters
44
43
  # @return [RestClient::Response]
45
- def create(id, optional={})
44
+ def create(id, optional = {})
46
45
  required = required_params(binding.send(:local_variables), binding)
47
46
  call(:post, path, :payload => { :required => required, :optional => optional })
48
47
  end
@@ -69,7 +68,7 @@ module Runcible
69
68
  # @param [Hash] criteria criteria based on Mongo syntax representing consumers to associate
70
69
  # @return [RestClient::Response]
71
70
  def associate(id, criteria)
72
- call(:post, path(id) + "actions/associate/", :payload => {:required => criteria})
71
+ call(:post, path(id) + 'actions/associate/', :payload => {:required => criteria})
73
72
  end
74
73
 
75
74
  # Unassociates Consumers with a Consumer Group
@@ -78,7 +77,7 @@ module Runcible
78
77
  # @param [Hash] criteria criteria based on Mongo syntax representing consumers ta unassociate
79
78
  # @return [RestClient::Response]
80
79
  def unassociate(id, criteria)
81
- call(:post, path(id) + "actions/unassociate/", :payload => {:required => criteria})
80
+ call(:post, path(id) + 'actions/unassociate/', :payload => {:required => criteria})
82
81
  end
83
82
 
84
83
  # Install a set of units to a Consumer Group
@@ -87,8 +86,8 @@ module Runcible
87
86
  # @param [Array] units array of units to install
88
87
  # @param [Hash] options hash of install options
89
88
  # @return [RestClient::Response]
90
- def install_units(id, units, options={})
91
- required = required_params(binding.send(:local_variables), binding, ["id"])
89
+ def install_units(id, units, options = {})
90
+ required = required_params(binding.send(:local_variables), binding, ['id'])
92
91
  call(:post, path("#{id}/actions/content/install"), :payload => { :required => required })
93
92
  end
94
93
 
@@ -98,8 +97,8 @@ module Runcible
98
97
  # @param [Array] units array of units to update
99
98
  # @param [Hash] options hash of update options
100
99
  # @return [RestClient::Response]
101
- def update_units(id, units, options={})
102
- required = required_params(binding.send(:local_variables), binding, ["id"])
100
+ def update_units(id, units, options = {})
101
+ required = required_params(binding.send(:local_variables), binding, ['id'])
103
102
  call(:post, path("#{id}/actions/content/update"), :payload => { :required => required })
104
103
  end
105
104
 
@@ -109,11 +108,10 @@ module Runcible
109
108
  # @param [Array] units array of units to uninstall
110
109
  # @param [Hash] options hash of uninstall options
111
110
  # @return [RestClient::Response]
112
- def uninstall_units(id, units, options={})
113
- required = required_params(binding.send(:local_variables), binding, ["id"])
111
+ def uninstall_units(id, units, options = {})
112
+ required = required_params(binding.send(:local_variables), binding, ['id'])
114
113
  call(:post, path("#{id}/actions/content/uninstall"), :payload => { :required => required })
115
114
  end
116
-
117
115
  end
118
116
  end
119
117
  end
@@ -27,13 +27,12 @@ module Runcible
27
27
  module Resources
28
28
  # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/content/index.html
29
29
  class Content < Runcible::Base
30
-
31
30
  # Generates the API path for Contents
32
31
  #
33
32
  # @param [String] upload_id the id of the upload_request
34
33
  # @return [String] the content path, may contain the upload_id if passed
35
- def upload_path(upload_id=nil)
36
- (upload_id == nil) ? "content/uploads/" : "content/uploads/#{upload_id}/"
34
+ def upload_path(upload_id = nil)
35
+ (upload_id.nil?) ? 'content/uploads/' : "content/uploads/#{upload_id}/"
37
36
  end
38
37
 
39
38
  # Creates an Upload Request
@@ -59,12 +58,14 @@ module Runcible
59
58
  # @param [String] repo_id identifies the associated repository
60
59
  # @param [String] unit_type_id identifies the type of unit the upload represents
61
60
  # @param [String] upload_id the id of the upload_request returned by create_upload_request
62
- # @param [Object] unit_key unique identifier for the new unit; the contents are contingent on the type of unit being uploaded
61
+ # @param [Object] unit_key unique identifier for the new unit; the contents are contingent
62
+ # on the type of unit being uploaded
63
63
  # @param [Hash] optional container for all optional parameters
64
64
  # @return [RestClient::Response] none
65
- def import_into_repo(repo_id, unit_type_id, upload_id, unit_key, optional={})
65
+ def import_into_repo(repo_id, unit_type_id, upload_id, unit_key, optional = {})
66
66
  required = required_params(binding.send(:local_variables), binding)
67
- call(:post, Repository.path("#{repo_id}/actions/import_upload/"), :payload => { :required =>required, :optional => optional })
67
+ call(:post, Repository.path("#{repo_id}/actions/import_upload/"),
68
+ :payload => { :required => required, :optional => optional })
68
69
  end
69
70
 
70
71
  # Delete an upload request
@@ -79,7 +80,8 @@ module Runcible
79
80
  # List all upload requests
80
81
  #
81
82
  # Query Parameters: None
82
- # @return [RestClient::Response] the list of IDs for all upload requests on the server; empty list if there are none
83
+ # @return [RestClient::Response] the list of IDs for all upload requests
84
+ # on the server; empty list if there are none
83
85
  def list_all_requests
84
86
  call(:get, upload_path)
85
87
  end
@@ -89,7 +91,7 @@ module Runcible
89
91
  # @param [String] type_id the type id of the orphaned content
90
92
  # @return [String] the content path, may contain the type_id if passed
91
93
  def orphan_path(type_id = nil)
92
- path = "content/orphans/"
94
+ path = 'content/orphans/'
93
95
  path << "#{type_id}/" if type_id
94
96
  path
95
97
  end
@@ -109,8 +111,6 @@ module Runcible
109
111
  def remove_orphans(type_id = nil)
110
112
  call(:delete, orphan_path(type_id))
111
113
  end
112
-
113
114
  end
114
115
  end
115
116
  end
116
-
@@ -21,12 +21,10 @@
21
21
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
-
25
24
  module Runcible
26
25
  module Resources
27
26
  # @see https://pulp-dev-guide.readthedocs.org/en/latest/events/index.html
28
27
  class EventNotifier < Runcible::Base
29
-
30
28
  class EventTypes
31
29
  REPO_SYNC_COMPLETE = 'repo.sync.finish'
32
30
  REPO_SYNC_START = 'repo.sync.start'
@@ -42,8 +40,8 @@ module Runcible
42
40
  #
43
41
  # @param [String] id the ID of the event notifier
44
42
  # @return [String] the event notifier path, may contain the ID if passed
45
- def self.path(id=nil)
46
- (id == nil) ? "events/" : "events/#{id}/"
43
+ def self.path(id = nil)
44
+ (id.nil?) ? 'events/' : "events/#{id}/"
47
45
  end
48
46
 
49
47
  # Creates an Event Notification
@@ -51,7 +49,7 @@ module Runcible
51
49
  # @param [String] notifier_type_id the type ID of the event notifier
52
50
  # @param [Hash] notifier_config configuration options for the notifier
53
51
  # @param [Hash] event_types event types to include in the notifier
54
- # @return [RestClient::Response]
52
+ # @return [RestClient::Response]
55
53
  def create(notifier_type_id, notifier_config, event_types)
56
54
  required = required_params(binding.send(:local_variables), binding)
57
55
  call(:post, path, :payload => {:required => required})
@@ -60,7 +58,7 @@ module Runcible
60
58
  # Deletes an Event Notification
61
59
  #
62
60
  # @param [String] id the ID of the event notifier
63
- # @return [RestClient::Response]
61
+ # @return [RestClient::Response]
64
62
  def delete(id)
65
63
  call(:delete, path(id))
66
64
  end
@@ -68,12 +66,10 @@ module Runcible
68
66
  # List all Event Notifiers
69
67
  #
70
68
  # @param [String] id the ID of the event notifier
71
- # @return [RestClient::Response]
69
+ # @return [RestClient::Response]
72
70
  def list
73
71
  call(:get, path)
74
72
  end
75
-
76
73
  end
77
74
  end
78
75
  end
79
-
@@ -31,8 +31,8 @@ module Runcible
31
31
  #
32
32
  # @param [String] id the id of the repository
33
33
  # @return [String] the repository path, may contain the id if passed
34
- def self.path(id=nil)
35
- (id == nil) ? "repositories/" : "repositories/#{id}/"
34
+ def self.path(id = nil)
35
+ (id.nil?) ? 'repositories/' : "repositories/#{id}/"
36
36
  end
37
37
 
38
38
  # Creates a repository
@@ -40,7 +40,7 @@ module Runcible
40
40
  # @param [String] id the id of the repository
41
41
  # @param [Hash] optional container for all optional parameters
42
42
  # @return [RestClient::Response]
43
- def create(id, optional={})
43
+ def create(id, optional = {})
44
44
  required = required_params(binding.send(:local_variables), binding)
45
45
  call(:post, path, :payload => { :required => required, :optional => optional })
46
46
  end
@@ -50,7 +50,7 @@ module Runcible
50
50
  # @param [String] id the id of the repository
51
51
  # @param [Hash] params container for optional query parameters
52
52
  # @return [RestClient::Response]
53
- def retrieve(id, params={})
53
+ def retrieve(id, params = {})
54
54
  call(:get, path(id), :params => params)
55
55
  end
56
56
 
@@ -59,7 +59,7 @@ module Runcible
59
59
  # @param [String] id the id of the repository
60
60
  # @param [Hash] optional container for all optional parameters
61
61
  # @return [RestClient::Response]
62
- def update(id, optional={})
62
+ def update(id, optional = {})
63
63
  call(:put, path(id), :payload => { :delta => optional })
64
64
  end
65
65
 
@@ -75,7 +75,7 @@ module Runcible
75
75
  #
76
76
  # @param [Hash] optional container for all optional parameters
77
77
  # @return [RestClient::Response]
78
- def retrieve_all(optional={})
78
+ def retrieve_all(optional = {})
79
79
  call(:get, path, :payload => { :optional => optional })
80
80
  end
81
81
 
@@ -84,9 +84,9 @@ module Runcible
84
84
  # @param [Hash] criteria criteria object containing Mongo syntax
85
85
  # @param [Hash] optional container for all optional parameters
86
86
  # @return [RestClient::Response]
87
- def search(criteria, optional={})
87
+ def search(criteria, optional = {})
88
88
  required = required_params(binding.send(:local_variables), binding)
89
- call(:post, path("search"), :payload => { :required => required, :optional => optional })
89
+ call(:post, path('search'), :payload => { :required => required, :optional => optional })
90
90
  end
91
91
 
92
92
  # Associates an importer to a repository
@@ -107,8 +107,8 @@ module Runcible
107
107
  # @param [Hash] distributor_config configuration options for the distributor
108
108
  # @param [Hash] optional container for all optional parameters
109
109
  # @return [RestClient::Response]
110
- def associate_distributor(id, distributor_type_id, distributor_config, optional={})
111
- required = required_params(binding.send(:local_variables), binding, ["id"])
110
+ def associate_distributor(id, distributor_type_id, distributor_config, optional = {})
111
+ required = required_params(binding.send(:local_variables), binding, ['id'])
112
112
  call(:post, path("#{id}/distributors"), :payload => { :required => required, :optional => optional })
113
113
  end
114
114
 
@@ -117,7 +117,7 @@ module Runcible
117
117
  # @param [String] id the id of the repository
118
118
  # @param [Hash] optional container for all optional parameters
119
119
  # @return [RestClient::Response]
120
- def sync(id, optional={})
120
+ def sync(id, optional = {})
121
121
  call(:post, "#{path(id)}actions/sync/", :payload => { :optional => optional })
122
122
  end
123
123
 
@@ -135,8 +135,8 @@ module Runcible
135
135
  # @param [String] source_repo_id the id of the source repository
136
136
  # @param [Hash] optional container for all optional parameters
137
137
  # @return [RestClient::Response]
138
- def unit_copy(destination_repo_id, source_repo_id, optional={})
139
- required = required_params(binding.send(:local_variables), binding, ["destination_repo_id"])
138
+ def unit_copy(destination_repo_id, source_repo_id, optional = {})
139
+ required = required_params(binding.send(:local_variables), binding, ['destination_repo_id'])
140
140
  call(:post, "#{path(destination_repo_id)}actions/associate/",
141
141
  :payload => { :required => required, :optional => optional })
142
142
  end
@@ -146,8 +146,8 @@ module Runcible
146
146
  # @param [String] source_repo_id the id of the source repository
147
147
  # @param [Hash] criteria criteria object containing Mongo syntax
148
148
  # @return [RestClient::Response]
149
- def unassociate_units(source_repo_id, criteria={})
150
- required = required_params(binding.send(:local_variables), binding, ["source_repo_id"])
149
+ def unassociate_units(source_repo_id, criteria = {})
150
+ required = required_params(binding.send(:local_variables), binding, ['source_repo_id'])
151
151
  call(:post, "#{path(source_repo_id)}actions/unassociate/",
152
152
  :payload => { :required => required })
153
153
  end
@@ -157,8 +157,8 @@ module Runcible
157
157
  # @param [String] id the id of the repository
158
158
  # @param [Hash] criteria criteria object containing Mongo syntax
159
159
  # @return [RestClient::Response]
160
- def unit_search(id, criteria={})
161
- call(:post, "#{path(id)}search/units/", :payload=>{:required=>{:criteria=>criteria}})
160
+ def unit_search(id, criteria = {})
161
+ call(:post, "#{path(id)}search/units/", :payload => {:required => {:criteria => criteria}})
162
162
  end
163
163
 
164
164
  # Publishes a repository using the specified distributor
@@ -167,8 +167,9 @@ module Runcible
167
167
  # @param [String] distributor_id the id of the distributor
168
168
  # @param [Hash] optional optional params
169
169
  # @return [RestClient::Response]
170
- def publish(id, distributor_id, optional={})
171
- call(:post, "#{path(id)}actions/publish/", :payload=>{:required=>{:id=>distributor_id}, :optional=>optional})
170
+ def publish(id, distributor_id, optional = {})
171
+ call(:post, "#{path(id)}actions/publish/",
172
+ :payload => {:required => {:id => distributor_id}, :optional => optional})
172
173
  end
173
174
 
174
175
  # Deletes the specified distributor from the repository
@@ -187,7 +188,7 @@ module Runcible
187
188
  # @param [Hash] distributor_config attributes to change
188
189
  # @return [RestClient::Response]
189
190
  def update_distributor(id, distributor_id, distributor_config)
190
- required = required_params(binding.send(:local_variables), binding, ["id", "distributor_id"])
191
+ required = required_params(binding.send(:local_variables), binding, ['id', 'distributor_id'])
191
192
  call(:put, path("#{id}/distributors/#{distributor_id}/"), :payload => { :required => required})
192
193
  end
193
194
 
@@ -207,7 +208,7 @@ module Runcible
207
208
  # @param [Hash] importer_config attributes to change
208
209
  # @return [RestClient::Response]
209
210
  def update_importer(id, importer_id, importer_config)
210
- required = required_params(binding.send(:local_variables), binding, ["id", "importer_id"])
211
+ required = required_params(binding.send(:local_variables), binding, ['id', 'importer_id'])
211
212
  call(:put, path("#{id}/importers/#{importer_id}/"), :payload => { :required => required})
212
213
  end
213
214
 
@@ -216,9 +217,8 @@ module Runcible
216
217
  # @param [Hash] options payload representing criteria
217
218
  # @return [RestClient::Response]
218
219
  def regenerate_applicability(options = {})
219
- call(:post, path("actions/content/regenerate_applicability/"), :payload => { :required => options})
220
+ call(:post, path('actions/content/regenerate_applicability/'), :payload => { :required => options})
220
221
  end
221
-
222
222
  end
223
223
  end
224
224
  end
@@ -27,13 +27,12 @@ module Runcible
27
27
  module Resources
28
28
  # @see https://pulp-dev-guide.readthedocs.org/en/latest/integration/rest-api/repo/groups/
29
29
  class RepositoryGroup < Runcible::Base
30
-
31
30
  # Generates the API path for Repository Groups
32
31
  #
33
32
  # @param [String] id the ID of the Repository group
34
33
  # @return [String] the Repository group path, may contain the id if passed
35
- def self.path(id=nil)
36
- groups = "repo_groups/"
34
+ def self.path(id = nil)
35
+ groups = 'repo_groups/'
37
36
  id.nil? ? groups : groups + "#{id}/"
38
37
  end
39
38
 
@@ -42,7 +41,7 @@ module Runcible
42
41
  # @param [String] id the ID of the group
43
42
  # @param [Hash] optional container for all optional parameters
44
43
  # @return [RestClient::Response]
45
- def create(id, optional={})
44
+ def create(id, optional = {})
46
45
  required = required_params(binding.send(:local_variables), binding)
47
46
  call(:post, path, :payload => { :required => required, :optional => optional })
48
47
  end
@@ -76,7 +75,7 @@ module Runcible
76
75
  # @param [Hash] criteria criteria based on Mongo syntax representing repos to associate
77
76
  # @return [RestClient::Response]
78
77
  def associate(id, criteria)
79
- call(:post, path(id) + "actions/associate/", :payload => {:required => criteria})
78
+ call(:post, path(id) + 'actions/associate/', :payload => {:required => criteria})
80
79
  end
81
80
 
82
81
  # Unassociates Repositories with a Repository Group
@@ -85,9 +84,8 @@ module Runcible
85
84
  # @param [Hash] criteria criteria based on Mongo syntax representing repos ta unassociate
86
85
  # @return [RestClient::Response]
87
86
  def unassociate(id, criteria)
88
- call(:post, path(id) + "actions/unassociate/", :payload => {:required => criteria})
87
+ call(:post, path(id) + 'actions/unassociate/', :payload => {:required => criteria})
89
88
  end
90
-
91
89
  end
92
90
  end
93
91
  end
@@ -27,17 +27,16 @@ module Runcible
27
27
  module Resources
28
28
  # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/repo/sync.html#scheduling-a-sync
29
29
  class RepositorySchedule < Runcible::Base
30
-
31
30
  # Generates the API path for Repository Schedules
32
31
  #
33
32
  # @param [String] repo_id the ID of the repository
34
33
  # @param [String] importer_id the ID of the importer
35
34
  # @param [String] schedule_id the ID of the schedule
36
35
  # @return [String] the repository schedule path, may contain the ID of the schedule if passed
37
- def self.path(repo_id, importer_id, schedule_id=nil)
36
+ def self.path(repo_id, importer_id, schedule_id = nil)
38
37
  repo_path = Runcible::Resources::Repository.path(repo_id)
39
38
  path = "#{repo_path}importers/#{importer_id}/schedules/sync/"
40
- (schedule_id == nil) ? path : "#{path}#{schedule_id}/"
39
+ (schedule_id.nil?) ? path : "#{path}#{schedule_id}/"
41
40
  end
42
41
 
43
42
  # List the schedules for a repository for a given importer type
@@ -56,9 +55,9 @@ module Runcible
56
55
  # @param [Hash] schedule a hash representing a schedule
57
56
  # @param [Hash] optional container for all optional parameters
58
57
  # @return [RestClient::Response]
59
- def create(repo_id, importer_type, schedule, optional={})
58
+ def create(repo_id, importer_type, schedule, optional = {})
60
59
  call(:post, path(repo_id, importer_type),
61
- :payload => { :required => {:schedule=>schedule}, :optional => optional })
60
+ :payload => { :required => {:schedule => schedule}, :optional => optional })
62
61
  end
63
62
 
64
63
  # Update a schedule for a repository for a given importer type
@@ -68,7 +67,7 @@ module Runcible
68
67
  # @param [String] schedule_id the ID of the schedule
69
68
  # @param [Hash] optional container for all optional parameters
70
69
  # @return [RestClient::Response]
71
- def update(repo_id, importer_type, schedule_id, optional={})
70
+ def update(repo_id, importer_type, schedule_id, optional = {})
72
71
  call(:put, path(repo_id, importer_type, schedule_id),
73
72
  :payload => {:optional => optional })
74
73
  end
@@ -82,7 +81,6 @@ module Runcible
82
81
  def delete(repo_id, importer_type, schedule_id)
83
82
  call(:delete, path(repo_id, importer_type, schedule_id))
84
83
  end
85
-
86
84
  end
87
85
  end
88
86
  end
@@ -21,27 +21,25 @@
21
21
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
-
25
24
  module Runcible
26
25
  module Resources
27
26
  # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/role/index.html
28
27
  class Role < Runcible::Base
29
-
30
28
  # Generates the API path for Roles
31
29
  #
32
30
  # @param [String] id the ID of the role
33
31
  # @return [String] the role path, may contain the ID if passed
34
- def self.path(id=nil)
35
- (id == nil) ? "roles/" : "roles/#{id}/"
32
+ def self.path(id = nil)
33
+ (id.nil?) ? 'roles/' : "roles/#{id}/"
36
34
  end
37
35
 
38
36
  # Adds a user to a role
39
37
  #
40
38
  # @param [String] id the ID of the role
41
39
  # @param [String] login the login of the user being added
42
- # @return [RestClient::Response]
40
+ # @return [RestClient::Response]
43
41
  def add(id, login)
44
- required = required_params(binding.send(:local_variables), binding, ["id"])
42
+ required = required_params(binding.send(:local_variables), binding, ['id'])
45
43
  call(:post, "#{path(id)}users/", :payload => { :required => required })
46
44
  end
47
45
 
@@ -49,11 +47,10 @@ module Runcible
49
47
  #
50
48
  # @param [String] id the ID of the role
51
49
  # @param [String] login the login of the user being removed
52
- # @return [RestClient::Response]
50
+ # @return [RestClient::Response]
53
51
  def remove(id, login)
54
52
  call(:delete, "#{path(id)}users/#{login}/")
55
53
  end
56
-
57
54
  end
58
55
  end
59
56
  end