Class: Backup::Notifier::HttpPost
- Defined in:
- lib/backup/notifier/http_post.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Hash of additional HTTP headers to send.
-
#params ⇒ Object
Hash of additional POST parameters to send.
-
#ssl_ca_file ⇒ Object
Path to a
cacert.pem
file to use forssl_verify_peer
. -
#ssl_verify_peer ⇒ Object
Verify the server’s certificate when using SSL.
-
#success_codes ⇒ Object
Successful HTTP Status Code(s) that should be returned.
-
#uri ⇒ Object
URI to post notification to.
Attributes inherited from Base
#max_retries, #message, #model, #on_failure, #on_success, #on_warning, #retry_waitsec
Instance Method Summary collapse
-
#initialize(model, &block) ⇒ HttpPost
constructor
A new instance of HttpPost.
Methods inherited from Base
Methods included from Config::Helpers
Constructor Details
#initialize(model, &block) ⇒ HttpPost
Returns a new instance of HttpPost.
69 70 71 72 73 74 75 76 |
# File 'lib/backup/notifier/http_post.rb', line 69 def initialize(model, &block) super instance_eval(&block) if block_given? @headers ||= {} @params ||= {} @success_codes ||= 200 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers
Instance Attribute Details
#headers ⇒ Object
Hash of additional HTTP headers to send.
This notifier sets the following headers: { ‘User-Agent’ => “Backup/#{ Backup::VERSION }”,
'Content-Type' => 'x-www-form-urlencoded' }
‘Content-Type’ may not be changed. ‘User-Agent’ may be overridden or omitted by setting it to nil
. e.g. { ‘Authorization’ => ‘my_auth_info’, ‘User-Agent’ => nil }
30 31 32 |
# File 'lib/backup/notifier/http_post.rb', line 30 def headers @headers end |
#params ⇒ Object
Hash of additional POST parameters to send.
This notifier will set two parameters: { ‘status’ => ‘success|warning|failure’,
'message' => '[Backup::(Success|Warning|Failure)] label (trigger)' }
‘status’ may not be changed. ‘message’ may be overridden or omitted by setting a nil
value. e.g. { ‘auth_token’ => ‘my_token’, ‘message’ => nil }
42 43 44 |
# File 'lib/backup/notifier/http_post.rb', line 42 def params @params end |
#ssl_ca_file ⇒ Object
Path to a cacert.pem
file to use for ssl_verify_peer
.
This is provided (via Excon), but may be specified if needed.
67 68 69 |
# File 'lib/backup/notifier/http_post.rb', line 67 def ssl_ca_file @ssl_ca_file end |
#ssl_verify_peer ⇒ Object
Verify the server’s certificate when using SSL.
This will default to true
for most systems. It may be forced by setting to true
, or disabled by setting to false
.
61 62 63 |
# File 'lib/backup/notifier/http_post.rb', line 61 def ssl_verify_peer @ssl_verify_peer end |
#success_codes ⇒ Object
Successful HTTP Status Code(s) that should be returned.
This may be a single code or an Array of acceptable codes. e.g. [200, 201, 204]
If any other response code is returned, the request will be retried using ‘max_retries` and `retry_waitsec`.
Default: 200
54 55 56 |
# File 'lib/backup/notifier/http_post.rb', line 54 def success_codes @success_codes end |
#uri ⇒ Object
URI to post notification to.
URI scheme may be ‘http` or `https`.
If Basic Authentication is needed, supply the ‘user:password` in the URI. e.g. ’user:[email protected]/path’
Port may also be supplied. e.g. ‘www.example.com:8080/path’
18 19 20 |
# File 'lib/backup/notifier/http_post.rb', line 18 def uri @uri end |