mirror of
https://github.com/iSharkFly-Docs/opensearch-docs-cn
synced 2025-03-02 06:20:03 +00:00
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
@ -526,3 +526,25 @@ response = client.indices.delete(index: index_name)
|
|||||||
|
|
||||||
puts MultiJson.dump(response, pretty: "true")
|
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…
x
Reference in New Issue
Block a user