From dd6c01534385f9b8688f004a0f27924b549574fa Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Tue, 23 Apr 2024 11:35:50 +0400 Subject: [PATCH] Add Connector API (#2531) --- docs/sphinx/api.rst | 1 + docs/sphinx/api/connector.rst | 9 + elasticsearch/_async/client/__init__.py | 2 + elasticsearch/_async/client/connector.py | 1072 ++++++++++++++++++++++ elasticsearch/_sync/client/__init__.py | 2 + elasticsearch/_sync/client/connector.py | 1072 ++++++++++++++++++++++ elasticsearch/client.py | 1 + 7 files changed, 2159 insertions(+) create mode 100644 docs/sphinx/api/connector.rst create mode 100644 elasticsearch/_async/client/connector.py create mode 100644 elasticsearch/_sync/client/connector.py diff --git a/docs/sphinx/api.rst b/docs/sphinx/api.rst index 0b28b145b..2198900c0 100644 --- a/docs/sphinx/api.rst +++ b/docs/sphinx/api.rst @@ -21,6 +21,7 @@ arguments are required for all calls. api/cat api/ccr api/cluster + api/connector api/dangling-indices api/enrich-policies api/eql diff --git a/docs/sphinx/api/connector.rst b/docs/sphinx/api/connector.rst new file mode 100644 index 000000000..bcb7ce9bb --- /dev/null +++ b/docs/sphinx/api/connector.rst @@ -0,0 +1,9 @@ +.. _cluster: + +Connector +--------- +.. py:module:: elasticsearch.client + :noindex: + +.. autoclass:: ConnectorClient + :members: diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index c7d190220..8d6aeddca 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -46,6 +46,7 @@ from .cat import CatClient from .ccr import CcrClient from .cluster import ClusterClient +from .connector import ConnectorClient from .dangling_indices import DanglingIndicesClient from .enrich import EnrichClient from .eql import EqlClient @@ -433,6 +434,7 @@ def __init__( self.autoscaling = AutoscalingClient(self) self.cat = CatClient(self) self.cluster = ClusterClient(self) + self.connector = ConnectorClient(self) self.fleet = FleetClient(self) self.features = FeaturesClient(self) self.indices = IndicesClient(self) diff --git a/elasticsearch/_async/client/connector.py b/elasticsearch/_async/client/connector.py new file mode 100644 index 000000000..8cdebdb19 --- /dev/null +++ b/elasticsearch/_async/client/connector.py @@ -0,0 +1,1072 @@ +# 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. + +import typing as t + +from elastic_transport import ObjectApiResponse + +from ._base import NamespacedClient +from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters + + +class ConnectorClient(NamespacedClient): + + @_rewrite_parameters() + async def check_in( + self, + *, + connector_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the last_seen timestamp in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be checked in + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_check_in' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.check_in", + path_parts=__path_parts, + ) + + @_rewrite_parameters() + async def delete( + self, + *, + connector_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Deletes a connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be deleted + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "DELETE", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.delete", + path_parts=__path_parts, + ) + + @_rewrite_parameters() + async def get( + self, + *, + connector_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Returns the details about a connector. + + ``_ + + :param connector_id: The unique identifier of the connector + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "GET", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.get", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=( + "last_access_control_sync_error", + "last_access_control_sync_scheduled_at", + "last_access_control_sync_status", + "last_deleted_document_count", + "last_incremental_sync_scheduled_at", + "last_indexed_document_count", + "last_seen", + "last_sync_error", + "last_sync_scheduled_at", + "last_sync_status", + "last_synced", + ), + ) + async def last_sync( + self, + *, + connector_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + last_access_control_sync_error: t.Optional[t.Union[None, t.Any]] = None, + last_access_control_sync_scheduled_at: t.Optional[t.Union[str, t.Any]] = None, + last_access_control_sync_status: t.Optional[ + t.Union[ + "t.Literal['canceled', 'canceling', 'completed', 'error', 'in_progress', 'pending', 'suspended']", + str, + ] + ] = None, + last_deleted_document_count: t.Optional[int] = None, + last_incremental_sync_scheduled_at: t.Optional[t.Union[str, t.Any]] = None, + last_indexed_document_count: t.Optional[int] = None, + last_seen: t.Optional[t.Union[None, t.Any]] = None, + last_sync_error: t.Optional[t.Union[None, t.Any]] = None, + last_sync_scheduled_at: t.Optional[t.Union[str, t.Any]] = None, + last_sync_status: t.Optional[ + t.Union[ + "t.Literal['canceled', 'canceling', 'completed', 'error', 'in_progress', 'pending', 'suspended']", + str, + ] + ] = None, + last_synced: t.Optional[t.Union[str, t.Any]] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the stats of last sync in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param last_access_control_sync_error: + :param last_access_control_sync_scheduled_at: + :param last_access_control_sync_status: + :param last_deleted_document_count: + :param last_incremental_sync_scheduled_at: + :param last_indexed_document_count: + :param last_seen: + :param last_sync_error: + :param last_sync_scheduled_at: + :param last_sync_status: + :param last_synced: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_last_sync' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if last_access_control_sync_error is not None: + __body["last_access_control_sync_error"] = ( + last_access_control_sync_error + ) + if last_access_control_sync_scheduled_at is not None: + __body["last_access_control_sync_scheduled_at"] = ( + last_access_control_sync_scheduled_at + ) + if last_access_control_sync_status is not None: + __body["last_access_control_sync_status"] = ( + last_access_control_sync_status + ) + if last_deleted_document_count is not None: + __body["last_deleted_document_count"] = last_deleted_document_count + if last_incremental_sync_scheduled_at is not None: + __body["last_incremental_sync_scheduled_at"] = ( + last_incremental_sync_scheduled_at + ) + if last_indexed_document_count is not None: + __body["last_indexed_document_count"] = last_indexed_document_count + if last_seen is not None: + __body["last_seen"] = last_seen + if last_sync_error is not None: + __body["last_sync_error"] = last_sync_error + if last_sync_scheduled_at is not None: + __body["last_sync_scheduled_at"] = last_sync_scheduled_at + if last_sync_status is not None: + __body["last_sync_status"] = last_sync_status + if last_synced is not None: + __body["last_synced"] = last_synced + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.last_sync", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def list( + self, + *, + connector_name: t.Optional[t.Union[str, t.Sequence[str]]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + from_: t.Optional[int] = None, + human: t.Optional[bool] = None, + index_name: t.Optional[t.Union[str, t.Sequence[str]]] = None, + pretty: t.Optional[bool] = None, + query: t.Optional[str] = None, + service_type: t.Optional[t.Union[str, t.Sequence[str]]] = None, + size: t.Optional[int] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Lists all connectors. + + ``_ + + :param connector_name: A comma-separated list of connector names to fetch connector + documents for + :param from_: Starting offset (default: 0) + :param index_name: A comma-separated list of connector index names to fetch connector + documents for + :param query: A wildcard query string that filters connectors with matching name, + description or index name + :param service_type: A comma-separated list of connector service types to fetch + connector documents for + :param size: Specifies a max number of results to get + """ + __path_parts: t.Dict[str, str] = {} + __path = "/_connector" + __query: t.Dict[str, t.Any] = {} + if connector_name is not None: + __query["connector_name"] = connector_name + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if index_name is not None: + __query["index_name"] = index_name + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __query["query"] = query + if service_type is not None: + __query["service_type"] = service_type + if size is not None: + __query["size"] = size + __headers = {"accept": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "GET", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.list", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=( + "index_name", + "description", + "is_native", + "language", + "name", + "service_type", + ), + ) + async def post( + self, + *, + index_name: t.Optional[t.Union[None, t.Any]] = None, + description: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + is_native: t.Optional[bool] = None, + language: t.Optional[str] = None, + name: t.Optional[str] = None, + pretty: t.Optional[bool] = None, + service_type: t.Optional[str] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Creates a connector. + + ``_ + + :param index_name: + :param description: + :param is_native: + :param language: + :param name: + :param service_type: + """ + if index_name is None and body is None: + raise ValueError("Empty value passed for parameter 'index_name'") + __path_parts: t.Dict[str, str] = {} + __path = "/_connector" + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if index_name is not None: + __body["index_name"] = index_name + if description is not None: + __body["description"] = description + if is_native is not None: + __body["is_native"] = is_native + if language is not None: + __body["language"] = language + if name is not None: + __body["name"] = name + if service_type is not None: + __body["service_type"] = service_type + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "POST", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.post", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=( + "index_name", + "description", + "is_native", + "language", + "name", + "service_type", + ), + ) + async def put( + self, + *, + connector_id: str, + index_name: t.Optional[t.Union[None, t.Any]] = None, + description: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + is_native: t.Optional[bool] = None, + language: t.Optional[str] = None, + name: t.Optional[str] = None, + pretty: t.Optional[bool] = None, + service_type: t.Optional[str] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Creates or updates a connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be created or + updated + :param index_name: + :param description: + :param is_native: + :param language: + :param name: + :param service_type: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if index_name is None and body is None: + raise ValueError("Empty value passed for parameter 'index_name'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if index_name is not None: + __body["index_name"] = index_name + if description is not None: + __body["description"] = description + if is_native is not None: + __body["is_native"] = is_native + if language is not None: + __body["language"] = language + if name is not None: + __body["name"] = name + if service_type is not None: + __body["service_type"] = service_type + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.put", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("api_key_id", "api_key_secret_id"), + ) + async def update_api_key_id( + self, + *, + connector_id: str, + api_key_id: t.Optional[t.Union[None, t.Any]] = None, + api_key_secret_id: t.Optional[t.Union[None, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the API key id and/or API key secret id fields in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param api_key_id: + :param api_key_secret_id: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_api_key_id' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if api_key_id is not None: + __body["api_key_id"] = api_key_id + if api_key_secret_id is not None: + __body["api_key_secret_id"] = api_key_secret_id + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_api_key_id", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("configuration", "values"), + ) + async def update_configuration( + self, + *, + connector_id: str, + configuration: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + values: t.Optional[t.Mapping[str, t.Any]] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the connector configuration. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param configuration: + :param values: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_configuration' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if configuration is not None: + __body["configuration"] = configuration + if values is not None: + __body["values"] = values + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_configuration", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("error",), + ) + async def update_error( + self, + *, + connector_id: str, + error: t.Optional[t.Union[None, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the error field in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param error: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if error is None and body is None: + raise ValueError("Empty value passed for parameter 'error'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_error' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if error is not None: + __body["error"] = error + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_error", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("filtering",), + ) + async def update_filtering( + self, + *, + connector_id: str, + filtering: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the filtering field in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param filtering: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if filtering is None and body is None: + raise ValueError("Empty value passed for parameter 'filtering'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_filtering' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if filtering is not None: + __body["filtering"] = filtering + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_filtering", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("index_name",), + ) + async def update_index_name( + self, + *, + connector_id: str, + index_name: t.Optional[t.Union[None, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the index name of the connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param index_name: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if index_name is None and body is None: + raise ValueError("Empty value passed for parameter 'index_name'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_index_name' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if index_name is not None: + __body["index_name"] = index_name + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_index_name", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("name", "description"), + ) + async def update_name( + self, + *, + connector_id: str, + name: t.Optional[str] = None, + description: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the name and/or description fields in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param name: + :param description: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if name is None and body is None: + raise ValueError("Empty value passed for parameter 'name'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_name' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if name is not None: + __body["name"] = name + if description is not None: + __body["description"] = description + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_name", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("is_native",), + ) + async def update_native( + self, + *, + connector_id: str, + is_native: t.Optional[bool] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the is_native flag of the connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param is_native: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if is_native is None and body is None: + raise ValueError("Empty value passed for parameter 'is_native'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_native' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if is_native is not None: + __body["is_native"] = is_native + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_native", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("pipeline",), + ) + async def update_pipeline( + self, + *, + connector_id: str, + pipeline: t.Optional[t.Mapping[str, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the pipeline field in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param pipeline: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if pipeline is None and body is None: + raise ValueError("Empty value passed for parameter 'pipeline'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_pipeline' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if pipeline is not None: + __body["pipeline"] = pipeline + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_pipeline", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("scheduling",), + ) + async def update_scheduling( + self, + *, + connector_id: str, + scheduling: t.Optional[t.Mapping[str, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the scheduling field in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param scheduling: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if scheduling is None and body is None: + raise ValueError("Empty value passed for parameter 'scheduling'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_scheduling' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if scheduling is not None: + __body["scheduling"] = scheduling + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_scheduling", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("service_type",), + ) + async def update_service_type( + self, + *, + connector_id: str, + service_type: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the service type of the connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param service_type: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if service_type is None and body is None: + raise ValueError("Empty value passed for parameter 'service_type'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_service_type' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if service_type is not None: + __body["service_type"] = service_type + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_service_type", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("status",), + ) + async def update_status( + self, + *, + connector_id: str, + status: t.Optional[ + t.Union[ + "t.Literal['configured', 'connected', 'created', 'error', 'needs_configuration']", + str, + ] + ] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the status of the connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param status: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if status is None and body is None: + raise ValueError("Empty value passed for parameter 'status'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_status' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if status is not None: + __body["status"] = status + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_status", + path_parts=__path_parts, + ) diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index 2b722719b..0a1d4699d 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -46,6 +46,7 @@ from .cat import CatClient from .ccr import CcrClient from .cluster import ClusterClient +from .connector import ConnectorClient from .dangling_indices import DanglingIndicesClient from .enrich import EnrichClient from .eql import EqlClient @@ -433,6 +434,7 @@ def __init__( self.autoscaling = AutoscalingClient(self) self.cat = CatClient(self) self.cluster = ClusterClient(self) + self.connector = ConnectorClient(self) self.fleet = FleetClient(self) self.features = FeaturesClient(self) self.indices = IndicesClient(self) diff --git a/elasticsearch/_sync/client/connector.py b/elasticsearch/_sync/client/connector.py new file mode 100644 index 000000000..93e292e72 --- /dev/null +++ b/elasticsearch/_sync/client/connector.py @@ -0,0 +1,1072 @@ +# 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. + +import typing as t + +from elastic_transport import ObjectApiResponse + +from ._base import NamespacedClient +from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters + + +class ConnectorClient(NamespacedClient): + + @_rewrite_parameters() + def check_in( + self, + *, + connector_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the last_seen timestamp in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be checked in + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_check_in' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.check_in", + path_parts=__path_parts, + ) + + @_rewrite_parameters() + def delete( + self, + *, + connector_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Deletes a connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be deleted + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return self.perform_request( # type: ignore[return-value] + "DELETE", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.delete", + path_parts=__path_parts, + ) + + @_rewrite_parameters() + def get( + self, + *, + connector_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Returns the details about a connector. + + ``_ + + :param connector_id: The unique identifier of the connector + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return self.perform_request( # type: ignore[return-value] + "GET", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.get", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=( + "last_access_control_sync_error", + "last_access_control_sync_scheduled_at", + "last_access_control_sync_status", + "last_deleted_document_count", + "last_incremental_sync_scheduled_at", + "last_indexed_document_count", + "last_seen", + "last_sync_error", + "last_sync_scheduled_at", + "last_sync_status", + "last_synced", + ), + ) + def last_sync( + self, + *, + connector_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + last_access_control_sync_error: t.Optional[t.Union[None, t.Any]] = None, + last_access_control_sync_scheduled_at: t.Optional[t.Union[str, t.Any]] = None, + last_access_control_sync_status: t.Optional[ + t.Union[ + "t.Literal['canceled', 'canceling', 'completed', 'error', 'in_progress', 'pending', 'suspended']", + str, + ] + ] = None, + last_deleted_document_count: t.Optional[int] = None, + last_incremental_sync_scheduled_at: t.Optional[t.Union[str, t.Any]] = None, + last_indexed_document_count: t.Optional[int] = None, + last_seen: t.Optional[t.Union[None, t.Any]] = None, + last_sync_error: t.Optional[t.Union[None, t.Any]] = None, + last_sync_scheduled_at: t.Optional[t.Union[str, t.Any]] = None, + last_sync_status: t.Optional[ + t.Union[ + "t.Literal['canceled', 'canceling', 'completed', 'error', 'in_progress', 'pending', 'suspended']", + str, + ] + ] = None, + last_synced: t.Optional[t.Union[str, t.Any]] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the stats of last sync in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param last_access_control_sync_error: + :param last_access_control_sync_scheduled_at: + :param last_access_control_sync_status: + :param last_deleted_document_count: + :param last_incremental_sync_scheduled_at: + :param last_indexed_document_count: + :param last_seen: + :param last_sync_error: + :param last_sync_scheduled_at: + :param last_sync_status: + :param last_synced: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_last_sync' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if last_access_control_sync_error is not None: + __body["last_access_control_sync_error"] = ( + last_access_control_sync_error + ) + if last_access_control_sync_scheduled_at is not None: + __body["last_access_control_sync_scheduled_at"] = ( + last_access_control_sync_scheduled_at + ) + if last_access_control_sync_status is not None: + __body["last_access_control_sync_status"] = ( + last_access_control_sync_status + ) + if last_deleted_document_count is not None: + __body["last_deleted_document_count"] = last_deleted_document_count + if last_incremental_sync_scheduled_at is not None: + __body["last_incremental_sync_scheduled_at"] = ( + last_incremental_sync_scheduled_at + ) + if last_indexed_document_count is not None: + __body["last_indexed_document_count"] = last_indexed_document_count + if last_seen is not None: + __body["last_seen"] = last_seen + if last_sync_error is not None: + __body["last_sync_error"] = last_sync_error + if last_sync_scheduled_at is not None: + __body["last_sync_scheduled_at"] = last_sync_scheduled_at + if last_sync_status is not None: + __body["last_sync_status"] = last_sync_status + if last_synced is not None: + __body["last_synced"] = last_synced + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.last_sync", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def list( + self, + *, + connector_name: t.Optional[t.Union[str, t.Sequence[str]]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + from_: t.Optional[int] = None, + human: t.Optional[bool] = None, + index_name: t.Optional[t.Union[str, t.Sequence[str]]] = None, + pretty: t.Optional[bool] = None, + query: t.Optional[str] = None, + service_type: t.Optional[t.Union[str, t.Sequence[str]]] = None, + size: t.Optional[int] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Lists all connectors. + + ``_ + + :param connector_name: A comma-separated list of connector names to fetch connector + documents for + :param from_: Starting offset (default: 0) + :param index_name: A comma-separated list of connector index names to fetch connector + documents for + :param query: A wildcard query string that filters connectors with matching name, + description or index name + :param service_type: A comma-separated list of connector service types to fetch + connector documents for + :param size: Specifies a max number of results to get + """ + __path_parts: t.Dict[str, str] = {} + __path = "/_connector" + __query: t.Dict[str, t.Any] = {} + if connector_name is not None: + __query["connector_name"] = connector_name + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if index_name is not None: + __query["index_name"] = index_name + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __query["query"] = query + if service_type is not None: + __query["service_type"] = service_type + if size is not None: + __query["size"] = size + __headers = {"accept": "application/json"} + return self.perform_request( # type: ignore[return-value] + "GET", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.list", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=( + "index_name", + "description", + "is_native", + "language", + "name", + "service_type", + ), + ) + def post( + self, + *, + index_name: t.Optional[t.Union[None, t.Any]] = None, + description: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + is_native: t.Optional[bool] = None, + language: t.Optional[str] = None, + name: t.Optional[str] = None, + pretty: t.Optional[bool] = None, + service_type: t.Optional[str] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Creates a connector. + + ``_ + + :param index_name: + :param description: + :param is_native: + :param language: + :param name: + :param service_type: + """ + if index_name is None and body is None: + raise ValueError("Empty value passed for parameter 'index_name'") + __path_parts: t.Dict[str, str] = {} + __path = "/_connector" + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if index_name is not None: + __body["index_name"] = index_name + if description is not None: + __body["description"] = description + if is_native is not None: + __body["is_native"] = is_native + if language is not None: + __body["language"] = language + if name is not None: + __body["name"] = name + if service_type is not None: + __body["service_type"] = service_type + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "POST", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.post", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=( + "index_name", + "description", + "is_native", + "language", + "name", + "service_type", + ), + ) + def put( + self, + *, + connector_id: str, + index_name: t.Optional[t.Union[None, t.Any]] = None, + description: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + is_native: t.Optional[bool] = None, + language: t.Optional[str] = None, + name: t.Optional[str] = None, + pretty: t.Optional[bool] = None, + service_type: t.Optional[str] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Creates or updates a connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be created or + updated + :param index_name: + :param description: + :param is_native: + :param language: + :param name: + :param service_type: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if index_name is None and body is None: + raise ValueError("Empty value passed for parameter 'index_name'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if index_name is not None: + __body["index_name"] = index_name + if description is not None: + __body["description"] = description + if is_native is not None: + __body["is_native"] = is_native + if language is not None: + __body["language"] = language + if name is not None: + __body["name"] = name + if service_type is not None: + __body["service_type"] = service_type + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.put", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("api_key_id", "api_key_secret_id"), + ) + def update_api_key_id( + self, + *, + connector_id: str, + api_key_id: t.Optional[t.Union[None, t.Any]] = None, + api_key_secret_id: t.Optional[t.Union[None, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the API key id and/or API key secret id fields in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param api_key_id: + :param api_key_secret_id: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_api_key_id' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if api_key_id is not None: + __body["api_key_id"] = api_key_id + if api_key_secret_id is not None: + __body["api_key_secret_id"] = api_key_secret_id + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_api_key_id", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("configuration", "values"), + ) + def update_configuration( + self, + *, + connector_id: str, + configuration: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + values: t.Optional[t.Mapping[str, t.Any]] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the connector configuration. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param configuration: + :param values: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_configuration' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if configuration is not None: + __body["configuration"] = configuration + if values is not None: + __body["values"] = values + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_configuration", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("error",), + ) + def update_error( + self, + *, + connector_id: str, + error: t.Optional[t.Union[None, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the error field in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param error: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if error is None and body is None: + raise ValueError("Empty value passed for parameter 'error'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_error' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if error is not None: + __body["error"] = error + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_error", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("filtering",), + ) + def update_filtering( + self, + *, + connector_id: str, + filtering: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the filtering field in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param filtering: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if filtering is None and body is None: + raise ValueError("Empty value passed for parameter 'filtering'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_filtering' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if filtering is not None: + __body["filtering"] = filtering + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_filtering", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("index_name",), + ) + def update_index_name( + self, + *, + connector_id: str, + index_name: t.Optional[t.Union[None, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the index name of the connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param index_name: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if index_name is None and body is None: + raise ValueError("Empty value passed for parameter 'index_name'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_index_name' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if index_name is not None: + __body["index_name"] = index_name + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_index_name", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("name", "description"), + ) + def update_name( + self, + *, + connector_id: str, + name: t.Optional[str] = None, + description: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the name and/or description fields in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param name: + :param description: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if name is None and body is None: + raise ValueError("Empty value passed for parameter 'name'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_name' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if name is not None: + __body["name"] = name + if description is not None: + __body["description"] = description + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_name", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("is_native",), + ) + def update_native( + self, + *, + connector_id: str, + is_native: t.Optional[bool] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the is_native flag of the connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param is_native: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if is_native is None and body is None: + raise ValueError("Empty value passed for parameter 'is_native'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_native' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if is_native is not None: + __body["is_native"] = is_native + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_native", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("pipeline",), + ) + def update_pipeline( + self, + *, + connector_id: str, + pipeline: t.Optional[t.Mapping[str, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the pipeline field in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param pipeline: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if pipeline is None and body is None: + raise ValueError("Empty value passed for parameter 'pipeline'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_pipeline' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if pipeline is not None: + __body["pipeline"] = pipeline + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_pipeline", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("scheduling",), + ) + def update_scheduling( + self, + *, + connector_id: str, + scheduling: t.Optional[t.Mapping[str, t.Any]] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the scheduling field in the connector document. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param scheduling: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if scheduling is None and body is None: + raise ValueError("Empty value passed for parameter 'scheduling'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_scheduling' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if scheduling is not None: + __body["scheduling"] = scheduling + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_scheduling", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("service_type",), + ) + def update_service_type( + self, + *, + connector_id: str, + service_type: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the service type of the connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param service_type: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if service_type is None and body is None: + raise ValueError("Empty value passed for parameter 'service_type'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_service_type' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if service_type is not None: + __body["service_type"] = service_type + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_service_type", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("status",), + ) + def update_status( + self, + *, + connector_id: str, + status: t.Optional[ + t.Union[ + "t.Literal['configured', 'connected', 'created', 'error', 'needs_configuration']", + str, + ] + ] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Updates the status of the connector. + + ``_ + + :param connector_id: The unique identifier of the connector to be updated + :param status: + """ + if connector_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_id'") + if status is None and body is None: + raise ValueError("Empty value passed for parameter 'status'") + __path_parts: t.Dict[str, str] = {"connector_id": _quote(connector_id)} + __path = f'/_connector/{__path_parts["connector_id"]}/_status' + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if status is not None: + __body["status"] = status + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.update_status", + path_parts=__path_parts, + ) diff --git a/elasticsearch/client.py b/elasticsearch/client.py index 8c028e3fc..24407ec97 100644 --- a/elasticsearch/client.py +++ b/elasticsearch/client.py @@ -27,6 +27,7 @@ from ._sync.client.cat import CatClient as CatClient # noqa: F401 from ._sync.client.ccr import CcrClient as CcrClient # noqa: F401 from ._sync.client.cluster import ClusterClient as ClusterClient # noqa: F401 +from ._sync.client.connector import ConnectorClient as ConnectorClient # noqa: F401 from ._sync.client.dangling_indices import ( # noqa: F401 DanglingIndicesClient as DanglingIndicesClient, )