Skip to content

Commit 686c483

Browse files
committed
Add index block removal API
Follow-up of elastic/elasticsearch#129128
1 parent d506a99 commit 686c483

File tree

5 files changed

+170
-12
lines changed

5 files changed

+170
-12
lines changed

specification/indices/add_block/IndicesAddBlockRequest.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import { RequestBase } from '@_types/Base'
2121
import { ExpandWildcards, IndexName } from '@_types/common'
2222
import { Duration } from '@_types/Time'
23+
import {IndexSettingBlocks, IndexSettings} from "../_types/IndexSettings";
2324

2425
/**
2526
* Add an index block.
@@ -49,7 +50,7 @@ export interface Request extends RequestBase {
4950
/**
5051
* The block type to add to the index.
5152
*/
52-
block: IndicesBlockOptions
53+
block: keyof IndexSettingBlocks
5354
}
5455
query_parameters: {
5556
/**
@@ -87,14 +88,3 @@ export interface Request extends RequestBase {
8788
timeout?: Duration // default: 30s
8889
}
8990
}
90-
91-
export enum IndicesBlockOptions {
92-
/** Disable metadata changes, such as closing the index. */
93-
metadata,
94-
/** Disable read operations. */
95-
read,
96-
/** Disable write operations and metadata changes. */
97-
read_only,
98-
/** Disable write operations. However, metadata changes are still allowed. */
99-
write
100-
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RequestBase } from '@_types/Base'
21+
import { ExpandWildcards, IndexName } from '@_types/common'
22+
import { Duration } from '@_types/Time'
23+
import {IndexSettingBlocks, IndexSettings} from "../_types/IndexSettings";
24+
25+
/**
26+
* Remove an index block.
27+
*
28+
* Remove an index block from an index.
29+
* Index blocks limit the operations allowed on an index by blocking specific operation types.
30+
* @rest_spec_name indices.remove_block
31+
* @availability stack since=9.1.0 stability=stable
32+
* @availability serverless stability=stable visibility=public
33+
* @doc_id index-block-remove
34+
*/
35+
export interface Request extends RequestBase {
36+
urls: [
37+
{
38+
path: '/{index}/_block/{block}'
39+
methods: ['DELETE']
40+
}
41+
]
42+
path_parts: {
43+
/**
44+
* A comma-separated list or wildcard expression of index names used to limit the request.
45+
* By default, you must explicitly name the indices you are removing blocks from.
46+
* To allow the removal of blocks from indices with `_all`, `*`, or other wildcard expressions, change the `action.destructive_requires_name` setting to `false`.
47+
* You can update this setting in the `elasticsearch.yml` file or by using the cluster update settings API.
48+
*/
49+
index: IndexName
50+
/**
51+
* The block type to remove from the index.
52+
*/
53+
block: keyof IndexSettingBlocks
54+
}
55+
query_parameters: {
56+
/**
57+
* If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.
58+
* This behavior applies even if the request targets other open indices.
59+
* For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
60+
* @server_default true
61+
*/
62+
allow_no_indices?: boolean // default: true
63+
/**
64+
* The type of index that wildcard patterns can match.
65+
* If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.
66+
* It supports comma-separated values, such as `open,hidden`.
67+
* @server_default open
68+
*/
69+
expand_wildcards?: ExpandWildcards // default: open
70+
/**
71+
* If `false`, the request returns an error if it targets a missing or closed index.
72+
* @server_default false
73+
*/
74+
ignore_unavailable?: boolean // default: false
75+
/**
76+
* The period to wait for the master node.
77+
* If the master node is not available before the timeout expires, the request fails and returns an error.
78+
* It can also be set to `-1` to indicate that the request should never timeout.
79+
* @server_default 30s
80+
*/
81+
master_timeout?: Duration // default: 30s
82+
/**
83+
* The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata.
84+
* If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged.
85+
* It can also be set to `-1` to indicate that the request should never timeout.
86+
* @server_default 30s
87+
*/
88+
timeout?: Duration // default: 30s
89+
}
90+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { IndexName } from '@_types/common'
21+
22+
export class Response {
23+
body: {
24+
acknowledged: boolean
25+
indices: IndicesBlockStatus[]
26+
}
27+
}
28+
29+
export class IndicesBlockStatus {
30+
name: IndexName
31+
unblocked: boolean
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
method_request: DELETE /my-index-000001/_block/write
2+
alternatives:
3+
- language: Python
4+
code: |-
5+
resp = client.indices.remove_block(
6+
index="my-index-000001",
7+
block="write",
8+
)
9+
- language: JavaScript
10+
code: |-
11+
const response = await client.indices.removeBlock({
12+
index: "my-index-000001",
13+
block: "write",
14+
});
15+
- language: Ruby
16+
code: |-
17+
response = client.indices.remove_block(
18+
index: "my-index-000001",
19+
block: "write"
20+
)
21+
- language: PHP
22+
code: |-
23+
$resp = $client->indices()->removeBlock([
24+
"index" => "my-index-000001",
25+
"block" => "write",
26+
]);
27+
- language: curl
28+
code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/my-index-000001/_block/write"'
29+
- language: Java
30+
code: |
31+
client.indices().removeBlock(a -> a
32+
.block(IndicesBlockOptions.Write)
33+
.index("my-index-000001")
34+
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# summary: ''
2+
description: A successful response from `DELETE /my-index-000001/_block/write`, which removes an index block from an index.'
3+
# type: response
4+
# response_code: 200
5+
value: |-
6+
{
7+
"acknowledged" : true,
8+
"indices" : [ {
9+
"name" : "my-index-000001",
10+
"unblocked" : true
11+
} ]
12+
}

0 commit comments

Comments
 (0)