Skip to content

Commit 7202534

Browse files
feat: add support for Platform API (#219)
Co-authored-by: Austin Walker <[email protected]>
1 parent 6009da1 commit 7202534

File tree

14 files changed

+1134
-23
lines changed

14 files changed

+1134
-23
lines changed

Diff for: .gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ __pycache__/
1111
# human-added igore files
1212
.ipynb_checkpoints/
1313
.idea/
14+
15+
.local
16+
*.ipynb
17+
1418
openapi.json
1519
openapi_client.json
20+
openapi_serverless.json
21+
openapi_platform_api.json
22+
openapi_merged.yaml
23+
openapi_platform_serverless_client.yaml
1624
# Environments
1725
.env
1826
.envrc

Diff for: .speakeasy/workflow.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sources:
44
my-source:
55
inputs:
66
- location: https://api.unstructured.io/general/openapi.json
7+
- location: https://platform.unstructuredapp.io/openapi.json
78
overlays:
89
- location: ./overlay_client.yaml
910
registry:

Diff for: CHANGELOG.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
## 0.30.0
2+
3+
### Enhancements
4+
5+
### Features
6+
* Add Unstructured Platform APIs to manage source and destination connectors, workflows, and workflow runs
7+
__WARNING__: This is a breaking change for the use of non-default `server_url` settings in the client usage.
8+
To set the custom URL for the client, use the the `server_url` parameter in a given operation:
9+
```python
10+
elements = client.general.partition(
11+
request=operations.PartitionRequest(
12+
partition_parameters=shared.PartitionParameters(
13+
files=shared.Files(
14+
content=doc_file,
15+
file_name="your_document.pdf",
16+
),
17+
strategy=shared.Strategy.FAST,
18+
)
19+
),
20+
server_url="your_server_url",
21+
)
22+
```
23+
24+
### Fixes
25+
126
## 0.26.1
227

328
### Enhancements

Diff for: Makefile

+21-13
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,28 @@ lint:
6262
# Speakeasy #
6363
#############
6464

65-
## client-generate: Pull the openapi spec from the free hosted API and generate the SDK
66-
.PHONY: client-generate
67-
client-generate:
68-
wget -nv -q -O openapi.json https://api.unstructured.io/general/openapi.json
65+
## download-openapi-specs: Download the openapi specs from the Serverless and Platform APIs
66+
.PHONY: download-openapi-specs
67+
download-openapi-specs:
68+
wget -nv -q -O openapi_serverless.json https://api.unstructured.io/general/openapi.json
69+
wget -nv -q -O openapi_platform_api.json https://platform.unstructuredapp.io/openapi.json
70+
71+
## client-merge-serverless-platform: Merge the Serverless and Platform APIs specs into a single schema
72+
.PHONY: client-merge-serverless-platform
73+
client-merge-serverless-platform:
74+
speakeasy merge -s ./openapi_serverless.json -s ./openapi_platform_api.json -o ./openapi_merged.yaml
75+
76+
## client-generate-unified-sdk-local: Generate the SDK using merged schemas
77+
.PHONY: client-generate-unified-sdk-local
78+
client-generate-unified-sdk-local:
6979
speakeasy overlay validate -o ./overlay_client.yaml
70-
speakeasy overlay apply -s ./openapi.json -o ./overlay_client.yaml > ./openapi_client.json
71-
speakeasy generate sdk -s ./openapi_client.json -o ./ -l python
80+
speakeasy overlay apply -s ./openapi_merged.yaml -o ./overlay_client.yaml > ./openapi_platform_serverless_client.yaml
81+
speakeasy generate sdk -s ./openapi_platform_serverless_client.yaml -o ./ -l python
82+
83+
## client-generate-sdk: Do all the steps to generate the SDK
84+
.PHONY: client-generate-sdk
85+
client-generate-sdk: download-openapi-specs client-merge-serverless-platform client-generate-unified-sdk-local
7286

73-
## client-generate-local: Generate the SDK using a local copy of openapi.json
74-
.PHONY: client-generate-local
75-
client-generate-local:
76-
speakeasy overlay validate -o ./overlay_client.yaml
77-
speakeasy overlay apply -s ./openapi.json -o ./overlay_client.yaml > ./openapi_client.json
78-
speakeasy generate sdk -s ./openapi_client.json -o ./ -l python
7987

8088
.PHONY: publish
8189
publish:
@@ -88,4 +96,4 @@ publish:
8896
## run-jupyter: starts jupyter notebook
8997
.PHONY: run-jupyter
9098
run-jupyter:
91-
PYTHONPATH=$(realpath .) JUPYTER_PATH=$(realpath .) jupyter-notebook --NotebookApp.token='' --NotebookApp.password=''
99+
PYTHONPATH=$(realpath .) JUPYTER_PATH=$(realpath .) jupyter-notebook --NotebookApp.token='' --NotebookApp.password=''

Diff for: _test_contract/platform_api/conftest.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
3+
import pytest
4+
5+
from unstructured_client import UnstructuredClient, RetryConfig
6+
from unstructured_client.utils import BackoffStrategy
7+
8+
FAKE_API_KEY = "91pmLBeETAbXCpNylRsLq11FdiZPTk"
9+
10+
11+
@pytest.fixture(scope="module")
12+
def platform_api_url():
13+
return "https://platform.unstructuredapp.io"
14+
15+
16+
@pytest.fixture(scope="module")
17+
def client(platform_api_url) -> UnstructuredClient:
18+
_client = UnstructuredClient(
19+
api_key_auth=FAKE_API_KEY,
20+
server_url="platform-api",
21+
retry_config=RetryConfig(
22+
strategy="backoff",
23+
retry_connection_errors=False,
24+
backoff=BackoffStrategy(
25+
max_elapsed_time=0, max_interval=0, exponent=0, initial_interval=0
26+
),
27+
),
28+
)
29+
yield _client

0 commit comments

Comments
 (0)