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 included from Logging
#log_from_response
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/ansible_tower_client/api.rb', line 121
def method_missing(method_name, *args, &block)
require 'faraday'
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#{log_from_response(response)}" }
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
29
30
31
|
# File 'lib/ansible_tower_client/api.rb', line 29
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
151
152
153
|
# File 'lib/ansible_tower_client/api.rb', line 151
def ad_hoc_command_class
@ad_hoc_command_class ||= AnsibleTowerClient::AdHocCommand
end
|
#ad_hoc_commands ⇒ Object
33
34
35
|
# File 'lib/ansible_tower_client/api.rb', line 33
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
155
156
157
|
# File 'lib/ansible_tower_client/api.rb', line 155
def credential_class
@credential_class ||= AnsibleTowerClient::Credential
end
|
#credential_type_class ⇒ Object
#credential_types ⇒ Object
41
42
43
|
# File 'lib/ansible_tower_client/api.rb', line 41
def credential_types
Collection.new(self, credential_type_class)
end
|
#credentials ⇒ Object
37
38
39
|
# File 'lib/ansible_tower_client/api.rb', line 37
def credentials
Collection.new(self, credential_class)
end
|
#group_class ⇒ Object
163
164
165
|
# File 'lib/ansible_tower_client/api.rb', line 163
def group_class
@group_class ||= AnsibleTowerClient::Group
end
|
#groups ⇒ Object
45
46
47
|
# File 'lib/ansible_tower_client/api.rb', line 45
def groups
Collection.new(self, group_class)
end
|
#host_class ⇒ Object
167
168
169
|
# File 'lib/ansible_tower_client/api.rb', line 167
def host_class
@host_class ||= AnsibleTowerClient::Host
end
|
#hosts ⇒ Object
49
50
51
|
# File 'lib/ansible_tower_client/api.rb', line 49
def hosts
Collection.new(self, host_class)
end
|
#inventories ⇒ Object
53
54
55
|
# File 'lib/ansible_tower_client/api.rb', line 53
def inventories
Collection.new(self, inventory_class)
end
|
#inventory_class ⇒ Object
171
172
173
|
# File 'lib/ansible_tower_client/api.rb', line 171
def inventory_class
@inventory_class ||= AnsibleTowerClient::Inventory
end
|
#inventory_source_class ⇒ Object
#inventory_sources ⇒ Object
57
58
59
|
# File 'lib/ansible_tower_client/api.rb', line 57
def inventory_sources
Collection.new(self, inventory_source_class)
end
|
#inventory_update_class ⇒ Object
#inventory_updates ⇒ Object
61
62
63
|
# File 'lib/ansible_tower_client/api.rb', line 61
def inventory_updates
Collection.new(self, inventory_update_class)
end
|
#job_class ⇒ Object
183
184
185
|
# File 'lib/ansible_tower_client/api.rb', line 183
def job_class
@job_class ||= AnsibleTowerClient::Job
end
|
#job_event_class ⇒ Object
187
188
189
|
# File 'lib/ansible_tower_client/api.rb', line 187
def job_event_class
@job_event_class ||= AnsibleTowerClient::JobEvent
end
|
#job_events ⇒ Object
69
70
71
|
# File 'lib/ansible_tower_client/api.rb', line 69
def job_events
Collection.new(self, job_event_class)
end
|
#job_play_class ⇒ Object
191
192
193
|
# File 'lib/ansible_tower_client/api.rb', line 191
def job_play_class
@job_play_class ||= AnsibleTowerClient::JobPlay
end
|
#job_plays ⇒ Object
73
74
75
|
# File 'lib/ansible_tower_client/api.rb', line 73
def job_plays
Collection.new(self, job_play_class)
end
|
#job_template_class ⇒ Object
195
196
197
198
199
200
201
202
203
|
# File 'lib/ansible_tower_client/api.rb', line 195
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
77
78
79
|
# File 'lib/ansible_tower_client/api.rb', line 77
def job_templates
Collection.new(self, job_template_class)
end
|
#jobs ⇒ Object
65
66
67
|
# File 'lib/ansible_tower_client/api.rb', line 65
def jobs
Collection.new(self, job_class)
end
|
#organization_class ⇒ Object
#organizations ⇒ Object
81
82
83
|
# File 'lib/ansible_tower_client/api.rb', line 81
def organizations
Collection.new(self, organization_class)
end
|
#project_class ⇒ Object
209
210
211
|
# File 'lib/ansible_tower_client/api.rb', line 209
def project_class
@project_class ||= AnsibleTowerClient::Project
end
|
#project_update_class ⇒ Object
#project_updates ⇒ Object
89
90
91
|
# File 'lib/ansible_tower_client/api.rb', line 89
def project_updates
Collection.new(self, project_update_class)
end
|
#projects ⇒ Object
85
86
87
|
# File 'lib/ansible_tower_client/api.rb', line 85
def projects
Collection.new(self, project_class)
end
|
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
141
142
143
|
# File 'lib/ansible_tower_client/api.rb', line 141
def respond_to_missing?(method, _include_private = false)
instance.respond_to?(method)
end
|
#schedule_class ⇒ Object
217
218
219
|
# File 'lib/ansible_tower_client/api.rb', line 217
def schedule_class
@schedule_class ||= AnsibleTowerClient::Schedule
end
|
#schedules ⇒ Object
93
94
95
|
# File 'lib/ansible_tower_client/api.rb', line 93
def schedules
Collection.new(self, schedule_class)
end
|
#system_job_class ⇒ Object
221
222
223
|
# File 'lib/ansible_tower_client/api.rb', line 221
def system_job_class
@system_job_class ||= AnsibleTowerClient::SystemJob
end
|
#system_job_template_class ⇒ Object
#system_job_templates ⇒ Object
101
102
103
|
# File 'lib/ansible_tower_client/api.rb', line 101
def system_job_templates
Collection.new(self, system_job_template_class)
end
|
#system_jobs ⇒ Object
97
98
99
|
# File 'lib/ansible_tower_client/api.rb', line 97
def system_jobs
Collection.new(self, system_job_class)
end
|
#verify_credentials ⇒ Object
22
23
24
25
26
27
|
# File 'lib/ansible_tower_client/api.rb', line 22
def verify_credentials
results = get("me/").body
JSON.parse(results).fetch_path("results", 0, "username")
rescue JSON::ParserError
raise AnsibleTowerClient::ConnectionError, "unexpected response"
end
|
#version ⇒ Object
18
19
20
|
# File 'lib/ansible_tower_client/api.rb', line 18
def version
@version ||= config["version"]
end
|
#workflow_job_class ⇒ Object
229
230
231
|
# File 'lib/ansible_tower_client/api.rb', line 229
def workflow_job_class
@workflow_job_class ||= AnsibleTowerClient::WorkflowJob
end
|
#workflow_job_node_class ⇒ Object
#workflow_job_nodes ⇒ Object
105
106
107
|
# File 'lib/ansible_tower_client/api.rb', line 105
def workflow_job_nodes
Collection.new(self, workflow_job_node_class)
end
|
#workflow_job_template_class ⇒ Object
#workflow_job_template_node_class ⇒ Object
#workflow_job_template_nodes ⇒ Object
117
118
119
|
# File 'lib/ansible_tower_client/api.rb', line 117
def workflow_job_template_nodes
Collection.new(self, workflow_job_template_node_class)
end
|
#workflow_job_templates ⇒ Object
113
114
115
|
# File 'lib/ansible_tower_client/api.rb', line 113
def workflow_job_templates
Collection.new(self, workflow_job_template_class)
end
|
#workflow_jobs ⇒ Object
109
110
111
|
# File 'lib/ansible_tower_client/api.rb', line 109
def workflow_jobs
Collection.new(self, workflow_job_class)
end
|