runcible 0.2.1 → 0.3

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.
data/lib/runcible.rb CHANGED
@@ -29,6 +29,7 @@ resources += Dir[File.dirname(__FILE__) + '/runcible/base.rb']
29
29
  resources += Dir[File.dirname(__FILE__) + '/runcible/resources/*.rb']
30
30
  resources += Dir[File.dirname(__FILE__) + '/runcible/extensions/importer.rb']
31
31
  resources += Dir[File.dirname(__FILE__) + '/runcible/extensions/distributor.rb']
32
+ resources += Dir[File.dirname(__FILE__) + '/runcible/extensions/unit.rb']
32
33
  resources += Dir[File.dirname(__FILE__) + '/runcible/extensions/*.rb']
33
34
 
34
- resources.each{ |f| require f }
35
+ resources.uniq.each{ |f| require f }
@@ -26,32 +26,63 @@ module Runcible
26
26
  module Extensions
27
27
  class Consumer < Runcible::Resources::Consumer
28
28
 
29
+ # Bind a consumer to all repositories with a given ID
30
+ #
31
+ # @param [String] id the consumer ID
32
+ # @param [String] repo_id the repo ID to bind to
33
+ # @return [RestClient::Response] set of tasks representing each bind operation
29
34
  def self.bind_all(id, repo_id)
30
- # bind the consumer to all repositories with the given repo_id
31
35
  Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].collect do |d|
32
36
  self.bind(id, repo_id, d['id'])
33
37
  end.flatten
34
38
  end
35
39
 
40
+ # Unbind a consumer to all repositories with a given ID
41
+ #
42
+ # @param [String] id the consumer ID
43
+ # @param [String] repo_id the repo ID to unbind from
44
+ # @return [RestClient::Response] set of tasks representing each unbind operation
36
45
  def self.unbind_all(id, repo_id)
37
- # unbind the consumer from all repositories with the given repo_id
38
46
  Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].collect do |d|
39
47
  self.unbind(id, repo_id, d['id'])
40
48
  end.flatten
41
49
  end
42
50
 
51
+ # Install content to a consumer
52
+ #
53
+ # @param [String] id the consumer ID
54
+ # @param [String] type_id the type of content to install (e.g. rpm, errata)
55
+ # @param [Array] units array of units to install
56
+ # @return [RestClient::Response] task representing the install operation
43
57
  def self.install_content(id, type_id, units)
44
58
  self.install_units(id, generate_content(type_id, units))
45
59
  end
46
60
 
61
+ # Update content on a consumer
62
+ #
63
+ # @param [String] id the consumer ID
64
+ # @param [String] type_id the type of content to update (e.g. rpm, errata)
65
+ # @param [Array] units array of units to update
66
+ # @return [RestClient::Response] task representing the update operation
47
67
  def self.update_content(id, type_id, units)
48
68
  self.update_units(id, generate_content(type_id, units))
49
69
  end
50
70
 
71
+ # Uninstall content from a consumer
72
+ #
73
+ # @param [String] id the consumer ID
74
+ # @param [String] type_id the type of content to uninstall (e.g. rpm, errata)
75
+ # @param [Array] units array of units to uninstall
76
+ # @return [RestClient::Response] task representing the uninstall operation
51
77
  def self.uninstall_content(id, type_id, units)
52
78
  self.uninstall_units(id, generate_content(type_id, units))
53
79
  end
54
80
 
81
+ # Generate the content units used by other functions
82
+ #
83
+ # @param [String] type_id the type of content (e.g. rpm, errata)
84
+ # @param [Array] units array of units
85
+ # @return [Array] array of formatted content units
55
86
  def self.generate_content(type_id, units)
56
87
  content = []
57
88
  units.each do |unit|
@@ -26,14 +26,28 @@ module Runcible
26
26
  module Extensions
27
27
  class ConsumerGroup < Runcible::Resources::ConsumerGroup
28
28
 
29
+ # Add consumers by ID to a consumer group
30
+ #
31
+ # @param [String] id the consumer group ID
32
+ # @param [Array] consumer_ids array of consumer IDs to add to the group
33
+ # @return [RestClient::Response] list of consumer IDs
29
34
  def self.add_consumers_by_id(id, consumer_ids)
30
35
  self.associate(id, make_consumer_criteria(consumer_ids))
31
36
  end
32
37
 
38
+ # Remove consumers by ID from a consumer group
39
+ #
40
+ # @param [String] id the consumer group ID
41
+ # @param [Array] consumer_ids array of consumer IDs to remove from the group
42
+ # @return [RestClient::Response] list of consumer IDs
33
43
  def self.remove_consumers_by_id(id, consumer_ids)
34
44
  self.unassociate(id, make_consumer_criteria(consumer_ids))
35
45
  end
36
46
 
47
+ # Generates consumer criteria query
48
+ #
49
+ # @param [Array] consumer_ids array of consumer IDs
50
+ # @return [Hash] the formatted query for consumers
37
51
  def self.make_consumer_criteria(consumer_ids)
38
52
  {:criteria =>
39
53
  {:filters =>
@@ -42,18 +56,41 @@ module Runcible
42
56
  }
43
57
  end
44
58
 
59
+ # Install content to a consumer group
60
+ #
61
+ # @param [String] id the consumer group ID
62
+ # @param [String] type_id the type of content to install (e.g. rpm, errata)
63
+ # @param [Array] units array of units to install
64
+ # @return [RestClient::Response] task representing the install operation
45
65
  def self.install_content(id, type_id, units)
46
66
  self.install_units(id, generate_content(type_id, units))
47
67
  end
48
68
 
69
+ # Update content on a consumer group
70
+ #
71
+ # @param [String] id the consumer group ID
72
+ # @param [String] type_id the type of content to update (e.g. rpm, errata)
73
+ # @param [Array] units array of units to update
74
+ # @return [RestClient::Response] task representing the update operation
49
75
  def self.update_content(id, type_id, units)
50
76
  self.update_units(id, generate_content(type_id, units))
51
77
  end
52
78
 
79
+ # Uninstall content from a consumer group
80
+ #
81
+ # @param [String] id the consumer group ID
82
+ # @param [String] type_id the type of content to uninstall (e.g. rpm, errata)
83
+ # @param [Array] units array of units to uninstall
84
+ # @return [RestClient::Response] task representing the uninstall operation
53
85
  def self.uninstall_content(id, type_id, units)
54
86
  self.uninstall_units(id, generate_content(type_id, units))
55
87
  end
56
88
 
89
+ # Generate the content units used by other functions
90
+ #
91
+ # @param [String] type_id the type of content (e.g. rpm, errata)
92
+ # @param [Array] units array of units
93
+ # @return [Array] array of formatted content units
57
94
  def self.generate_content(type_id, units)
58
95
  content = []
59
96
  units.each do |unit|
@@ -24,23 +24,10 @@
24
24
 
25
25
  module Runcible
26
26
  module Extensions
27
- class Distribution < Runcible::Resources::Unit
28
- TYPE = 'distribution'
27
+ class Distribution < Runcible::Extensions::Unit
29
28
 
30
- def self.all()
31
- search(TYPE, {})
32
- end
33
-
34
- def self.find(id)
35
- find_all([id]).first
36
- end
37
-
38
- def self.find_all(ids)
39
- search(TYPE, :filters=> {:id=> {'$in'=> ids}})
40
- end
41
-
42
- def self.find_all_by_unit_ids(ids)
43
- search(TYPE, :filters=> {:_id=> {'$in'=> ids}})
29
+ def self.content_type
30
+ 'distribution'
44
31
  end
45
32
 
46
33
  end
@@ -24,23 +24,10 @@
24
24
 
25
25
  module Runcible
26
26
  module Extensions
27
- class Errata < Runcible::Resources::Unit
28
- TYPE = 'erratum'
27
+ class Errata < Runcible::Extensions::Unit
29
28
 
30
- def self.all()
31
- search(TYPE, {})
32
- end
33
-
34
- def self.find(id)
35
- find_all([id]).first
36
- end
37
-
38
- def self.find_all(ids)
39
- search(TYPE, {:filters=> {:_id=> {'$in'=> ids}}}, {:include_repos=>true})
40
- end
41
-
42
- def self.find_all_by_errata_ids(ids)
43
- search(TYPE, {:filters=>{:id=> {'$in'=> ids}}}, {:include_repos => true})
29
+ def self.content_type
30
+ 'erratum'
44
31
  end
45
32
 
46
33
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Justin Sherrill
1
+ # Copyright (c) 2012
2
2
  #
3
3
  # MIT License
4
4
  #
@@ -27,7 +27,9 @@ require 'active_support/json'
27
27
 
28
28
  module Runcible
29
29
  module Extensions
30
- #Importers should supply id & config methods
30
+
31
+ # Generic class to represent Pulp Importers
32
+ # Child classes should supply id & config methods
31
33
  class Importer
32
34
  def initialize(params={})
33
35
  params.each{|k,v| self.send("#{k.to_s}=",v)}
@@ -35,4 +37,4 @@ module Runcible
35
37
  end
36
38
 
37
39
  end
38
- end
40
+ end
@@ -1,22 +1,33 @@
1
- module Runcible
2
- module Extensions
3
- class PackageCategory < Runcible::Base
4
- TYPE = 'package_category'
5
-
6
- def self.all
7
- Runcible::Resources::Unit.search(TYPE, {})
8
- end
1
+ # Copyright (c) 2012
2
+ #
3
+ # MIT License
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
23
 
10
- def self.find(id)
11
- find_all([id]).first
12
- end
13
24
 
14
- def self.find_all(ids)
15
- Runcible::Resources::Unit.search(TYPE, :filters => {'id'=> {'$in'=> ids}})
16
- end
25
+ module Runcible
26
+ module Extensions
27
+ class PackageCategory < Runcible::Extensions::Unit
17
28
 
18
- def self.find_all_by_unit_ids(ids)
19
- Runcible::Resources::Unit.search(TYPE, :filters => {:_id=> {'$in'=> ids}})
29
+ def self.content_type
30
+ 'package_category'
20
31
  end
21
32
 
22
33
  end
@@ -1,22 +1,33 @@
1
- module Runcible
2
- module Extensions
3
- class PackageGroup < Runcible::Base
4
- TYPE = 'package_group'
5
-
6
- def self.all
7
- Runcible::Resources::Unit.search(TYPE, {})
8
- end
1
+ # Copyright (c) 2012
2
+ #
3
+ # MIT License
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
23
 
10
- def self.find(id)
11
- find_all([id]).first
12
- end
13
24
 
14
- def self.find_all(ids)
15
- Runcible::Resources::Unit.search(TYPE, :filters => {'id'=> {'$in'=> ids}})
16
- end
25
+ module Runcible
26
+ module Extensions
27
+ class PackageGroup < Runcible::Extensions::Unit
17
28
 
18
- def self.find_all_by_unit_ids(ids)
19
- Runcible::Resources::Unit.search(TYPE, :filters => {:_id=> {'$in'=> ids}})
29
+ def self.content_type
30
+ 'package_group'
20
31
  end
21
32
 
22
33
  end
@@ -26,14 +26,31 @@ module Runcible
26
26
  module Extensions
27
27
  class Repository < Runcible::Resources::Repository
28
28
 
29
+ # Utility function that allows an importer to be added at repository creation time
30
+ #
31
+ # @param [String] id the id of the repository being created
32
+ # @param [Hash, Runcible::Extensions::Importer] importer either a hash representing an importer or an Importer object
33
+ # @return [RestClient::Response] the created repository
29
34
  def self.create_with_importer(id, importer)
30
35
  create_with_importer_and_distributors(id, importer)
31
36
  end
32
37
 
38
+ # Utility function that allows distributors to be added at repository creation time
39
+ #
40
+ # @param [String] id the id of the repository being created
41
+ # @param [Array] distributors an array of hashes representing distributors or an array of Distributor objects
42
+ # @return [RestClient::Response] the created repository
33
43
  def self.create_with_distributors(id, distributors)
34
44
  create_with_importer_and_distributors(id, nil, distributors)
35
45
  end
36
46
 
47
+ # Utility function that allows an importer and distributors to be added at repository creation time
48
+ #
49
+ # @param [String] id the id of the repository being created
50
+ # @param [Hash, Runcible::Extensions::Importer] importer either a hash representing an importer or an Importer object
51
+ # @param [Array] distributors an array of hashes representing distributors or an array of Distributor objects
52
+ # @param [Hash] optional container for all optional parameters
53
+ # @return [RestClient::Response] the created repository
37
54
  def self.create_with_importer_and_distributors(id, importer, distributors=[], optional={})
38
55
  if importer.is_a?(Importer)
39
56
  optional[:importer_type_id] = importer.id
@@ -62,10 +79,18 @@ module Runcible
62
79
  create(id, optional)
63
80
  end
64
81
 
82
+ # Retrieves the sync status for a repository
83
+ #
84
+ # @param [String] repo_id the repository ID
85
+ # @return [RestClient::Response] a task representing the sync status
65
86
  def self.sync_status(repo_id)
66
87
  Runcible::Resources::Task.list(["pulp:repository:#{repo_id}", "pulp:action:sync"])
67
88
  end
68
89
 
90
+ # Retrieves a set of repositories by their IDs
91
+ #
92
+ # @param [Array] repository_ids the repository ID
93
+ # @return [RestClient::Response] the set of repositories requested
69
94
  def self.search_by_repository_ids(repository_ids)
70
95
  criteria = {:filters =>
71
96
  { "id" => {"$in" => repository_ids}}
@@ -73,9 +98,16 @@ module Runcible
73
98
  search(criteria)
74
99
  end
75
100
 
101
+ # Copies RPMs from one repository to another
102
+ #
76
103
  # optional
77
104
  # :package_ids
78
105
  # :name_blacklist
106
+ #
107
+ # @param [String] source_repo_id the source repository ID
108
+ # @param [String] destination_repo_id the destination repository ID
109
+ # @param [Hash] optional container for all optional parameters
110
+ # @return [RestClient::Response] a task representing the unit copy operation
79
111
  def self.rpm_copy(source_repo_id, destination_repo_id, optional={})
80
112
 
81
113
  criteria = {:type_ids => ['rpm'], :filters => {}}
@@ -87,14 +119,26 @@ module Runcible
87
119
  unit_copy(destination_repo_id, source_repo_id, payload)
88
120
  end
89
121
 
90
- def self.rpm_remove(repo_id, package_ids)
122
+ # Removes RPMs from a repository
123
+ #
124
+ # @param [String] repo_id the repository ID to remove RPMs from
125
+ # @param [Array] rpm_ids array of RPM IDs to remove
126
+ # @return [RestClient::Response] a task representing the unit unassociate operation
127
+ def self.rpm_remove(repo_id, rpm_ids)
91
128
  criteria = {:type_ids => ['rpm'], :filters => {}}
92
- criteria[:filters]['association'] = {'unit_id' => {'$in' => package_ids}}
129
+ criteria[:filters]['association'] = {'unit_id' => {'$in' => rpm_ids}}
93
130
  self.unassociate_units(repo_id, criteria)
94
131
  end
95
132
 
96
- #optional
97
- # errata_ids
133
+ # Copies errata from one repository to another
134
+ #
135
+ # optional
136
+ # :errata_ids
137
+ #
138
+ # @param [String] source_repo_id the source repository ID
139
+ # @param [String] destination_repo_id the destination repository ID
140
+ # @param [Hash] optional container for all optional parameters
141
+ # @return [RestClient::Response] a task representing the unit copy operation
98
142
  def self.errata_copy(source_repo_id, destination_repo_id, optional={})
99
143
  criteria = {:type_ids => ['erratum'], :filters => {}}
100
144
  criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:errata_ids]}} if optional[:errata_ids]
