Added doc for Ruby Sigv4 (#2089)

* Added doc for Ruby Sigv4

Signed-off-by: Theo Truong <theotr@amazon.com>

* Update _clients/ruby.md

Style update

Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com>

Signed-off-by: Theo Truong <theotr@amazon.com>
Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com>
This commit is contained in:
Theo Nam Truong 2022-12-05 11:16:34 -07:00 committed by GitHub
parent 867167a3b4
commit dc09ea070d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 1 deletions

View File

@ -526,3 +526,25 @@ response = client.indices.delete(index: index_name)
puts MultiJson.dump(response, pretty: "true")
```
# Ruby AWS Sigv4 Client
The [opensearch-aws-sigv4](https://github.com/opensearch-project/opensearch-ruby/tree/main/opensearch-aws-sigv4) gem provides the `OpenSearch::Aws::Sigv4Client` class, which has all features of `OpenSearch::Client`. The only difference between these two clients is that `OpenSearch::Aws::Sigv4Client` requires an instance of `Aws::Sigv4::Signer` during instantiation to authenticate with AWS:
```ruby
require 'opensearch-aws-sigv4'
require 'aws-sigv4'
signer = Aws::Sigv4::Signer.new(service: 'es',
region: 'us-west-2',
access_key_id: 'key_id',
secret_access_key: 'secret')
client = OpenSearch::Aws::Sigv4Client.new({ log: true }, signer)
client.cluster.health
client.transport.reload_connections!
client.search q: 'test'
```