Skip to content

create_recommendation_template

create_recommendation_template(
    assessment_arn: Arn,
    name: EntityName,
    *,
    config_overrides: Optional[resiliencehubClientConfig] = None,
    recommendation_ids: Optional[RecommendationIdList] = None,
    format: Optional[TemplateFormat] = None,
    recommendation_types: Optional[RenderRecommendationTypeList] = None,
    client_token: Optional[ClientToken] = None,
    tags: Optional[TagMap] = None,
    bucket_name: Optional[EntityName] = None,
) -> CreateRecommendationTemplateResponse

Creates a new recommendation template for the Resilience Hub application.

Parameters:

  • recommendation_ids (Optional[RecommendationIdList], default: None ) –

    Identifiers for the recommendations used to create a recommendation template.

  • format (Optional[TemplateFormat], default: None ) –

    The format for the recommendation template.

    CfnJson

    The template is CloudFormation JSON.

    CfnYaml

    The template is CloudFormation YAML.

  • recommendation_types (Optional[RenderRecommendationTypeList], default: None ) –

    An array of strings that specify the recommendation template type or types.

    Alarm

    The template is an AlarmRecommendation template.

    Sop

    The template is a SopRecommendation template.

    Test

    The template is a TestRecommendation template.

  • assessment_arn (Arn) –

    Amazon Resource Name (ARN) of the assessment. The format for this ARN is: arn:partition:resiliencehub:region:account:app-assessment/app-id. For more information about ARNs, see Amazon Resource Names (ARNs) in the Amazon Web Services General Reference guide.

  • name (EntityName) –

    The name for the recommendation template.

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

    Used for an idempotency token. A client token is a unique, case-sensitive string of up to 64 ASCII characters. You should not reuse the same client token for other API requests.

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

    Tags assigned to the resource. A tag is a label that you assign to an Amazon Web Services resource. Each tag consists of a key/value pair.

  • bucket_name (Optional[EntityName], default: None ) –

    The name of the Amazon S3 bucket that will contain the recommendation template.

Raises:

  • AccessDeniedException –

    You don't have permissions to perform the requested operation. The user or role that is making the request must have at least one IAM permissions policy attached that grants the required permissions.

  • ConflictException –

    This exception occurs when a conflict with a previous successful write is detected. This generally occurs when the previous write did not have time to propagate to the host serving the current request. A retry (with appropriate backoff logic) is the recommended response to this exception.

  • InternalServerException –

    This exception occurs when there is an internal failure in the Resilience Hub service.

  • ResourceNotFoundException –

    This exception occurs when the specified resource could not be found.

  • ServiceQuotaExceededException –

    This exception occurs when you have exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use Service Quotas to request a service quota increase.

  • ThrottlingException –

    This exception occurs when you have exceeded the limit on the number of requests per second.

  • ValidationException –

    This exception occurs when a request is not valid.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_resiliencehub/_services/resiliencehub.py
