Skip to content

create_agent_context

create_agent_context(
    profile_arn: AgentProfileArn,
    title: SensitiveString,
    context_type: ContextType,
    content: ContextContent,
    *,
    config_overrides: Optional[WellArchitectedClientConfig] = None,
    client_token: Optional[str] = None,
) -> CreateAgentContextResponse

Creates a context associated with an optimization profile. Contexts provide application and environment information used during recommendation generation.

Parameters:

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

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

  • profile_arn (AgentProfileArn) –

    The Amazon Resource Name (ARN) of the profile to associate the context with.

  • title (SensitiveString) –

    The title of the context.

  • context_type (ContextType) –

    The type of the context.

  • content (ContextContent) –

    The typed content of the context. The structure contains application-specific fields such as account IDs, Regions, services, and resource types.

Raises:

Source code in docs_src/capo_wellarchitected/_services/well_architected.py
def create_agent_context(
    self,
    profile_arn: "capo_wellarchitected.types.agent_profile_arn.AgentProfileArn",
    title: "capo_wellarchitected.types.sensitive_string.SensitiveString",
    context_type: "capo_wellarchitected.types.context_type.ContextType",
    content: "capo_wellarchitected.types.context_content.ContextContent",
    *,
    config_overrides: Optional[WellArchitectedClientConfig] = None,
    client_token: Optional[str] = None,
) -> "capo_wellarchitected.types.create_agent_context_response.CreateAgentContextResponse":
    """<p>Creates a context associated with an optimization profile. Contexts provide application and environment information used during recommendation generation.</p>

    Args:
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.</p>
        profile_arn: <p>The Amazon Resource Name (ARN) of the profile to associate the context with.</p>
        title: <p>The title of the context.</p>
        context_type: <p>The type of the context.</p>
        content: <p>The typed content of the context. The structure contains application-specific fields such as account IDs, Regions, services, and resource types.</p>

    Raises:
        capo_wellarchitected.errors.access_denied_exception.AccessDeniedException: <p>User does not have sufficient access to perform this action.</p>
        capo_wellarchitected.errors.conflict_exception.ConflictException: <p>The resource has already been processed, was deleted, or is too large.</p>
        capo_wellarchitected.errors.internal_server_exception.InternalServerException: <p>There is a problem with the Well-Architected Tool API service.</p>
        capo_wellarchitected.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource was not found.</p>
        capo_wellarchitected.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The user has reached their resource quota.</p>
        capo_wellarchitected.errors.throttling_exception.ThrottlingException: <p>Request was denied due to request throttling.</p>
        capo_wellarchitected.errors.validation_exception.ValidationException: <p>The user input is not valid.</p>
        capo_wellarchitected.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_wellarchitected.types.create_agent_context_request.CreateAgentContextRequest]",
    ) -> OperationResponse[
        "capo_wellarchitected.types.create_agent_context_response.CreateAgentContextResponse"
    ]:
        import capo_wellarchitected._operations.well_architected_api_service_lambda.create_agent_context

        output, http_response = (
            capo_wellarchitected._operations.well_architected_api_service_lambda.create_agent_context.create_agent_context(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_wellarchitected.types.create_agent_context_request.CreateAgentContextRequest",
    ) -> dict[str, Any]:
        import capo_wellarchitected.types.create_agent_context_request

        return capo_wellarchitected.types.create_agent_context_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_wellarchitected.types.create_agent_context_response.CreateAgentContextResponse",
    ) -> dict[str, Any]:
        import capo_wellarchitected.types.create_agent_context_response

        return capo_wellarchitected.types.create_agent_context_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateAgentContext",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_wellarchitected.types.create_agent_context_request.CreateAgentContextRequest = {
        "profile_arn": profile_arn,
        "title": title,
        "context_type": context_type,
        "content": content,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output