Class: AnsibleTowerClient::Api
Constant Summary
collapse
- DEFAULT_ERROR_MSG =
"An unknown error was returned from the provider".freeze
Instance Attribute Summary collapse
Attributes inherited from Connection
#connection
Instance Method Summary
collapse
Methods inherited from Connection
#api
Constructor Details
#initialize(connection) ⇒ Api
Returns a new instance of Api.
10
11
12
|
# File 'lib/ansible_tower_client/api.rb', line 10
def initialize(connection)
@instance = connection
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/ansible_tower_client/api.rb', line 86
def method_missing(method_name, *args, &block)
if instance.respond_to?(method_name)
path = build_path_to_resource(args.shift)
args.unshift(path)
logger.debug { "#{self.class.name} Sending <#{method_name}> with <#{args.inspect}>" }
instance.send(method_name, *args, &block).tap do |response|
logger.debug { "#{self.class.name} Response:\n#{JSON.parse(response.body).pretty_inspect}" }
end
else
super
end
rescue Faraday::ConnectionFailed => err
raise AnsibleTowerClient::ConnectionError, err
rescue Faraday::SSLError => err
raise AnsibleTowerClient::SSLError, err
rescue Faraday::ClientError => err
raise AnsibleTowerClient::ConnectionError, err
end
|
Instance Attribute Details
#instance ⇒ Object
Returns the value of attribute instance.
9
10
11
|
# File 'lib/ansible_tower_client/api.rb', line 9
def instance
@instance
end
|
Instance Method Details
#activity_stream ⇒ Object
26
27
28
|
# File 'lib/ansible_tower_client/api.rb', line 26
def activity_stream
Collection.new(self, activity_stream_class)
end
|
#activity_stream_class ⇒ Object
Object class accessors patched for the appropriate version of the API
#ad_hoc_command_class ⇒ Object
115
116
117
|
# File 'lib/ansible_tower_client/api.rb', line 115
def ad_hoc_command_class
@ad_hoc_command_class ||= AnsibleTowerClient::AdHocCommand
end
|
#ad_hoc_commands ⇒ Object
30
31
32
|
# File 'lib/ansible_tower_client/api.rb', line 30
def ad_hoc_commands
Collection.new(self, ad_hoc_command_class)
end
|
#config ⇒ Object
14
15
16
|
# File 'lib/ansible_tower_client/api.rb', line 14
def config
JSON.parse(get("config").body)
end
|
#credential_class ⇒ Object
119
120
121
|
# File 'lib/ansible_tower_client/api.rb', line 119
def credential_class
@credential_class ||= AnsibleTowerClient::Credential
end
|
#credentials ⇒ Object
34
35
36
|
# File 'lib/ansible_tower_client/api.rb', line 34
def credentials
Collection.new(self, credential_class)
end
|
#group_class ⇒ Object
123
124
125
|
# File 'lib/ansible_tower_client/api.rb', line 123
def group_class
@group_class ||= AnsibleTowerClient::Group
end
|
#groups ⇒ Object
38
39
40
|
# File 'lib/ansible_tower_client/api.rb', line 38
def groups
Collection.new(self, group_class)
end
|
#host_class ⇒ Object
127
128
129
|
# File 'lib/ansible_tower_client/api.rb', line 127
def host_class
@host_class ||= AnsibleTowerClient::Host
end
|
#hosts ⇒ Object
42
43
44
|
# File 'lib/ansible_tower_client/api.rb', line 42
def hosts
Collection.new(self, host_class)
end
|
#inventories ⇒ Object
46
47
48
|
# File 'lib/ansible_tower_client/api.rb', line 46
def inventories
Collection.new(self, inventory_class)
end
|
#inventory_class ⇒ Object
131
132
133
|
# File 'lib/ansible_tower_client/api.rb', line 131
def inventory_class
@inventory_class ||= AnsibleTowerClient::Inventory
end
|
#inventory_source_class ⇒ Object
#inventory_sources ⇒ Object
50
51
52
|
# File 'lib/ansible_tower_client/api.rb', line 50
def inventory_sources
Collection.new(self, inventory_source_class)
end
|
#inventory_update_class ⇒ Object
#inventory_updates ⇒ Object
54
55
56
|
# File 'lib/ansible_tower_client/api.rb', line 54
def inventory_updates
Collection.new(self, inventory_update_class)
end
|
#job_class ⇒ Object
143
144
145
|
# File 'lib/ansible_tower_client/api.rb', line 143
def job_class
@job_class ||= AnsibleTowerClient::Job
end
|
#job_event_class ⇒ Object
147
148
149
|
# File 'lib/ansible_tower_client/api.rb', line 147
def job_event_class
@job_event_class ||= AnsibleTowerClient::JobEvent
end
|
#job_events ⇒ Object
62
63
64
|
# File 'lib/ansible_tower_client/api.rb', line 62
def job_events
Collection.new(self, job_event_class)
end
|
#job_play_class ⇒ Object
151
152
153
|
# File 'lib/ansible_tower_client/api.rb', line 151
def job_play_class
@job_play_class ||= AnsibleTowerClient::JobPlay
end
|
#job_plays ⇒ Object
66
67
68
|
# File 'lib/ansible_tower_client/api.rb', line 66
def job_plays
Collection.new(self, job_play_class)
end
|
#job_template_class ⇒ Object
155
156
157
158
159
160
161
162
163
|
# File 'lib/ansible_tower_client/api.rb', line 155
def job_template_class
@job_template_class ||= begin
if Gem::Version.new(version).between?(Gem::Version.new(2), Gem::Version.new(3))
AnsibleTowerClient::JobTemplateV2
else
AnsibleTowerClient::JobTemplate
end
end
end
|
#job_templates ⇒ Object
70
71
72
|
# File 'lib/ansible_tower_client/api.rb', line 70
def job_templates
Collection.new(self, job_template_class)
end
|
#jobs ⇒ Object
58
59
60
|
# File 'lib/ansible_tower_client/api.rb', line 58
def jobs
Collection.new(self, job_class)
end
|
#organization_class ⇒ Object
#organizations ⇒ Object
74
75
76
|
# File 'lib/ansible_tower_client/api.rb', line 74
def organizations
Collection.new(self, organization_class)
end
|
#project_class ⇒ Object
169
170
171
|
# File 'lib/ansible_tower_client/api.rb', line 169
def project_class
@project_class ||= AnsibleTowerClient::Project
end
|
#project_update_class ⇒ Object
#project_updates ⇒ Object
82
83
84
|
# File 'lib/ansible_tower_client/api.rb', line 82
def project_updates
Collection.new(self, project_update_class)
end
|
#projects ⇒ Object
78
79
80
|
# File 'lib/ansible_tower_client/api.rb', line 78
def projects
Collection.new(self, project_class)
end
|
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
105
106
107
|
# File 'lib/ansible_tower_client/api.rb', line 105
def respond_to_missing?(method, _include_private = false)
instance.respond_to?(method)
end
|
#verify_credentials ⇒ Object
22
23
24
|
# File 'lib/ansible_tower_client/api.rb', line 22
def verify_credentials
JSON.parse(get("me").body).fetch_path("results", 0, "username")
end
|
#version ⇒ Object
18
19
20
|
# File 'lib/ansible_tower_client/api.rb', line 18
def version
@version ||= config["version"]
end
|