@@ -102,14 +146,26 @@ module Runcible
102
146
  unit_copy(destination_repo_id, source_repo_id, payload)
103
147
  end
104
148
 
149
+ # Removes errata from a repository
150
+ #
151
+ # @param [String] repo_id the repository ID to remove errata from
152
+ # @param [Array] errata_ids array of errata IDs to remove
153
+ # @return [RestClient::Response] a task representing the unit unassociate operation
105
154
  def self.errata_remove(repo_id, errata_ids)
106
155
  criteria = {:type_ids => ['erratum'], :filters => {}}
107
156
  criteria[:filters]['association'] = {'unit_id' => {'$in' => errata_ids}}
108
157
  self.unassociate_units(repo_id, criteria)
109
158
  end
110
159
 
111
- #optoinal
112
- # distribution_ids
160
+ # Copies distributions from one repository to another
161
+ #
162
+ # optoinal
163
+ # :distribution_ids
164
+ #
165
+ # @param [String] source_repo_id the source repository ID
166
+ # @param [String] destination_repo_id the destination repository ID
167
+ # @param [Hash] optional container for all optional parameters
168
+ # @return [RestClient::Response] a task representing the unit copy operation
113
169
  def self.distribution_copy(source_repo_id, destination_repo_id, optional={})
114
170
  criteria = {:type_ids => ['distribution'], :filters => {}}
