Changes the plan tier of an existing subscription.
Upgrades take effect immediately. Downgrades are scheduled and the current tier remains unchanged until the end of the billing cycle (calendar month). You cannot update a subscription while a scheduled change is pending. To make a new change, first cancel the pending change using CancelSubscriptionChange.
This operation replaces the plan tier value. If you omit the optional usageLevel field, it is reset to the default.
Parameters:
-
arn
(SubscriptionArn)
–
The ARN of the subscription to update.
-
plan_tier
(str)
–
The new tier level for the subscription.
-
usage_level
(Optional[str], default:
None
)
–
The usage level within the plan tier. Specify DEFAULT for the base configuration. If omitted, the usage level is reset to the default.
-
if_match
(str)
–
The ETag value from a previous GetSubscription or ListSubscriptions response. This ensures you are updating the expected version of the subscription.
-
client_token
(Optional[IdempotencyToken], default:
None
)
–
A unique, case-sensitive identifier that you provide to ensure the request is handled only once.
Raises:
-
AccessDeniedException
–
You do not have the required permissions to perform this operation. Verify that your IAM policy grants access to this action.
-
ConflictException
–
The request conflicts with the current state of the resource. This typically occurs when the ETag value in the If-Match header does not match the current version of the subscription. Retrieve the latest version and retry.
-
InternalServerException
–
An unexpected error occurred on the server. Retry the request.
-
ResourceNotFoundException
–
The specified subscription was not found. Verify that the ARN is correct and that the subscription belongs to your account.
-
ServiceQuotaExceededException
–
The request would exceed a service limit. You have reached the maximum number of subscriptions allowed for your account.
-
ThrottlingException
–
The request rate exceeds the allowed limit. Wait briefly and retry the request.
-
ValidationException
–
The request failed a business rule validation. For example, the specified resource might already be associated with another subscription, or the subscription might not be in the required state for this operation.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
Update a subscription plan tier
>>> client.update_subscription(arn='arn:aws:pricingplanmanager::123456789012:subscription/sub-1234567890', plan_tier='BUSINESS', if_match='1')
Source code in docs_src/capo_pricing_plan_manager/_services/pricing_plan_manager.py
| def update_subscription(
self,
arn: "capo_pricing_plan_manager.types.subscription_arn.SubscriptionArn",
plan_tier: str,
if_match: str,
*,
config_overrides: Optional[PricingPlanManagerClientConfig] = None,
usage_level: Optional[str] = None,
client_token: Optional[
"capo_pricing_plan_manager.types.idempotency_token.IdempotencyToken"
] = None,
) -> "capo_pricing_plan_manager.types.update_subscription_output.UpdateSubscriptionOutput":
"""<p>Changes the plan tier of an existing subscription.</p> <note> <p>Upgrades take effect immediately. Downgrades are scheduled and the current tier remains unchanged until the end of the billing cycle (calendar month). You cannot update a subscription while a scheduled change is pending. To make a new change, first cancel the pending change using <code>CancelSubscriptionChange</code>.</p> <p>This operation replaces the plan tier value. If you omit the optional <code>usageLevel</code> field, it is reset to the default.</p> </note>
Args:
arn: <p>The ARN of the subscription to update.</p>
plan_tier: <p>The new tier level for the subscription.</p>
usage_level: <p>The usage level within the plan tier. Specify <code>DEFAULT</code> for the base configuration. If omitted, the usage level is reset to the default.</p>
if_match: <p>The <code>ETag</code> value from a previous <code>GetSubscription</code> or <code>ListSubscriptions</code> response. This ensures you are updating the expected version of the subscription.</p>
client_token: <p>A unique, case-sensitive identifier that you provide to ensure the request is handled only once.</p>
Raises:
capo_pricing_plan_manager.errors.access_denied_exception.AccessDeniedException: <p>You do not have the required permissions to perform this operation. Verify that your IAM policy grants access to this action.</p>
capo_pricing_plan_manager.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. This typically occurs when the <code>ETag</code> value in the <code>If-Match</code> header does not match the current version of the subscription. Retrieve the latest version and retry.</p>
capo_pricing_plan_manager.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred on the server. Retry the request.</p>
capo_pricing_plan_manager.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified subscription was not found. Verify that the ARN is correct and that the subscription belongs to your account.</p>
capo_pricing_plan_manager.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a service limit. You have reached the maximum number of subscriptions allowed for your account.</p>
capo_pricing_plan_manager.errors.throttling_exception.ThrottlingException: <p>The request rate exceeds the allowed limit. Wait briefly and retry the request.</p>
capo_pricing_plan_manager.errors.validation_exception.ValidationException: <p>The request failed a business rule validation. For example, the specified resource might already be associated with another subscription, or the subscription might not be in the required state for this operation.</p>
capo_pricing_plan_manager.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
Update a subscription plan tier
>>> client.update_subscription(arn='arn:aws:pricingplanmanager::123456789012:subscription/sub-1234567890', plan_tier='BUSINESS', if_match='1')
"""
def _handler(
req: "OperationRequest[capo_pricing_plan_manager.types.update_subscription_input.UpdateSubscriptionInput]",
) -> OperationResponse[
"capo_pricing_plan_manager.types.update_subscription_output.UpdateSubscriptionOutput"
]:
import capo_pricing_plan_manager._operations.aws_pricing_plan_manager.update_subscription
output, http_response = (
capo_pricing_plan_manager._operations.aws_pricing_plan_manager.update_subscription.update_subscription(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("UpdateSubscription")
)
input_: capo_pricing_plan_manager.types.update_subscription_input.UpdateSubscriptionInput = {
"arn": arn,
"plan_tier": plan_tier,
"if_match": if_match,
}
if usage_level is not None:
input_["usage_level"] = usage_level
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
|