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¶
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 ansnowflake.core.exceptions.ConflictError
if the api integration already exists in Snowflake. Equivalent to SQLcreate api integration <name> ...
.CreateMode.or_replace
: Replace if the api integration already exists in Snowflake. Equivalent to SQLcreate or replace api integration <name> ...
.CreateMode.if_not_exists
: Do nothing if the api integration already exists in Snowflake. Equivalent to SQLcreate 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)
- 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)
- keys() KeysView[str] ¶
- values() ValuesView[T] ¶