Skip to content

create_calculated_attribute_definition

create_calculated_attribute_definition(
    domain_name: name,
    calculated_attribute_name: typeName,
    attribute_details: AttributeDetails,
    statistic: Statistic,
    *,
    config_overrides: Optional[CustomerProfilesClientConfig] = None,
    display_name: Optional[displayName] = None,
    description: Optional[sensitiveText] = None,
    conditions: Optional[Conditions] = None,
    filter: Optional[Filter] = None,
    use_historical_data: Optional[optionalBoolean] = None,
    tags: Optional[TagMap] = None,
) -> CreateCalculatedAttributeDefinitionResponse

Creates a new calculated attribute definition. After creation, new object data ingested into Customer Profiles will be included in the calculated attribute, which can be retrieved for a profile using the GetCalculatedAttributeForProfile API. Defining a calculated attribute makes it available for all profiles within a domain. Each calculated attribute can only reference one ObjectType and at most, two fields from that ObjectType.

Parameters:

  • domain_name (name) –

    The unique name of the domain.

  • calculated_attribute_name (typeName) –

    The unique name of the calculated attribute.

  • display_name (Optional[displayName], default: None ) –

    The display name of the calculated attribute.

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

    The description of the calculated attribute.

  • attribute_details (AttributeDetails) –

    Mathematical expression and a list of attribute items specified in that expression.

  • conditions (Optional[Conditions], default: None ) –

    The conditions including range, object count, and threshold for the calculated attribute.

  • filter (Optional[Filter], default: None ) –

    Defines how to filter incoming objects to include part of the Calculated Attribute.

  • statistic (Statistic) –

    The aggregation operation to perform for the calculated attribute.

  • use_historical_data (Optional[optionalBoolean], default: None ) –

    Whether historical data ingested before the Calculated Attribute was created should be included in calculations.

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

    The tags used to organize, track, or control access for this resource.

Raises:

Source code in docs_src/capo_customer_profiles/_services/customer_profiles.py
def create_calculated_attribute_definition(
    self,
    domain_name: "capo_customer_profiles.types.name.name",
    calculated_attribute_name: "capo_customer_profiles.types.type_name.typeName",
    attribute_details: "capo_customer_profiles.types.attribute_details.AttributeDetails",
    statistic: "capo_customer_profiles.types.statistic.Statistic",
    *,
    config_overrides: Optional[CustomerProfilesClientConfig] = None,
    display_name: Optional[
        "capo_customer_profiles.types.display_name.displayName"
    ] = None,
    description: Optional[
        "capo_customer_profiles.types.sensitive_text.sensitiveText"
    ] = None,
    conditions: Optional[
        "capo_customer_profiles.types.conditions.Conditions"
    ] = None,
    filter: Optional["capo_customer_profiles.types.filter.Filter"] = None,
    use_historical_data: Optional[
        "capo_customer_profiles.types.optional_boolean.optionalBoolean"
    ] = None,
    tags: Optional["capo_customer_profiles.types.tag_map.TagMap"] = None,
) -> "capo_customer_profiles.types.create_calculated_attribute_definition_response.CreateCalculatedAttributeDefinitionResponse":
    """<p>Creates a new calculated attribute definition. After creation, new object data ingested into Customer Profiles will be included in the calculated attribute, which can be retrieved for a profile using the <a href="https://docs.aws.amazon.com/customerprofiles/latest/APIReference/API_GetCalculatedAttributeForProfile.html">GetCalculatedAttributeForProfile</a> API. Defining a calculated attribute makes it available for all profiles within a domain. Each calculated attribute can only reference one <code>ObjectType</code> and at most, two fields from that <code>ObjectType</code>.</p>

    Args:
        domain_name: <p>The unique name of the domain.</p>
        calculated_attribute_name: <p>The unique name of the calculated attribute.</p>
        display_name: <p>The display name of the calculated attribute.</p>
        description: <p>The description of the calculated attribute.</p>
        attribute_details: <p>Mathematical expression and a list of attribute items specified in that expression.</p>
        conditions: <p>The conditions including range, object count, and threshold for the calculated attribute.</p>
        filter: <p>Defines how to filter incoming objects to include part of the Calculated Attribute.</p>
        statistic: <p>The aggregation operation to perform for the calculated attribute.</p>
        use_historical_data: <p>Whether historical data ingested before the Calculated Attribute was created should be included in calculations.</p>
        tags: <p>The tags used to organize, track, or control access for this resource.</p>

    Raises:
        capo_customer_profiles.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_customer_profiles.errors.bad_request_exception.BadRequestException: <p>The input you provided is invalid.</p>
        capo_customer_profiles.errors.internal_server_exception.InternalServerException: <p>An internal service error occurred.</p>
        capo_customer_profiles.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource does not exist, or access was denied.</p>
        capo_customer_profiles.errors.throttling_exception.ThrottlingException: <p>You exceeded the maximum number of requests.</p>
        capo_customer_profiles.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_customer_profiles.types.create_calculated_attribute_definition_request.CreateCalculatedAttributeDefinitionRequest]",
    ) -> OperationResponse[
        "capo_customer_profiles.types.create_calculated_attribute_definition_response.CreateCalculatedAttributeDefinitionResponse"
    ]:
        import capo_customer_profiles._operations.customer_profiles_20200815.create_calculated_attribute_definition

        output, http_response = (
            capo_customer_profiles._operations.customer_profiles_20200815.create_calculated_attribute_definition.create_calculated_attribute_definition(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_customer_profiles.types.create_calculated_attribute_definition_request.CreateCalculatedAttributeDefinitionRequest",
    ) -> dict[str, Any]:
        import capo_customer_profiles.types.create_calculated_attribute_definition_request

        return capo_customer_profiles.types.create_calculated_attribute_definition_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_customer_profiles.types.create_calculated_attribute_definition_response.CreateCalculatedAttributeDefinitionResponse",
    ) -> dict[str, Any]:
        import capo_customer_profiles.types.create_calculated_attribute_definition_response

        return capo_customer_profiles.types.create_calculated_attribute_definition_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateCalculatedAttributeDefinition",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_customer_profiles.types.create_calculated_attribute_definition_request.CreateCalculatedAttributeDefinitionRequest = {
        "domain_name": domain_name,
        "calculated_attribute_name": calculated_attribute_name,
        "attribute_details": attribute_details,
        "statistic": statistic,
    }
    if display_name is not None:
        input_["display_name"] = display_name
    if description is not None:
        input_["description"] = description
    if conditions is not None:
        input_["conditions"] = conditions
    if filter is not None:
        input_["filter"] = filter
    if use_historical_data is not None:
        input_["use_historical_data"] = use_historical_data
    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