runcible 0.1.4 → 0.2

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.
@@ -28,16 +28,16 @@ module Runcible
28
28
 
29
29
  def self.bind_all(id, repo_id)
30
30
  # bind the consumer to all repositories with the given repo_id
31
- Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].each do |d|
31
+ Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].collect do |d|
32
32
  self.bind(id, repo_id, d['id'])
33
- end
33
+ end.flatten
34
34
  end
35
35
 
36
36
  def self.unbind_all(id, repo_id)
37
37
  # unbind the consumer from all repositories with the given repo_id
38
- Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].each do |d|
38
+ Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].collect do |d|
39
39
  self.unbind(id, repo_id, d['id'])
40
- end
40
+ end.flatten
41
41
  end
42
42
 
43
43
  def self.install_content(id, type_id, units)
@@ -1,10 +1,34 @@
1
+ # Copyright (c) 2012 Red Hat
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
+
1
25
  module Runcible
2
26
  module Extensions
3
- class Distribution < Runcible::Base
27
+ class Distribution < Runcible::Resources::Unit
4
28
  TYPE = 'distribution'
5
29
 
6
30
  def self.all()
7
- Runcible::Resources::Unit.search(TYPE, {})
31
+ search(TYPE, {})
8
32
  end
9
33
 
10
34
  def self.find(id)
@@ -12,11 +36,11 @@ module Runcible
12
36
  end
13
37
 
14
38
  def self.find_all(ids)
15
- Runcible::Resources::Unit.search(TYPE, :filters=> {:id=> {'$in'=> ids}})
39
+ search(TYPE, :filters=> {:id=> {'$in'=> ids}})
16
40
  end
17
41
 
18
42
  def self.find_all_by_unit_ids(ids)
19
- Runcible::Resources::Unit.search(TYPE, :filters=> {:_id=> {'$in'=> ids}})
43
+ search(TYPE, :filters=> {:_id=> {'$in'=> ids}})
20
44
  end
21
45
 
22
46
  end
@@ -24,11 +24,11 @@
24
24
 
25
25
  module Runcible
26
26
  module Extensions
27
- class Errata < Runcible::Base
27
+ class Errata < Runcible::Resources::Unit
28
28
  TYPE = 'erratum'
29
29
 
30
30
  def self.all()
31
- Runcible::Resources::Unit.search(TYPE, {})
31
+ search(TYPE, {})
32
32
  end
33
33
 
34
34
  def self.find(id)
@@ -36,13 +36,11 @@ module Runcible
36
36
  end
37
37
 
38
38
  def self.find_all(ids)
39
- Runcible::Resources::Unit.search(TYPE, {:filters=>{:id=> {'$in'=> ids}}},
40
- {:include_repos => true})
39
+ search(TYPE, {:filters=> {:_id=> {'$in'=> ids}}}, {:include_repos=>true})
41
40
  end
42
41
 
43
- def self.find_all_by_unit_ids(ids)
44
- Runcible::Resources::Unit.search(TYPE, {:filters=> {:_id=> {'$in'=> ids}}},
45
- {:include_repos=>true})
42
+ def self.find_all_by_errata_ids(ids)
43
+ search(TYPE, {:filters=>{:id=> {'$in'=> ids}}}, {:include_repos => true})
46
44
  end
47
45
 
48
46
  end
@@ -97,14 +97,14 @@ module Runcible
97
97
  # errata_ids
98
98
  def self.errata_copy(source_repo_id, destination_repo_id, optional={})
99
99
  criteria = {:type_ids => ['erratum'], :filters => {}}
100
- criteria[:filters][:unit] = { :id=>{ '$in' => optional[:errata_ids] } } if optional[:errata_ids]
100
+ criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:errata_ids]}} if optional[:errata_ids]
101
101
  payload = {:criteria => criteria}
102
102
  unit_copy(destination_repo_id, source_repo_id, payload)
103
103
  end
104
104
 
105
105
  def self.errata_remove(repo_id, errata_ids)
106
106
  criteria = {:type_ids => ['erratum'], :filters => {}}
107
- criteria[:filters][:unit] = { :id=>{ '$in' => errata_ids } }
107
+ criteria[:filters]['association'] = {'unit_id' => {'$in' => errata_ids}}
108
108
  self.unassociate_units(repo_id, criteria)
109
109
  end
110
110
 
@@ -158,6 +158,11 @@ module Runcible
158
158
  self.unit_search(id, criteria).collect{|i| i['unit_id']}
159
159
  end
160
160
 
