|
| 1 | +# Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +# license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright |
| 4 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +# the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +import typing as t |
| 19 | + |
| 20 | +from elastic_transport import ObjectApiResponse, TextApiResponse |
| 21 | + |
| 22 | +from ._base import NamespacedClient |
| 23 | +from .utils import ( |
| 24 | + SKIP_IN_PATH, |
| 25 | + Stability, |
| 26 | + _availability_warning, |
| 27 | + _quote, |
| 28 | + _rewrite_parameters, |
| 29 | +) |
| 30 | + |
| 31 | + |
| 32 | +class StreamsClient(NamespacedClient): |
| 33 | + |
| 34 | + @_rewrite_parameters() |
| 35 | + @_availability_warning(Stability.EXPERIMENTAL) |
| 36 | + async def logs_disable( |
| 37 | + self, |
| 38 | + *, |
| 39 | + name: t.Union[str, t.Literal["logs", "logs.ecs", "logs.otel"]], |
| 40 | + error_trace: t.Optional[bool] = None, |
| 41 | + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, |
| 42 | + human: t.Optional[bool] = None, |
| 43 | + master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, |
| 44 | + pretty: t.Optional[bool] = None, |
| 45 | + timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, |
| 46 | + ) -> t.Union[ObjectApiResponse[t.Any], TextApiResponse]: |
| 47 | + """ |
| 48 | + .. raw:: html |
| 49 | +
|
| 50 | + <p>Disable a named stream.</p> |
| 51 | + <p>Turn off the named stream feature for this cluster.</p> |
| 52 | +
|
| 53 | +
|
| 54 | + `<https://www.elastic.co/docs/api/doc/elasticsearch#TODO>`_ |
| 55 | +
|
| 56 | + :param name: The stream type to disable. |
| 57 | + :param master_timeout: The period to wait for a connection to the master node. |
| 58 | + If no response is received before the timeout expires, the request fails |
| 59 | + and returns an error. |
| 60 | + :param timeout: The period to wait for a response. If no response is received |
| 61 | + before the timeout expires, the request fails and returns an error. |
| 62 | + """ |
| 63 | + if name in SKIP_IN_PATH: |
| 64 | + raise ValueError("Empty value passed for parameter 'name'") |
| 65 | + __path_parts: t.Dict[str, str] = {"name": _quote(name)} |
| 66 | + __path = f'/_streams/{__path_parts["name"]}/_disable' |
| 67 | + __query: t.Dict[str, t.Any] = {} |
| 68 | + if error_trace is not None: |
| 69 | + __query["error_trace"] = error_trace |
| 70 | + if filter_path is not None: |
| 71 | + __query["filter_path"] = filter_path |
| 72 | + if human is not None: |
| 73 | + __query["human"] = human |
| 74 | + if master_timeout is not None: |
| 75 | + __query["master_timeout"] = master_timeout |
| 76 | + if pretty is not None: |
| 77 | + __query["pretty"] = pretty |
| 78 | + if timeout is not None: |
| 79 | + __query["timeout"] = timeout |
| 80 | + __headers = {"accept": "text/plain,application/json"} |
| 81 | + return await self.perform_request( # type: ignore[return-value] |
| 82 | + "POST", |
| 83 | + __path, |
| 84 | + params=__query, |
| 85 | + headers=__headers, |
| 86 | + endpoint_id="streams.logs_disable", |
| 87 | + path_parts=__path_parts, |
| 88 | + ) |
| 89 | + |
| 90 | + @_rewrite_parameters() |
| 91 | + @_availability_warning(Stability.EXPERIMENTAL) |
| 92 | + async def logs_enable( |
| 93 | + self, |
| 94 | + *, |
| 95 | + name: t.Union[str, t.Literal["logs", "logs.ecs", "logs.otel"]], |
| 96 | + error_trace: t.Optional[bool] = None, |
| 97 | + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, |
| 98 | + human: t.Optional[bool] = None, |
| 99 | + master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, |
| 100 | + pretty: t.Optional[bool] = None, |
| 101 | + timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, |
| 102 | + ) -> t.Union[ObjectApiResponse[t.Any], TextApiResponse]: |
| 103 | + """ |
| 104 | + .. raw:: html |
| 105 | +
|
| 106 | + <p>Enable a named stream.</p> |
| 107 | + <p>Turn on the named stream feature for this cluster.</p> |
| 108 | + <p>NOTE: To protect existing data, this feature can be turned on only if the cluster does not have |
| 109 | + existing indices or data streams that match the pattern <code><name>|<name>.*</code> for the enabled stream |
| 110 | + type name. If those indices or data streams exist, a <code>409 - Conflict</code> response and error is |
| 111 | + returned.</p> |
| 112 | +
|
| 113 | +
|
| 114 | + `<https://www.elastic.co/docs/api/doc/elasticsearch#TODO>`_ |
| 115 | +
|
| 116 | + :param name: The stream type to enable. |
| 117 | + :param master_timeout: The period to wait for a connection to the master node. |
| 118 | + If no response is received before the timeout expires, the request fails |
| 119 | + and returns an error. |
| 120 | + :param timeout: The period to wait for a response. If no response is received |
| 121 | + before the timeout expires, the request fails and returns an error. |
| 122 | + """ |
| 123 | + if name in SKIP_IN_PATH: |
| 124 | + raise ValueError("Empty value passed for parameter 'name'") |
| 125 | + __path_parts: t.Dict[str, str] = {"name": _quote(name)} |
| 126 | + __path = f'/_streams/{__path_parts["name"]}/_enable' |
| 127 | + __query: t.Dict[str, t.Any] = {} |
| 128 | + if error_trace is not None: |
| 129 | + __query["error_trace"] = error_trace |
| 130 | + if filter_path is not None: |
| 131 | + __query["filter_path"] = filter_path |
| 132 | + if human is not None: |
| 133 | + __query["human"] = human |
| 134 | + if master_timeout is not None: |
| 135 | + __query["master_timeout"] = master_timeout |
| 136 | + if pretty is not None: |
| 137 | + __query["pretty"] = pretty |
| 138 | + if timeout is not None: |
| 139 | + __query["timeout"] = timeout |
| 140 | + __headers = {"accept": "text/plain,application/json"} |
| 141 | + return await self.perform_request( # type: ignore[return-value] |
| 142 | + "POST", |
| 143 | + __path, |
| 144 | + params=__query, |
| 145 | + headers=__headers, |
| 146 | + endpoint_id="streams.logs_enable", |
| 147 | + path_parts=__path_parts, |
| 148 | + ) |
| 149 | + |
| 150 | + @_rewrite_parameters() |
| 151 | + @_availability_warning(Stability.EXPERIMENTAL) |
| 152 | + async def status( |
| 153 | + self, |
| 154 | + *, |
| 155 | + error_trace: t.Optional[bool] = None, |
| 156 | + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, |
| 157 | + human: t.Optional[bool] = None, |
| 158 | + master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, |
| 159 | + pretty: t.Optional[bool] = None, |
| 160 | + ) -> ObjectApiResponse[t.Any]: |
| 161 | + """ |
| 162 | + .. raw:: html |
| 163 | +
|
| 164 | + <p>Get the status of streams.</p> |
| 165 | + <p>Get the current status for all types of streams.</p> |
| 166 | +
|
| 167 | +
|
| 168 | + `<https://www.elastic.co/docs/api/doc/elasticsearch#TODO>`_ |
| 169 | +
|
| 170 | + :param master_timeout: Period to wait for a connection to the master node. If |
| 171 | + no response is received before the timeout expires, the request fails and |
| 172 | + returns an error. |
| 173 | + """ |
| 174 | + __path_parts: t.Dict[str, str] = {} |
| 175 | + __path = "/_streams/status" |
| 176 | + __query: t.Dict[str, t.Any] = {} |
| 177 | + if error_trace is not None: |
| 178 | + __query["error_trace"] = error_trace |
| 179 | + if filter_path is not None: |
| 180 | + __query["filter_path"] = filter_path |
| 181 | + if human is not None: |
| 182 | + __query["human"] = human |
| 183 | + if master_timeout is not None: |
| 184 | + __query["master_timeout"] = master_timeout |
| 185 | + if pretty is not None: |
| 186 | + __query["pretty"] = pretty |
| 187 | + __headers = {"accept": "application/json"} |
| 188 | + return await self.perform_request( # type: ignore[return-value] |
| 189 | + "GET", |
| 190 | + __path, |
| 191 | + params=__query, |
| 192 | + headers=__headers, |
| 193 | + endpoint_id="streams.status", |
| 194 | + path_parts=__path_parts, |
| 195 | + ) |
0 commit comments