class InstanceTemplateRequestToTemplateConverter {

    public Template convert(InstanceTemplateRequest source, CloudPlatform cloudPlatform, String accountId) {
        Template template = new Template();
        template.setName(missingResourceNameGenerator.generateName(APIResourceType.TEMPLATE));
        template.setStatus(ResourceStatus.USER_MANAGED);
        setVolumesProperty(source.getAttachedVolumes(), template, cloudPlatform);
        template.setInstanceType(Objects.requireNonNullElse(source.getInstanceType(), defaultInstanceTypeProvider.getForPlatform(cloudPlatform.name())));
        Map<String, Object> attributes = new HashMap<>();
        if (cloudPlatform == CloudPlatform.AWS && entitlementService.freeIpaDlEbsEncryptionEnabled(INTERNAL_ACTOR_CRN, accountId)) {
            // FIXME Enable EBS encryption with appropriate KMS key
            attributes.put(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED, Boolean.TRUE);
            attributes.put(AwsInstanceTemplate.FAST_EBS_ENCRYPTION_ENABLED, entitlementService.fastEbsEncryptionEnabled(INTERNAL_ACTOR_CRN, accountId));
            attributes.put(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, EncryptionType.DEFAULT.name());
        }
        Optional.ofNullable(source.getAws())
                .map(AwsInstanceTemplateParameters::getSpot)
                .ifPresent(spotParameters -> {
                            attributes.put(AwsInstanceTemplate.EC2_SPOT_PERCENTAGE, spotParameters.getPercentage());
                            if (Objects.nonNull(spotParameters.getMaxPrice())) {
                                attributes.put(AwsInstanceTemplate.EC2_SPOT_MAX_PRICE, spotParameters.getMaxPrice());
                            }
                        }
                );
        template.setAttributes(new Json(attributes));
        return template;
    }

}