Skip to content

Commit

Permalink
Add models for the /_remotestore/_restore API endpoint (#70)
Browse files Browse the repository at this point in the history
* Add models for the `/_remotestore/_restore` API endpoint

Signed-off-by: Thomas Farr <[email protected]>

* Flag as unstable

Signed-off-by: Thomas Farr <[email protected]>

* Fix `test/scripts/operation-filter.py` to work with multiline ops list

Signed-off-by: Thomas Farr <[email protected]>

* Add example to PostRemoteStoreRestore operation

Signed-off-by: Thomas Farr <[email protected]>

* Create test for `/_remotestore/_restore` endpoint

Signed-off-by: Thomas Farr <[email protected]>

---------

Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia authored Feb 10, 2023
1 parent 8d8572c commit bf080fc
Show file tree
Hide file tree
Showing 9 changed files with 387 additions and 6 deletions.
4 changes: 4 additions & 0 deletions model/common_datatypes.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ enum SettingType {
DEFAULTS = "defaults"
}

list IndexNameList {
member: IndexName
}

list UserDefinedValueList{
member: String
}
Expand Down
20 changes: 19 additions & 1 deletion model/opensearch.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,23 @@ use aws.protocols#restJson1
@restJson1
service OpenSearch {
version: "2021-11-23",
operations: [PutCreateIndex, PutIndexMappingWithIndex, GetCatIndices, GetCatIndicesWithIndex, GetCatNodes, PostSearch, PostSearchWithIndex, DeleteIndex, GetDocumentDoc, GetDocumentSource, GetClusterInfo, PutUpdateClusterSettings, GetClusterSettings, PostAliases, GetSettingsIndex, GetSettingsIndexSetting]
operations: [
PutCreateIndex,
PutIndexMappingWithIndex,
GetCatIndices,
GetCatIndicesWithIndex,
GetCatNodes,
PostSearch,
PostSearchWithIndex,
DeleteIndex,
GetDocumentDoc,
GetDocumentSource,
GetClusterInfo,
PutUpdateClusterSettings,
GetClusterSettings,
PostAliases,
GetSettingsIndex,
GetSettingsIndexSetting,
PostRemoteStoreRestore
]
}
21 changes: 21 additions & 0 deletions model/remotestore/restore/operations.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.

$version: "2"
namespace OpenSearch

@unstable
@externalDocumentation(
"OpenSearch Documentation": "https://opensearch.org/docs/latest/opensearch/remote/#restoring-from-a-backup"
)

@suppress(["HttpUriConflict"])
@http(method: "POST", uri: "/_remotestore/_restore")
@documentation("Restore one or more indices from a remote backup.")
operation PostRemoteStoreRestore{
input: PostRemoteStoreRestoreInput,
output: PostRemoteStoreRestoreOutput
}
59 changes: 59 additions & 0 deletions model/remotestore/restore/structures.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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.

$version: "2"
namespace OpenSearch

@unstable
structure PostRemoteStoreRestoreInput {
@httpQuery("cluster_manager_timeout")
cluster_manager_timeout: Time,

@httpQuery("wait_for_completion")
wait_for_completion: Boolean,

@required
indices: IndexNameList
}

@unstable
structure PostRemoteStoreRestoreOutput {
accepted: Boolean,
remote_store: RemoteStoreRestoreInfo
}

@unstable
structure RemoteStoreRestoreInfo {
snapshot: String,
indices: IndexNameList,
shards: RemoteStoreRestoreShardsInfo
}

@unstable
structure RemoteStoreRestoreShardsInfo {
total: Integer,
failed: Integer,
successful: Integer
}

apply PostRemoteStoreRestore @examples([
{
title: "Examples for Post Remote Storage Restore Operation.",
input: {
indices: ["books"]
},
output: {
remote_store: {
indices: ["books"],
shards: {
total: 1,
failed: 0,
successful: 1
}
}
}
}
])
13 changes: 9 additions & 4 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
version: '3'
services:
opensearch-node1:
image: opensearchproject/opensearch:latest
build: ./opensearch
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node1
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_master_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
- path.repo=/mnt/snapshots
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m -Dopensearch.experimental.feature.replication_type.enabled=true -Dopensearch.experimental.feature.remote_store.enabled=true"
ulimits:
memlock:
soft: -1
Expand All @@ -19,22 +20,24 @@ services:
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data
- opensearch-snapshots:/mnt/snapshots
ports:
- 9200:9200
- 9600:9600 # required for Performance Analyzer
networks:
- opensearch-net

opensearch-node2:
image: opensearchproject/opensearch:latest
build: ./opensearch
container_name: opensearch-node2
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node2
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_master_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
- path.repo=/mnt/snapshots
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m -Dopensearch.experimental.feature.replication_type.enabled=true -Dopensearch.experimental.feature.remote_store.enabled=true"
ulimits:
memlock:
soft: -1
Expand All @@ -44,12 +47,14 @@ services:
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data
- opensearch-snapshots:/mnt/snapshots
networks:
- opensearch-net

volumes:
opensearch-data1:
opensearch-data2:
opensearch-snapshots:

networks:
opensearch-net:
169 changes: 169 additions & 0 deletions test/models/remotestore/restore/OpenSearchModel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"openapi": "3.0.2",
"info": {
"title": "OpenSearch",
"version": "2021-11-23"
},
"paths": {
"/_remotestore/_restore": {
"post": {
"description": "Restore one or more indices from a remote backup.",
"operationId": "PostRemoteStoreRestore",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PostRemoteStoreRestoreRequestContent"
},
"examples": {
"PostRemoteStoreRestore_example1": {
"summary": "Examples for Post Remote Storage Restore Operation.",
"description": "",
"value": {
"indices": [
"books"
]
}
}
}
}
},
"required": true
},
"parameters": [
{
"name": "cluster_manager_timeout",
"in": "query",
"schema": {
"type": "string",
"pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$"
}
},
{
"name": "wait_for_completion",
"in": "query",
"schema": {
"type": "boolean"
}
}
],
"responses": {
"200": {
"description": "PostRemoteStoreRestore 200 response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PostRemoteStoreRestoreResponseContent"
},
"examples": {
"PostRemoteStoreRestore_example1": {
"summary": "Examples for Post Remote Storage Restore Operation.",
"description": "",
"value": {
"remote_store": {
"indices": [
"books"
],
"shards": {
"total": 1,
"failed": 0,
"successful": 1
}
}
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"PostRemoteStoreRestoreRequestContent": {
"type": "object",
"properties": {
"indices": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$"
}
}
},
"required": [
"indices"
]
},
"PostRemoteStoreRestoreResponseContent": {
"type": "object",
"properties": {
"accepted": {
"type": "boolean"
},
"remote_store": {
"$ref": "#/components/schemas/RemoteStoreRestoreInfo"
}
},
"example": {
"remote_store": {
"indices": [
"books"
],
"shards": {
"total": 1,
"failed": 0,
"successful": 1
}
}
}
},
"RemoteStoreRestoreInfo": {
"type": "object",
"properties": {
"snapshot": {
"type": "string"
},
"indices": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$"
}
},
"shards": {
"$ref": "#/components/schemas/RemoteStoreRestoreShardsInfo"
}
}
},
"RemoteStoreRestoreShardsInfo": {
"type": "object",
"properties": {
"total": {
"type": "number"
},
"failed": {
"type": "number"
},
"successful": {
"type": "number"
}
}
}
},
"securitySchemes": {
"smithy.api.httpBasicAuth": {
"type": "http",
"description": "HTTP Basic authentication",
"scheme": "Basic"
}
}
},
"security": [
{
"smithy.api.httpBasicAuth": []
}
]
}
Loading

0 comments on commit bf080fc

Please sign in to comment.