Skip to content

update_billing_preferences async

update_billing_preferences(
    feature: BillingFeature,
    billing_preferences_per_key: BillingPreferencesPerKey,
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
) -> UpdateBillingPreferencesResponse

Updates billing preferences for the specified feature. Each feature targets a distinct billing capability and has its own set of supported keys. The action sets the value for each provided key; keys not present in the request are unchanged.

To set sharing keys (RI_SHARING, CREDIT_SHARING, CREDIT_LEVEL_SHARING, BENEFIT_LEVEL_SHARING, and sharing keys under CREDIT_PREFERENCE_OPTIONS), you must use the management account of a consolidated billing family. To set the credit/{creditId}/status key, you must own the credit or use the management account of its family.

Parameters:

  • feature (BillingFeature) –

    The feature to update. Valid values: BILLING_ALERTS, RI_SHARING, CREDIT_SHARING, CREDIT_LEVEL_SHARING, CREDIT_PREFERENCE_OPTIONS, BENEFIT_LEVEL_SHARING. The history features (RI_SHARING_HISTORY and CREDIT_SHARING_HISTORY) are read-only and cannot be updated.

  • billing_preferences_per_key (BillingPreferencesPerKey) –

    Key/value pairs to apply. All keys in a single request must be valid for the specified feature and must not be duplicated. For CREDIT_PREFERENCE_OPTIONS, all keys must reference the same creditId.

    For BENEFIT_LEVEL_SHARING, all keys must reference the same Reserved Instance or Savings Plan. To share it with the accounts in one Cost Category rule, send these three keys with the value ENABLED:

    • benefit/{ri|sp}/{benefitId}/sharing/costCategoryArn/{costCategoryArn}

    • benefit/{ri|sp}/{benefitId}/sharing/ruleName/{ruleName}

    • benefit/{ri|sp}/{benefitId}/sharing/mode/{prioritized|restricted}

    With prioritized, any benefit that the rule's accounts don't use goes to the rest of your consolidated billing family, following your family sharing settings. With restricted, only the owner and the rule's accounts receive it. The Cost Category must belong to your account. To stop sharing, send the same three keys with the value DISABLED.

    For RI_SHARING and CREDIT_SHARING, you can share benefits by account group. Each rule in a Cost Category is one group. Send exactly one of these group keys with the value ENABLED:

    • open-sharing - Share across the whole consolidated billing family, with no groups.

    • costcategory-prioritized/{costCategoryArn} - Share within each group first, then with the rest of the family.

    • costcategory-restricted/{costCategoryArn} - An account in a group shares only with accounts in the same group.

    For RI_SHARING, the costcategory- keys use a Cost Category that supports the billing:rispgroupsharing resource type. To use a Cost Category that supports the billing:benefitgroupsharing resource type, use the benefitgroup-prioritized/ or benefitgroup-restricted/ prefix instead. For CREDIT_SHARING, the Cost Category must support the billing:benefitgroupsharing resource type. The Cost Category must belong to your account. GetBillingPreferences returns the group key that is in effect.

Raises:

