diff --git a/Makefile b/Makefile index 09eccf4..0e1cad5 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,18 @@ export COMPOSE_IGNORE_ORPHANS ?= true export RUBY_VERSION ?= 2.3.1 RUBY_VERSION_MAJOR = $(word 1,$(subst ., ,$(RUBY_VERSION))) +RUBY_VERSION_MINOR = $(word 2,$(subst ., ,$(RUBY_VERSION))) export BUNDLER_VERSION ?= ifeq ($(BUNDLER_VERSION),) ifeq ($(RUBY_VERSION_MAJOR),2) +# Use old bundler for Ruby 2.3-2.6; Ruby 2.7 needs bundler 2.x to avoid resolver bugs +ifeq ($(RUBY_VERSION_MINOR),7) +export BUNDLER_VERSION = 2.4.22 +else export BUNDLER_VERSION = 1.17.3 endif endif +endif PROJECT_NAME = $(shell ls *.gemspec | sed 's/\.gemspec//') export COMPOSE_PROJECT_NAME ?= $(PROJECT_NAME)-$(subst .,_,$(RUBY_VERSION)) diff --git a/lib/aptible/api/external_aws_account.rb b/lib/aptible/api/external_aws_account.rb index 45c67ba..90f7191 100644 --- a/lib/aptible/api/external_aws_account.rb +++ b/lib/aptible/api/external_aws_account.rb @@ -27,6 +27,23 @@ def organization auth = Aptible::Auth::Organization.new(token: token, headers: headers) @organization = auth.find_by_url(organization_url) end + + def check! + response = HyperResource::Link.new( + self, + 'href' => "#{href}/check" + ).get + ExternalAwsAccountCheckResponse.new( + state: response.attributes['state'], + checks: (response.attributes['checks'] || []).map do |c| + ExternalAwsAccountCheck.new( + check_name: c['check_name'], + state: c['state'], + details: c['details'] + ) + end + ) + end end end end diff --git a/lib/aptible/api/external_aws_account_check_response.rb b/lib/aptible/api/external_aws_account_check_response.rb new file mode 100644 index 0000000..6f1d8cb --- /dev/null +++ b/lib/aptible/api/external_aws_account_check_response.rb @@ -0,0 +1,22 @@ +module Aptible + module Api + class ExternalAwsAccountCheckResponse + attr_reader :state, :checks + + def initialize(state:, checks:) + @state = state + @checks = checks + end + end + + class ExternalAwsAccountCheck + attr_reader :check_name, :state, :details + + def initialize(check_name:, state:, details:) + @check_name = check_name + @state = state + @details = details + end + end + end +end diff --git a/lib/aptible/api/resource.rb b/lib/aptible/api/resource.rb index e71f7a5..d952e79 100644 --- a/lib/aptible/api/resource.rb +++ b/lib/aptible/api/resource.rb @@ -58,6 +58,7 @@ def root_url require 'aptible/api/disk_attachment' require 'aptible/api/maintenance' require 'aptible/api/vpn_tunnel' +require 'aptible/api/external_aws_account_check_response' require 'aptible/api/external_aws_account' require 'aptible/api/external_aws_resource' require 'aptible/api/external_aws_database_credential' diff --git a/lib/aptible/api/version.rb b/lib/aptible/api/version.rb index 6e41988..da87dec 100644 --- a/lib/aptible/api/version.rb +++ b/lib/aptible/api/version.rb @@ -1,5 +1,5 @@ module Aptible module Api - VERSION = '1.11.2'.freeze + VERSION = '1.12.0'.freeze end end diff --git a/spec/aptible/api_spec.rb b/spec/aptible/api_spec.rb index fcafc9c..19fd1d3 100644 --- a/spec/aptible/api_spec.rb +++ b/spec/aptible/api_spec.rb @@ -6,12 +6,17 @@ it 'should have a configurable root_url' do config = described_class.configuration expect(config).to be_a GemConfig::Configuration - expect(config.root_url).to eq 'https://api.aptible.com' + with_env 'APTIBLE_API_ROOT_URL', nil do + load 'aptible/api.rb' + config.reset + expect(config.root_url).to eq 'https://api.aptible.com' + end end - pending 'uses ENV["APTIBLE_API_ROOT_URL"] if defined' do + it 'uses ENV["APTIBLE_API_ROOT_URL"] if defined' do config = described_class.configuration with_env 'APTIBLE_API_ROOT_URL', 'http://foobar.com' do + load 'aptible/api.rb' config.reset expect(config.root_url).to eq 'http://foobar.com' end