Skip to content

Commit 43a418a

Browse files
authored
Workflow Endpoint: migration guidance for deprecated ConnectorConfigInput and ConnectorType classes (#709)
1 parent 11fc252 commit 43a418a

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: Migration
3+
---
4+
5+
This page contains information about how to migrate from previous versions of the
6+
[UnstructuredWorkflow Endpoint](/api-reference/workflow/overview).
7+
8+
## ConnectorConfigInput and ConnectorType classes are deprecated
9+
10+
**Applies to**: The [Unstructured Python SDK](/api-reference/workflow/overview#unstructured-python-sdk) only.
11+
12+
**Issue**: Referencing classes that end in `ConnectorConfigInput` such as `S3SourceConnectorConfigInput`
13+
and `S3DestinationConnectorConfigInput`, and referencing classes that end in `ConnectorType` such as
14+
`S3SourceConnectorType` and `S3DestinationConnectorType`, produce warnings at design time and errors at run time.
15+
16+
**Cause**: The preceding classes have been deprecated and are no longer supported.
17+
18+
**Solution**:
19+
20+
- Remove references to classes that end in `ConnectorConfigInput` from your code. Replace these references with a
21+
dictionary. This dictionary must contain the same fields as the
22+
class that you removed, with dictionary key/value pairs instead of object parameter/argument pairs.
23+
- Remove references to classes that end in `ConnectorType` from your code. Replace these references with a string reference instead. This
24+
string corresponds to Unstructured's programmatic identifier for the connector type, for example `s3` for Amazon S3.
25+
26+
For example, the following code template shows the deprecated approach for programmatically creating an S3 source connector.
27+
28+
```python Python SDK
29+
# Deprecated code example. Do not use.
30+
import os
31+
32+
from unstructured_client import UnstructuredClient
33+
from unstructured_client.models.operations import CreateSourceRequest
34+
# The SourceConnectorType and S3SourceConnectorConfigInput classes are deprecated.
35+
from unstructured_client.models.shared import (
36+
CreateSourceConnector,
37+
SourceConnectorType, # <- Remove. Deprecated.
38+
S3SourceConnectorConfigInput # <- Remove. Deprecated.
39+
)
40+
41+
with UnstructuredClient(api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")) as client:
42+
response = client.sources.create_source(
43+
request=CreateSourceRequest(
44+
create_source_connector=CreateSourceConnector(
45+
name="<name>",
46+
type=SourceConnectorType.S3, # <- Replace SourceConnectorType.S3 with a string reference to "s3".
47+
# Replace S3SourceConnectorConfigInput with a typed dictionary.
48+
config=S3SourceConnectorConfigInput(
49+
# For anonymous authentication:
50+
anonymous=True,
51+
52+
# For AWS access key ID with AWS secret access key authentication:
53+
key="<key>",
54+
secret="<secret>",
55+
56+
# For AWS STS token authentication:
57+
token="<token>",
58+
key="<key>",
59+
secret="<secret>",
60+
61+
remote_url="<remote_url>",
62+
endpoint_url="<endpoint-url>",
63+
recursive=<True|False>
64+
)
65+
)
66+
)
67+
)
68+
69+
print(response.source_connector_information)
70+
```
71+
72+
To address this issue, use the following code template instead, which removes the
73+
`SourceConnectorType` and `S3SourceConnectorConfigInput` class references and replaces them
74+
with the correct substitutions.
75+
76+
```python Python SDK
77+
import os
78+
79+
from unstructured_client import UnstructuredClient
80+
from unstructured_client.models.operations import CreateSourceRequest
81+
from unstructured_client.models.shared import CreateSourceConnector
82+
83+
with UnstructuredClient(api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")) as client:
84+
response = client.sources.create_source(
85+
request=CreateSourceRequest(
86+
create_source_connector=CreateSourceConnector(
87+
name="<name>",
88+
type="s3",
89+
config={
90+
# For anonymous authentication:
91+
"anonymous": True,
92+
93+
# For AWS access key ID with AWS secret access key authentication:
94+
"key": "<key>",
95+
"secret": "<secret>",
96+
97+
# For AWS STS token authentication:
98+
"token": "<token>",
99+
"key": "<key>",
100+
"secret": "<secret>",
101+
102+
"remote_url": "<remote_url>",
103+
"endpoint_url": "<endpoint-url>",
104+
"recursive": <True|False>
105+
}
106+
)
107+
)
108+
)
109+
110+
print(response.source_connector_information)
111+
```

docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
"api-reference/workflow/workflows",
204204
"api-reference/workflow/jobs",
205205
"api-reference/workflow/errors",
206+
"api-reference/workflow/migration",
206207
{
207208
"group": "Endpoint Playground",
208209
"openapi": "https://platform.unstructuredapp.io/openapi.json"

0 commit comments

Comments
 (0)