Skip to content

update_connection async

update_connection(
    connection_id: ConnectionIdentifier,
    ingestion_config: IngestionConfig,
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    name: Optional[ResourceName] = None,
    scope: Optional[DataSourceScope] = None,
    access_config: Optional[AccessConfig] = None,
    sync_schedule: Optional[SyncSchedule] = None,
    glue_connection_mappings: Optional[GlueConnectionMappingList] = None,
    publish: Optional[bool] = None,
) -> UpdateConnectionResponse

Updates a connection's configuration.

Parameters:

  • connection_id (ConnectionIdentifier) –

    The connection to update, by its ID (which starts with conn-) or its ARN.

  • name (Optional[ResourceName], default: None ) –

    The new name. If you omit it, the name is unchanged.

  • scope (Optional[DataSourceScope], default: None ) –

    The new ingestion scope for the connection. If you omit it, the existing scope is unchanged. The rules of CreateConnectionRequest.scope apply, with the following additions:

    • A DATABRICKS or SNOWFLAKE scope names at most one databricksCatalog or snowflakeDatabase, unless the existing scope already names each one.

    • If the stored scope has a selector with a glueService segment, the new scope can't be empty. Every selector that it adds must also have a glueService segment. Otherwise, the request fails with ValidationException. You can keep a selector that the stored scope already has, so resending the stored scope unchanged succeeds.

  • access_config (Optional[AccessConfig], default: None ) –

    The updated access configuration for the data source. If you omit it, the existing configuration is unchanged. If you provide one, it replaces the stored configuration, including its variant.

    For DATABRICKS and SNOWFLAKE, a configuration with no variant clears a stored iamRole, and the connection is then returned with no accessConfig.

    For GLUE_DATA_CATALOG and BEDROCK_KNOWLEDGE_BASE, you cannot add or remove the iamRole. An update that adds an iamRole to a connection stored without one fails with ValidationException. So does an update that provides a configuration without iamRole for a connection that has one. You can replace a stored role with another role. To change how such a connection reads its data source, delete the connection and create it again.

  • sync_schedule (Optional[SyncSchedule], default: None ) –

    The new sync schedule for a DATABRICKS or SNOWFLAKE source. If you omit it, the existing schedule is unchanged. Not accepted for GLUE_DATA_CATALOG and BEDROCK_KNOWLEDGE_BASE connections.

  • ingestion_config (IngestionConfig) –

    The ingestion configuration: the IAM role that a data producer assumes to push data into this connection. Required on every update, so that an existing connection always has an ingestion role that AWS Context can authorize. You must have iam:PassRole permission to pass this role to the data producer, and the role must be in your account. You can't clear the role.

  • glue_connection_mappings (Optional[GlueConnectionMappingList], default: None ) –

    The AWS Glue connection for each redshiftNamespace, and for each rdsInstance and rdsDatabase pair, in scope. If you omit it, the stored list is kept. A list replaces the stored list, and an empty list clears it. If the update changes scope, or changes the role of a connection to another account's catalog, AWS Context validates the kept list again. The rules are those of CreateConnectionRequest.glueConnectionMappings. You can't change the list of a SNOWFLAKE connection, which is keyed by snowflakeDatabase: omit it or send it unchanged.

  • publish (Optional[bool], default: None ) –

    Specifies whether to publish a third-party connection created with publish: false. If true, AWS Context configures catalog synchronization. The connection moves to ACTIVE when AWS Glue finishes provisioning the managed crawler. This has no effect on an ACTIVE connection. false is not accepted, because a connection can't be unpublished. Delete the connection instead.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.

  • InternalServerException –

    The request failed because of an internal error. Retry the request.

  • ThrottlingException –

    The request was denied because it exceeded a request rate quota. Wait, then retry the request.

  • ValidationException –

    The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.

  • ConflictException –

    The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.

  • ResourceNotFoundException –

    The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.

  • ServiceQuotaExceededException –

    The request would exceed a service quota. Check the quota that quotaCode names, reduce your usage, and then retry the request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Update the scope of a connection The following example adds the marketing_db database to the scope of the connection conn-e5f6a7b8c9d04e1f8a2b3c4d5e6f7a8b and keeps its ingestion role, which every update must specify.