161
+ def self.errata(id, filter = {})
162
+ criteria = {:type_ids=>['erratum']}
163
+ self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
164
+ end
165
+
161
166
  def self.distributions(id)
162
167
  criteria = {:type_ids=>['distribution']}
163
168
 
@@ -24,11 +24,11 @@
24
24
 
25
25
  module Runcible
26
26
  module Extensions
27
- class Rpm < Runcible::Base
27
+ class Rpm < Runcible::Resources::Unit
28
28
  TYPE = 'rpm'
29
29
 
30
30
  def self.all
31
- Runcible::Resources::Unit.search(TYPE, {})
31
+ search(TYPE, {})
32
32
  end
33
33
 
34
34
  def self.find(id)
@@ -36,7 +36,7 @@ module Runcible
36
36
  end
37
37
 
38
38
  def self.find_all(ids)
39
- Runcible::Resources::Unit.search(TYPE, {:filters => {'_id'=> {'$in'=> ids}}}, {:include_repos=>true})
39
+ search(TYPE, {:filters => {'_id'=> {'$in'=> ids}}}, {:include_repos=>true})
40
40
  end
41
41
  end
42
42
  end
@@ -24,65 +24,139 @@
24
24
 
25
25
  module Runcible
26
26
  module Resources
27
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/consumer/index.html
27
28
  class Consumer < Runcible::Base
28
29
 
30
+ # Generates the API path for Consumers
31
+ #
32
+ # @param [String] id the ID of the consumer
33
+ # @return [String] the consumer path, may contain the id if passed
29
34
  def self.path(id=nil)
30
35
  (id == nil) ? "consumers/" : "consumers/#{id}/"
31
36
  end
32
37
 
38
+ # Creates a consumer
39
+ #
40
+ # @param [String] id the ID of the consumer
41
+ # @param [Hash] optional container for all optional parameters
42
+ # @return [RestClient::Response]
33
43
  def self.create(id, optional={})
34
44
  required = required_params(binding.send(:local_variables), binding)
35
45
  call(:post, path, :payload => { :required => required, :optional => optional })
36
46
  end
37
47
 
48
+ # Retrieves a consumer
49
+ #
50
+ # @param [String] id the ID of the consumer
51
+ # @return [RestClient::Response]
38
52
  def self.retrieve(id)
39
53
  call(:get, path(id))
40
54
  end
41
55
 
56
+ # Updates a consumer
57
+ #
58
+ # @param [String] id the ID of the consumer
59
+ # @param [Hash] optional container for all optional parameters
60
+ # @return [RestClient::Response]
42
61
  def self.update(id, optional={})
43
62
  call(:put, path(id), :payload => { :delta => optional })
44
63
  end
45
64
 
65
+ # Deletes a consumer
66
+ #
67
+ # @param [String] id the id of the consumer
68
+ # @return [RestClient::Response]
69
+ def self.delete(id)
70
+ call(:delete, path(id))
71
+ end
72
+
73
+ # Create consumer profile
74
+ #
75
+ # @param [String] id the ID of the consumer
76
+ # @param [String] content_type the content type
77
+ # @param [Hash] profile hash representing the consumer profile
78
+ # @return [RestClient::Response]
46
79
  def self.upload_profile(id, content_type, profile)
47
80
  required = required_params(binding.send(:local_variables), binding, ["id"])
48
81
  call(:post, path("#{id}/profiles/"), :payload => { :required => required })
49
82
  end
50
83
 
51
- def self.profile(id, content_type)
84
+ # Retrieve a consumer profile
85
+ #
86
+ # @param [String] id the ID of the consumer
87
+ # @param [String] content_type the content type
88
+ # @return [RestClient::Response]
89
+ def self.retrieve_profile(id, content_type)
52
90
  call(:get, path("#{id}/profiles/#{content_type}/"))
53
91
  end
54
92
 
55
- def self.delete(id)
56
- call(:delete, path(id))
57
- end
58
-
93
+ # Retrieve a consumer binding
94
+ #
95
+ # @param [String] id the ID of the consumer
96
+ # @param [String] repo_id the ID of the repository
97
+ # @param [String] distributor_id the ID of the distributor
98
+ # @return [RestClient::Response]
59
99
  def self.retrieve_binding(id, repo_id, distributor_id)
