Skip to content

Commit

Permalink
SnapshotManagement namespace api (opensearch-project#701)
Browse files Browse the repository at this point in the history
* Created yaml structures

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* Fixing errors while linting

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* Changed CHANGELOG.md

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* Tests

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* Linted

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* Fixed the tests. Moved each start,explain and stop API to separate file.Renamed snapshot managment to 'sm'

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* Added version condition

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* changed version.using quoting

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* fixing validation failure

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>

* Quote parameters with backticks.

Signed-off-by: Daniel (dB.) Doubrovkine <dblock@dblock.org>

---------

Signed-off-by: alen_abeshov <a_abeshov@kbtu.kz>
Signed-off-by: Daniel (dB.) Doubrovkine <dblock@dblock.org>
Co-authored-by: Daniel (dB.) Doubrovkine <dblock@dblock.org>
  • Loading branch information
aabeshov and dblock authored Dec 9, 2024
1 parent 8146594 commit 87847db
Show file tree
Hide file tree
Showing 7 changed files with 1,019 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added API spec for `adjust_pure_negative` for bool queries ([#641](https://github.com/opensearch-project/opensearch-api-specification/pull/641))
- Added a spec style checker [#620](https://github.com/opensearch-project/opensearch-api-specification/pull/620).
- Added `remote_store` to node `Stats` ([#643](https://github.com/opensearch-project/opensearch-api-specification/pull/643))
- Added `sm` namespace API specifications ([#701](https://github.com/opensearch-project/opensearch-api-specification/pull/701))

### Changed

Expand Down
325 changes: 325 additions & 0 deletions spec/namespaces/sm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
openapi: 3.1.0
info:
title: OpenSearch Snapshot Management API
description: API for automating snapshot management tasks.
version: 1.0.0

paths:
/_plugins/_sm/policies:
get:
operationId: sm.get_policies.0
x-operation-group: sm.get_policies
x-version-added: '2.1'
description: Retrieves all snapshot management policies with optional pagination and filtering.
parameters:
- $ref: '#/components/parameters/sm.get_policies::query.from'
- $ref: '#/components/parameters/sm.get_policies::query.queryString'
- $ref: '#/components/parameters/sm.get_policies::query.size'
- $ref: '#/components/parameters/sm.get_policies::query.sortField'
- $ref: '#/components/parameters/sm.get_policies::query.sortOrder'
responses:
'200':
$ref: '#/components/responses/sm.get_policies@200'

/_plugins/_sm/policies/{policy_name}:
get:
operationId: sm.get_policy.0
x-operation-group: sm.get_policy
x-version-added: '2.1'
description: Retrieves a specific snapshot management policy by name.
parameters:
- $ref: '#/components/parameters/sm.get_policy::path.policy_name'
responses:
'200':
$ref: '#/components/responses/sm.get_policy@200'
'404':
$ref: '#/components/responses/sm.get_policy@404'
post:
operationId: sm.create_policy.0
x-operation-group: sm.create_policy
x-version-added: '2.1'
description: Creates a snapshot management policy.
parameters:
- $ref: '#/components/parameters/sm.create_policy::path.policy_name'
requestBody:
$ref: '#/components/requestBodies/sm.create_policy'
responses:
'201':
$ref: '#/components/responses/sm.create_policy@201'
'400':
$ref: '#/components/responses/sm.create_policy@400'
put:
operationId: sm.update_policy.0
x-operation-group: sm.update_policy
x-version-added: '2.1'
description: Updates an existing snapshot management policy. Requires `if_seq_no` and `if_primary_term`.
parameters:
- $ref: '#/components/parameters/sm.update_policy::path.policy_name'
- $ref: '#/components/parameters/sm.update_policy::query.if_primary_term'
- $ref: '#/components/parameters/sm.update_policy::query.if_seq_no'
requestBody:
$ref: '#/components/requestBodies/sm.update_policy'
responses:
'200':
$ref: '#/components/responses/sm.update_policy@200'
'404':
$ref: '#/components/responses/sm.update_policy@404'
delete:
operationId: sm.delete_policy.0
x-operation-group: sm.delete_policy
x-version-added: '2.1'
description: Deletes a snapshot management policy.
parameters:
- $ref: '#/components/parameters/sm.delete_policy::path.policy_name'
responses:
'200':
$ref: '#/components/responses/sm.delete_policy@200'
'404':
$ref: '#/components/responses/sm.delete_policy@404'

/_plugins/_sm/policies/{policy_name}/_explain:
get:
operationId: sm.explain_policy.0
x-operation-group: sm.explain_policy
x-version-added: '2.1'
description: Explains the state of the snapshot management policy.
parameters:
- $ref: '#/components/parameters/sm.explain_policy::path.policy_name'
responses:
'200':
$ref: '#/components/responses/sm.explain_policy@200'

/_plugins/_sm/policies/{policy_name}/_start:
post:
operationId: sm.start_policy.0
x-operation-group: sm.start_policy
x-version-added: '2.1'
description: Starts a snapshot management policy.
parameters:
- $ref: '#/components/parameters/sm.start_policy::path.policy_name'
responses:
'200':
$ref: '#/components/responses/sm.start_policy@200'

/_plugins/_sm/policies/{policy_name}/_stop:
post:
operationId: sm.stop_policy.0
x-operation-group: sm.stop_policy
x-version-added: '2.1'
description: Stops a snapshot management policy.
parameters:
- $ref: '#/components/parameters/sm.stop_policy::path.policy_name'
responses:
'200':
$ref: '#/components/responses/sm.stop_policy@200'

components:
requestBodies:
sm.create_policy:
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/CreateUpdatePolicyRequest'
sm.update_policy:
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/CreateUpdatePolicyRequest'

responses:
sm.get_policies@200:
description: Successfully retrieved the list of snapshot management policies.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/GetPoliciesResponse'

sm.create_policy@201:
description: Successfully created the snapshot management policy.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/PolicyResponse'
sm.create_policy@400:
description: Bad request when creating the snapshot management policy.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/BadRequestResponse'

sm.get_policy@200:
description: Successfully retrieved the snapshot management policy.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/PolicyResponse'
sm.get_policy@404:
description: Snapshot management policy not found.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/NotFoundResponse'

sm.update_policy@200:
description: Successfully updated the snapshot management policy.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/PolicyResponse'
sm.update_policy@404:
description: Snapshot management policy not found.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/NotFoundResponse'

sm.delete_policy@200:
description: Successfully deleted the snapshot management policy.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/DeletePolicyResponse'
sm.delete_policy@404:
description: Snapshot management policy not found.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/NotFoundResponse'

sm.explain_policy@200:
description: Successfully explained the state of the snapshot management policy.
content:
application/json:
schema:
$ref: '../schemas/sm._common.yaml#/components/schemas/PolicyExplanation'

sm.start_policy@200:
description: Successfully started the snapshot management policy.
content:
application/json:
schema:
type: object
properties:
acknowledged:
type: boolean

sm.stop_policy@200:
description: Successfully stopped the snapshot management policy.
content:
application/json:
schema:
type: object
properties:
acknowledged:
type: boolean

parameters:
sm.create_policy::path.policy_name:
name: policy_name
in: path
description: The name of the snapshot management policy.
required: true
schema:
type: string

sm.get_policy::path.policy_name:
name: policy_name
in: path
description: The name of the snapshot management policy.
required: true
schema:
type: string

sm.get_policies::query.from:
name: from
in: query
description: 'The starting index (default: 0)'
schema:
type: integer

sm.update_policy::path.policy_name:
name: policy_name
in: path
description: The name of the snapshot management policy.
required: true
schema:
type: string

sm.update_policy::query.if_seq_no:
name: if_seq_no
in: query
description: The sequence number of the policy to update.
required: true
schema:
type: integer

sm.update_policy::query.if_primary_term:
name: if_primary_term
in: query
description: The primary term of the policy to update.
required: true
schema:
type: integer

sm.delete_policy::path.policy_name:
name: policy_name
in: path
description: The name of the snapshot management policy.
required: true
schema:
type: string

sm.explain_policy::path.policy_name:
name: policy_name
in: path
description: The name of the snapshot management policy.
required: true
schema:
type: string

sm.start_policy::path.policy_name:
name: policy_name
in: path
description: The name of the snapshot management policy.
required: true
schema:
type: string

sm.stop_policy::path.policy_name:
name: policy_name
in: path
description: The name of the snapshot management policy.
required: true
schema:
type: string

sm.get_policies::query.size:
name: size
in: query
description:
The number of policies to return.
schema:
type: integer

sm.get_policies::query.queryString:
name: queryString
in: query
description: A query string to filter policies.
schema:
type: string

sm.get_policies::query.sortField:
name: sortField
in: query
description: The field to sort on.
schema:
type: string

sm.get_policies::query.sortOrder:
name: sortOrder
in: query
description: The order of sorting.
schema:
type: string
enum: [asc, desc]
default: asc
Loading

0 comments on commit 87847db

Please sign in to comment.