Skip to content

Commit

Permalink
Added ISM CRUD APIs.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Sep 11, 2024
1 parent 40bd0a5 commit 691b32e
Show file tree
Hide file tree
Showing 3 changed files with 318 additions and 0 deletions.
168 changes: 168 additions & 0 deletions spec/namespaces/ism.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
openapi: 3.1.0
info:
title: OpenSearch ISM API
description: Use the index state management operations to programmatically work with policies and managed indexes.
version: 1.0.0
paths:
/_plugins/_ism/policies/{policy_id}:
get:
operationId: ism.get_policy.0
x-operation-group: ism.get_policy
description: Gets the policy.
externalDocs:
url: https://opensearch.org/docs/latest/im-plugin/ism/api/#get-policy
parameters:
- $ref: '#/components/parameters/ism.get_policy::path.policy_id'
responses:
'200':
$ref: '#/components/responses/ism.get_policy@200'
put:
operationId: ism.put_policy.0
x-operation-group: ism.put_policy
description: Creates or updates a policy.
externalDocs:
url: https://opensearch.org/docs/latest/im-plugin/ism/api/#create-policy
parameters:
- $ref: '#/components/parameters/ism.put_policy::path.policy_id'
- $ref: '#/components/parameters/ism.put_policy::query.if_primary_term'
- $ref: '#/components/parameters/ism.put_policy::query.if_seq_no'
requestBody:
$ref: '#/components/requestBodies/ism.put_policy'
responses:
'201':
$ref: '#/components/responses/ism.put_policy@201'
'200':
$ref: '#/components/responses/ism.put_policy@200'
delete:
operationId: ism.delete_policy.0
x-operation-group: ism.delete_policy
description: Deletes a policy.
externalDocs:
url: https://opensearch.org/docs/latest/im-plugin/ism/api/#delete-policy
parameters:
- $ref: '#/components/parameters/ism.delete_policy::path.policy_id'
responses:
'200':
$ref: '#/components/responses/ism.delete_policy@200'
/_plugins/_ism/add/{index}:
post:
operationId: ism.add_policy.0
x-operation-group: ism.add_policy
description: Adds a policy to an index.
externalDocs:
url: https://opensearch.org/docs/latest/im-plugin/ism/api/#add-policy
parameters:
- $ref: '#/components/parameters/ism.add_policy::path.index'
requestBody:
$ref: '#/components/requestBodies/ism.add_policy'
responses:
'200':
$ref: '#/components/responses/ism.add_policy@200'
/_plugins/_ism/remove/{index}:
post:
operationId: ism.remove_policy.0
x-operation-group: ism.remove_policy
description: Removes a policy from an index.
externalDocs:
url: https://opensearch.org/docs/latest/im-plugin/ism/api/#remove-policy
parameters:
- $ref: '#/components/parameters/ism.remove_policy::path.index'
responses:
'200':
$ref: '#/components/responses/ism.remove_policy@200'
components:
requestBodies:
ism.put_policy:
content:
application/json:
schema:
type: object
ism.add_policy:
content:
application/json:
schema:
type: object
responses:
ism.get_policy@200:
content:
application/json:
schema:
$ref: '../schemas/ism._common.yaml#/components/schemas/GetPolicyResponse'
ism.put_policy@201:
content:
application/json:
schema:
$ref: '../schemas/ism._common.yaml#/components/schemas/PutPolicyResponse'
ism.put_policy@200:
content:
application/json:
schema:
$ref: '../schemas/ism._common.yaml#/components/schemas/PutPolicyResponse'
ism.delete_policy@200:
content:
application/json:
schema:
$ref: '../schemas/ism._common.yaml#/components/schemas/DeletePolicyResponse'
ism.add_policy@200:
content:
application/json:
schema:
$ref: '../schemas/ism._common.yaml#/components/schemas/AddPolicyResponse'
ism.remove_policy@200:
content:
application/json:
schema:
$ref: '../schemas/ism._common.yaml#/components/schemas/RemovePolicyResponse'
parameters:
ism.get_policy::path.policy_id:
name: policy_id
in: path
required: true
schema:
type: string
ism.put_policy::path.policy_id:
name: policy_id
in: path
required: true
schema:
type: string
ism.delete_policy::path.policy_id:
name: policy_id
in: path
required: true
schema:
type: string
ism.put_policy::query.if_seq_no:
name: if_seq_no
in: query
description: Only perform the operation if the document has this sequence number.
schema:
$ref: '../schemas/_common.yaml#/components/schemas/SequenceNumber'
style: form
ism.put_policy::query.if_primary_term:
name: if_primary_term
in: query
description: Only perform the operation if the document has this primary term.
schema:
type: number
style: form
ism.add_policy::path.index:
name: index
in: path
description: |-
Comma-separated list of data streams, indices, and aliases.
Supports wildcards (`*`).
required: true
schema:
$ref: '../schemas/_common.yaml#/components/schemas/IndexName'
style: simple
ism.remove_policy::path.index:
name: index
in: path
description: |-
Comma-separated list of data streams, indices, and aliases.
Supports wildcards (`*`).
required: true
schema:
$ref: '../schemas/_common.yaml#/components/schemas/IndexName'
style: simple
83 changes: 83 additions & 0 deletions spec/schemas/ism._common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
openapi: 3.1.0
info:
title: Schemas of ism._common Category
description: Schemas of ism._common category.
version: 1.0.0
paths: {}
components:
schemas:
GetPolicyResponse:
type: object
PutPolicyResponse:
type: object
properties:
_id:
$ref: '_common.yaml#/components/schemas/Id'
_primary_term:
type: number
_seq_no:
$ref: '_common.yaml#/components/schemas/SequenceNumber'
_version:
$ref: '_common.yaml#/components/schemas/VersionNumber'
policy:
$ref: '#/components/schemas/PolicyEnvelope'
required:
- _id
- _version
DeletePolicyResponse:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
AddPolicyResponse:
type: object
RemovePolicyResponse:
type: object
PolicyEnvelope:
type: object
properties:
policy:
$ref: '#/components/schemas/Policy'
Policy:
type: object
properties:
policy_id:
type: string
description:
type: string
last_updated_time:
type: integer
schema_version:
type: number
error_notification:
type: [string, 'null']