>>> await client.update_connection(connection_id='conn-e5f6a7b8c9d04e1f8a2b3c4d5e6f7a8b', scope={'selectors': [{'path': [{'level': 'glueCatalog', 'id': 'arn:aws:glue:us-east-1:111122223333:catalog'}, {'level': 'glueDatabase', 'id': 'sales_db'}]}, {'path': [{'level': 'glueCatalog', 'id': 'arn:aws:glue:us-east-1:111122223333:catalog'}, {'level': 'glueDatabase', 'id': 'marketing_db'}]}]}, ingestion_config={'roleArn': 'arn:aws:iam::111122223333:role/ContextIngestionRole'})
Source code in docs_src/capo_context/_services/async_context.py
async def update_connection(
    self,
    connection_id: "capo_context.types.connection_identifier.ConnectionIdentifier",
    ingestion_config: "capo_context.types.ingestion_config.IngestionConfig",
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    name: Optional["capo_context.types.resource_name.ResourceName"] = None,
    scope: Optional["capo_context.types.data_source_scope.DataSourceScope"] = None,
    access_config: Optional["capo_context.types.access_config.AccessConfig"] = None,
    sync_schedule: Optional["capo_context.types.sync_schedule.SyncSchedule"] = None,
    glue_connection_mappings: Optional[
        "capo_context.types.glue_connection_mapping_list.GlueConnectionMappingList"
    ] = None,
    publish: Optional[bool] = None,
) -> "capo_context.types.update_connection_response.UpdateConnectionResponse":
    """<p>Updates a connection's configuration.</p>

    Args:
        connection_id: <p>The connection to update, by its ID (which starts with <code>conn-</code>) or its ARN.</p>
        name: <p>The new name. If you omit it, the name is unchanged.</p>
        scope: <p>The new ingestion scope for the connection. If you omit it, the existing scope is unchanged. The rules of <code>CreateConnectionRequest.scope</code> apply, with the following additions:</p> <ul> <li> <p>A <code>DATABRICKS</code> or <code>SNOWFLAKE</code> scope names at most one <code>databricksCatalog</code> or <code>snowflakeDatabase</code>, unless the existing scope already names each one.</p> </li> <li> <p>If the stored scope has a selector with a <code>glueService</code> segment, the new scope can't be empty. Every selector that it adds must also have a <code>glueService</code> segment. Otherwise, the request fails with <code>ValidationException</code>. You can keep a selector that the stored scope already has, so resending the stored scope unchanged succeeds.</p> </li> </ul>
        access_config: <p>The updated access configuration for the data source. If you omit it, the existing configuration is unchanged. If you provide one, it replaces the stored configuration, including its variant.</p> <p>For <code>DATABRICKS</code> and <code>SNOWFLAKE</code>, a configuration with no variant clears a stored <code>iamRole</code>, and the connection is then returned with no <code>accessConfig</code>.</p> <p>For <code>GLUE_DATA_CATALOG</code> and <code>BEDROCK_KNOWLEDGE_BASE</code>, you cannot add or remove the <code>iamRole</code>. An update that adds an <code>iamRole</code> to a connection stored without one fails with <code>ValidationException</code>. So does an update that provides a configuration without <code>iamRole</code> for a connection that has one. You can replace a stored role with another role. To change how such a connection reads its data source, delete the connection and create it again.</p>
        sync_schedule: <p>The new sync schedule for a <code>DATABRICKS</code> or <code>SNOWFLAKE</code> source. If you omit it, the existing schedule is unchanged. Not accepted for <code>GLUE_DATA_CATALOG</code> and <code>BEDROCK_KNOWLEDGE_BASE</code> connections.</p>
        ingestion_config: <p>The ingestion configuration: the IAM role that a data producer assumes to push data into this connection. Required on every update, so that an existing connection always has an ingestion role that AWS Context can authorize. You must have <code>iam:PassRole</code> permission to pass this role to the data producer, and the role must be in your account. You can't clear the role.</p>
        glue_connection_mappings: <p>The AWS Glue connection for each <code>redshiftNamespace</code>, and for each <code>rdsInstance</code> and <code>rdsDatabase</code> pair, in <code>scope</code>. If you omit it, the stored list is kept. A list replaces the stored list, and an empty list clears it. If the update changes <code>scope</code>, or changes the role of a connection to another account's catalog, AWS Context validates the kept list again. The rules are those of <code>CreateConnectionRequest.glueConnectionMappings</code>. You can't change the list of a <code>SNOWFLAKE</code> connection, which is keyed by <code>snowflakeDatabase</code>: omit it or send it unchanged.</p>
        publish: <p>Specifies whether to publish a third-party connection created with <code>publish: false</code>. If <code>true</code>, AWS Context configures catalog synchronization. The connection moves to ACTIVE when AWS Glue finishes provisioning the managed crawler. This has no effect on an ACTIVE connection. <code>false</code> is not accepted, because a connection can't be unpublished. Delete the connection instead.</p>

    Raises:
        capo_context.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.</p>
        capo_context.errors.internal_server_exception.InternalServerException: <p>The request failed because of an internal error. Retry the request.</p>
        capo_context.errors.throttling_exception.ThrottlingException: <p>The request was denied because it exceeded a request rate quota. Wait, then retry the request.</p>
        capo_context.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.</p>
        capo_context.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.</p>
        capo_context.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.</p>
        capo_context.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a service quota. Check the quota that <code>quotaCode</code> names, reduce your usage, and then retry the request.</p>
        capo_context.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Update the scope of a connection
        The following example adds the marketing_db database to the scope of the connection conn-e5f6a7b8c9d04e1f8a2b3c4d5e6f7a8b and keeps its ingestion role, which every update must specify.

        >>> await client.update_connection(connection_id='conn-e5f6a7b8c9d04e1f8a2b3c4d5e6f7a8b', scope={'selectors': [{'path': [{'level': 'glueCatalog', 'id': 'arn:aws:glue:us-east-1:111122223333:catalog'}, {'level': 'glueDatabase', 'id': 'sales_db'}]}, {'path': [{'level': 'glueCatalog', 'id': 'arn:aws:glue:us-east-1:111122223333:catalog'}, {'level': 'glueDatabase', 'id': 'marketing_db'}]}]}, ingestion_config={'roleArn': 'arn:aws:iam::111122223333:role/ContextIngestionRole'})
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_context.types.update_connection_request.UpdateConnectionRequest]",
    ) -> AsyncOperationResponse[
        "capo_context.types.update_connection_response.UpdateConnectionResponse"
    ]:
        import capo_context._operations.context.update_connection

        (
            output,
            http_response,
        ) = await capo_context._operations.context.update_connection.async_update_connection(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateConnection")
    )
    input_: capo_context.types.update_connection_request.UpdateConnectionRequest = {
        "connection_id": connection_id,
        "ingestion_config": ingestion_config,
    }
    if name is not None:
        input_["name"] = name
    if scope is not None:
        input_["scope"] = scope
    if access_config is not None:
        input_["access_config"] = access_config
    if sync_schedule is not None:
        input_["sync_schedule"] = sync_schedule
    if glue_connection_mappings is not None:
        input_["glue_connection_mappings"] = glue_connection_mappings
    if publish is not None:
        input_["publish"] = publish

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output