Class: Jets::Resource::ApiGateway::RestApi::ChangeDetection

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
AwsServices
Defined in:
lib/jets/resource/api_gateway/rest_api/change_detection.rb

Instance Method Summary collapse

Methods included from AwsServices

#apigateway, #cfn, #lambda, #logs, #s3, #s3_resource, #sns, #sqs, #sts

Methods included from AwsServices::StackStatus

#lookup, #stack_exists?, #stack_in_progress?

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


6
7
8
9
10
# File 'lib/jets/resource/api_gateway/rest_api/change_detection.rb', line 6

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

#current_binary_media_typesObject

Duplicated in rest_api/change_detection.rb, base_path/role.rb, rest_api/routes.rb



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jets/resource/api_gateway/rest_api/change_detection.rb', line 19

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

#new_binary_media_typesObject



12
13
14
15
# File 'lib/jets/resource/api_gateway/rest_api/change_detection.rb', line 12

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

#parent_stack_exists?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/jets/resource/api_gateway/rest_api/change_detection.rb', line 34

def parent_stack_exists?
  stack_exists?(parent_stack_name)
end

#parent_stack_nameObject



38
39
40
# File 'lib/jets/resource/api_gateway/rest_api/change_detection.rb', line 38

def parent_stack_name
  Jets::Naming.parent_stack_name
end