-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CODE_GEN] Added
remote_store.restore
action
Signed-off-by: Theo Truong <theotr@amazon.com>
- Loading branch information
Showing
5 changed files
with
154 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
# | ||
# Modifications Copyright OpenSearch Contributors. See | ||
# GitHub history for details. | ||
|
||
# This code was generated from OpenSearch API Spec. | ||
# Update the code generation logic instead of modifying this file directly. | ||
|
||
# frozen_string_literal: true | ||
|
||
module OpenSearch | ||
module API | ||
module RemoteStore | ||
module Actions | ||
RESTORE_QUERY_PARAMS = Set.new(%i[ | ||
cluster_manager_timeout | ||
wait_for_completion | ||
]).freeze | ||
|
||
# Restores from remote store. | ||
# | ||
# @option arguments [Time] :cluster_manager_timeout Operation timeout for connection to cluster-manager node. | ||
# @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning. | ||
# @option arguments [Hash] :body *Required* Comma-separated list of index IDs | ||
# | ||
# {API Reference}[https://opensearch.org/docs/latest/opensearch/remote/#restoring-from-a-backup] | ||
def restore(arguments = {}) | ||
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] | ||
|
||
arguments = arguments.clone | ||
headers = arguments.delete(:headers) || {} | ||
body = arguments.delete(:body) | ||
url = Utils.__pathify '_remotestore', '_restore' | ||
method = OpenSearch::API::HTTP_POST | ||
params = Utils.__validate_and_extract_params arguments, RESTORE_QUERY_PARAMS | ||
|
||
perform_request(method, url, params, body, headers).body | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
# | ||
# Modifications Copyright OpenSearch Contributors. See | ||
# GitHub history for details. | ||
|
||
# This code was generated from OpenSearch API Spec. | ||
# Update the code generation logic instead of modifying this file directly. | ||
|
||
# frozen_string_literal: true | ||
|
||
module OpenSearch | ||
module API | ||
module RemoteStore | ||
module Actions; end | ||
|
||
# Client for the "remote_store" namespace (includes the RemoteStore::Actions methods) | ||
class RemoteStoreClient | ||
include RemoteStore::Actions | ||
include Common::Client | ||
include Common::Client::Base | ||
end | ||
|
||
# Proxy method for RemoteStoreClient, available in the receiving object | ||
def remote_store | ||
@remote_store ||= RemoteStoreClient.new(self) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
# | ||
# Modifications Copyright OpenSearch Contributors. See | ||
# GitHub history for details. | ||
|
||
# This code was generated from OpenSearch API Spec. | ||
# Update the code generation logic instead of modifying this file directly. | ||
|
||
# frozen_string_literal: true | ||
|
||
require_relative '../../../../spec_helper' | ||
|
||
describe 'client.remote_store#restore' do | ||
let(:expected_args) do | ||
[ | ||
'POST', | ||
'_remotestore/_restore', | ||
{ cluster_manager_timeout: '1m', | ||
wait_for_completion: true }, | ||
{}, | ||
{} | ||
] | ||
end | ||
|
||
let(:client) do | ||
Class.new { include OpenSearch::API }.new | ||
end | ||
|
||
it 'requires the :body argument' do | ||
expect do | ||
client.remote_store.restore | ||
end.to raise_exception(ArgumentError) | ||
end | ||
|
||
it 'performs the request with all optional params' do | ||
expect(client_double.remote_store.restore( | ||
cluster_manager_timeout: '1m', | ||
wait_for_completion: true, | ||
body: {} | ||
)).to eq({}) | ||
end | ||
end |