Skip to content

Commit

Permalink
Add Block Index APi
Browse files Browse the repository at this point in the history
Signed-off-by: Archer <[email protected]>
  • Loading branch information
Naarcha-AWS committed Jul 25, 2024
1 parent 6882b99 commit 39a1ced
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions _api-reference/index-apis/blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
layout: default
title: Blocks
parent: Index APIs
nav_order: 6
---

# Blocks
**Introduced 1.0**
{: .label .label-purple }

The Blocks API limits which operations are available on the specified index. OpenSearch provides different types of blocks that allow you to restrict write, read, or metadata operations on an index. When adding a write block through the API, it ensures that all shards of the index have properly accounted for the block before returning a successful response to the user. This means that any in-flight write operations to the index have been completed before the write block takes effect.

Check failure on line 12 in _api-reference/index-apis/blocks.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _api-reference/index-apis/blocks.md#L12

[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'index. When'.
Raw output
{"message": "[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'index. When'.", "location": {"path": "_api-reference/index-apis/blocks.md", "range": {"start": {"line": 12, "column": 193}}}, "severity": "ERROR"}

## Path and HTTP methods

```json
PUT /<index>/_block/<block>
```

## Path parameters

| Parameter | Type | Description |
:--- | :--- | :---
| `index` | String | A comma-delimited list of index names. Wildcard expressions (`*`) are supported. To target all data streams and indexes in a cluster, use `_all` or `*`. Optional. |
| `<block>` | String | Specifies the type of block to apply to the index. Valid values are: <br> `metadata`: Disables all metadata changes, such as closing the index. <br> `read`: Disables any read operations. <br> `read_only`: Disables any write operations and metadata changes. <br> `write`: Disables write operations. However, metadata changes are still allowed. |

Check failure on line 25 in _api-reference/index-apis/blocks.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _api-reference/index-apis/blocks.md#L25

[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'index. Valid'.
Raw output
{"message": "[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'index. Valid'.", "location": {"path": "_api-reference/index-apis/blocks.md", "range": {"start": {"line": 25, "column": 68}}}, "severity": "ERROR"}

## Query parameters

The following table lists the available query parameters. All query parameters are optional.

| Parameter | Data type | Description |
| :--- | :--- | :--- |
| `ignore_unavailable` | Boolean | When `false`, the request returns an error when it targets a missing or closed index. Default is `false`.
| `allow_no_indices` | Boolean | When `false`, the Refresh Index API returns an error when a wildcard expression, index alias, or `_all` targets only closed or missing indexes, even when the request is made against open indexes. Default is `true`. |
| `expand_wildcards` | String | The type of index that the wildcard patterns can match. If the request targets data streams, this argument determines whether the wildcard expressions match any hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are `all`, `open`, `closed`, `hidden`, and `none`. |
`cluster_manager_timeout` | Time | The amount of time to wait for a connection to the cluster manager node. Default is `30s`.
`timeout` | Time | The amount of time to wait for the request to return. Default is `30s`. |

## Example request

The following example request disables any `write` operations made to the test index:

```json
PUT /test-index/_block/write
```

## Example response

```json
{
"acknowledged" : true,
"shards_acknowledged" : true,
"indices" : [ {
"name" : "test-index",
"blocked" : true
} ]
}
```

0 comments on commit 39a1ced

Please sign in to comment.