Skip to content

Conversation

@Paul-Cornell
Copy link
Collaborator

@Paul-Cornell Paul-Cornell commented Mar 3, 2025

@awalker4
Copy link
Contributor

awalker4 commented Mar 4, 2025

I'd suggest showing code to explicitly create or update each connector, since it's not obvious how these structures are passed into the sources.create_source, etc, operations. Something like the below will show how to construct the request object, how to pass the connector id when updating, etc.

from unstructured_client import UnstructuredClient
from unstructured_client.models.shared import S3SourceConnectorConfigInput, CreateSourceConnector, UpdateSourceConnector

s3_source_connector_config = S3SourceConnectorConfigInput(
    # For anonymous authentication:
    anonymous=<True|False>,

    # For AWS access key ID with AWS secret access key authentication:
    key="<key>",
    secret="<secret>",

    # For AWS STS token authentication:
    token="<token>",

    remote_url="<remote_url>",
    endpoint_url="<endpoint-url>",
    recursive=<True|False>
)

with UnstructuredClient(api_key_auth=api_key) as client:
    ###############################
    # Create a new source connector:
    ###############################
    res = client.sources.create_source(
        request={
            "create_source_connector":
            CreateSourceConnector(
                name="S3 Source Connector",
                type=SourceConnectorType.S3,
                config=s3_source_connector_config,
            )
        }
    )

    print(res.source_connector_information)

    ##################################
    # Update existing source connector:
    ##################################
    existing_source_id = "e3be70ce-9876-4cde-aaa1-ccac3f5586e0"
    res = client.sources.update_source(
        request={
            "destination_id": existing_source_id,
            "update_source_connector":
            UpdateSourceConnector(
                config=s3_source_connector_config,  # Resubmit with any fields you'd like to update
            )
        }
    )

    print(res.source_connector_information)

@awalker4
Copy link
Contributor

awalker4 commented Mar 4, 2025

Using the client in a context (with UnstructuredClient as client) is new. For consistency, we don't have to show that but Speakeasy recommends this pattern going forward.

@awalker4
Copy link
Contributor

awalker4 commented Mar 4, 2025

But that's definitely a lot of work to take another pass at everything - lgtm for now.

@Paul-Cornell Paul-Cornell merged commit 8c05e88 into main Mar 4, 2025
1 check passed
@Paul-Cornell Paul-Cornell deleted the DOCS-202-python-sdk branch March 4, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants