Skip to content

create_retrieval_instruction async

create_retrieval_instruction(
    name: RetrievalInstructionName,
    instruction: RetrievalInstructionContent,
    *,
    config_overrides: Optional[AsyncBedrockAgentClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    description: Optional[RetrievalInstructionDescription] = None,
    customer_encryption_key_arn: Optional[KmsKeyArn] = None,
    tags: Optional[TagsMap] = None,
) -> CreateRetrievalInstructionResponse

Creates a new retrieval instruction. The retrieval instruction is usable once its status becomes ACTIVE. Use GetRetrievalInstruction to check whether it is ready.

Parameters:

  • client_token (Optional[ClientToken], default: None ) –

    A caller-supplied token that makes a retried create return the existing resource rather than a second one. The window is 8 hours.

  • name (RetrievalInstructionName) –

    Specifies the name of the retrieval instruction.

  • instruction (RetrievalInstructionContent) –

    The instruction content, as a set of named fields. Get does not return this field until the create review passes.

  • description (Optional[RetrievalInstructionDescription], default: None ) –

    Specifies a description of the retrieval instruction.

  • customer_encryption_key_arn (Optional[KmsKeyArn], default: None ) –

    The Amazon Resource Name (ARN) of a customer managed AWS Key Management Service (AWS KMS) key used to encrypt the instruction content at rest. If you omit it, the service uses an AWS owned key. You fix the key at create and cannot change it later.

  • tags (Optional[TagsMap], default: None ) –

    Tags for the retrieval instruction.

Raises:

Source code in docs_src/capo_bedrock_agent/_services/async_bedrock_agent.py
async def create_retrieval_instruction(
    self,
    name: "capo_bedrock_agent.types.retrieval_instruction_name.RetrievalInstructionName",
    instruction: "capo_bedrock_agent.types.retrieval_instruction_content.RetrievalInstructionContent",
    *,
    config_overrides: Optional[AsyncBedrockAgentClientConfig] = None,
    client_token: Optional[
        "capo_bedrock_agent.types.client_token.ClientToken"
    ] = None,
    description: Optional[
        "capo_bedrock_agent.types.retrieval_instruction_description.RetrievalInstructionDescription"
    ] = None,
    customer_encryption_key_arn: Optional[
        "capo_bedrock_agent.types.kms_key_arn.KmsKeyArn"
    ] = None,
    tags: Optional["capo_bedrock_agent.types.tags_map.TagsMap"] = None,
) -> "capo_bedrock_agent.types.create_retrieval_instruction_response.CreateRetrievalInstructionResponse":
    """<p>Creates a new retrieval instruction. The retrieval instruction is usable once its status becomes ACTIVE. Use GetRetrievalInstruction to check whether it is ready.</p>

    Args:
        client_token: <p>A caller-supplied token that makes a retried create return the existing resource rather than a second one. The window is 8 hours.</p>
        name: <p>Specifies the name of the retrieval instruction.</p>
        instruction: <p>The instruction content, as a set of named fields. Get does not return this field until the create review passes.</p>
        description: <p>Specifies a description of the retrieval instruction.</p>
        customer_encryption_key_arn: <p>The Amazon Resource Name (ARN) of a customer managed AWS Key Management Service (AWS KMS) key used to encrypt the instruction content at rest. If you omit it, the service uses an AWS owned key. You fix the key at create and cannot change it later.</p>
        tags: <p>Tags for the retrieval instruction.</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.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The number of requests exceeds the service quota. Resubmit your request later.</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.create_retrieval_instruction_request.CreateRetrievalInstructionRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock_agent.types.create_retrieval_instruction_response.CreateRetrievalInstructionResponse"
    ]:
        import capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.create_retrieval_instruction

        (
            output,
            http_response,
        ) = await capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.create_retrieval_instruction.async_create_retrieval_instruction(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agent.types.create_retrieval_instruction_request.CreateRetrievalInstructionRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_agent.types.create_retrieval_instruction_request

        return capo_bedrock_agent.types.create_retrieval_instruction_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_bedrock_agent.types.create_retrieval_instruction_response.CreateRetrievalInstructionResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agent.types.create_retrieval_instruction_response

        return capo_bedrock_agent.types.create_retrieval_instruction_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateRetrievalInstruction",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_bedrock_agent.types.create_retrieval_instruction_request.CreateRetrievalInstructionRequest = {
        "name": name,
        "instruction": instruction,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if customer_encryption_key_arn is not None:
        input_["customer_encryption_key_arn"] = customer_encryption_key_arn
    if tags is not None:
        input_["tags"] = tags

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