Sha256: e2775f3f56c435b8097d46dafff65c46e7a6755fcd8437c72f53ba32ded6ac77

Contents?: true

Size: 1.17 KB

Versions: 106

Compression:

Stored size: 1.17 KB

Contents

class Jets::Resource::ApiGateway::RestApi
  class ChangeDetection
    extend Memoist
    include Jets::AwsServices

    def changed?
      return false unless parent_stack_exists?
      current_binary_media_types != new_binary_media_types ||
      Routes.changed?
    end

    def new_binary_media_types
      rest_api = Jets::Resource::ApiGateway::RestApi.new
      rest_api.binary_media_types
    end
    memoize :new_binary_media_types

    # Duplicated in rest_api/change_detection.rb, base_path/role.rb, rest_api/routes.rb
    def current_binary_media_types
      return nil unless parent_stack_exists?

      stack = cfn.describe_stacks(stack_name: parent_stack_name).stacks.first

      api_gateway_stack_arn = lookup(stack[:outputs], "ApiGateway")

      stack = cfn.describe_stacks(stack_name: api_gateway_stack_arn).stacks.first
      rest_api_id = lookup(stack[:outputs], "RestApi")

      resp = apigateway.get_rest_api(rest_api_id: rest_api_id)
      resp.binary_media_types
    end
    memoize :current_binary_media_types

    def parent_stack_exists?
      stack_exists?(parent_stack_name)
    end

    def parent_stack_name
      Jets::Naming.parent_stack_name
    end
  end
end

Version data entries

106 entries across 106 versions & 3 rubygems

Version Path
jets_bb_fork-0.0.4 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-2.1.1 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-2.1.0 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-2.0.6 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-2.0.5 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-2.0.4 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-2.0.3 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-2.0.1 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-2.0.0 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.32 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.31 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.30 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.29 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.28 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.27 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.26 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.25 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.24 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.23 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.22 lib/jets/resource/api_gateway/rest_api/change_detection.rb