Class: Pulp::Connection::Base
Direct Known Subclasses
Pulp::Cds, Pulp::Consumer, Pulp::Consumergroup, Pulp::Content, Distribution, Errata, Event, Filter, Package, PackageGroup, PackageGroupCategory, Repository, Service, Task, TaskHistory, TaskSnapshot, User
Class Attribute Summary collapse
Class Method Summary
collapse
-
.base ⇒ Object
-
.base_delete(cmd, item = nil, params = nil) ⇒ Object
-
.base_get(cmd, item = nil, params = nil) ⇒ Object
-
.base_post(cmd, item = nil, params = nil) ⇒ Object
-
.base_put(cmd, item = nil, params = nil) ⇒ Object
-
.base_unparsed_delete(cmd, item = nil, params = nil) ⇒ Object
-
.base_unparsed_get(cmd, item = nil, params = nil) ⇒ Object
-
.base_unparsed_post(cmd, item = nil, params = nil) ⇒ Object
-
.base_unparsed_put(cmd, item = nil, params = nil, binary_data = false) ⇒ Object
-
.identifier ⇒ Object
-
.merge_params(params) ⇒ Object
-
.parse_item_cmd(item, cmd) ⇒ Object
-
.plain_base ⇒ Object
-
.plain_get(cmd, params = nil) ⇒ Object
-
.plain_unparsed_get(cmd, params = nil) ⇒ Object
-
.reset ⇒ Object
-
.s(uri) ⇒ Object
sanitize uri if uri is already escaped, we don’t do anything, otherwise we escape it.
Instance Method Summary
collapse
#fields, included, #locked_fields, #record_fields, #special_fields, #user_fields
Constructor Details
#initialize(data = {}) ⇒ Base
Returns a new instance of Base.
8
9
10
|
# File 'lib/pulp/connection/base.rb', line 8
def initialize(data={})
set_fields(data)
end
|
Class Attribute Details
.hostname ⇒ Object
Returns the value of attribute hostname.
17
18
19
|
# File 'lib/pulp/connection/base.rb', line 17
def hostname
@hostname
end
|
.https ⇒ Object
Returns the value of attribute https.
17
18
19
|
# File 'lib/pulp/connection/base.rb', line 17
def https
@https
end
|
.password ⇒ Object
Returns the value of attribute password.
17
18
19
|
# File 'lib/pulp/connection/base.rb', line 17
def password
@password
end
|
.username ⇒ Object
Returns the value of attribute username.
17
18
19
|
# File 'lib/pulp/connection/base.rb', line 17
def username
@username
end
|
Class Method Details
.base ⇒ Object
73
74
75
|
# File 'lib/pulp/connection/base.rb', line 73
def base
Pulp::Connection::Handler.instance_for(self.identifier, hostname, username, password, (https.nil? ? true : https))
end
|
.base_delete(cmd, item = nil, params = nil) ⇒ Object
62
63
64
|
# File 'lib/pulp/connection/base.rb', line 62
def base_delete(cmd,item=nil,params=nil)
base.parsed{|conn| conn[s(parse_item_cmd(item,cmd))].delete(merge_params(params)) }
end
|
.base_get(cmd, item = nil, params = nil) ⇒ Object
58
59
60
|
# File 'lib/pulp/connection/base.rb', line 58
def base_get(cmd,item=nil,params=nil)
base.parsed{|conn| conn[s(parse_item_cmd(item,cmd))].get(merge_params(params)) }
end
|
.base_post(cmd, item = nil, params = nil) ⇒ Object
66
67
68
|
# File 'lib/pulp/connection/base.rb', line 66
def base_post(cmd,item=nil,params=nil)
base.parsed{|conn| conn[s(parse_item_cmd(item,cmd))].post(params.nil? ? nil : params.to_json, :content_type => :json ) }
end
|
.base_put(cmd, item = nil, params = nil) ⇒ Object
69
70
71
|
# File 'lib/pulp/connection/base.rb', line 69
def base_put(cmd,item=nil,params=nil)
base.parsed{|conn| conn[s(parse_item_cmd(item,cmd))].put(params.nil? ? nil : params.to_json, :content_type => :json ) }
end
|
.base_unparsed_delete(cmd, item = nil, params = nil) ⇒ Object
35
36
37
|
# File 'lib/pulp/connection/base.rb', line 35
def base_unparsed_delete(cmd,item=nil,params=nil)
base.connection[s(parse_item_cmd(item,cmd))].delete(merge_params(params)).body
end
|
.base_unparsed_get(cmd, item = nil, params = nil) ⇒ Object
31
32
33
|
# File 'lib/pulp/connection/base.rb', line 31
def base_unparsed_get(cmd,item=nil,params=nil)
base.connection[s(parse_item_cmd(item,cmd))].get(merge_params(params)).body
end
|
.base_unparsed_post(cmd, item = nil, params = nil) ⇒ Object
39
40
41
|
# File 'lib/pulp/connection/base.rb', line 39
def base_unparsed_post(cmd,item=nil,params=nil)
base.connection[s(parse_item_cmd(item,cmd))].post(params.nil? ? nil : params.to_json, :content_type => :json ).body
end
|
.base_unparsed_put(cmd, item = nil, params = nil, binary_data = false) ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/pulp/connection/base.rb', line 43
def base_unparsed_put(cmd,item=nil,params=nil,binary_data=false)
if binary_data
p = params
ct = 'application/stream'
else
p = params.nil? ? nil : params.to_json
ct = :json
end
base.connection[s(parse_item_cmd(item,cmd))].put(p, :content_type => ct).body
end
|
.identifier ⇒ Object
23
24
25
|
# File 'lib/pulp/connection/base.rb', line 23
def identifier
@identifier ||= name.demodulize.downcase
end
|
.merge_params(params) ⇒ Object
85
86
87
|
# File 'lib/pulp/connection/base.rb', line 85
def merge_params(params)
params.nil? ? {} : { :params => params }
end
|
.parse_item_cmd(item, cmd) ⇒ Object
81
82
83
|
# File 'lib/pulp/connection/base.rb', line 81
def parse_item_cmd(item,cmd)
"#{"/#{item}" unless item.nil?}#{(cmd =~ /^\//) ? cmd : "/#{cmd}"}"
end
|
.plain_base ⇒ Object
77
78
79
|
# File 'lib/pulp/connection/base.rb', line 77
def plain_base
Pulp::Connection::Handler.instance_for('', hostname, username, password, (https.nil? ? true : https))
end
|
.plain_get(cmd, params = nil) ⇒ Object
54
55
56
|
# File 'lib/pulp/connection/base.rb', line 54
def plain_get(cmd, params=nil)
plain_base.parsed{|conn| conn[s(cmd.sub(/^#{Regexp.escape(plain_base.api_path)}\//,''))].get(merge_params(params)) }
end
|
.plain_unparsed_get(cmd, params = nil) ⇒ Object
27
28
29
|
# File 'lib/pulp/connection/base.rb', line 27
def plain_unparsed_get(cmd, params=nil)
plain_base.connection[s(cmd.sub(/^#{Regexp.escape(plain_base.api_path)}\//,''))].get(merge_params(params)).body
end
|
.s(uri) ⇒ Object
sanitize uri if uri is already escaped, we don’t do anything, otherwise we escape it.
91
92
93
|
# File 'lib/pulp/connection/base.rb', line 91
def s(uri)
(URI.decode(uri) != uri) ? uri : URI.escape(uri)
end
|
Instance Method Details
#set_fields(field_data) ⇒ Object
12
13
14
|
# File 'lib/pulp/connection/base.rb', line 12
def set_fields(field_data)
@fields = field_data
end
|