Skip to content

Commit

Permalink
Merge branch 'main' of github.com:opensearch-project/opensearch-ruby …
Browse files Browse the repository at this point in the history
…into admin
  • Loading branch information
derek-ho committed Feb 27, 2024
2 parents 7760359 + faf3b79 commit b7e2aa3
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
disable-security: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
ruby-version: 3.3
- name: Build and test with Rake
run: |
sudo apt-get update
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
disable-security: false
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
ruby-version: 3.3
- name: Build and test with Rake
run: |
sudo apt-get update
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, jruby-9.3 ]
ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -30,8 +30,7 @@ jobs:
sudo sysctl -w vm.max_map_count=262144
- uses: ./.github/actions/opensearch
with:
# TODO: change cluster-version back to `latest` after OS 2.9.1 or later is released
cluster-version: "2.8.0"
cluster-version: latest
disable-security: true
- uses: ruby/setup-ruby@v1
with:
Expand All @@ -53,7 +52,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ 2.6, 2.7, '3.0', 3.1, 3.2, jruby-9.3 ]
ruby: [ 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -65,8 +64,7 @@ jobs:
sudo sysctl -w vm.max_map_count=262144
- uses: ./.github/actions/opensearch
with:
# TODO: change cluster-version back to `latest` after OS 2.9.1 or later is released
cluster-version: "2.8.0"
cluster-version: latest
disable-security: true
- uses: ruby/setup-ruby@v1
with:
Expand All @@ -87,7 +85,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, jruby-9.3 ]
ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
fail-fast: false
matrix:
entry:
- { ruby_version: '3.2', opensearch_ref: '1.x' }
- { ruby_version: '3.2', opensearch_ref: '2.x' }
- { ruby_version: '3.2', opensearch_ref: '2.0' }
- { ruby_version: '3.2', opensearch_ref: 'main' }
- { ruby_version: '3.3', opensearch_ref: '1.x' }
- { ruby_version: '3.3', opensearch_ref: '2.x' }
- { ruby_version: '3.3', opensearch_ref: '2.0' }
- { ruby_version: '3.3', opensearch_ref: 'main' }

steps:
- uses: ruby/setup-ruby@v1
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
### Security

## [3.2.0]
### Added
- Added support for Ruby 3.3 ([#220](https://github.com/opensearch-project/opensearch-ruby/pull/220))
- Added `search_pipeline` parameter to `search` API ([#227](https://github.com/opensearch-project/opensearch-ruby/pull/227))
### Changed
### Deprecated
### Removed
- Removed dependency on the base64 gem ([#221](https://github.com/opensearch-project/opensearch-ruby/pull/221))
- Removed logging of hosts in `transport` base ([#227](https://github.com/opensearch-project/opensearch-ruby/pull/227))
### Fixed
- Switch back to the latest OpenSearch version when testing in CI ([#219](https://github.com/opensearch-project/opensearch-ruby/pull/219))
### Security

## [3.1.0]
### Added
- Added `http.get`, `http.post`, `http.patch`, `http.put`, `http.trace`, `http.head`, `http.options`, `http.connect`, and `http.delete` ([#211](https://github.com/opensearch-project/opensearch-ruby/pull/211))
Expand Down
8 changes: 5 additions & 3 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ To add the client to your project, install it using [RubyGems](https://rubygems.
`gem install opensearch-ruby`

or add it to your Gemfile:
```
gem opensearch-ruby
```ruby
gem 'opensearch-ruby'
```
and run:
```
Expand All @@ -23,7 +23,9 @@ bundle install

Import the client:

`require 'opensearch'`
```ruby
require 'opensearch'
```

## Basic Usage
```ruby
Expand Down
2 changes: 2 additions & 0 deletions lib/opensearch/api/actions/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module Actions
# @option arguments [String] :q Query in the Lucene query string syntax
# @option arguments [List] :routing A comma-separated list of specific routing values
# @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
# @option arguments [String] :search_pipeline Customizable sequence of processing stages applied to search queries.
# @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch)
# @option arguments [Number] :size Number of hits to return (default: 10)
# @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
Expand Down Expand Up @@ -128,6 +129,7 @@ def search(arguments = {})
q
routing
scroll
search_pipeline
search_type
size
sort
Expand Down
8 changes: 4 additions & 4 deletions lib/opensearch/transport/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
# specific language governing permissions and limitations
# under the License.

require 'base64'

module OpenSearch
module Transport
# Handles communication with an OpenSearch cluster.
Expand Down Expand Up @@ -225,7 +223,8 @@ def extract_cloud_creds(arguments)
return unless arguments[:cloud_id] && !arguments[:cloud_id].empty?

name = arguments[:cloud_id].split(':')[0]
cloud_url, opensearch_instance = Base64.decode64(arguments[:cloud_id].gsub("#{name}:", '')).split('$')
base64_decoded = arguments[:cloud_id].gsub("#{name}:", '').unpack1('m')
cloud_url, opensearch_instance = base64_decoded.split('$')

if cloud_url.include?(':')
url, port = cloud_url.split(':')
Expand Down Expand Up @@ -355,7 +354,8 @@ def __auto_detect_adapter
# Encode credentials for the Authorization Header
# Credentials is the base64 encoding of id and api_key joined by a colon
def __encode(api_key)
Base64.strict_encode64([api_key[:id], api_key[:api_key]].join(':'))
joined = [api_key[:id], api_key[:api_key]].join(':')
[joined].pack('m0')
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions lib/opensearch/transport/transport/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ def get_connection(options = {})
# @see Sniffer#hosts
#
def reload_connections!
puts hosts
hosts = sniffer.hosts
puts hosts
__rebuild_connections hosts: hosts, options: options
self
rescue SnifferTimeoutError
Expand Down
2 changes: 1 addition & 1 deletion lib/opensearch/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
# under the License.

module OpenSearch
VERSION = '3.1.0'.freeze
VERSION = '3.2.0'.freeze
end
3 changes: 2 additions & 1 deletion spec/opensearch/transport/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
end

it 'Adds the ApiKey header to the connection' do
expect(authorization_header).to eq("ApiKey #{Base64.strict_encode64('my_id:my_api_key')}")
strict_base64_encoded = ["my_id:my_api_key"].pack("m0")
expect(authorization_header).to eq("ApiKey #{strict_base64_encoded}")
end
end

Expand Down

0 comments on commit b7e2aa3

Please sign in to comment.