Skip to content

create_savings_plan

create_savings_plan(
    savings_plan_offering_id: SavingsPlanOfferingId,
    commitment: Amount,
    *,
    config_overrides: Optional[savingsplansClientConfig] = None,
    upfront_payment_amount: Optional[Amount] = None,
    purchase_time: Optional[DateTime] = None,
    client_token: Optional[ClientToken] = None,
    tags: Optional[TagMap] = None,
) -> CreateSavingsPlanResponse

Creates a Savings Plan.

Parameters:

  • savings_plan_offering_id (SavingsPlanOfferingId) –

    The ID of the offering.

  • commitment (Amount) –

    The hourly commitment, in the same currency of the savingsPlanOfferingId. This is a value between 0.001 and 1 million. You cannot specify more than five digits after the decimal point.

  • upfront_payment_amount (Optional[Amount], default: None ) –

    The up-front payment amount. This is a whole number between 50 and 99 percent of the total value of the Savings Plan. This parameter is only supported if the payment option is Partial Upfront.

  • purchase_time (Optional[DateTime], default: None ) –

    The purchase time of the Savings Plan in UTC format (YYYY-MM-DDTHH:MM:SSZ).

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

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

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

    One or more tags.

Raises:

Source code in docs_src/capo_savingsplans/_services/savingsplans.py
def create_savings_plan(
    self,
    savings_plan_offering_id: "capo_savingsplans.types.savings_plan_offering_id.SavingsPlanOfferingId",
    commitment: "capo_savingsplans.types.amount.Amount",
    *,
    config_overrides: Optional[savingsplansClientConfig] = None,
    upfront_payment_amount: Optional[
        "capo_savingsplans.types.amount.Amount"
    ] = None,
    purchase_time: Optional["capo_savingsplans.types.date_time.DateTime"] = None,
    client_token: Optional[
        "capo_savingsplans.types.client_token.ClientToken"
    ] = None,
    tags: Optional["capo_savingsplans.types.tag_map.TagMap"] = None,
) -> (
    "capo_savingsplans.types.create_savings_plan_response.CreateSavingsPlanResponse"
):
    """<p>Creates a Savings Plan.</p>

    Args:
        savings_plan_offering_id: <p>The ID of the offering.</p>
        commitment: <p>The hourly commitment, in the same currency of the <code>savingsPlanOfferingId</code>. This is a value between 0.001 and 1 million. You cannot specify more than five digits after the decimal point.</p>
        upfront_payment_amount: <p>The up-front payment amount. This is a whole number between 50 and 99 percent of the total value of the Savings Plan. This parameter is only supported if the payment option is <code>Partial Upfront</code>.</p>
        purchase_time: <p>The purchase time of the Savings Plan in UTC format (YYYY-MM-DDTHH:MM:SSZ).</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.</p>
        tags: <p>One or more tags.</p>

    Raises:
        capo_savingsplans.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred.</p>
        capo_savingsplans.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found.</p>
        capo_savingsplans.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>A service quota has been exceeded.</p>
        capo_savingsplans.errors.validation_exception.ValidationException: <p>One of the input parameters is not valid.</p>
        capo_savingsplans.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_savingsplans.types.create_savings_plan_request.CreateSavingsPlanRequest]",
    ) -> OperationResponse[
        "capo_savingsplans.types.create_savings_plan_response.CreateSavingsPlanResponse"
    ]:
        import capo_savingsplans._operations.aws_savings_plan.create_savings_plan

        output, http_response = (
            capo_savingsplans._operations.aws_savings_plan.create_savings_plan.create_savings_plan(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSavingsPlan")
    )
    input_: capo_savingsplans.types.create_savings_plan_request.CreateSavingsPlanRequest = {
        "savings_plan_offering_id": savings_plan_offering_id,
        "commitment": commitment,
    }
    if upfront_payment_amount is not None:
        input_["upfront_payment_amount"] = upfront_payment_amount
    if purchase_time is not None:
        input_["purchase_time"] = purchase_time
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    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