class TemplateToInstanceTemplateV4ResponseConverter extends AbstractConversionServiceAwareConverter<Template, InstanceTemplateV4Response> {

    @Override
    public InstanceTemplateV4Response convert(Template source) {
        InstanceTemplateV4Response response = new InstanceTemplateV4Response();
        response.setId(source.getId());
        response.setRootVolume(rootVolume(source));
        response.setAttachedVolumes(source.getVolumeTemplates().stream()
                .map(volume -> getConversionService().convert(volume, VolumeV4Response.class))
                .collect(Collectors.toSet()));
        response.setInstanceType(source.getInstanceType());
        Json attributes = source.getAttributes();
        if (attributes != null) {
            Map<String, Object> parameters = attributes.getMap();
            ofNullable(source.getSecretAttributes()).ifPresent(attr -> parameters.putAll(new Json(attr).getMap()));
            providerParameterCalculator.parse(parameters, response);
        }
        response.setCloudPlatform(CloudPlatform.valueOf(source.cloudPlatform()));
        return response;
    }

}