Class: Jets::Resource::ApiGateway::RestApi::Routes::Change::MediaTypes

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb

Instance Method Summary collapse

Methods inherited from Base

changed?, #controller_action_from_api, #controller_action_from_string, #deployed_routes, #get_controller_action, #lambda_function_description, #method_uri, #new_routes, #recreate_to, #rest_api_id, #to

Methods included from AwsServices

#apigateway, #aws_lambda, #aws_options, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts

Methods included from AwsServices::StackStatus

#lookup, #stack_exists?, #stack_in_progress?

Methods included from AwsServices::GlobalMemoist

included

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb', line 3

def changed?
  current_binary_media_types != new_binary_media_types
end

#current_binary_media_typesObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb', line 13

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



7
8
9
10
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb', line 7

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

#parent_stack_exists?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb', line 28

def parent_stack_exists?
  stack_exists?(parent_stack_name)
end

#parent_stack_nameObject



32
33
34
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb', line 32

def parent_stack_name
  Jets::Naming.parent_stack_name
end