|
| 1 | +# Copyright 2024 Palantir Technologies, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +from __future__ import annotations |
| 17 | + |
| 18 | +from typing import Any |
| 19 | +from typing import Dict |
| 20 | +from typing import Optional |
| 21 | + |
| 22 | +from pydantic import Field |
| 23 | +from pydantic import StrictInt |
| 24 | +from pydantic import validate_call |
| 25 | +from typing_extensions import Annotated |
| 26 | + |
| 27 | +from foundry._core import ApiClient |
| 28 | +from foundry._core import Auth |
| 29 | +from foundry._core import RequestInfo |
| 30 | +from foundry._errors import handle_unexpected |
| 31 | +from foundry.v2.connectivity.models._file_import_rid import FileImportRid |
| 32 | +from foundry.v2.core.models._preview_mode import PreviewMode |
| 33 | +from foundry.v2.orchestration.models._build_rid import BuildRid |
| 34 | + |
| 35 | + |
| 36 | +class FileImportClient: |
| 37 | + def __init__(self, auth: Auth, hostname: str) -> None: |
| 38 | + self._api_client = ApiClient(auth=auth, hostname=hostname) |
| 39 | + |
| 40 | + @validate_call |
| 41 | + @handle_unexpected |
| 42 | + def trigger( |
| 43 | + self, |
| 44 | + file_import_rid: FileImportRid, |
| 45 | + *, |
| 46 | + preview: Optional[PreviewMode] = None, |
| 47 | + request_timeout: Optional[Annotated[StrictInt, Field(gt=0)]] = None, |
| 48 | + ) -> BuildRid: |
| 49 | + """ |
| 50 | + Triggers the FileImport, which runs asynchronously as a [Foundry Build](/docs/foundry/data-integration/builds/). |
| 51 | + The returned BuildRid can be used to check the status via the Orchestration API. |
| 52 | +
|
| 53 | + :param file_import_rid: fileImportRid |
| 54 | + :type file_import_rid: FileImportRid |
| 55 | + :param preview: preview |
| 56 | + :type preview: Optional[PreviewMode] |
| 57 | + :param request_timeout: timeout setting for this request in seconds. |
| 58 | + :type request_timeout: Optional[int] |
| 59 | + :return: Returns the result object. |
| 60 | + :rtype: BuildRid |
| 61 | + """ |
| 62 | + |
| 63 | + return self._api_client.call_api( |
| 64 | + RequestInfo( |
| 65 | + method="POST", |
| 66 | + resource_path="/v2/connectivity/fileImports/{fileImportRid}/trigger", |
| 67 | + query_params={ |
| 68 | + "preview": preview, |
| 69 | + }, |
| 70 | + path_params={ |
| 71 | + "fileImportRid": file_import_rid, |
| 72 | + }, |
| 73 | + header_params={ |
| 74 | + "Accept": "application/json", |
| 75 | + }, |
| 76 | + body=None, |
| 77 | + body_type=None, |
| 78 | + response_type=BuildRid, |
| 79 | + request_timeout=request_timeout, |
| 80 | + ), |
| 81 | + ) |
0 commit comments