You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NEXUS-909 feat Enable custom server URLs in the workflow endpoints (#265)
## Summary
* `server_url` logic in workflow endpoints is now the same as partition
endpoint: user should be able to pass it from Client init to each
endpoint and if no input we will just fallback to default based on
endpoint operation
* NOTE changes to developers: generate GHA will need manual changes
* you need to change the automate speakeasy bot PR made generate GHA ->
so that it won't revert the changes on `base_url` in each endpoint (see
#266)
* we could add those file under `.genignore` so that speakeasy bot
ignore the ^^ changes -> but i don't like this way since we might still
need to modify workflow API endpoint and speakeasy bot will ignore them
if we do
* [another
trick](https://www.speakeasy.com/docs/customize/code/code-regions/overview)
i found that could solve the issue -> we could pay speakeasy more... but
still not very flexible
* or we could also patch `_get_url` in `basesdk.py` but thats in deeper
stack of code might be difficult to read the flow (and write tests)
* all reasons ^^^^ include i decide to go with manual changes in
generate GHA -> we need a developer to approve that auto PR anyway
## Test
you got three ways of using the url
```
## make sure the version of unstructured_client is the local one should be 0.34.0
import unstructured_client
from unstructured_client.models import operations, shared
from unstructured_client import UnstructuredClient
# 1. init custom url when you create the Client (suggested way for in-VPC)
uc_client = UnstructuredClient(server_url="http://localhost:8081/", api_key_auth="XXXX")
create_workflow_data = {
"name": "custom sdk workflow",
"workflow_type": shared.WorkflowType.BASIC,
}
client_res = uc_client.workflows.create_workflow(request={
"create_workflow": create_workflow_data,
})
# 2. pass url when you call the specific endpoint (probably nobody will use this one...)
uc_client = UnstructuredClient(api_key_auth="XXX")
create_workflow_data = {
"name": "custom sdk workflow",
"workflow_type": shared.WorkflowType.BASIC,
}
client_res = uc_client.workflows.create_workflow(
request={"create_workflow": create_workflow_data,},
server_url="http://localhost:8081/",
)
# 3. no passing any url, fallback to default
uc_client = UnstructuredClient(api_key_auth="XXX)
create_workflow_data = {
"name": "custom sdk workflow",
"workflow_type": shared.WorkflowType.BASIC,
}
client_res = uc_client.workflows.create_workflow(
request={"create_workflow": create_workflow_data,},
)
```
and responses would be (last one is default fallback)
```
INFO: HTTP Request: POST http://localhost:8081/api/v1/workflows/ "HTTP/1.1 200 OK"
INFO: HTTP Request: POST http://localhost:8081/api/v1/workflows/ "HTTP/1.1 200 OK"
INFO: HTTP Request: POST https://platform.unstructuredapp.io/api/v1/workflows/ "HTTP/1.1 200 OK"
```
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: speakeasybot <[email protected]>
0 commit comments