deadwood 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +19 -0
- data/README.md +19 -0
- data/Rakefile +65 -0
- data/examples/deadwood-config.yml +5 -0
- data/lib/deadwood.rb +45 -0
- data/lib/deadwood/active_resource_oauth_client.rb +74 -0
- data/lib/deadwood/model/activation_key.rb +24 -0
- data/lib/deadwood/model/base.rb +82 -0
- data/lib/deadwood/model/changeset.rb +28 -0
- data/lib/deadwood/model/consumer.rb +18 -0
- data/lib/deadwood/model/crl.rb +18 -0
- data/lib/deadwood/model/entitlement.rb +18 -0
- data/lib/deadwood/model/environment.rb +40 -0
- data/lib/deadwood/model/errata.rb +18 -0
- data/lib/deadwood/model/gpg_key.rb +37 -0
- data/lib/deadwood/model/organization.rb +21 -0
- data/lib/deadwood/model/pool.rb +18 -0
- data/lib/deadwood/model/product.rb +33 -0
- data/lib/deadwood/model/provider.rb +24 -0
- data/lib/deadwood/model/repository.rb +18 -0
- data/lib/deadwood/model/role.rb +38 -0
- data/lib/deadwood/model/status.rb +18 -0
- data/lib/deadwood/model/subscription.rb +18 -0
- data/lib/deadwood/model/system.rb +24 -0
- data/lib/deadwood/model/system_group.rb +33 -0
- data/lib/deadwood/model/task.rb +18 -0
- data/lib/deadwood/model/template.rb +24 -0
- data/lib/deadwood/model/user.rb +28 -0
- data/lib/deadwood/model/version.rb +18 -0
- data/rake/rpmtask.rb +126 -0
- data/spec/models/activation_key_spec.rb +35 -0
- data/spec/models/base_spec.rb +30 -0
- data/spec/models/changeset_spec.rb +38 -0
- data/spec/models/crl_spec.rb +25 -0
- data/spec/models/environment_spec.rb +54 -0
- data/spec/models/gpg_key_spec.rb +30 -0
- data/spec/models/organization_spec.rb +75 -0
- data/spec/models/product_spec.rb +38 -0
- data/spec/models/provider_spec.rb +72 -0
- data/spec/models/repository_spec.rb +36 -0
- data/spec/models/role_spec.rb +57 -0
- data/spec/models/system_group_spec.rb +31 -0
- data/spec/models/task_spec.rb +26 -0
- data/spec/models/template_spec.rb +37 -0
- data/spec/models/user_spec.rb +53 -0
- data/spec/spec_helper.rb +50 -0
- data/spec/vcr/cassettes/create_activation_key.yml +255 -0
- data/spec/vcr/cassettes/create_changeset.yml +257 -0
- data/spec/vcr/cassettes/create_find_all_environment.yml +130 -0
- data/spec/vcr/cassettes/create_find_single_environment.yml +130 -0
- data/spec/vcr/cassettes/create_gpg_key.yml +173 -0
- data/spec/vcr/cassettes/create_provider_for_default_org.yml +171 -0
- data/spec/vcr/cassettes/create_repository.yml +261 -0
- data/spec/vcr/cassettes/create_role.yml +130 -0
- data/spec/vcr/cassettes/create_system.yml +171 -0
- data/spec/vcr/cassettes/create_template.yml +253 -0
- data/spec/vcr/cassettes/create_user.yml +130 -0
- data/spec/vcr/cassettes/create_user_role.yml +263 -0
- data/spec/vcr/cassettes/find_ACME_Corporation.yml +44 -0
- data/spec/vcr/cassettes/find_admin.yml +44 -0
- data/spec/vcr/cassettes/find_crl.yml +62 -0
- data/spec/vcr/cassettes/find_template.yml +44 -0
- data/spec/vcr/cassettes/find_users.yml +44 -0
- data/spec/vcr/cassettes/organization_1_exists.yml +85 -0
- data/spec/vcr/cassettes/organization_create.yml +128 -0
- data/spec/vcr/cassettes/organization_default_exists.yml +44 -0
- data/spec/vcr/cassettes/organization_exists.yml +44 -0
- data/spec/vcr/cassettes/organization_update.yml +130 -0
- data/spec/vcr/cassettes/provider_1_exists.yml +44 -0
- data/spec/vcr/cassettes/providers_all_exists.yml +44 -0
- data/spec/vcr/cassettes/read_products.yml +257 -0
- data/spec/vcr/cassettes/update_environment_name_description.yml +216 -0
- data/spec/vcr/cassettes/update_provider_for_org.yml +175 -0
- data/spec/vcr/cassettes/update_role.yml +175 -0
- data/spec/vcr/cassettes/update_user.yml +130 -0
- data/spec/vcr_setup.rb +46 -0
- metadata +242 -0
data/COPYING
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012 Chris Alfonso
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= deadwood
|
2
|
+
|
3
|
+
Deadwood is a ruby client library to interact with a Katello server (http://katello.org/)
|
4
|
+
|
5
|
+
== Contributing to deadwood
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Chris Alfonso. See COPYING for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/clean'
|
6
|
+
require 'rubygems/package_task'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
require 'rdoc/task'
|
10
|
+
require './rake/rpmtask'
|
11
|
+
|
12
|
+
RPMBUILD_DIR = "#{File.expand_path('~')}/rpmbuild"
|
13
|
+
RPM_SPEC = "rubygem-deadwood.spec"
|
14
|
+
RPM_SPEC_IN = "rubygem-deadwood.spec.in"
|
15
|
+
PKG_VERSION = "0.0.1"
|
16
|
+
|
17
|
+
spec = Gem::Specification.new do |s|
|
18
|
+
s.name = 'deadwood'
|
19
|
+
s.version = PKG_VERSION
|
20
|
+
s.summary= 'Ruby client for interacting with a Katello server'
|
21
|
+
s.description = 'Ruby client for interacting with a Katello server'
|
22
|
+
s.author = 'Chris Alfonso'
|
23
|
+
s.email = 'calfonso@redhat.com'
|
24
|
+
s.license = 'ASL 2.0'
|
25
|
+
s.homepage = 'http://aeolusproject.org'
|
26
|
+
|
27
|
+
s.files = Dir["{lib}/**/*.rb", "COPYING", "*.md", "Rakefile", "rake/rpmtask.rb"]
|
28
|
+
s.test_files = Dir["spec/**/*.*", "examples/deadwood-config.yml"]
|
29
|
+
s.require_path = "lib"
|
30
|
+
s.add_dependency('nokogiri', '>=0.4.0')
|
31
|
+
s.add_dependency('rest-client')
|
32
|
+
s.add_dependency('activeresource', '~>3.0.10')
|
33
|
+
s.add_dependency('oauth')
|
34
|
+
s.add_development_dependency('rspec', '~>1.3.0')
|
35
|
+
end
|
36
|
+
|
37
|
+
Gem::PackageTask.new(spec) do |p|
|
38
|
+
p.gem_spec = spec
|
39
|
+
p.need_tar = true
|
40
|
+
p.need_zip = true
|
41
|
+
end
|
42
|
+
|
43
|
+
Rake::TestTask.new(:test) do |test|
|
44
|
+
test.libs << 'lib' << 'test'
|
45
|
+
test.pattern = 'test/**/test_*.rb'
|
46
|
+
test.verbose = true
|
47
|
+
end
|
48
|
+
|
49
|
+
Rake::RDocTask.new do |rdoc|
|
50
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "deadwood #{version}"
|
53
|
+
rdoc.rdoc_files.include('README.md')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
57
|
+
Rake::RpmTask.new(RPM_SPEC, {:suffix => '.in', :pkg_version => PKG_VERSION}) do |rpm|
|
58
|
+
rpm.need_tar = true
|
59
|
+
rpm.package_files.include("lib/*")
|
60
|
+
rpm.topdir = "#{RPMBUILD_DIR}"
|
61
|
+
end
|
62
|
+
|
63
|
+
RSpec::Core::RakeTask.new do |t|
|
64
|
+
t.pattern = FileList['spec/**/*.rb']
|
65
|
+
end
|
data/lib/deadwood.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'active_resource'
|
22
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'base')
|
23
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'activation_key')
|
24
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'changeset')
|
25
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'consumer')
|
26
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'crl')
|
27
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'entitlement')
|
28
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'environment')
|
29
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'errata')
|
30
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'gpg_key')
|
31
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'organization')
|
32
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'pool')
|
33
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'product')
|
34
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'provider')
|
35
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'repository')
|
36
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'role')
|
37
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'status')
|
38
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'subscription')
|
39
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'system')
|
40
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'system_group')
|
41
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'task')
|
42
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'template')
|
43
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'user')
|
44
|
+
require File.join(File.dirname(__FILE__), 'deadwood/model', 'version')
|
45
|
+
require File.join(File.dirname(__FILE__), 'deadwood', 'active_resource_oauth_client.rb')
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
# # Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
# of this software and associated documentation files (the "Software"), to deal
|
4
|
+
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
5
|
+
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
|
6
|
+
# # The above copyright notice and this permission notice shall be included in
|
7
|
+
# all copies or substantial portions of the Software. #
|
8
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
10
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
11
|
+
# THE SOFTWARE.
|
12
|
+
|
13
|
+
require 'oauth'
|
14
|
+
require 'json'
|
15
|
+
# Monkey-patch ActiveResource to allow us to merge our OAuth headers in.
|
16
|
+
# Portions of the below are taken from Active Resource which is MIT licensed;
|
17
|
+
# hence this whole file is being licensed under the MIT License to err on the side of safety.
|
18
|
+
module ActiveResourceOAuthClient
|
19
|
+
ActiveResource::Connection.class_eval do
|
20
|
+
|
21
|
+
def request_with_oauth(method, path, *arguments)
|
22
|
+
@oauth_config = Deadwood::Katello::Base.config || {}
|
23
|
+
# Take care to fall back to the standard request method if we don't have full OAuth credentials
|
24
|
+
unless use_oauth_for_url?("#{site.scheme}://#{site.host}:#{site.port}#{path}")
|
25
|
+
return request_without_oauth(method, path, *arguments)
|
26
|
+
end
|
27
|
+
|
28
|
+
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
|
29
|
+
payload[:method] = method
|
30
|
+
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
|
31
|
+
oauth_consumer = OAuth::Consumer.new(
|
32
|
+
@oauth_config[:consumer_key],
|
33
|
+
@oauth_config[:consumer_secret],
|
34
|
+
:site => "#{site.scheme}://#{site.host}:#{site.port}" )
|
35
|
+
token = OAuth::AccessToken.new(oauth_consumer)
|
36
|
+
# Katello objects must not include the id attribute on updates
|
37
|
+
if method.to_s.include?('put')
|
38
|
+
obj = JSON.parse(arguments.first)
|
39
|
+
obj[obj.keys.first].delete('id')
|
40
|
+
arguments[0] = obj.to_json
|
41
|
+
end
|
42
|
+
base_request = oauth_consumer.create_signed_request(method, path, token, {}, *arguments)
|
43
|
+
payload[:result] = http.request(base_request)
|
44
|
+
end
|
45
|
+
# Error-handling code from OAuth
|
46
|
+
# http://wiki.oauth.net/w/page/12238543/ProblemReporting
|
47
|
+
auth_header = result.to_hash['www-authenticate']
|
48
|
+
problem_header = auth_header ? auth_header.select{|h| h =~ /^OAuth /}.select{|h| h =~ /oauth_problem/}.first : nil
|
49
|
+
if auth_header && problem_header
|
50
|
+
params = OAuth::Helper.parse_header(problem_header)
|
51
|
+
raise OAuth::Problem.new(params.delete("oauth_problem"), result, params)
|
52
|
+
end
|
53
|
+
# Error-handling code from ActiveResource
|
54
|
+
handle_response(result)
|
55
|
+
rescue Timeout::Error => e
|
56
|
+
raise TimeoutError.new(e.message)
|
57
|
+
rescue OpenSSL::SSL::SSLError => e
|
58
|
+
raise SSLError.new(e.message)
|
59
|
+
end
|
60
|
+
|
61
|
+
def use_oauth_for_url?(url)
|
62
|
+
Deadwood::Katello::Base.use_oauth? and
|
63
|
+
url.include?(Deadwood::Katello::Base.config[:site])
|
64
|
+
end
|
65
|
+
|
66
|
+
def default_header
|
67
|
+
@default_header ||= {}
|
68
|
+
config = Deadwood::Katello::Base.config || {}
|
69
|
+
@default_header = {'HTTP_KATELLO_USER' => config[:katello_user]}
|
70
|
+
end
|
71
|
+
alias_method_chain :request, :oauth
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
# # Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
# of this software and associated documentation files (the "Software"), to deal
|
4
|
+
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
5
|
+
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
|
6
|
+
# # The above copyright notice and this permission notice shall be included in
|
7
|
+
# all copies or substantial portions of the Software. #
|
8
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
10
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
11
|
+
# THE SOFTWARE.
|
12
|
+
|
13
|
+
module Deadwood
|
14
|
+
module Katello
|
15
|
+
class ActivationKey < Base
|
16
|
+
def collection_path(prefix_options = {}, query_options = nil)
|
17
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
18
|
+
query_options.merge!(self.attributes)
|
19
|
+
attributes.delete(:environment_id)
|
20
|
+
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}#{query_string(query_options)}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
# # Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
# of this software and associated documentation files (the "Software"), to deal
|
4
|
+
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
5
|
+
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
|
6
|
+
# # The above copyright notice and this permission notice shall be included in
|
7
|
+
# all copies or substantial portions of the Software. #
|
8
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
10
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
11
|
+
# THE SOFTWARE.
|
12
|
+
|
13
|
+
module Deadwood
|
14
|
+
module Katello
|
15
|
+
class Base < ActiveResource::Base
|
16
|
+
self.format = :json
|
17
|
+
self.ssl_options = {:verify_mode => OpenSSL::SSL::VERIFY_NONE}
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def element_path(id, prefix_options = {}, query_options = nil)
|
21
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
22
|
+
"#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def collection_path(prefix_options = {}, query_options = nil)
|
26
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
27
|
+
"#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def instantiate_collection(collection, prefix_options = {})
|
31
|
+
if collection.kind_of? Array
|
32
|
+
collection.collect! { |record| instantiate_record(record, prefix_options) }
|
33
|
+
elsif collection.kind_of? String
|
34
|
+
collection
|
35
|
+
else
|
36
|
+
[instantiate_record(collection, prefix_options)]
|
37
|
+
end
|
38
|
+
rescue ArgumentError
|
39
|
+
end
|
40
|
+
|
41
|
+
def get(method_name, options = {})
|
42
|
+
object_array = connection.get(custom_method_collection_url(method_name, options), headers)
|
43
|
+
if object_array.class.to_s=="Array"
|
44
|
+
object_array.collect! {|record| self.class.new.load(record)}
|
45
|
+
else
|
46
|
+
self.class.new.load(object_array)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def config
|
51
|
+
@@config
|
52
|
+
end
|
53
|
+
|
54
|
+
def config=(conf={})
|
55
|
+
@@config = conf
|
56
|
+
self.site = @@config[:site]
|
57
|
+
end
|
58
|
+
|
59
|
+
def use_oauth?
|
60
|
+
config[:consumer_key] && config[:consumer_secret] && config[:site]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_attributes_from_response(response)
|
65
|
+
if response['Content-Length'] != "0" && response.body.strip.size > 0
|
66
|
+
load(self.class.format.decode(response.body))
|
67
|
+
end
|
68
|
+
rescue ArgumentError
|
69
|
+
end
|
70
|
+
|
71
|
+
def collection_path(prefix_options = {}, query_options = nil)
|
72
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
73
|
+
query_options.merge!(self.attributes)
|
74
|
+
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}#{query_string(query_options)}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def query_string(options)
|
78
|
+
"?#{options.to_query}" unless options.nil? || options.empty?
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
# # Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
# of this software and associated documentation files (the "Software"), to deal
|
4
|
+
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
5
|
+
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
|
6
|
+
# # The above copyright notice and this permission notice shall be included in
|
7
|
+
# all copies or substantial portions of the Software. #
|
8
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
10
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
11
|
+
# THE SOFTWARE.
|
12
|
+
|
13
|
+
module Deadwood
|
14
|
+
module Katello
|
15
|
+
class Changeset < Base
|
16
|
+
def collection_path(prefix_options = {}, query_options = nil)
|
17
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
18
|
+
query_options.merge!(self.attributes)
|
19
|
+
org_id = self.organization_id
|
20
|
+
env_id = self.environment_id
|
21
|
+
# Remove the attributes that aren't allowed to be updated
|
22
|
+
attributes.delete(:organization_id)
|
23
|
+
attributes.delete(:environment_id)
|
24
|
+
"#{self.class.prefix(prefix_options)}organizations/#{org_id}/environments/#{env_id}/#{self.class.collection_name}#{query_string(query_options)}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
# # Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
# of this software and associated documentation files (the "Software"), to deal
|
4
|
+
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
5
|
+
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
|
6
|
+
# # The above copyright notice and this permission notice shall be included in
|
7
|
+
# all copies or substantial portions of the Software. #
|
8
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
10
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
11
|
+
# THE SOFTWARE.
|
12
|
+
|
13
|
+
module Deadwood
|
14
|
+
module Katello
|
15
|
+
class Consumer < Base
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
# # Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
# of this software and associated documentation files (the "Software"), to deal
|
4
|
+
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
5
|
+
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
|
6
|
+
# # The above copyright notice and this permission notice shall be included in
|
7
|
+
# all copies or substantial portions of the Software. #
|
8
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
10
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
11
|
+
# THE SOFTWARE.
|
12
|
+
|
13
|
+
module Deadwood
|
14
|
+
module Katello
|
15
|
+
class Crl < Base
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
# # Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
# of this software and associated documentation files (the "Software"), to deal
|
4
|
+
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
5
|
+
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
|
6
|
+
# # The above copyright notice and this permission notice shall be included in
|
7
|
+
# all copies or substantial portions of the Software. #
|
8
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
10
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
11
|
+
# THE SOFTWARE.
|
12
|
+
|
13
|
+
module Deadwood
|
14
|
+
module Katello
|
15
|
+
class Entitlement < Base
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright (c) 2012 Chris Alfonso
|
2
|
+
# # Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
# of this software and associated documentation files (the "Software"), to deal
|
4
|
+
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
5
|
+
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
|
6
|
+
# # The above copyright notice and this permission notice shall be included in
|
7
|
+
# all copies or substantial portions of the Software. #
|
8
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
10
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
11
|
+
# THE SOFTWARE.
|
12
|
+
|
13
|
+
module Deadwood
|
14
|
+
module Katello
|
15
|
+
class Environment < Base
|
16
|
+
def collection_path(prefix_options = {}, query_options = nil)
|
17
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
18
|
+
query_options.merge!(self.attributes)
|
19
|
+
org_id = self.organization_id
|
20
|
+
attributes.delete(:organization_id)
|
21
|
+
"#{self.class.prefix(prefix_options)}organizations/#{org_id}/#{self.class.collection_name}#{query_string(query_options)}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def element_path(id = self.id, prefix_options = {}, query_options = nil)
|
25
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
26
|
+
org_id = self.organization
|
27
|
+
# Remove the attributes that aren't allowed to be updated
|
28
|
+
attributes.delete(:organization_id)
|
29
|
+
attributes.delete(:organization)
|
30
|
+
attributes.delete(:library)
|
31
|
+
attributes.delete(:updated_at)
|
32
|
+
attributes.delete(:created_at)
|
33
|
+
attributes.delete(:prior_id)
|
34
|
+
attributes.delete(:prior)
|
35
|
+
attributes.delete(:name)
|
36
|
+
"#{self.class.prefix(prefix_options)}organizations/#{org_id}/#{self.class.collection_name}/#{self.id}#{query_string(query_options)}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|