Class: OpenAI::Providers::Bedrock::SigV4Auth Private
- Inherits:
-
Object
- Object
- OpenAI::Providers::Bedrock::SigV4Auth
- Defined in:
- lib/openai/providers/bedrock.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(region:, base_url:, credentials_provider:, default_chain:) ⇒ SigV4Auth
constructor
private
A new instance of SigV4Auth.
- #prepare_request(request) ⇒ Object private
Constructor Details
#initialize(region:, base_url:, credentials_provider:, default_chain:) ⇒ SigV4Auth
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SigV4Auth.
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/openai/providers/bedrock.rb', line 131 def initialize(region:, base_url:, credentials_provider:, default_chain:) @region = region @base_url = URI(base_url) @default_chain = default_chain @signer = Aws::Sigv4::Signer.new( service: SERVICE, region: region, credentials_provider: credentials_provider ) end |
Instance Method Details
#prepare_request(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/openai/providers/bedrock.rb', line 142 def prepare_request(request) url = request.fetch(:url) Bedrock.validate_origin!(url, @base_url, action: "sign") Bedrock.validate_endpoint_region!(url, @region) body = request[:body] unless body.nil? || body.is_a?(String) raise OpenAI::Errors::Error, NON_REPLAYABLE_BODY_MESSAGE end headers = Bedrock.provider_headers(request, marker: SIGV4_AUTH_MARKER) SIGNING_HEADERS.each { headers.delete(_1) } signature = sign_request( http_method: request.fetch(:method).to_s.upcase, url: url.to_s, headers: headers, body: body ) request.merge( headers: OpenAI::Internal::Util.normalized_headers(headers, signature.headers), follow_redirects: false, provider_auth: SIGV4_AUTH_MARKER ) end |