Check failure on line 51 in spec/schemas/ism._common.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected sequence values to be in ascending order. 'null' should be before 'string'
default_state:
type: string
states:
type: array
items:
$ref: '#/components/schemas/State'
ism_template:
type: [string, 'null']

Check failure on line 59 in spec/schemas/ism._common.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected sequence values to be in ascending order. 'null' should be before 'string'
State:
type: object
properties:
name:
type: string
actions:
type: array
items:
$ref: '#/components/schemas/Action'
transitions:
type: array
items:
$ref: '#/components/schemas/Transition'
Action:
type: object
additionalProperties: true
Transition:
type: object
properties:
state_name:
type: string
conditions:
type: object
additionalProperties: true
67 changes: 67 additions & 0 deletions tests/default/ism/policies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test index state management operations.
epilogues:
- path: /_plugins/_ism/policies/logs
method: DELETE
status: [200, 404]
chapters:
- synopsis: Create a policy.
id: policy
path: /_plugins/_ism/policies/{policy_id}
method: PUT
parameters:
policy_id: logs
request:
payload:
policy:
description: Ingesting logs.
default_state: ingest
states:
- name: ingest
actions:
- rollover:
min_doc_count: 5
transitions:
- state_name: search
- name: search
actions: []
transitions:
- state_name: delete
conditions:
min_index_age: 5m
- name: delete
actions:
- delete: {}
transitions: []
response:
status: 201
output:
primary_term: payload._primary_term
seq_no: payload._seq_no
- synopsis: Update a policy.
path: /_plugins/_ism/policies/{policy_id}
method: PUT
parameters:
policy_id: logs
if_primary_term: ${policy.primary_term}
if_seq_no: ${policy.seq_no}
request:
payload:
policy:
description: Ingesting logs.
default_state: ingest
states:
- name: ingest
actions:
- rollover:
min_doc_count: 3
response:
status: 200
- synopsis: Delete a policy.
path: /_plugins/_ism/policies/{policy_id}
method: DELETE
parameters:
policy_id: logs
response:
status: 200

0 comments on commit 691b32e

Please sign in to comment.