115
171
  criteria[:filters][:unit] = { :id=>{ '$in' => optional[:distribution_ids] } } if optional[:distribution_ids]
@@ -117,30 +173,60 @@ module Runcible
117
173
  unit_copy(destination_repo_id, source_repo_id, payload)
118
174
  end
119
175
 
120
- def self.package_group_copy(source_repo_id, destination_repo_id, optional={})
121
- criteria = {:type_ids => [Runcible::Extensions::PackageGroup::TYPE], :filters => {}}
122
- criteria[:filters][:unit] = { :id=>{ '$in' => optional[:package_group_ids] } } if optional[:package_group_ids]
123
- payload = {:criteria => criteria}
124
- unit_copy(destination_repo_id, source_repo_id, payload)
125
- end
126
-
176
+ # Removes a distribution from a repository
177
+ #
178
+ # @param [String] repo_id the repository ID to remove the distribution from
179
+ # @param [String] distribution_id the distribution ID to remove
180
+ # @return [RestClient::Response] a task representing the unit unassociate operation
127
181
  def self.distribution_remove(repo_id, distribution_id)
128
182
  criteria = {:type_ids => ['distribution'], :filters => {}}
129
183
  criteria[:filters][:unit] = { :id=>{ '$in' => [distribution_id] } }
130
184
  self.unassociate_units(repo_id, criteria)
