Class: CfnGuardian::Models::HttpEvent

Inherits:
BaseEvent
  • Object
show all
Defined in:
lib/cfnguardian/models/event.rb

Direct Known Subclasses

InternalHttpEvent

Instance Attribute Summary collapse

Attributes inherited from BaseEvent

#cron, #enabled, #environment, #group, #hash, #name, #resource, #target, #type

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ HttpEvent

Returns a new instance of HttpEvent.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cfnguardian/models/event.rb', line 45

def initialize(resource)
  super(resource)
  @group = 'Http'
  @name = 'HttpEvent'
  @target = 'HttpCheckFunction'
  @endpoint = resource['Id']
  @method = resource.fetch('Method','GET')
  @timeout = resource.fetch('Timeout',50)
  @status_code = resource.fetch('StatusCode',200)
  @body_regex = resource.fetch('BodyRegex',nil)
  @headers = resource.fetch('Headers',nil)
  @user_agent = resource.fetch('UserAgent',nil)
  @payload = resource.fetch('Payload',nil)
  @compressed = resource.fetch('Compressed',false)
  @hmac_secret_ssm = resource.fetch('HmacSecretSsm',nil)
  @hmac_key_id = resource.fetch('HmacKeyId','default')
  @hmac_header_prefix = resource.fetch('HmacHeaderPrefix','X-Health')
  @health_config_overrides = resource.fetch('HealthConfigOverrides',nil)
  @report_response_body = resource.fetch('ReportResponseBody',false)
end

Instance Attribute Details

#body_regexObject

Returns the value of attribute body_regex.



37
38
39
# File 'lib/cfnguardian/models/event.rb', line 37

def body_regex
  @body_regex
end

#endpointObject

Returns the value of attribute endpoint.



37
38
39
# File 'lib/cfnguardian/models/event.rb', line 37

def endpoint
  @endpoint
end

#headersObject

Returns the value of attribute headers.



37
38
39
# File 'lib/cfnguardian/models/event.rb', line 37

def headers
  @headers
end

#methodObject

Returns the value of attribute method.



37
38
39
# File 'lib/cfnguardian/models/event.rb', line 37

def method
  @method
end

#payloadObject

Returns the value of attribute payload.



37
38
39
# File 'lib/cfnguardian/models/event.rb', line 37

def payload
  @payload
end

#status_codeObject

Returns the value of attribute status_code.



37
38
39
# File 'lib/cfnguardian/models/event.rb', line 37

def status_code
  @status_code
end

#timeoutObject

Returns the value of attribute timeout.



37
38
39
# File 'lib/cfnguardian/models/event.rb', line 37

def timeout
  @timeout
end

Instance Method Details

#http_headersObject



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cfnguardian/models/event.rb', line 66

def http_headers
  parts = []
  parts << @headers unless @headers.nil? || @headers.empty?
  unless @health_config_overrides.nil?
    override_value = @health_config_overrides.is_a?(String) ?
      @health_config_overrides :
      JSON.generate(@health_config_overrides)
    parts << "X-Health-Config-Overrides=#{override_value.gsub(' ', '%20')}"
  end
  parts.empty? ? nil : parts.join(' ')
end

#ssm_parametersObject



100
101
102
# File 'lib/cfnguardian/models/event.rb', line 100

def ssm_parameters
  @hmac_secret_ssm.nil? ? [] : [@hmac_secret_ssm]
end