60
100
  call(:get, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
61
101
  end
62
102
 
103
+ # Retrieve all consumer bindings
104
+ #
105
+ # @param [String] id the ID of the consumer
106
+ # @return [RestClient::Response]
63
107
  def self.retrieve_bindings(id)
64
108
  call(:get, path("#{id}/bindings/"))
65
109
  end
66
110
 
111
+ # Bind a consumer to a repository for a given distributor
112
+ #
113
+ # @param [String] id the ID of the consumer
114
+ # @param [String] repo_id the ID of the repository
115
+ # @param [String] distributor_id the ID of the distributor
116
+ # @return [RestClient::Response]
67
117
  def self.bind(id, repo_id, distributor_id)
68
118
  required = required_params(binding.send(:local_variables), binding, ["id"])
69
- call(:post, path("#{id}/bindings"), :payload => { :required => required })
119
+ call(:post, path("#{id}/bindings/"), :payload => { :required => required })
70
120
  end
71
121
 
122
+ # Unbind a consumer to a repository for a given distributor
123
+ #
124
+ # @param [String] id the ID of the consumer
125
+ # @param [String] repo_id the ID of the repository
126
+ # @param [String] distributor_id the ID of the distributor
127
+ # @return [RestClient::Response]
72
128
  def self.unbind(id, repo_id, distributor_id)
73
129
  call(:delete, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
74
130
  end
75
131
 
132
+ # Install a set of units onto a consumer
133
+ #
134
+ # @param [String] id the ID of the consumer
135
+ # @param [Array] units array of units to install
136
+ # @param [Hash] options hash of install options
137
+ # @return [RestClient::Response]
76
138
  def self.install_units(id, units, options={})
77
139
  required = required_params(binding.send(:local_variables), binding, ["id"])
78
140
  call(:post, path("#{id}/actions/content/install/"), :payload => { :required => required })
79
141
  end
80
142
 
143
+ # Update a set of units on a consumer
144
+ #
145
+ # @param [String] id the ID of the consumer
146
+ # @param [Array] units array of units to update
147
+ # @param [Hash] options hash of update options
148
+ # @return [RestClient::Response]
81
149
  def self.update_units(id, units, options={})
82
150
  required = required_params(binding.send(:local_variables), binding, ["id"])
83
151
  call(:post, path("#{id}/actions/content/update/"), :payload => { :required => required })
84
152
  end
85
153
 
154
+ # Uninstall a set of units from a consumer
155
+ #
156
+ # @param [String] id the ID of the consumer
157
+ # @param [Array] units array of units to uninstall
158
+ # @param [Hash] options hash of uninstall options
159
+ # @return [RestClient::Response]
86
160
  def self.uninstall_units(id, units, options={})
87
161
  required = required_params(binding.send(:local_variables), binding, ["id"])
88
162
  call(:post, path("#{id}/actions/content/uninstall/"), :payload => { :required => required })
@@ -25,62 +25,90 @@ require 'active_support/core_ext/hash'
25
25
 
26
26
  module Runcible
27
27
  module Resources
28
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/consumer/group/index.html
28
29
  class ConsumerGroup < Runcible::Base
29
30
 
31
+ # Generates the API path for Consumer Groups
32
+ #
33
+ # @param [String] id the ID of the consumer group
34
+ # @return [String] the consumer group path, may contain the id if passed
30
35
  def self.path(id=nil)
31
36
  groups = "consumer_groups/"
32
37
  id.nil? ? groups : groups + "#{id}/"
33
38
  end
34
39
 
40
+ # Creates a Consumer Group
41
+ #
42
+ # @param [String] id the ID of the consumer
43
+ # @param [Hash] optional container for all optional parameters
44
+ # @return [RestClient::Response]
35
45
  def self.create(id, optional={})
36
46
  required = required_params(binding.send(:local_variables), binding)
37
47
  call(:post, path, :payload => { :required => required, :optional => optional })
38
48
  end
39
49
 
40
- def self.delete(id)
41
- call(:delete, path(id))
42
- end
43
-
50
+ # Retrieves a Consumer Group
51
+ #
52
+ # @param [String] id the ID of the consumer group
53
+ # @return [RestClient::Response]
44
54
  def self.retrieve(id)
45
55
  call(:get, path(id))
46
56
  end
47
57
 
58
+ # Deletes a Consumer Group
59
+ #
60
+ # @param [String] id the ID of the consumer group
61
+ # @return [RestClient::Response]
62
+ def self.delete(id)
63
+ call(:delete, path(id))
64
+ end
48
65
 
66
+ # Associates Consumers with a Consumer Group
67
+ #
68
+ # @param [String] id the ID of the consumer group
69
+ # @param [Hash] criteria criteria based on Mongo syntax representing consumers to associate
70
+ # @return [RestClient::Response]
49
71
  def self.associate(id, criteria)
50
72
  call(:post, path(id) + "actions/associate/", :payload => {:required => criteria})
51
73
  end
52
74
 
75
+ # Unassociates Consumers with a Consumer Group
76
+ #
77
+ # @param [String] id the ID of the consumer group
78
+ # @param [Hash] criteria criteria based on Mongo syntax representing consumers ta unassociate
79
+ # @return [RestClient::Response]
53
80
  def self.unassociate(id, criteria)
54
81
  call(:post, path(id) + "actions/unassociate/", :payload => {:required => criteria})
55
82
  end
56
83
 
57
- #def self.retrieve_binding(id, repo_id, distributor_id)
58
- # call(:get, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
59
- #end
60
- #
61
- #def self.retrieve_bindings(id)
62
- # call(:get, path("#{id}/bindings/"))
63
- #end
84
+ # Install a set of units to a Consumer Group
64
85
  #
65
- #def self.bind(id, repo_id, distributor_id)
66
- # required = required_params(binding.send(:local_variables), binding, ["id"])
67
- # call(:post, path("#{id}/bindings"), :payload => { :required => required })
68
- #end
69
- #
70
- #def self.unbind(id, repo_id, distributor_id)
71
- # call(:delete, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
72
- #end
73
-
86
+ # @param [String] id the ID of the consumer group
87
+ # @param [Array] units array of units to install
88
+ # @param [Hash] options hash of install options
89
+ # @return [RestClient::Response]
74
90
  def self.install_units(id, units, options={})
75
91
  required = required_params(binding.send(:local_variables), binding, ["id"])
76
92
  call(:post, path("#{id}/actions/content/install/"), :payload => { :required => required })
77
93
  end
78
94
 
95
+ # Update a set of units on a Consumer Group
96
+ #
97
+ # @param [String] id the ID of the consumer group
98
+ # @param [Array] units array of units to update
99
+ # @param [Hash] options hash of update options
100
+ # @return [RestClient::Response]
79
101
  def self.update_units(id, units, options={})
80
102
  required = required_params(binding.send(:local_variables), binding, ["id"])
81
103
  call(:post, path("#{id}/actions/content/update/"), :payload => { :required => required })
82
104
  end
83
105
 
106
+ # Uninstall a set of units from a Consumer Group
107
+ #
108
+ # @param [String] id the ID of the consumer group
109
+ # @param [Array] units array of units to uninstall
110
+ # @param [Hash] options hash of uninstall options
111
+ # @return [RestClient::Response]
84
112
  def self.uninstall_units(id, units, options={})
85
113
  required = required_params(binding.send(:local_variables), binding, ["id"])
86
114
  call(:post, path("#{id}/actions/content/uninstall/"), :payload => { :required => required })
@@ -1,6 +1,30 @@
1
+ # Copyright (c) 2012 Red Hat
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
+
1
24
 
2
25
  module Runcible
3
26
  module Resources
27
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/events/index.html
4
28
  class EventNotifier < Runcible::Base
5
29
 
6
30
  class EventTypes
@@ -14,22 +38,41 @@ module Runcible
14
38
  REST_API = 'rest-api'
15
39
  end
16
40
 
41
+ # Generates the API path for Event Notifiers
42
+ #
43
+ # @param [String] id the ID of the event notifier
44
+ # @return [String] the event notifier path, may contain the ID if passed
45
+ def self.path(id=nil)
46
+ (id == nil) ? "events/" : "events/#{id}/"
47
+ end
48
+
49
+ # Creates an Event Notification
50
+ #
51
+ # @param [String] notifier_type_id the type ID of the event notifier
52
+ # @param [Hash] notifier_config configuration options for the notifier
53
+ # @param [Hash] event_types event types to include in the notifier
54
+ # @return [RestClient::Response]
17
55
  def self.create(notifier_type_id, notifier_config, event_types)
18
56
  required = required_params(binding.send(:local_variables), binding)
19
57
  call(:post, path, :payload => {:required => required})
20
58
  end
21
59
 
60
+ # Deletes an Event Notification
61
+ #
62
+ # @param [String] id the ID of the event notifier
63
+ # @return [RestClient::Response]
22
64
  def self.delete(id)
23
65
  call(:delete, path(id))
24
66
  end
25
67
 
68
+ # List all Event Notifiers
69
+ #
70
+ # @param [String] id the ID of the event notifier
71
+ # @return [RestClient::Response]
26
72
  def self.list
27
73
  call(:get, path)
28
74
  end
29
75
 
30
- def self.path(id=nil)
31
- (id == nil) ? "events/" : "events/#{id}/"
32
- end
33
76
  end
34
77
  end
35
78
  end
@@ -25,78 +25,159 @@ require 'active_support/core_ext/hash'
25
25
 
26
26
  module Runcible
27
27
  module Resources
28
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/repo/index.html
28
29
  class Repository < Runcible::Base
29
30
 
31
+ # Generates the API path for Repositories
32
+ #
33
+ # @param [String] id the id of the repository
34
+ # @return [String] the repository path, may contain the id if passed
30
35
  def self.path(id=nil)
31
36
  (id == nil) ? "repositories/" : "repositories/#{id}/"
32
37
  end
33
38
 
39
+ # Creates a repository
40
+ #
41
+ # @param [String] id the id of the repository
42
+ # @param [Hash] optional container for all optional parameters
43
+ # @return [RestClient::Response]
34
44
  def self.create(id, optional={})
35
45
  required = required_params(binding.send(:local_variables), binding)
36
46
  call(:post, path, :payload => { :required => required, :optional => optional })
37
47
  end
38
48
 
49
+ # Retrieves a repository
50
+ #
51
+ # @param [String] id the id of the repository
52
+ # @param [Hash] params container for optional query parameters
53
+ # @return [RestClient::Response]
39
54
  def self.retrieve(id, params={})
40
55
  call(:get, path(id), :params => params)
41
56
  end
42
57
 
58
+ # Updates a repository
59
+ #
60
+ # @param [String] id the id of the repository
61
+ # @param [Hash] optional container for all optional parameters
62
+ # @return [RestClient::Response]
43
63
  def self.update(id, optional={})
44
64
  call(:put, path(id), :payload => { :delta => optional })
45
65
  end
46
66
 
67
+ # Deletes a repository
68
+ #
69
+ # @param [String] id the id of the repository
70
+ # @return [RestClient::Response]
47
71
  def self.delete(id)
48
72
  call(:delete, path(id))
49
73
  end
50
74
 
75
+ # Retrieve all repositories
76
+ #
77
+ # @param [Hash] optional container for all optional parameters
78
+ # @return [RestClient::Response]
51
79
  def self.retrieve_all(optional={})
52
80
  call(:get, path, :payload => { :optional => optional })
53
81
  end
54
82
 
83
+ # Searches for repositories based on criteria
84
+ #
85
+ # @param [Hash] criteria criteria object containing Mongo syntax
86
+ # @param [Hash] optional container for all optional parameters
87
+ # @return [RestClient::Response]
55
88
  def self.search(criteria, optional={})
56
89
  required = required_params(binding.send(:local_variables), binding)
57
90
  call(:post, path("search"), :payload => { :required => required, :optional => optional })
58
91
  end
59
92
 
93
+ # Associates an importer to a repository
94
+ #
95
+ # @param [String] id the ID of the repository
96
+ # @param [String] importer_type_id the type ID of the importer being associated
97
+ # @param [Hash] importer_config configuration options for the importer
98
+ # @return [RestClient::Response]
60
99
  def self.associate_importer(id, importer_type_id, importer_config)
61
100
  required = required_params(binding.send(:local_variables), binding)
62
101
  call(:post, path("#{id}/importers"), :payload => { :required => required })
63
102
  end
64
103
 
104
+ # Associates a distributor to a repository
105
+ #
106
+ # @param [String] id the ID of the repository
107
+ # @param [String] distributor_type_id the type ID of the distributor being associated
108
+ # @param [Hash] distributor_config configuration options for the distributor
109
+ # @param [Hash] optional container for all optional parameters
110
+ # @return [RestClient::Response]
65
111
  def self.associate_distributor(id, distributor_type_id, distributor_config, optional={})
66
112
  required = required_params(binding.send(:local_variables), binding, ["id"])
67
113
  call(:post, path("#{id}/distributors"), :payload => { :required => required, :optional => optional })
68
114
  end
69
115
 
116
+ # Syncs a repository
117
+ #
118
+ # @param [String] id the id of the repository
119
+ # @param [Hash] optional container for all optional parameters
120
+ # @return [RestClient::Response]
70
121
  def self.sync(id, optional={})
71
122
  call(:post, "#{path(id)}actions/sync/", :payload => { :optional => optional })
72
123
  end
73
124
 
125
+ # History of all sync actions on a repository
126
+ #
127
+ # @param [String] id the id of the repository
128
+ # @return [RestClient::Response]
74
129
  def self.sync_history(id)
75
130
  call(:get, "#{path(id)}/history/sync/")
76
131
  end
77
132
 
78
- def self.unit_copy(destination_repo_id, source_repo_id, optional={:criteria=>{}})
133
+ # Copies units from one repository to another
134
+ #
135
+ # @param [String] destination_repo_id the id of the destination repository
136
+ # @param [String] source_repo_id the id of the source repository
137
+ # @param [Hash] optional container for all optional parameters
138
+ # @return [RestClient::Response]
139
+ def self.unit_copy(destination_repo_id, source_repo_id, optional={})
79
140
  required = required_params(binding.send(:local_variables), binding, ["destination_repo_id"])
80
141
  call(:post, "#{path(destination_repo_id)}actions/associate/",
81
- :payload => { :required => required, :optional=> optional })
142
+ :payload => { :required => required, :optional => optional })
82
143
  end
83
144
 
145
+ # Unassociates units from the repository
146
+ #
147
+ # @param [String] source_repo_id the id of the source repository
148
+ # @param [Hash] criteria criteria object containing Mongo syntax
149
+ # @return [RestClient::Response]
84
150
  def self.unassociate_units(source_repo_id, criteria={})
85
151
  required = required_params(binding.send(:local_variables), binding, ["source_repo_id"])
86
152
  call(:post, "#{path(source_repo_id)}actions/unassociate/",
87
- :payload => { :required => { :criteria => criteria }})
153
+ :payload => { :required => required })
88
154
  end
