1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
|
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
class TransformClient(NamespacedClient):
@query_params(
"force",
"timeout",
response_mimetypes=["application/json"],
)
def delete_transform(self, transform_id, params=None, headers=None):
"""
Deletes an existing transform.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-transform.html>`_
:arg transform_id: The id of the transform to delete
:arg force: When `true`, the transform is deleted regardless of
its current state. The default value is `false`, meaning that the
transform must be `stopped` before it can be deleted.
:arg timeout: Controls the time to wait for the transform
deletion
"""
if transform_id in SKIP_IN_PATH:
raise ValueError(
"Empty value passed for a required argument 'transform_id'."
)
return self.transport.perform_request(
"DELETE",
_make_path("_transform", transform_id),
params=params,
headers=headers,
)
@query_params(
"allow_no_match",
"exclude_generated",
"from_",
"size",
response_mimetypes=["application/json"],
)
def get_transform(self, transform_id=None, params=None, headers=None):
"""
Retrieves configuration information for transforms.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-transform.html>`_
:arg transform_id: The id or comma delimited list of id
expressions of the transforms to get, '_all' or '*' implies get all
transforms
:arg allow_no_match: Whether to ignore if a wildcard expression
matches no transforms. (This includes `_all` string or when no
transforms have been specified)
:arg exclude_generated: Omits fields that are illegal to set on
transform PUT
:arg from_: skips a number of transform configs, defaults to 0
:arg size: specifies a max number of transforms to get, defaults
to 100
"""
if "from_" in params:
params["from"] = params.pop("from_")
return self.transport.perform_request(
"GET",
_make_path("_transform", transform_id),
params=params,
headers=headers,
)
@query_params(
"allow_no_match",
"from_",
"size",
response_mimetypes=["application/json"],
)
def get_transform_stats(self, transform_id, params=None, headers=None):
"""
Retrieves usage information for transforms.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-transform-stats.html>`_
:arg transform_id: The id of the transform for which to get
stats. '_all' or '*' implies all transforms
:arg allow_no_match: Whether to ignore if a wildcard expression
matches no transforms. (This includes `_all` string or when no
transforms have been specified)
:arg from_: skips a number of transform stats, defaults to 0
:arg size: specifies a max number of transform stats to get,
defaults to 100
"""
if "from_" in params:
params["from"] = params.pop("from_")
if transform_id in SKIP_IN_PATH:
raise ValueError(
"Empty value passed for a required argument 'transform_id'."
)
return self.transport.perform_request(
"GET",
_make_path("_transform", transform_id, "_stats"),
params=params,
headers=headers,
)
@query_params(
"timeout",
request_mimetypes=["application/json"],
response_mimetypes=["application/json"],
)
def preview_transform(
self, body=None, transform_id=None, params=None, headers=None
):
"""
Previews a transform.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/preview-transform.html>`_
:arg body: The definition for the transform to preview
:arg transform_id: The id of the transform to preview.
:arg timeout: Controls the time to wait for the preview
"""
return self.transport.perform_request(
"POST",
_make_path("_transform", transform_id, "_preview"),
params=params,
headers=headers,
body=body,
)
@query_params(
"defer_validation",
"timeout",
request_mimetypes=["application/json"],
response_mimetypes=["application/json"],
)
def put_transform(self, transform_id, body, params=None, headers=None):
"""
Instantiates a transform.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-transform.html>`_
:arg transform_id: The id of the new transform.
:arg body: The transform definition
:arg defer_validation: If validations should be deferred until
transform starts, defaults to false.
:arg timeout: Controls the time to wait for the transform to
start
"""
for param in (transform_id, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT",
_make_path("_transform", transform_id),
params=params,
headers=headers,
body=body,
)
@query_params(
"timeout",
response_mimetypes=["application/json"],
)
def start_transform(self, transform_id, params=None, headers=None):
"""
Starts one or more transforms.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/start-transform.html>`_
:arg transform_id: The id of the transform to start
:arg timeout: Controls the time to wait for the transform to
start
"""
if transform_id in SKIP_IN_PATH:
raise ValueError(
"Empty value passed for a required argument 'transform_id'."
)
return self.transport.perform_request(
"POST",
_make_path("_transform", transform_id, "_start"),
params=params,
headers=headers,
)
@query_params(
"allow_no_match",
"force",
"timeout",
"wait_for_checkpoint",
"wait_for_completion",
response_mimetypes=["application/json"],
)
def stop_transform(self, transform_id, params=None, headers=None):
"""
Stops one or more transforms.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/stop-transform.html>`_
:arg transform_id: The id of the transform to stop
:arg allow_no_match: Whether to ignore if a wildcard expression
matches no transforms. (This includes `_all` string or when no
transforms have been specified)
:arg force: Whether to force stop a failed transform or not.
Default to false
:arg timeout: Controls the time to wait until the transform has
stopped. Default to 30 seconds
:arg wait_for_checkpoint: Whether to wait for the transform to
reach a checkpoint before stopping. Default to false
:arg wait_for_completion: Whether to wait for the transform to
fully stop before returning or not. Default to false
"""
if transform_id in SKIP_IN_PATH:
raise ValueError(
"Empty value passed for a required argument 'transform_id'."
)
return self.transport.perform_request(
"POST",
_make_path("_transform", transform_id, "_stop"),
params=params,
headers=headers,
)
@query_params(
"defer_validation",
"timeout",
request_mimetypes=["application/json"],
response_mimetypes=["application/json"],
)
def update_transform(self, transform_id, body, params=None, headers=None):
"""
Updates certain properties of a transform.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/update-transform.html>`_
:arg transform_id: The id of the transform.
:arg body: The update transform definition
:arg defer_validation: If validations should be deferred until
transform starts, defaults to false.
:arg timeout: Controls the time to wait for the update
"""
for param in (transform_id, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"POST",
_make_path("_transform", transform_id, "_update"),
params=params,
headers=headers,
body=body,
)
@query_params(
"dry_run",
"timeout",
request_mimetypes=["application/json"],
response_mimetypes=["application/json"],
)
def upgrade_transforms(self, params=None, headers=None):
"""
Upgrades all transforms.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/upgrade-transforms.html>`_
:arg dry_run: Whether to only check for updates but don't
execute
:arg timeout: Controls the time to wait for the upgrade
"""
return self.transport.perform_request(
"POST", "/_transform/_upgrade", params=params, headers=headers
)
|