Class: Cumulus::VPC::EndpointConfig
- Inherits:
-
Object
- Object
- Cumulus::VPC::EndpointConfig
- Defined in:
- lib/vpc/models/EndpointConfig.rb
Overview
Public: An object representing configuration for a VPC endpoint
Instance Attribute Summary collapse
-
#policy ⇒ Object
Returns the value of attribute policy.
-
#route_tables ⇒ Object
readonly
Returns the value of attribute route_tables.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Instance Method Summary collapse
-
#diff(aws) ⇒ Object
Public: Produce an array of differences between this local configuration and the configuration in AWS.
-
#initialize(json = nil) ⇒ EndpointConfig
constructor
Public: Constructor.
- #populate!(aws, route_table_map) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(json = nil) ⇒ EndpointConfig
Public: Constructor
json - a hash containing the JSON configuration for the endpoint
20 21 22 23 24 25 26 |
# File 'lib/vpc/models/EndpointConfig.rb', line 20 def initialize(json = nil) if !json.nil? @service_name = json["service-name"] @policy = json["policy"] @route_tables = json["route-tables"] || [] end end |
Instance Attribute Details
#policy ⇒ Object
Returns the value of attribute policy.
14 15 16 |
# File 'lib/vpc/models/EndpointConfig.rb', line 14 def policy @policy end |
#route_tables ⇒ Object (readonly)
Returns the value of attribute route_tables.
15 16 17 |
# File 'lib/vpc/models/EndpointConfig.rb', line 15 def route_tables @route_tables end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
13 14 15 |
# File 'lib/vpc/models/EndpointConfig.rb', line 13 def service_name @service_name end |
Instance Method Details
#diff(aws) ⇒ Object
Public: Produce an array of differences between this local configuration and the configuration in AWS
aws - the AWS resource
Returns an array of the EndpointDiffs that were found
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/vpc/models/EndpointConfig.rb', line 50 def diff(aws) diffs = [] # policy aws_policy_statements = aws.parsed_policy["Statement"] local_policy_statements = Loader.policy(@policy)["Statement"] policy_diff = EndpointDiff.policy(aws_policy_statements, local_policy_statements) if policy_diff diffs << policy_diff end # routes aws_rts = aws.route_table_ids.map { |rt_id| EC2::id_route_tables[rt_id] } aws_rt_names = aws_rts.map { |rt| rt.name || rt.route_table_id } rt_diff = EndpointDiff.route_tables(aws_rt_names, @route_tables) if rt_diff diffs << rt_diff end diffs end |
#populate!(aws, route_table_map) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/vpc/models/EndpointConfig.rb', line 36 def populate!(aws, route_table_map) @service_name = aws.service_name @policy = aws.parsed_policy["Version"] @route_tables = aws.route_table_ids.map { |rt_id| route_table_map[rt_id] || rt_id } self end |
#to_hash ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/vpc/models/EndpointConfig.rb', line 28 def to_hash { "service-name" => @service_name, "policy" => @policy, "route-tables" => @route_tables.sort, }.reject { |k, v| v.nil? } end |