89
155
 
156
+ # Searches the repository for units based on criteria
157
+ #
158
+ # @param [String] id the id of the repository
159
+ # @param [Hash] criteria criteria object containing Mongo syntax
160
+ # @return [RestClient::Response]
90
161
  def self.unit_search(id, criteria={})
91
162
  call(:post, "#{path(id)}search/units/", :payload=>{:required=>{:criteria=>criteria}})
92
163
  end
93
164
 
94
- def self.publish(repo_id, distributor_id)
95
- call(:post, "#{path(repo_id)}actions/publish/", :payload=>{:required=>{:id=>distributor_id}})
165
+ # Publishes a repository using the specified distributor
166
+ #
167
+ # @param [String] id the id of the repository
168
+ # @param [String] distributor_id the id of the distributor
169
+ # @return [RestClient::Response]
170
+ def self.publish(id, distributor_id)
171
+ call(:post, "#{path(id)}actions/publish/", :payload=>{:required=>{:id=>distributor_id}})
96
172
  end
97
173
 
98
- def self.delete_distributor(repo_id, distributor_id)
99
- call(:delete, "#{path(repo_id)}/distributors/#{distributor_id}/")
174
+ # Deletes the specified distributor from the repository
175
+ #
176
+ # @param [String] id the id of the repository
177
+ # @param [String] distributor_id the id of the distributor
178
+ # @return [RestClient::Response]
179
+ def self.delete_distributor(id, distributor_id)
180
+ call(:delete, "#{path(id)}/distributors/#{distributor_id}/")
100
181
  end
