createTemplate method

Future<CreateTemplateResponse> createTemplate({
  1. required String domainId,
  2. required String name,
  3. String? description,
  4. LayoutConfiguration? layoutConfiguration,
  5. List<RequiredField>? requiredFields,
  6. List<TemplateRule>? rules,
  7. TemplateStatus? status,
  8. List<TagPropagationConfiguration>? tagPropagationConfigurations,
})

Creates a template in the Cases domain. This template is used to define the case object model (that is, to define what data can be captured on cases) in a Cases domain. A template must have a unique name within a domain, and it must reference existing field IDs and layout IDs. Additionally, multiple fields with same IDs are not allowed within the same Template. A template can be either Active or Inactive, as indicated by its status. Inactive templates cannot be used to create cases.

Other template APIs are:

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter domainId : The unique identifier of the Cases domain.

Parameter name : A name for the template. It must be unique per domain.

Parameter description : A brief description of the template.

Parameter layoutConfiguration : Configuration of layouts associated to the template.

Parameter requiredFields : A list of fields that must contain a value for a case to be successfully created with this template.

Parameter rules : A list of case rules (also known as case field conditions) on a template.

Parameter status : The status of the template.

Parameter tagPropagationConfigurations : Defines tag propagation configuration for resources created within a domain. Tags specified here will be automatically applied to resources being created for the specified resource type.

Implementation

Future<CreateTemplateResponse> createTemplate({
  required String domainId,
  required String name,
  String? description,
  LayoutConfiguration? layoutConfiguration,
  List<RequiredField>? requiredFields,
  List<TemplateRule>? rules,
  TemplateStatus? status,
  List<TagPropagationConfiguration>? tagPropagationConfigurations,
}) async {
  final $payload = <String, dynamic>{
    'name': name,
    if (description != null) 'description': description,
    if (layoutConfiguration != null)
      'layoutConfiguration': layoutConfiguration,
    if (requiredFields != null) 'requiredFields': requiredFields,
    if (rules != null) 'rules': rules,
    if (status != null) 'status': status.value,
    if (tagPropagationConfigurations != null)
      'tagPropagationConfigurations': tagPropagationConfigurations,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/domains/${Uri.encodeComponent(domainId)}/templates',
    exceptionFnMap: _exceptionFns,
  );
  return CreateTemplateResponse.fromJson(response);
}