def create_recommendation_template(
    self,
    assessment_arn: "capo_resiliencehub.types.arn.Arn",
    name: "capo_resiliencehub.types.entity_name.EntityName",
    *,
    config_overrides: Optional[resiliencehubClientConfig] = None,
    recommendation_ids: Optional[
        "capo_resiliencehub.types.recommendation_id_list.RecommendationIdList"
    ] = None,
    format: Optional[
        "capo_resiliencehub.types.template_format.TemplateFormat"
    ] = None,
    recommendation_types: Optional[
        "capo_resiliencehub.types.render_recommendation_type_list.RenderRecommendationTypeList"
    ] = None,
    client_token: Optional[
        "capo_resiliencehub.types.client_token.ClientToken"
    ] = None,
    tags: Optional["capo_resiliencehub.types.tag_map.TagMap"] = None,
    bucket_name: Optional["capo_resiliencehub.types.entity_name.EntityName"] = None,
) -> "capo_resiliencehub.types.create_recommendation_template_response.CreateRecommendationTemplateResponse":
    """<p>Creates a new recommendation template for the Resilience Hub application.</p>

    Args:
        recommendation_ids: <p>Identifiers for the recommendations used to create a recommendation template.</p>
        format: <p>The format for the recommendation template.</p> <dl> <dt>CfnJson</dt> <dd> <p>The template is CloudFormation JSON.</p> </dd> <dt>CfnYaml</dt> <dd> <p>The template is CloudFormation YAML.</p> </dd> </dl>
        recommendation_types: <p>An array of strings that specify the recommendation template type or types.</p> <dl> <dt>Alarm</dt> <dd> <p>The template is an <a>AlarmRecommendation</a> template.</p> </dd> <dt>Sop</dt> <dd> <p>The template is a <a>SopRecommendation</a> template.</p> </dd> <dt>Test</dt> <dd> <p>The template is a <a>TestRecommendation</a> template.</p> </dd> </dl>
        assessment_arn: <p>Amazon Resource Name (ARN) of the assessment. The format for this ARN is: arn:<code>partition</code>:resiliencehub:<code>region</code>:<code>account</code>:app-assessment/<code>app-id</code>. For more information about ARNs, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html"> Amazon Resource Names (ARNs)</a> in the <i>Amazon Web Services General Reference</i> guide.</p>
        name: <p>The name for the recommendation template.</p>
        client_token: <p>Used for an idempotency token. A client token is a unique, case-sensitive string of up to 64 ASCII characters. You should not reuse the same client token for other API requests.</p>
        tags: <p>Tags assigned to the resource. A tag is a label that you assign to an Amazon Web Services resource. Each tag consists of a key/value pair.</p>
        bucket_name: <p>The name of the Amazon S3 bucket that will contain the recommendation template.</p>

    Raises:
        capo_resiliencehub.errors.access_denied_exception.AccessDeniedException: <p>You don't have permissions to perform the requested operation. The user or role that is making the request must have at least one IAM permissions policy attached that grants the required permissions.</p>
        capo_resiliencehub.errors.conflict_exception.ConflictException: <p>This exception occurs when a conflict with a previous successful write is detected. This generally occurs when the previous write did not have time to propagate to the host serving the current request. A retry (with appropriate backoff logic) is the recommended response to this exception.</p>
        capo_resiliencehub.errors.internal_server_exception.InternalServerException: <p>This exception occurs when there is an internal failure in the Resilience Hub service.</p>
        capo_resiliencehub.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception occurs when the specified resource could not be found.</p>
        capo_resiliencehub.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>This exception occurs when you have exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use Service Quotas to request a service quota increase.</p>
        capo_resiliencehub.errors.throttling_exception.ThrottlingException: <p>This exception occurs when you have exceeded the limit on the number of requests per second.</p>
        capo_resiliencehub.errors.validation_exception.ValidationException: <p>This exception occurs when a request is not valid.</p>
        capo_resiliencehub.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_resiliencehub.types.create_recommendation_template_request.CreateRecommendationTemplateRequest]",
    ) -> OperationResponse[
        "capo_resiliencehub.types.create_recommendation_template_response.CreateRecommendationTemplateResponse"
    ]:
        import capo_resiliencehub._operations.aws_resilience_hub.create_recommendation_template

        output, http_response = (
            capo_resiliencehub._operations.aws_resilience_hub.create_recommendation_template.create_recommendation_template(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_resiliencehub.types.create_recommendation_template_request.CreateRecommendationTemplateRequest",
    ) -> dict[str, Any]:
        import capo_resiliencehub.types.create_recommendation_template_request

        return capo_resiliencehub.types.create_recommendation_template_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_resiliencehub.types.create_recommendation_template_response.CreateRecommendationTemplateResponse",
    ) -> dict[str, Any]:
        import capo_resiliencehub.types.create_recommendation_template_response

        return capo_resiliencehub.types.create_recommendation_template_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateRecommendationTemplate",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_resiliencehub.types.create_recommendation_template_request.CreateRecommendationTemplateRequest = {
        "assessment_arn": assessment_arn,
        "name": name,
    }
    if recommendation_ids is not None:
        input_["recommendation_ids"] = recommendation_ids
    if format is not None:
        input_["format"] = format
    if recommendation_types is not None:
        input_["recommendation_types"] = recommendation_types
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags
    if bucket_name is not None:
        input_["bucket_name"] = bucket_name

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