Associates a resource policy with a knowledge base. A resource policy allows other AWS accounts to access the knowledge base. For more information, see Cross-account access for knowledge bases.
Parameters:
-
resource_arn
(ResourceArn)
–
The Amazon Resource Name (ARN) of the knowledge base to attach the resource policy to.
-
policy
(ResourcePolicy)
–
The JSON-formatted resource policy to associate with the knowledge base.
-
expected_revision_id
(Optional[RevisionId], default:
None
)
–
The expected revision identifier of the resource policy. Use this to prevent conflicts when multiple users update the same policy concurrently. Specify the revisionId from the most recent GetResourcePolicy or PutResourcePolicy response.
Raises:
Source code in docs_src/capo_bedrock_agent/_services/async_bedrock_agent.py
| async def put_resource_policy(
self,
resource_arn: "capo_bedrock_agent.types.resource_arn.ResourceArn",
policy: "capo_bedrock_agent.types.resource_policy.ResourcePolicy",
*,
config_overrides: Optional[AsyncBedrockAgentClientConfig] = None,
expected_revision_id: Optional[
"capo_bedrock_agent.types.revision_id.RevisionId"
] = None,
) -> "capo_bedrock_agent.types.put_resource_policy_response.PutResourcePolicyResponse":
"""<p>Associates a resource policy with a knowledge base. A resource policy allows other AWS accounts to access the knowledge base. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-managed-cross-account.html">Cross-account access for knowledge bases</a>.</p>
Args:
resource_arn: <p>The Amazon Resource Name (ARN) of the knowledge base to attach the resource policy to.</p>
policy: <p>The JSON-formatted resource policy to associate with the knowledge base.</p>
expected_revision_id: <p>The expected revision identifier of the resource policy. Use this to prevent conflicts when multiple users update the same policy concurrently. Specify the <code>revisionId</code> from the most recent <code>GetResourcePolicy</code> or <code>PutResourcePolicy</code> response.</p>
Raises:
capo_bedrock_agent.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
capo_bedrock_agent.errors.conflict_exception.ConflictException: <p>There was a conflict performing an operation.</p>
capo_bedrock_agent.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
capo_bedrock_agent.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.</p>
capo_bedrock_agent.errors.throttling_exception.ThrottlingException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
capo_bedrock_agent.errors.validation_exception.ValidationException: <p>Input validation failed. Check your request parameters and retry the request.</p>
capo_bedrock_agent.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_bedrock_agent.types.put_resource_policy_request.PutResourcePolicyRequest]",
) -> AsyncOperationResponse[
"capo_bedrock_agent.types.put_resource_policy_response.PutResourcePolicyResponse"
]:
import capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.put_resource_policy
(
output,
http_response,
) = await capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.put_resource_policy.async_put_resource_policy(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutResourcePolicy")
)
input_: capo_bedrock_agent.types.put_resource_policy_request.PutResourcePolicyRequest = {
"resource_arn": resource_arn,
"policy": policy,
}
if expected_revision_id is not None:
input_["expected_revision_id"] = expected_revision_id
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|