Class: Jets::Cfn::Builders::ApiResourcesBuilder
- Inherits:
-
Object
- Object
- Jets::Cfn::Builders::ApiResourcesBuilder
- Includes:
- AwsServices, Interface
- Defined in:
- lib/jets/cfn/builders/api_resources_builder.rb
Instance Method Summary collapse
- #add_gateway_routes ⇒ Object
- #add_rest_api_parameter ⇒ Object
-
#compose ⇒ Object
compose is an interface method.
-
#initialize(options = {}, paths = [], page) ⇒ ApiResourcesBuilder
constructor
A new instance of ApiResourcesBuilder.
- #part_of_template?(parent_path) ⇒ Boolean
-
#template_path ⇒ Object
template_path is an interface method.
Methods included from AwsServices
#apigateway, #aws_lambda, #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
Methods included from Interface
#add_output, #add_outputs, #add_parameter, #add_parameters, #add_resource, #add_resources, #add_template_resource, #build, #post_process_template, #template, #text, #write
Constructor Details
#initialize(options = {}, paths = [], page) ⇒ ApiResourcesBuilder
Returns a new instance of ApiResourcesBuilder.
6 7 8 9 |
# File 'lib/jets/cfn/builders/api_resources_builder.rb', line 6 def initialize(={}, paths=[], page) @options, @paths, @page = , paths, page @template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {}) end |
Instance Method Details
#add_gateway_routes ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jets/cfn/builders/api_resources_builder.rb', line 28 def add_gateway_routes @paths.each do |path| homepage = path == '' next if homepage # handled by RootResourceId output already resource = Jets::Resource::ApiGateway::Resource.new(path) add_resource(resource) add_outputs(resource.outputs) parent_path = resource.parent_path_parameter add_parameter(parent_path) unless part_of_template?(parent_path) end end |
#add_rest_api_parameter ⇒ Object
24 25 26 |
# File 'lib/jets/cfn/builders/api_resources_builder.rb', line 24 def add_rest_api_parameter add_parameter("RestApi", Description: "RestApi") end |
#compose ⇒ Object
compose is an interface method
12 13 14 15 16 17 |
# File 'lib/jets/cfn/builders/api_resources_builder.rb', line 12 def compose return unless @options[:templates] || @options[:stack_type] != :minimal add_rest_api_parameter add_gateway_routes end |
#part_of_template?(parent_path) ⇒ Boolean
42 43 44 |
# File 'lib/jets/cfn/builders/api_resources_builder.rb', line 42 def part_of_template?(parent_path) @template["Resources"].key?(parent_path) end |
#template_path ⇒ Object
template_path is an interface method
20 21 22 |
# File 'lib/jets/cfn/builders/api_resources_builder.rb', line 20 def template_path Jets::Naming.api_resources_template_path(@page) end |