Skip to content

Commit b8744bb

Browse files
SK-2199: Update Python SDK v2 with latest Detect API changes (v4.0) (#189)
* SK-2199: update detect interfaces with new detect openapi spec changes
1 parent e3279f0 commit b8744bb

File tree

56 files changed

+1138
-2104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1138
-2104
lines changed

skyflow/generated/rest/__init__.py

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
# isort: skip_file
44

55
from .types import (
6-
AdvancedOptionsColumnMapping,
7-
AdvancedOptionsEntityColumnMap,
8-
AdvancedOptionsVaultSchema,
96
AllowRegex,
10-
AudioConfigTranscriptionType,
117
AuditEventAuditResourceType,
128
AuditEventContext,
139
AuditEventData,
1410
AuditEventHttpInfo,
1511
BatchRecordMethod,
12+
CheckGuardrailsResponse,
13+
CheckGuardrailsResponseValidation,
14+
ConfigurationId,
1615
ContextAccessType,
1716
ContextAuthMode,
1817
DeidentifyFileOutput,
@@ -21,12 +20,7 @@
2120
DeidentifyStatusResponse,
2221
DeidentifyStatusResponseOutputType,
2322
DeidentifyStatusResponseStatus,
24-
DeidentifyStatusResponseWordCharacterCount,
2523
DeidentifyStringResponse,
26-
DetectDataAccuracy,
27-
DetectDataEntities,
28-
DetectFileRequestDataType,
29-
DetectRequestDeidentifyOption,
3024
DetectedEntity,
3125
DetokenizeRecordResponseValueType,
3226
EntityLocation,
@@ -36,9 +30,11 @@
3630
ErrorResponseError,
3731
ErrorString,
3832
GooglerpcStatus,
39-
ProcessedFileOutputProcessedFileType,
4033
ProtobufAny,
4134
RedactionEnumRedaction,
35+
ReidentifyFileResponse,
36+
ReidentifyFileResponseOutput,
37+
ReidentifyFileResponseStatus,
4238
ReidentifyStringResponse,
4339
RequestActionType,
4440
ResourceId,
@@ -51,9 +47,6 @@
5147
TransformationsShiftDates,
5248
TransformationsShiftDatesEntityTypesItem,
5349
Uuid,
54-
V1AdvancedOptions,
55-
V1AudioConfig,
56-
V1AudioOptions,
5750
V1AuditAfterOptions,
5851
V1AuditEventResponse,
5952
V1AuditResponse,
@@ -68,29 +61,17 @@
6861
V1Card,
6962
V1DeleteFileResponse,
7063
V1DeleteRecordResponse,
71-
V1DetectFileResponse,
72-
V1DetectStatusResponse,
73-
V1DetectStatusResponseStatus,
74-
V1DetectTextRequest,
75-
V1DetectTextResponse,
7664
V1DetokenizeRecordRequest,
7765
V1DetokenizeRecordResponse,
7866
V1DetokenizeResponse,
7967
V1FieldRecords,
8068
V1FileAvScanStatus,
81-
V1FileDataFormat,
8269
V1GetAuthTokenResponse,
8370
V1GetFileScanStatusResponse,
8471
V1GetQueryResponse,
85-
V1ImageOptions,
8672
V1InsertRecordResponse,
87-
V1Locations,
8873
V1MemberType,
89-
V1PdfConfig,
90-
V1PdfOptions,
91-
V1ProcessedFileOutput,
9274
V1RecordMetaProperties,
93-
V1ResponseEntities,
9475
V1TokenizeRecordRequest,
9576
V1TokenizeRecordResponse,
9677
V1TokenizeResponse,
@@ -100,7 +81,7 @@
10081
VaultId,
10182
)
10283
from .errors import BadRequestError, InternalServerError, NotFoundError, UnauthorizedError
103-
from . import audit, authentication, bin_lookup, deprecated, files, query, records, strings, tokens
84+
from . import audit, authentication, bin_lookup, files, guardrails, query, records, strings, tokens
10485
from .audit import (
10586
AuditServiceListAuditEventsRequestFilterOpsActionType,
10687
AuditServiceListAuditEventsRequestFilterOpsContextAccessType,
@@ -130,6 +111,9 @@
130111
DeidentifyStructuredTextRequestFile,
131112
DeidentifyStructuredTextRequestFileDataFormat,
132113
DeidentifyTextRequestFile,
114+
ReidentifyFileRequestFile,
115+
ReidentifyFileRequestFileDataFormat,
116+
ReidentifyFileRequestFormat,
133117
)
134118
from .records import (
135119
RecordServiceBulkGetRecordRequestOrderBy,
@@ -140,12 +124,8 @@
140124
from .version import __version__
141125

142126
__all__ = [
143-
"AdvancedOptionsColumnMapping",
144-
"AdvancedOptionsEntityColumnMap",
145-
"AdvancedOptionsVaultSchema",
146127
"AllowRegex",
147128
"AsyncSkyflow",
148-
"AudioConfigTranscriptionType",
149129
"AuditEventAuditResourceType",
150130
"AuditEventContext",
151131
"AuditEventData",
@@ -158,6 +138,9 @@
158138
"AuditServiceListAuditEventsRequestSortOpsOrderBy",
159139
"BadRequestError",
160140
"BatchRecordMethod",
141+
"CheckGuardrailsResponse",
142+
"CheckGuardrailsResponseValidation",
143+
"ConfigurationId",
161144
"ContextAccessType",
162145
"ContextAuthMode",
163146
"DeidentifyAudioRequestFile",
@@ -181,15 +164,10 @@
181164
"DeidentifyStatusResponse",
182165
"DeidentifyStatusResponseOutputType",
183166
"DeidentifyStatusResponseStatus",
184-
"DeidentifyStatusResponseWordCharacterCount",
185167
"DeidentifyStringResponse",
186168
"DeidentifyStructuredTextRequestFile",
187169
"DeidentifyStructuredTextRequestFileDataFormat",
188170
"DeidentifyTextRequestFile",
189-
"DetectDataAccuracy",
190-
"DetectDataEntities",
191-
"DetectFileRequestDataType",
192-
"DetectRequestDeidentifyOption",
193171
"DetectedEntity",
194172
"DetokenizeRecordResponseValueType",
195173
"EntityLocation",
@@ -201,12 +179,17 @@
201179
"GooglerpcStatus",
202180
"InternalServerError",
203181
"NotFoundError",
204-
"ProcessedFileOutputProcessedFileType",
205182
"ProtobufAny",
206183
"RecordServiceBulkGetRecordRequestOrderBy",
207184
"RecordServiceBulkGetRecordRequestRedaction",
208185
"RecordServiceGetRecordRequestRedaction",
209186
"RedactionEnumRedaction",
187+
"ReidentifyFileRequestFile",
188+
"ReidentifyFileRequestFileDataFormat",
189+
"ReidentifyFileRequestFormat",
190+
"ReidentifyFileResponse",
191+
"ReidentifyFileResponseOutput",
192+
"ReidentifyFileResponseStatus",
210193
"ReidentifyStringRequestFormat",
211194
"ReidentifyStringResponse",
212195
"RequestActionType",
@@ -223,9 +206,6 @@
223206
"TransformationsShiftDatesEntityTypesItem",
224207
"UnauthorizedError",
225208
"Uuid",
226-
"V1AdvancedOptions",
227-
"V1AudioConfig",
228-
"V1AudioOptions",
229209
"V1AuditAfterOptions",
230210
"V1AuditEventResponse",
231211
"V1AuditResponse",
@@ -240,29 +220,17 @@
240220
"V1Card",
241221
"V1DeleteFileResponse",
242222
"V1DeleteRecordResponse",
243-
"V1DetectFileResponse",
244-
"V1DetectStatusResponse",
245-
"V1DetectStatusResponseStatus",
246-
"V1DetectTextRequest",
247-
"V1DetectTextResponse",
248223
"V1DetokenizeRecordRequest",
249224
"V1DetokenizeRecordResponse",
250225
"V1DetokenizeResponse",
251226
"V1FieldRecords",
252227
"V1FileAvScanStatus",
253-
"V1FileDataFormat",
254228
"V1GetAuthTokenResponse",
255229
"V1GetFileScanStatusResponse",
256230
"V1GetQueryResponse",
257-
"V1ImageOptions",
258231
"V1InsertRecordResponse",
259-
"V1Locations",
260232
"V1MemberType",
261-
"V1PdfConfig",
262-
"V1PdfOptions",
263-
"V1ProcessedFileOutput",
264233
"V1RecordMetaProperties",
265-
"V1ResponseEntities",
266234
"V1TokenizeRecordRequest",
267235
"V1TokenizeRecordResponse",
268236
"V1TokenizeResponse",
@@ -274,8 +242,8 @@
274242
"audit",
275243
"authentication",
276244
"bin_lookup",
277-
"deprecated",
278245
"files",
246+
"guardrails",
279247
"query",
280248
"records",
281249
"strings",

skyflow/generated/rest/client.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from .authentication.client import AsyncAuthenticationClient, AuthenticationClient
88
from .bin_lookup.client import AsyncBinLookupClient, BinLookupClient
99
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
10-
from .deprecated.client import AsyncDeprecatedClient, DeprecatedClient
1110
from .environment import SkyflowEnvironment
1211
from .files.client import AsyncFilesClient, FilesClient
12+
from .guardrails.client import AsyncGuardrailsClient, GuardrailsClient
1313
from .query.client import AsyncQueryClient, QueryClient
1414
from .records.client import AsyncRecordsClient, RecordsClient
1515
from .strings.client import AsyncStringsClient, StringsClient
@@ -35,6 +35,9 @@ class Skyflow:
3535
3636
3737
token : typing.Union[str, typing.Callable[[], str]]
38+
headers : typing.Optional[typing.Dict[str, str]]
39+
Additional headers to send with every request.
40+
3841
timeout : typing.Optional[float]
3942
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
4043
@@ -59,6 +62,7 @@ def __init__(
5962
base_url: typing.Optional[str] = None,
6063
environment: SkyflowEnvironment = SkyflowEnvironment.PRODUCTION,
6164
token: typing.Union[str, typing.Callable[[], str]],
65+
headers: typing.Optional[typing.Dict[str, str]] = None,
6266
timeout: typing.Optional[float] = None,
6367
follow_redirects: typing.Optional[bool] = True,
6468
httpx_client: typing.Optional[httpx.Client] = None,
@@ -69,6 +73,7 @@ def __init__(
6973
self._client_wrapper = SyncClientWrapper(
7074
base_url=_get_base_url(base_url=base_url, environment=environment),
7175
token=token,
76+
headers=headers,
7277
httpx_client=httpx_client
7378
if httpx_client is not None
7479
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
@@ -82,7 +87,7 @@ def __init__(
8287
self.tokens = TokensClient(client_wrapper=self._client_wrapper)
8388
self.query = QueryClient(client_wrapper=self._client_wrapper)
8489
self.authentication = AuthenticationClient(client_wrapper=self._client_wrapper)
85-
self.deprecated = DeprecatedClient(client_wrapper=self._client_wrapper)
90+
self.guardrails = GuardrailsClient(client_wrapper=self._client_wrapper)
8691
self.strings = StringsClient(client_wrapper=self._client_wrapper)
8792
self.files = FilesClient(client_wrapper=self._client_wrapper)
8893

@@ -106,6 +111,9 @@ class AsyncSkyflow:
106111
107112
108113
token : typing.Union[str, typing.Callable[[], str]]
114+
headers : typing.Optional[typing.Dict[str, str]]
115+
Additional headers to send with every request.
116+
109117
timeout : typing.Optional[float]
110118
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
111119
@@ -130,6 +138,7 @@ def __init__(
130138
base_url: typing.Optional[str] = None,
131139
environment: SkyflowEnvironment = SkyflowEnvironment.PRODUCTION,
132140
token: typing.Union[str, typing.Callable[[], str]],
141+
headers: typing.Optional[typing.Dict[str, str]] = None,
133142
timeout: typing.Optional[float] = None,
134143
follow_redirects: typing.Optional[bool] = True,
135144
httpx_client: typing.Optional[httpx.AsyncClient] = None,
@@ -140,6 +149,7 @@ def __init__(
140149
self._client_wrapper = AsyncClientWrapper(
141150
base_url=_get_base_url(base_url=base_url, environment=environment),
142151
token=token,
152+
headers=headers,
143153
httpx_client=httpx_client
144154
if httpx_client is not None
145155
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
@@ -153,7 +163,7 @@ def __init__(
153163
self.tokens = AsyncTokensClient(client_wrapper=self._client_wrapper)
154164
self.query = AsyncQueryClient(client_wrapper=self._client_wrapper)
155165
self.authentication = AsyncAuthenticationClient(client_wrapper=self._client_wrapper)
156-
self.deprecated = AsyncDeprecatedClient(client_wrapper=self._client_wrapper)
166+
self.guardrails = AsyncGuardrailsClient(client_wrapper=self._client_wrapper)
157167
self.strings = AsyncStringsClient(client_wrapper=self._client_wrapper)
158168
self.files = AsyncFilesClient(client_wrapper=self._client_wrapper)
159169

skyflow/generated/rest/core/client_wrapper.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ def __init__(
1111
self,
1212
*,
1313
token: typing.Union[str, typing.Callable[[], str]],
14+
headers: typing.Optional[typing.Dict[str, str]] = None,
1415
base_url: str,
1516
timeout: typing.Optional[float] = None,
1617
):
1718
self._token = token
19+
self._headers = headers
1820
self._base_url = base_url
1921
self._timeout = timeout
2022

2123
def get_headers(self) -> typing.Dict[str, str]:
2224
headers: typing.Dict[str, str] = {
2325
"X-Fern-Language": "Python",
24-
"X-Fern-SDK-Name": "skyflow.generated.rest",
25-
"X-Fern-SDK-Version": "0.0.209",
26+
"X-Fern-SDK-Name": "skyflow_vault",
27+
"X-Fern-SDK-Version": "0.0.252",
28+
**(self.get_custom_headers() or {}),
2629
}
2730
headers["Authorization"] = f"Bearer {self._get_token()}"
2831
return headers
@@ -33,6 +36,9 @@ def _get_token(self) -> str:
3336
else:
3437
return self._token()
3538

39+
def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]:
40+
return self._headers
41+
3642
def get_base_url(self) -> str:
3743
return self._base_url
3844

@@ -45,11 +51,12 @@ def __init__(
4551
self,
4652
*,
4753
token: typing.Union[str, typing.Callable[[], str]],
54+
headers: typing.Optional[typing.Dict[str, str]] = None,
4855
base_url: str,
4956
timeout: typing.Optional[float] = None,
5057
httpx_client: httpx.Client,
5158
):
52-
super().__init__(token=token, base_url=base_url, timeout=timeout)
59+
super().__init__(token=token, headers=headers, base_url=base_url, timeout=timeout)
5360
self.httpx_client = HttpClient(
5461
httpx_client=httpx_client,
5562
base_headers=self.get_headers,
@@ -63,11 +70,12 @@ def __init__(
6370
self,
6471
*,
6572
token: typing.Union[str, typing.Callable[[], str]],
73+
headers: typing.Optional[typing.Dict[str, str]] = None,
6674
base_url: str,
6775
timeout: typing.Optional[float] = None,
6876
httpx_client: httpx.AsyncClient,
6977
):
70-
super().__init__(token=token, base_url=base_url, timeout=timeout)
78+
super().__init__(token=token, headers=headers, base_url=base_url, timeout=timeout)
7179
self.httpx_client = AsyncHttpClient(
7280
httpx_client=httpx_client,
7381
base_headers=self.get_headers,

skyflow/generated/rest/core/pydantic_utilities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class UniversalBaseModel(pydantic.BaseModel):
5959
protected_namespaces=(),
6060
)
6161

62-
@pydantic.model_serializer(mode="wrap", when_used="json") # type: ignore[attr-defined]
63-
def serialize_model(self, handler: pydantic.SerializerFunctionWrapHandler) -> Any: # type: ignore[name-defined]
64-
serialized = handler(self)
62+
@pydantic.model_serializer(mode="plain", when_used="json") # type: ignore[attr-defined]
63+
def serialize_model(self) -> Any: # type: ignore[name-defined]
64+
serialized = self.model_dump()
6565
data = {k: serialize_datetime(v) if isinstance(v, dt.datetime) else v for k, v in serialized.items()}
6666
return data
6767

0 commit comments

Comments
 (0)