131
185
  end
132
186
 
187
+ # Copies package groups from one repository to another
188
+ #
189
+ # optoinal
190
+ # :package_group_ids
191
+ #
192
+ # @param [String] source_repo_id the source repository ID
193
+ # @param [String] destination_repo_id the destination repository ID
194
+ # @param [Hash] optional container for all optional parameters
195
+ # @return [RestClient::Response] a task representing the unit copy operation
196
+ def self.package_group_copy(source_repo_id, destination_repo_id, optional={})
197
+ criteria = {:type_ids => [Runcible::Extensions::PackageGroup.content_type], :filters => {}}
198
+ criteria[:filters][:unit] = { :id=>{ '$in' => optional[:package_group_ids] } } if optional[:package_group_ids]
199
+ payload = {:criteria => criteria}
200
+ unit_copy(destination_repo_id, source_repo_id, payload)
201
+ end
202
+
203
+ # Retrieves the RPM IDs for a single repository
204
+ #
205
+ # @param [String] id the ID of the repository
206
+ # @return [RestClient::Response] the set of repository RPM IDs
133
207
  def self.rpm_ids(id)
134
208
  criteria = {:type_ids=>['rpm']}
135
209
  self.unit_search(id, criteria).collect{|i| i['unit_id']}
136
210
  end
137
211
 
212
+ # Retrieves the RPMs for a single repository
213
+ #
214
+ # @param [String] id the ID of the repository
215
+ # @return [RestClient::Response] the set of repository RPMs
138
216
  def self.rpms(id)
139
217
  criteria = {:type_ids=>['rpm']}
140
218
  self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
141
219
  end
142
220
 
143
- def self.packages_by_nvre(id, name, version=nil, release=nil, epoch=nil)
221
+ # Retrieves the RPMs by NVRE for a single repository
222
+ #
223
+ # @param [String] id the ID of the repository
224
+ # @param [String] name the name of the RPMs
225
+ # @param [String] version the version of the RPMs
226
+ # @param [String] release the release of the RPMs
227
+ # @param [String] epoch the epoch of the RPMs
228
+ # @return [RestClient::Response] the set of repository RPMs
229
+ def self.rpms_by_nvre(id, name, version=nil, release=nil, epoch=nil)
144
230
  and_condition = []
145
231
  and_condition << {:name=>name} if name
146
232
  and_condition << {:version=>version} if version
@@ -159,34 +245,60 @@ module Runcible
159
245
  self.unit_search(id, criteria).collect{|p| p['metadata'].with_indifferent_access}
160
246
  end
161
247
 
162
- def self.errata_ids(id, filter = {})
248
+ # Retrieves the errata IDs for a single repository
249
+ #
250
+ # @param [String] id the ID of the repository
251
+ # @return [RestClient::Response] the set of repository errata IDs
252
+ def self.errata_ids(id)
163
253
  criteria = {:type_ids=>['erratum']}
164
254
 
165
255
  self.unit_search(id, criteria).collect{|i| i['unit_id']}
166
256
  end
167
257
 
168
- def self.errata(id, filter = {})
258
+ # Retrieves the errata for a single repository
259
+ #
260
+ # @param [String] id the ID of the repository
261
+ # @return [RestClient::Response] the set of repository errata
262
+ def self.errata(id)
169
263
  criteria = {:type_ids=>['erratum']}
170
264
  self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
171
265
  end
172
266
 
267
+ # Retrieves the distributions for a single repository
268
+ #
269
+ # @param [String] id the ID of the repository
270
+ # @return [RestClient::Response] the set of repository distributions
173
271
  def self.distributions(id)
174
272
  criteria = {:type_ids=>['distribution']}
175
273
 
176
274
  self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
177
275
  end
178
276
 
277
+ # Retrieves the package groups for a single repository
278
+ #
279
+ # @param [String] id the ID of the repository
280
+ # @return [RestClient::Response] the set of repository package groups
179
281
  def self.package_groups(id)
180
- criteria = {:type_ids=>[Runcible::Extensions::PackageGroup::TYPE]}
282
+ criteria = {:type_ids=>[Runcible::Extensions::PackageGroup.content_type]}
181
283
 
182
284
  self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
183
285
  end
184
286
 
287
+ # Retrieves the package group categoriess for a single repository
288
+ #
289
+ # @param [String] id the ID of the repository
290
+ # @return [RestClient::Response] the set of repository package group categories
185
291
  def self.package_categories(id)
186
- criteria = {:type_ids=>[Runcible::Extensions::PackageCategory::TYPE]}
292
+ criteria = {:type_ids=>[Runcible::Extensions::PackageCategory.content_type]}
187
293
  self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
188
294
  end
189
295
 
296
+ # Creates or updates a sync schedule for a repository
297
+ #
298
+ # @param [String] repo_id the ID of the repository
299
+ # @param [String] type the importer type
300
+ # @param [String] schedule the time as an iso8601 interval
301
+ # @return [RestClient::Response] the newly created or updated schedule
190
302
  def self.create_or_update_schedule(repo_id, type, schedule)
191
303
  schedules = Runcible::Resources::RepositorySchedule.list(repo_id, type)
192
304
  if schedules.empty?
@@ -196,6 +308,11 @@ module Runcible
196
308
  end
197
309
  end
198
310
 
311
+ # Removes a scheduled sync from a repository
312
+ #
313
+ # @param [String] repo_id the ID of the repository
314
+ # @param [String] type the importer type
315
+ # @return [RestClient::Response]
199
316
  def self.remove_schedules(repo_id, type)
200
317
  schedules = Runcible::Resources::RepositorySchedule.list(repo_id, type)
201
318
  schedules.each do |schedule|
@@ -203,6 +320,10 @@ module Runcible
203
320
  end
204
321
  end
205
322
 
323
+ # Publishes a repository for all of it's distributors
324
+ #
325
+ # @param [String] repo_id the ID of the repository
326
+ # @return [RestClient::Response] set of tasks representing each publish
206
327
  def self.publish_all(repo_id)
207
328
  to_ret = []
208
329
  self.retrieve_with_details(repo_id)['distributors'].each do |d|
@@ -211,9 +332,14 @@ module Runcible
211
332
  to_ret
212
333
  end
213
334
 
335
+ # Retrieves a repository with details that include importer and distributors
336
+ #
337
+ # @param [String] repo_id the ID of the repository
338
+ # @return [RestClient::Response] the repository with full details
214
339
  def self.retrieve_with_details(repo_id)
215
340
  self.retrieve(repo_id, {:details => true})
216
341
  end
342
+
217
343
  end
218
344
  end
219
345
  end
@@ -24,20 +24,22 @@
24
24
 
25
25
  module Runcible
26
26
  module Extensions
27
- class Rpm < Runcible::Resources::Unit
28
- TYPE = 'rpm'
27
+ class Rpm < Runcible::Extensions::Unit
29
28
 
30
- def self.all
31
- search(TYPE, {})
29
+ def self.content_type
30
+ 'rpm'
32
31
  end
33
32
 
34
- def self.find(id)
35
- find_all([id]).first
33
+ # This function is not implemented for RPMs since they do not have content IDs
34
+ def self.find
35
+ raise NotImplementedError
36
36
  end
37
37
 
38
- def self.find_all(ids)
39
- search(TYPE, {:filters => {'_id'=> {'$in'=> ids}}}, {:include_repos=>true})
38
+ # This function is not implemented for RPMs since they do not have content IDs
39
+ def self.find_all
40
+ raise NotImplementedError
40
41
  end
42
+
41
43
  end
42
44
  end
43
45
  end
@@ -0,0 +1,79 @@
1
+ # Copyright (c) 2012
2
+ #
3
+ # MIT License
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ module Runcible
26
+ module Extensions
27
+ class Unit < Runcible::Resources::Unit
28
+
29
+ # The content type (e.g. rpm, errata)
30
+ def self.content_type
31
+ ''
32
+ end
33
+
34
+ # Retrieves all content of a certain @@type
35
+ #
36
+ # @return [RestClient::Response] list of all content for the given type
37
+ def self.all
38
+ self.search(content_type, {})
39
+ end
40
+
41
+ # Retrieves a single content by it's content ID
42
+ #
43
+ # @param [Array] id the content ID of the content to retrieve
44
+ # @return [RestClient::Response] the requested content
45
+ def self.find(id, optional={})
46
+ optional ||= { :include_repos => true }
47
+ find_all([id], optional).first
48
+ end
49
+
50
+ # Retrieves a set of content by the contents IDs
51
+ #
52
+ # @param [Array] ids list of content IDs to retrieve
53
+ # @return [RestClient::Response] list of content
54
+ def self.find_all(ids, optional={})
55
+ optional ||= { :include_repos => true }
56
+ self.search(content_type, { :filters => {'id'=> {'$in'=> ids}} }, optional)
57
+ end
58
+
59
+ # Retrieves a single content by it's unit ID
60
+ #
61
+ # @param [Array] id the unit ID of the content to retrieve
62
+ # @return [RestClient::Response] the requested content
63
+ def self.find_by_unit_id(id, optional={})
64
+ optional ||= { :include_repos => true }
65
+ find_all_by_unit_ids([id], optional).first
66
+ end
67
+
68
+ # Retrieves a set of content by the Pulp unit IDs
69
+ #
70
+ # @param [Array] ids list of content unit IDs to retrieve
71
+ # @return [RestClient::Response] list of content
72
+ def self.find_all_by_unit_ids(ids, optional={})
73
+ optional ||= { :include_repos => true }
74
+ self.search(content_type, { :filters => {:_id=> {'$in'=> ids}} }, optional)
75
+ end
76
+
77
+ end
78
+ end
79
+ end
@@ -41,4 +41,4 @@ module Runcible
41
41
  end
42
42
  end
43
43
  end
44
- end
44
+ end
@@ -28,14 +28,14 @@ module Runcible
28
28
  class EventNotifier < Runcible::Base
29
29
 
30
30
  class EventTypes
31
- REPO_SYNC_COMPLETE = 'repo.sync.finish'
32
- REPO_SYNC_START = 'repo.sync.start'
31
+ REPO_SYNC_COMPLETE = 'repo.sync.finish'
32
+ REPO_SYNC_START = 'repo.sync.start'
33
33
  REPO_PUBLISH_COMPLETE = 'repo.publish.finish'
34
- REPO_PUBLISH_START = 'repo.publish.start'
34
+ REPO_PUBLISH_START = 'repo.publish.start'
35
35
  end
36
36
 
37
37
  class NotifierTypes
38
- REST_API = 'rest-api'
38
+ REST_API = 'http'
39
39
  end
40
40
 
41
41
  # Generates the API path for Event Notifiers
@@ -1,3 +1,3 @@
1
1
  module Runcible
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3"
3
3
  end
metadata CHANGED
@@ -1,90 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: runcible
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.3'
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Eric D Helms
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-11-29 00:00:00 Z
12
+ date: 2013-01-11 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: Exposing Pulp's juiciest components to the Ruby world.
22
- email:
15
+ email:
23
16
  - ehelms@redhat.com
24
17
  executables: []
25
-
26
18
  extensions: []
27
-
28
19
  extra_rdoc_files: []
29
-
30
- files:
20
+ files:
31
21
  - lib/runcible.rb
32
- - lib/runcible/resources/role.rb
33
- - lib/runcible/resources/unit.rb
34
- - lib/runcible/resources/consumer_group.rb
35
- - lib/runcible/resources/user.rb
36
- - lib/runcible/resources/task.rb
37
- - lib/runcible/resources/repository.rb
38
- - lib/runcible/resources/event_notifier.rb
39
- - lib/runcible/resources/consumer.rb
40
- - lib/runcible/resources/repository_schedule.rb
41
22
  - lib/runcible/base.rb
42
- - lib/runcible/version.rb
43
23
  - lib/runcible/extensions/consumer_group.rb
24
+ - lib/runcible/extensions/consumer.rb
25
+ - lib/runcible/extensions/rpm.rb
26
+ - lib/runcible/extensions/errata.rb
44
27
  - lib/runcible/extensions/repository.rb
45
28
  - lib/runcible/extensions/package_category.rb
46
29
  - lib/runcible/extensions/yum_importer.rb
47
- - lib/runcible/extensions/consumer.rb
48
- - lib/runcible/extensions/package_group.rb
49
- - lib/runcible/extensions/yum_distributor.rb
50
30
  - lib/runcible/extensions/importer.rb
31
+ - lib/runcible/extensions/unit.rb
51
32
  - lib/runcible/extensions/distributor.rb
52
- - lib/runcible/extensions/rpm.rb
53
33
  - lib/runcible/extensions/distribution.rb
54
- - lib/runcible/extensions/errata.rb
34
+ - lib/runcible/extensions/yum_distributor.rb
35
+ - lib/runcible/extensions/package_group.rb
36
+ - lib/runcible/resources/task.rb
37
+ - lib/runcible/resources/consumer_group.rb
38
+ - lib/runcible/resources/consumer.rb
39
+ - lib/runcible/resources/repository_schedule.rb
40
+ - lib/runcible/resources/user.rb
41
+ - lib/runcible/resources/repository.rb
42
+ - lib/runcible/resources/role.rb
43
+ - lib/runcible/resources/unit.rb
44
+ - lib/runcible/resources/event_notifier.rb
45
+ - lib/runcible/version.rb
55
46
  homepage: https://github.com/Katello/runcible
56
47
  licenses: []
57
-
58
48
  post_install_message:
59
49
  rdoc_options: []
60
-
61
- require_paths:
50
+ require_paths:
62
51
  - lib
63
- required_ruby_version: !ruby/object:Gem::Requirement
52
+ required_ruby_version: !ruby/object:Gem::Requirement
64
53
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- hash: 3
69
- segments:
70
- - 0
71
- version: "0"
72
- required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
59
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
81
64
  requirements: []
82
-
83
65
  rubyforge_project:
84
- rubygems_version: 1.8.11
66
+ rubygems_version: 1.8.24
85
67
  signing_key:
86
68
  specification_version: 3
87
- summary: ""
69
+ summary: ''
88
70
  test_files: []
89
-
90
71
  has_rdoc: