Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add models for the /_remotestore/_restore API endpoint #70

Merged
merged 5 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the names of the operation and structures inline with what we would want in the generated code? Or do they need to be changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're named to match the naming scheme of the rest of the specs in the repo. Naming (or encoding friendly names as metadata similar to #73) will likely be a bigger issue, but hard to solve in advance until we get to the point of actually generating parts of a client from these.

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