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-1.9.1 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.9.0 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.14 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.13 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.12 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.11 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.10 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.9 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.8 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.7 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.6 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.5 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.4 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.3 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.2 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.1 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.8.0 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.7.2 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.7.1 lib/jets/resource/api_gateway/rest_api/change_detection.rb
jets-1.7.0 lib/jets/resource/api_gateway/rest_api/change_detection.rb