ansible_tower_client 0.16.0 → 0.17.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1b0a1ac463760d8b5494152a6e9646ed367655dfbf857f1899a322cbf89b98f
4
- data.tar.gz: 643abb688c74f01c1e7caaed8fb7cb3e1e65eab2a658c1825a5dd1e7176cc398
3
+ metadata.gz: afa572e7a5320c8c4128c1b60a256b3becdbf63b2962e126b3295b7096f7472f
4
+ data.tar.gz: af3e60d79451302d1c5cfe8b9a7ee0371117370a7e002e0eccd7887f733690a3
5
5
  SHA512:
6
- metadata.gz: 9f7a7d8a683736eddec813fd3e85aab35675e6bbe1cddc3da13f780e6ebe8d0672ea76bccfe0352f5cdd2255ad2500abf875b193973740e530db2e8704ed200f
7
- data.tar.gz: 7d3388d96c17847d266597a5a47d31b02cd6777d819dcad8c448df4e44bf1787399f0d282c39d2ae45453db8f62efa4376a93f99acd04c641d91a1715f54eb18
6
+ metadata.gz: e4a3651e8cf033e8b1c8c2a012aa4f0013d721e458d5cb90f390c40abde1d9ec25429b653af29bf576ebea41c1be82c9cdd8ef499778472c612870be9387ef50
7
+ data.tar.gz: e0217ab79d41ad8f9cb592aa42a7d7a050e8b83077992afd28ed0d65d706fbf24973efc6c7f4686441021ee0b79bed3a08db0f87cbc10a7945b1eb35ebb89bfb
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.17.0] - 2018-07-27
9
+ ### Removed
10
+ - Reverted support for API v2 and v2 Credentials [(#117)](https://github.com/ansible/ansible_tower_client_ruby/pull/117)
11
+
12
+ ### Fixed
13
+ - Fix WorkflowJobNode#job and add tests[(#116)](https://github.com/ansible/ansible_tower_client_ruby/pull/116)
14
+
8
15
  ## [0.16.0] - 2018-07-06
9
16
  ### Added
10
17
  - Added support for API v2 and v2 Credentials [(#107)](https://github.com/ansible/ansible_tower_client_ruby/pull/107)
@@ -91,7 +98,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
91
98
  ### Fixed
92
99
  - Adjusted project_spec to test on a Project [(#63)](https://github.com/ansible/ansible_tower_client_ruby/pull/63)
93
100
 
94
- [Unreleased]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.16.0...master
101
+ [Unreleased]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.17.0...master
102
+ [0.17.0]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.16.0...v0.17.0
95
103
  [0.16.0]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.15.0...v0.16.0
96
104
  [0.15.0]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.14.0...v0.15.0
97
105
  [0.14.0]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.13.0...v0.14.0
@@ -34,8 +34,6 @@ require "ansible_tower_client/base_models/workflow_job_template"
34
34
  require "ansible_tower_client/base_models/workflow_job_template_node"
35
35
 
36
36
  require "ansible_tower_client/v2/job_template_v2"
37
- require "ansible_tower_client/v2/credential_v2"
38
- require "ansible_tower_client/v2/credential_type_v2"
39
37
 
40
38
  require "more_core_extensions/all"
41
39
  require "active_support/inflector"
@@ -6,10 +6,9 @@ module AnsibleTowerClient
6
6
 
7
7
  DEFAULT_ERROR_MSG = "An unknown error was returned from the provider".freeze
8
8
 
9
- attr_reader :instance, :api_version
10
- def initialize(connection, api_version)
11
- @instance = connection
12
- @api_version = api_version
9
+ attr_reader :instance
10
+ def initialize(connection)
11
+ @instance = connection
13
12
  end
14
13
 
15
14
  def config
@@ -36,11 +35,6 @@ module AnsibleTowerClient
36
35
  Collection.new(self, credential_class)
37
36
  end
38
37
 
39
- def credential_types
40
- raise AnsibleTowerClient::UnsupportedApiError, 'requires API v2 or higher' if api_version?(1)
41
- Collection.new(self, credential_type_class)
42
- end
43
-
44
38
  def groups
45
39
  Collection.new(self, group_class)
46
40
  end
@@ -152,17 +146,7 @@ module AnsibleTowerClient
152
146
  end
153
147
 
154
148
  def credential_class
155
- @credential_class ||= begin
156
- if api_version?(2)
157
- AnsibleTowerClient::CredentialV2
158
- else
159
- AnsibleTowerClient::Credential
160
- end
161
- end
162
- end
163
-
164
- def credential_type_class
165
- @credential_type_class ||= AnsibleTowerClient::CredentialTypeV2
149
+ @credential_class ||= AnsibleTowerClient::Credential
166
150
  end
167
151
 
168
152
  def group_class
@@ -199,7 +183,7 @@ module AnsibleTowerClient
199
183
 
200
184
  def job_template_class
201
185
  @job_template_class ||= begin
202
- if awx_version_between?(2, 3)
186
+ if Gem::Version.new(version).between?(Gem::Version.new(2), Gem::Version.new(3))
203
187
  AnsibleTowerClient::JobTemplateV2
204
188
  else
205
189
  AnsibleTowerClient::JobTemplate
@@ -254,13 +238,5 @@ module AnsibleTowerClient
254
238
  return original if instance.url_prefix.path == "/"
255
239
  File.join(instance.url_prefix.path, Regexp.last_match[1])
256
240
  end
257
-
258
- def awx_version_between?(min, max)
259
- Gem::Version.new(version).between?(Gem::Version.new(min), Gem::Version.new(max))
260
- end
261
-
262
- def api_version?(desired)
263
- Gem::Version.new(api_version).eql?(Gem::Version.new(desired))
264
- end
265
241
  end
266
242
  end
@@ -5,7 +5,7 @@ module AnsibleTowerClient
5
5
  end
6
6
 
7
7
  def job
8
- job_id.nil? ? nil : api.jobs.find(job_id)
8
+ api.jobs.find(job_id) if respond_to?(:job_id) && job_id
9
9
  end
10
10
  end
11
11
  end
@@ -1,70 +1,31 @@
1
1
  module AnsibleTowerClient
2
2
  class Connection
3
- attr_reader :options
3
+ attr_reader :connection
4
4
 
5
- # Options:
6
- # - base_url: you have two options here:
7
- # a) pass in only scheme and hostname e.g. 'https://localhost:54321' to allow client to connect to both api v1
8
- # and v2 versions like this: `client.api(:version => 1)` and `client.api(:version => 2)`. This requires ansible
9
- # tower API being accessible directly at `https://localhost:54321/api/v1` and `https://localhost:54321/api/v2`.
10
- # b) pass in a complete api address e.g. 'https://localhost:54321/tower'. Client will then connect to the path
11
- # directly and it's your responsibility to know what version of API is there.
12
- # - username
13
- # - password
14
- # - verify_ssl
15
- def initialize(options = {})
5
+ def initialize(options = nil)
16
6
  raise "Credentials are required" unless options[:username] && options[:password]
17
7
  raise ":base_url is required" unless options[:base_url]
18
- logger = options[:logger] || AnsibleTowerClient.logger
8
+ logger = options[:logger] || AnsibleTowerClient.logger
9
+ verify_ssl = options[:verify_ssl] || OpenSSL::SSL::VERIFY_PEER
10
+ verify_ssl = verify_ssl == OpenSSL::SSL::VERIFY_NONE ? false : true
19
11
 
20
12
  require 'faraday'
21
13
  require 'faraday_middleware'
22
14
  require 'ansible_tower_client/middleware/raise_tower_error'
23
15
  Faraday::Response.register_middleware :raise_tower_error => -> { Middleware::RaiseTowerError }
24
-
25
- @options = {
26
- :url => options[:base_url],
27
- :verify_ssl => (options[:verify_ssl] || OpenSSL::SSL::VERIFY_PEER) != OpenSSL::SSL::VERIFY_NONE,
28
- :username => options[:username],
29
- :password => options[:password],
30
- :logger => logger,
31
- }
32
-
33
- reset
34
- end
35
-
36
- def connection(url:, username:, password:, verify_ssl: false, logger: nil)
37
- Faraday.new(url, :ssl => {:verify => verify_ssl}) do |f|
16
+ @connection = Faraday.new(options[:base_url], :ssl => {:verify => verify_ssl}) do |f|
38
17
  f.use(FaradayMiddleware::EncodeJson)
39
18
  f.use(FaradayMiddleware::FollowRedirects, :limit => 3, :standards_compliant => true)
40
19
  f.request(:url_encoded)
41
20
  f.response(:raise_tower_error)
42
21
  f.response(:logger, logger)
43
22
  f.adapter(Faraday.default_adapter)
44
- f.basic_auth(username, password)
23
+ f.basic_auth(options[:username], options[:password])
45
24
  end
46
25
  end
47
26
 
48
- def api(version: 2)
49
- @api[version] ||= begin
50
- # Build uri path.
51
- options = @options.clone.tap do |opts|
52
- opts[:url] = URI(opts[:url]).tap { |url| url.path = url_path_for_version(url.path, version) }
53
- end
54
-
55
- Api.new(connection(**options), version)
56
- end
57
- end
58
-
59
- def reset
60
- @api = {}
61
- end
62
-
63
- private
64
-
65
- def url_path_for_version(orig_path, api_version)
66
- return orig_path unless orig_path.sub(/\/$/, "").empty?
67
- "/api/v#{api_version}"
27
+ def api
28
+ @api ||= Api.new(connection)
68
29
  end
69
30
  end
70
31
  end
@@ -7,5 +7,4 @@ module AnsibleTowerClient
7
7
  class ResourceNotFoundError < ClientError; end
8
8
  class SSLError < ClientError; end
9
9
  class UnlicensedFeatureError < ClientError; end
10
- class UnsupportedApiError < ClientError; end
11
10
  end
@@ -1,3 +1,3 @@
1
1
  module AnsibleTowerClient
2
- VERSION = "0.16.0".freeze
2
+ VERSION = "0.17.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansible_tower_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dunne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-07-06 00:00:00.000000000 Z
12
+ date: 2018-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -175,8 +175,6 @@ files:
175
175
  - lib/ansible_tower_client/logging.rb
176
176
  - lib/ansible_tower_client/middleware/raise_tower_error.rb
177
177
  - lib/ansible_tower_client/null_logger.rb
178
- - lib/ansible_tower_client/v2/credential_type_v2.rb
179
- - lib/ansible_tower_client/v2/credential_v2.rb
180
178
  - lib/ansible_tower_client/v2/job_template_v2.rb
181
179
  - lib/ansible_tower_client/version.rb
182
180
  homepage: https://github.com/Ansible/ansible_tower_client_ruby
@@ -1,9 +0,0 @@
1
- module AnsibleTowerClient
2
- class CredentialTypeV2 < BaseModel
3
- class Inputs < BaseModel; end
4
-
5
- def self.endpoint
6
- 'credential_types'
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module AnsibleTowerClient
2
- class CredentialV2 < Credential
3
- class Inputs < BaseModel
4
- def size
5
- @raw_hash.keys.size
6
- end
7
- end
8
-
9
- def self.endpoint
10
- 'credentials'
11
- end
12
- end
13
- end