Class: OpenSearch::Aws::Sigv4Client
- Inherits:
-
Client
- Object
- Client
- OpenSearch::Aws::Sigv4Client
- Defined in:
- lib/opensearch-aws-sigv4.rb
Overview
AWS Sigv4 Wrapper for OpenSearch::Client. This client accepts a Sigv4 Signer during initialization, and signs every request with a Sigv4 Signature with the provided signer.
Instance Attribute Summary collapse
-
#sigv4_signer ⇒ Aws::Sigv4::Signer
Signer used to sign every request.
Instance Method Summary collapse
-
#initialize(transport_args, sigv4_signer, options: {}, &block) ⇒ Sigv4Client
constructor
A new instance of Sigv4Client.
- #perform_request(method, path, params = {}, body = nil, headers = nil) ⇒ Object
Constructor Details
#initialize(transport_args, sigv4_signer, options: {}, &block) ⇒ Sigv4Client
Returns a new instance of Sigv4Client.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/opensearch-aws-sigv4.rb', line 47 def initialize(transport_args, sigv4_signer, options: {}, &block) unless sigv4_signer.is_a?(::Aws::Sigv4::Signer) raise ArgumentError, "Please pass a Aws::Sigv4::Signer. A #{sigv4_signer.class} was given." end @sigv4_signer = sigv4_signer @sigv4_debug = [:sigv4_debug] @logger = nil super(transport_args, &block) end |
Instance Attribute Details
#sigv4_signer ⇒ Aws::Sigv4::Signer
Signer used to sign every request
39 40 41 |
# File 'lib/opensearch-aws-sigv4.rb', line 39 def sigv4_signer @sigv4_signer end |
Instance Method Details
#perform_request(method, path, params = {}, body = nil, headers = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/opensearch-aws-sigv4.rb', line 59 def perform_request(method, path, params = {}, body = nil, headers = nil) signature_body = body.is_a?(Hash) ? body.to_json : body.to_s signature = sigv4_signer.sign_request( http_method: method, url: signature_url(path, params), headers: headers, body: signature_body ) headers = (headers || {}).merge(signature.headers) log_signature_info(signature) super(method, path, params, signature_body, headers) end |