101
182
 
102
183
  end
@@ -25,32 +25,64 @@ require 'active_support/core_ext/hash'
25
25
 
26
26
  module Runcible
27
27
  module Resources
28
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/repo/sync.html#scheduling-a-sync
28
29
  class RepositorySchedule < Runcible::Base
29
30
 
30
- def self.path(repo_id, importer, schedule_id=nil)
31
+ # Generates the API path for Repository Schedules
32
+ #
33
+ # @param [String] repo_id the ID of the repository
34
+ # @param [String] importer_id the ID of the importer
35
+ # @param [String] schedule_id the ID of the schedule
36
+ # @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)
31
38
  repo_path = Runcible::Resources::Repository.path(repo_id)
32
- path = "#{repo_path}importers/#{importer}/schedules/sync/"
39
+ path = "#{repo_path}importers/#{importer_id}/schedules/sync/"
33
40
  (schedule_id == nil) ? path : "#{path}#{schedule_id}/"
34
41
  end
35
42
 
43
+ # List the schedules for a repository for a given importer type
44
+ #
45
+ # @param [String] repo_id the ID of the repository
46
+ # @param [String] importer_type the importer type
47
+ # @return [RestClient::Response]
36
48
  def self.list(repo_id, importer_type)
37
49
  call(:get, path(repo_id, importer_type))