Source code in docs_src/capo_billing/_services/async_billing.py
async def update_billing_preferences(
    self,
    feature: "capo_billing.types.billing_feature.BillingFeature",
    billing_preferences_per_key: "capo_billing.types.billing_preferences_per_key.BillingPreferencesPerKey",
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
) -> "capo_billing.types.update_billing_preferences_response.UpdateBillingPreferencesResponse":
    """<p>Updates billing preferences for the specified feature. Each feature targets a distinct billing capability and has its own set of supported keys. The action sets the value for each provided key; keys not present in the request are unchanged.</p> <p>To set sharing keys (<code>RI_SHARING</code>, <code>CREDIT_SHARING</code>, <code>CREDIT_LEVEL_SHARING</code>, <code>BENEFIT_LEVEL_SHARING</code>, and sharing keys under <code>CREDIT_PREFERENCE_OPTIONS</code>), you must use the management account of a consolidated billing family. To set the <code>credit/{creditId}/status</code> key, you must own the credit or use the management account of its family.</p>

    Args:
        feature: <p>The feature to update. Valid values: <code>BILLING_ALERTS</code>, <code>RI_SHARING</code>, <code>CREDIT_SHARING</code>, <code>CREDIT_LEVEL_SHARING</code>, <code>CREDIT_PREFERENCE_OPTIONS</code>, <code>BENEFIT_LEVEL_SHARING</code>. The history features (<code>RI_SHARING_HISTORY</code> and <code>CREDIT_SHARING_HISTORY</code>) are read-only and cannot be updated.</p>
        billing_preferences_per_key: <p>Key/value pairs to apply. All keys in a single request must be valid for the specified <code>feature</code> and must not be duplicated. For <code>CREDIT_PREFERENCE_OPTIONS</code>, all keys must reference the same <code>creditId</code>.</p> <p>For <code>BENEFIT_LEVEL_SHARING</code>, all keys must reference the same Reserved Instance or Savings Plan. To share it with the accounts in one Cost Category rule, send these three keys with the value <code>ENABLED</code>:</p> <ul> <li> <p> <code>benefit/{ri|sp}/{benefitId}/sharing/costCategoryArn/{costCategoryArn}</code> </p> </li> <li> <p> <code>benefit/{ri|sp}/{benefitId}/sharing/ruleName/{ruleName}</code> </p> </li> <li> <p> <code>benefit/{ri|sp}/{benefitId}/sharing/mode/{prioritized|restricted}</code> </p> </li> </ul> <p>With <code>prioritized</code>, any benefit that the rule's accounts don't use goes to the rest of your consolidated billing family, following your family sharing settings. With <code>restricted</code>, only the owner and the rule's accounts receive it. The Cost Category must belong to your account. To stop sharing, send the same three keys with the value <code>DISABLED</code>.</p> <p>For <code>RI_SHARING</code> and <code>CREDIT_SHARING</code>, you can share benefits by account group. Each rule in a Cost Category is one group. Send exactly one of these group keys with the value <code>ENABLED</code>:</p> <ul> <li> <p> <code>open-sharing</code> - Share across the whole consolidated billing family, with no groups.</p> </li> <li> <p> <code>costcategory-prioritized/{costCategoryArn}</code> - Share within each group first, then with the rest of the family.</p> </li> <li> <p> <code>costcategory-restricted/{costCategoryArn}</code> - An account in a group shares only with accounts in the same group.</p> </li> </ul> <p>For <code>RI_SHARING</code>, the <code>costcategory-</code> keys use a Cost Category that supports the <code>billing:rispgroupsharing</code> resource type. To use a Cost Category that supports the <code>billing:benefitgroupsharing</code> resource type, use the <code>benefitgroup-prioritized/</code> or <code>benefitgroup-restricted/</code> prefix instead. For <code>CREDIT_SHARING</code>, the Cost Category must support the <code>billing:benefitgroupsharing</code> resource type. The Cost Category must belong to your account. <code>GetBillingPreferences</code> returns the group key that is in effect.</p>

    Raises:
        capo_billing.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_billing.errors.internal_server_exception.InternalServerException: <p>The request processing failed because of an unknown error, exception, or failure. </p>
        capo_billing.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. </p>
        capo_billing.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service. </p>
        capo_billing.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_billing.types.update_billing_preferences_request.UpdateBillingPreferencesRequest]",
    ) -> AsyncOperationResponse[
        "capo_billing.types.update_billing_preferences_response.UpdateBillingPreferencesResponse"
    ]:
        import capo_billing._operations.aws_billing.update_billing_preferences

        (
            output,
            http_response,
        ) = await capo_billing._operations.aws_billing.update_billing_preferences.async_update_billing_preferences(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateBillingPreferences")
    )
    input_: capo_billing.types.update_billing_preferences_request.UpdateBillingPreferencesRequest = {
        "feature": feature,
        "billing_preferences_per_key": billing_preferences_per_key,
    }

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