Skip to content

create_curation_policy

create_curation_policy(
    name: ResourceName,
    policy_document: PolicyText,
    *,
    config_overrides: Optional[ContextClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    description: Optional[UserDefinedString] = None,
    auto_reject_after_seconds: Optional[AutoRejectAfterSeconds] = None,
    tags: Optional[TagMap] = None,
) -> CreateCurationPolicyResponse

Creates a curation policy, which decides which changes to an agent context are held for review as curation proposals instead of applied automatically. The policy starts as an unpublished draft. The agent contexts associated with it enforce it once CreateCurationPolicyVersion publishes it.

Parameters:

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

    A unique, case-sensitive identifier that you provide to make the request idempotent. A retry with the same token and the same parameters returns the curation policy that the first request created. If you don't specify one, the AWS SDKs generate one.

  • name (ResourceName) –

    The name of the curation policy. 3 to 63 characters: it must start with a letter and can contain only ASCII letters, digits, and hyphens.

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

    A description of the curation policy. Up to 1,024 characters, with no control characters.

  • policy_document (PolicyText) –

    The policy's rules, as a Cedar policy document.

  • auto_reject_after_seconds (Optional[AutoRejectAfterSeconds], default: None ) –

    The number of seconds that a curation proposal held for review under this policy can wait for a decision before it is rejected automatically. Valid range: 86,400 (1 day) to 15,552,000 (180 days). If you omit it, proposals held under this policy are never rejected automatically.

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

    Tags to add to the curation policy when you create it: up to 200 in the request, of which at most 50 can be user tags. Keys can't start with aws:. To add tags, you also need context:TagResource permission on the new curation policy. If you specify more than 50 user tags, the request fails with ServiceQuotaExceededException, as on TagResource. If an AWS Organizations tag policy refuses a tag, the request fails with ValidationException.

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.

  • 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:

Create a curation policy The following example creates a curation policy that holds change sets that trace analysis generates for review, and rejects a held proposal after 7 days without a decision.

>>> client.create_curation_policy(name='hold-trace-analysis-changes', description='Holds changes that trace analysis generates for review before they are applied.', policy_document='forbid (\n    principal,\n    action == AWS::Context::Action::"PublishChangeSet",\n    resource is AWS::Context::ChangeSet\n)\nwhen { resource has generatedBy && resource.generatedBy == AWS::Context::Activity::"TRACE_ANALYSIS" };', auto_reject_after_seconds=604800, tags={'team': 'sales-analytics'})
Source code in docs_src/capo_context/_services/context.py
def create_curation_policy(
    self,
    name: "capo_context.types.resource_name.ResourceName",
    policy_document: "capo_context.types.policy_text.PolicyText",
    *,
    config_overrides: Optional[ContextClientConfig] = None,
    client_token: Optional["capo_context.types.client_token.ClientToken"] = None,
    description: Optional[
        "capo_context.types.user_defined_string.UserDefinedString"
    ] = None,
    auto_reject_after_seconds: Optional[
        "capo_context.types.auto_reject_after_seconds.AutoRejectAfterSeconds"
    ] = None,
    tags: Optional["capo_context.types.tag_map.TagMap"] = None,
) -> "capo_context.types.create_curation_policy_response.CreateCurationPolicyResponse":
    r"""<p>Creates a curation policy, which decides which changes to an agent context are held for review as curation proposals instead of applied automatically. The policy starts as an unpublished draft. The agent contexts associated with it enforce it once CreateCurationPolicyVersion publishes it.</p>

    Args:
        client_token: <p>A unique, case-sensitive identifier that you provide to make the request idempotent. A retry with the same token and the same parameters returns the curation policy that the first request created. If you don't specify one, the AWS SDKs generate one.</p>
        name: <p>The name of the curation policy. 3 to 63 characters: it must start with a letter and can contain only ASCII letters, digits, and hyphens.</p>
        description: <p>A description of the curation policy. Up to 1,024 characters, with no control characters.</p>
        policy_document: <p>The policy's rules, as a Cedar policy document.</p>
        auto_reject_after_seconds: <p>The number of seconds that a curation proposal held for review under this policy can wait for a decision before it is rejected automatically. Valid range: 86,400 (1 day) to 15,552,000 (180 days). If you omit it, proposals held under this policy are never rejected automatically.</p>
        tags: <p>Tags to add to the curation policy when you create it: up to 200 in the request, of which at most 50 can be user tags. Keys can't start with <code>aws:</code>. To add tags, you also need <code>context:TagResource</code> permission on the new curation policy. If you specify more than 50 user tags, the request fails with <code>ServiceQuotaExceededException</code>, as on TagResource. If an AWS Organizations tag policy refuses a tag, the request fails with <code>ValidationException</code>.</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.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:
        Create a curation policy
        The following example creates a curation policy that holds change sets that trace analysis generates for review, and rejects a held proposal after 7 days without a decision.

        >>> client.create_curation_policy(name='hold-trace-analysis-changes', description='Holds changes that trace analysis generates for review before they are applied.', policy_document='forbid (\n    principal,\n    action == AWS::Context::Action::"PublishChangeSet",\n    resource is AWS::Context::ChangeSet\n)\nwhen { resource has generatedBy && resource.generatedBy == AWS::Context::Activity::"TRACE_ANALYSIS" };', auto_reject_after_seconds=604800, tags={'team': 'sales-analytics'})
    """

    def _handler(
        req: "OperationRequest[capo_context.types.create_curation_policy_request.CreateCurationPolicyRequest]",
    ) -> OperationResponse[
        "capo_context.types.create_curation_policy_response.CreateCurationPolicyResponse"
    ]:
        import capo_context._operations.context.create_curation_policy

        output, http_response = (
            capo_context._operations.context.create_curation_policy.create_curation_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCurationPolicy")
    )
    input_: capo_context.types.create_curation_policy_request.CreateCurationPolicyRequest = {
        "name": name,
        "policy_document": policy_document,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if auto_reject_after_seconds is not None:
        input_["auto_reject_after_seconds"] = auto_reject_after_seconds
    if tags is not None:
        input_["tags"] = tags

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