38
50
  end
39
51
 
52
+ # Create a schedule for a repository for a given importer type
53
+ #
54
+ # @param [String] repo_id the ID of the repository
55
+ # @param [String] importer_type the importer type
56
+ # @param [Hash] schedule a hash representing a schedule
57
+ # @param [Hash] optional container for all optional parameters
58
+ # @return [RestClient::Response]
40
59
  def self.create(repo_id, importer_type, schedule, optional={})
41
60
  call(:post, path(repo_id, importer_type),
42
61
  :payload => { :required => {:schedule=>schedule}, :optional => optional })
43
62
  end
44
63
 
45
- # specific call to just update the sync schedule for a repo
64
+ # Update a schedule for a repository for a given importer type
65
+ #
66
+ # @param [String] repo_id the ID of the repository
67
+ # @param [String] importer_type the importer type
68
+ # @param [String] schedule_id the ID of the schedule
69
+ # @param [Hash] optional container for all optional parameters
70
+ # @return [RestClient::Response]
46
71
  def self.update(repo_id, importer_type, schedule_id, optional={})
47
72
  call(:put, path(repo_id, importer_type, schedule_id),
48
73
  :payload => {:optional => optional })
49
74
  end
50
75
 
76
+ # Delete a schedule for a repository for a given importer type
77
+ #
78
+ # @param [String] repo_id the ID of the repository
79
+ # @param [String] importer_type the importer type
80
+ # @param [String] schedule_id the ID of the schedule
81
+ # @return [RestClient::Response]
51
82
  def self.delete(repo_id, importer_type, schedule_id)
52
83
  call(:delete, path(repo_id, importer_type, schedule_id))
53
84
  end
85
+
54
86
  end
55
87
  end
56
88
  end
@@ -24,17 +24,32 @@
24
24
 
25
25
  module Runcible
26
26
  module Resources
27
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/role/index.html
27
28
  class Role < Runcible::Base
28
29
 
29
- def self.path(role=nil)
30
- (role == nil) ? "roles/" : "roles/#{role}/"
30
+ # Generates the API path for Roles
31
+ #
32
+ # @param [String] id the ID of the role
33
+ # @return [String] the role path, may contain the ID if passed
34
+ def self.path(id=nil)
35
+ (id == nil) ? "roles/" : "roles/#{id}/"
31
36
  end
32
37
 
38
+ # Adds a user to a role
39
+ #
40
+ # @param [String] id the ID of the role
41
+ # @param [String] login the login of the user being added
42
+ # @return [RestClient::Response]
33
43
  def self.add(id, login)
34
44
  required = required_params(binding.send(:local_variables), binding, ["id"])
35
45
  call(:post, "#{path(id)}users/", :payload => { :required => required })
36
46
  end
37
47
 
48
+ # Removes a user from a role
49
+ #
50
+ # @param [String] id the ID of the role
51
+ # @param [String] login the login of the user being removed
52
+ # @return [RestClient::Response]
38
53
  def self.remove(id, login)
39
54
  call(:delete, "#{path(id)}users/#{login}/")
40
55
  end
@@ -24,29 +24,49 @@
24
24
 
25
25
  module Runcible
26
26
  module Resources
27
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/dispatch/index.html
27
28
  class Task < Runcible::Base
28
29
 
30
+ # Generates the API path for Tasks
31
+ #
32
+ # @param [String] id the id of the task
33
+ # @return [String] the task path, may contain the id if passed
29
34
  def self.path(id=nil)
30
35
  (id == nil) ? "tasks/" : "tasks/#{id}/"
31
36
  end
32
37
 
38
+ # Polls for the status of a task
39
+ #
40
+ # @param [String] id the id of the task
41
+ # @return [RestClient::Response]
33
42
  def self.poll(id)
34
43
  call(:get, path(id))
35
44
  end
36
45
 
46
+ # Cancels a task
47
+ #
48
+ # @param [String] id the id of the task
49
+ # @return [RestClient::Response]
37
50
  def self.cancel(id)
38
51
  #cancelling a task may require cancelling some higher level
39
52
  # task, so query the tasks _href field to make sure
40
53
  call(:delete, poll(id)['_href'])
41
54
  end
42
55
 
56
+ # List all tasks based on a set of tags
57
+ #
58
+ # @param [Array] tags array of tags to scope the list on
59
+ # @return [RestClient::Response]
43
60
  def self.list(tags=[])
44
61
  call(:get, path, :params=>{:tag=>tags})
45
62
  end
