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:
parent
867167a3b4
commit
dc09ea070d
|
@ -525,4 +525,26 @@ puts 'Deleting the index:'
|
|||
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'
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue