You are viewing documentation about an older version (1.4.0). View latest version

snowflake.core.api_integration.ApiIntegrationCollection

class snowflake.core.api_integration.ApiIntegrationCollection(root: Root)

Bases: AccountObjectCollectionParent[ApiIntegrationResource]

Represents the collection operations on the Snowflake api integration resource.

With this collection, you can create, iterate through, and search for api integration that you have access to in the current context.

Examples

Creating an ApiIntegration instance using AWS API Gateway:

>>> api_integrations = root.api_integrations
>>> new_api_integration = ApiIntegration(
...     name="name",
...     api_hook=AwsHook(
...         api_provider="AWS_API_GATEWAY",
...         api_aws_role_arn="your_arn",
...         api_key=os.environ.get("YOUR_API_KEY"),
...     ),
...     api_allowed_prefixes=["https://snowflake.com"],
...     enabled=True,
... )
>>> api_integrations.create(new_api_integration)

Attributes

root

The Root object this collection belongs to.

Methods

create(api_integration: ApiIntegration, *, mode: CreateMode = CreateMode.error_if_exists) ApiIntegrationResource

Create an API integration in Snowflake.

Parameters:
  • api_integration (ApiIntegration) – The ApiIntegration object.

  • mode (CreateMode, optional) –

    One of the following enum values:

    CreateMode.error_if_exists: Throw an snowflake.core.exceptions.ConflictError if the api integration already exists in Snowflake. Equivalent to SQL create api integration <name> ....

    CreateMode.or_replace: Replace if the api integration already exists in Snowflake. Equivalent to SQL create or replace api integration <name> ....

    CreateMode.if_not_exists: Do nothing if the api integration already exists in Snowflake. Equivalent to SQL create api integration <name> if not exists...

    Default is CreateMode.error_if_exists.

Examples

Creating an API integration, replacing any existing api integration with the same name:

>>> api_integrations = root.api_integrations
>>> new_api_integration = ApiIntegration(
...     name="name",
...     api_hook=AwsHook(
...         api_provider="AWS_API_GATEWAY",
...         api_aws_role_arn="your_arn",
...         api_key=os.environ.get("YOUR_API_KEY"),
...     ),
...     api_allowed_prefixes=["https://snowflake.com"],
...     enabled=True,
... )
>>> api_integrations.create(new_api_integration, mode=CreateMode.or_replace)
create_async(api_integration: ApiIntegration, *, mode: CreateMode = CreateMode.error_if_exists) PollingOperation[ApiIntegrationResource]

An asynchronous version of create().

Refer to PollingOperation for more information on asynchronous execution and the return type.

items() ItemsView[str, T]
iter(*, like: Annotated[str, Strict(strict=True)] | None = None) Iterator[ApiIntegration]

Iterate through ApiIntegration objects from Snowflake, filtering on any optional ‘like’ pattern.

Parameters:

like (str, optional) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _).

Examples

Showing all api integrations that you have access to see:

>>> api_integrations = root.api_integrations.iter()

Showing information of the exact api integration you want to see:

>>> api_integrations = root.api_integrations.iter(like="your-api-integration-name")

Showing api integrations starting with ‘your-api-integration-name-‘:

>>> api_integrations = root.api_integrations.iter(like="your-api-integration-name-%")

Using a for loop to retrieve information from iterator:

>>> for api_integration in api_integrations:
...     print(api_integration.name)
iter_async(like: Annotated[str, Strict(strict=True)] | None = None) PollingOperation[Iterator[ApiIntegration]]

An asynchronous version of iter().

Refer to PollingOperation for more information on asynchronous execution and the return type.

keys() KeysView[str]
values() ValuesView[T]