46
63
 
64
+ # Polls all tasks based on array of IDs
65
+ # temporary solution until https://bugzilla.redhat.com/show_bug.cgi?id=860089
66
+ #
67
+ # @param [Array] ids array of ids to poll the status of
68
+ # @return [Array] array of RestClient::Response task poll objects
47
69
  def self.poll_all(ids)
48
- # temporary solution until https://bugzilla.redhat.com/show_bug.cgi?id=860089
49
- # is resolved
50
70
  return ids.collect{|id| self.poll(id)}
51
71
  end
52
72
 
@@ -1,11 +1,46 @@
1
+ # Copyright (c) 2012 Red Hat
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
+
1
25
  module Runcible
2
26
  module Resources
27
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/content/index.html
3
28
  class Unit < Runcible::Base
4
29
 
30
+ # Generates the API path for Units
31
+ #
32
+ # @param [String] type the unit type
33
+ # @return [String] the unit search path
5
34
  def self.path(type)
6
35
  "content/units/#{type}/search/"
7
36
  end
8
37
 
38
+ # Searches a given unit type based on criteria
39
+ #
40
+ # @param [String] type the unit type
41
+ # @param [Hash] criteria criteria object containing Mongo syntax
42
+ # @param [Hash] optional container for all optional parameters
43
+ # @return [RestClient::Response]
9
44
  def self.search(type, criteria, optional={})
10
45
  call(:post, path(type), :payload=>{:required=>{:criteria=>criteria}, :optional=>optional})
11
46
  end
@@ -24,27 +24,48 @@
24
24
 
25
25
  module Runcible
26
26
  module Resources
27
+ # @see https://pulp-dev-guide.readthedocs.org/en/latest/rest-api/user/index.html
27
28
  class User < Runcible::Base
28
29
 
30
+ # Generates the API path for Users
31
+ #
32
+ # @param [String] login the user's login
33
+ # @return [String] the user path, may contain the login if passed
29
34
  def self.path(login=nil)
30
35
  (login == nil) ? "users/" : "users/#{login}/"
31
36
  end
32
37
 
38
+ # Retrieves all users
39
+ #
40
+ # @return [RestClient::Response]
33
41
  def self.retrieve_all
34
42
  call(:get, path)
35
43
  end
36
44
 
45
+ # Creates a user
46
+ #
47
+ # @param [String] login the login requested for the user
48
+ # @param [Hash] optional container for all optional parameters
49
+ # @return [RestClient::Response]
37
50
  def self.create(login, optional={})
38
51
  required = required_params(binding.send(:local_variables), binding)
39
52
  call(:post, path, :payload => { :required => required, :optional => optional })
40
53
  end
41
54
 
42
- def self.retrieve(id)
43
- call(:get, path(id))
55
+ # Retrieves a user
56
+ #
57
+ # @param [String] login the login of the user being retrieved
58
+ # @return [RestClient::Response]
59
+ def self.retrieve(login)
60
+ call(:get, path(login))
44
61
  end
45
62
 
46
- def self.delete(id)
47
- call(:delete, path(id))
63
+ # Deletes a user
64
+ #
65
+ # @param [String] login the login of the user being deleted
66
+ # @return [RestClient::Response]
67
+ def self.delete(login)
68
+ call(:delete, path(login))
48
69
  end
49
70
 
50
71
  end
@@ -1,3 +1,3 @@
1
1
  module Runcible
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2"
3
3
  end
metadata CHANGED
@@ -1,33 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: runcible
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 4
10
- version: 0.1.4
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-12 00:00:00 Z
12
+ date: 2012-11-16 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
22
  - lib/runcible/base.rb
33
23
  - lib/runcible/extensions/errata.rb
@@ -54,36 +44,27 @@ files:
54
44
  - lib/runcible/resources/unit.rb
55
45
  homepage: https://github.com/Katello/runcible
56
46
  licenses: []
57
-
58
47
  post_install_message:
59
48
  rdoc_options: []
60
-
61
- require_paths:
49
+ require_paths:
62
50
  - lib
63
- required_ruby_version: !ruby/object:Gem::Requirement
51
+ required_ruby_version: !ruby/object:Gem::Requirement
64
52
  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
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
58
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
81
63
  requirements: []
82
-
83
64
  rubyforge_project:
84
65
  rubygems_version: 1.8.24
85
66
  signing_key:
86
67
  specification_version: 3
87
- summary: ""
68
+ summary: ''
88
69
  test_files: []
89
-
70
+ has_rdoc: