class RunBillingMapper extends AbstractEntityMapper<PipelineRunBillingInfo> {

    @Override
    public XContentBuilder map(final EntityContainer<PipelineRunBillingInfo> container) {
        try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
            final PipelineRunBillingInfo billingInfo = container.getEntity();
            final PipelineRun run = billingInfo.getEntity().getPipelineRun();
            jsonBuilder
                .startObject()
                .field(DOC_TYPE_FIELD, SearchDocumentType.PIPELINE_RUN.name())
                .field("run_id", run.getId())
                .field("resource_type", billingInfo.getResourceType())
                .field("pipeline", run.getPipelineId())
                .field("tool", run.getDockerImage())
                .field("instance_type", run.getInstance().getNodeType())
                .field("compute_type", billingInfo.getEntity().getRunType())
                .field("cost", billingInfo.getCost())
                .field("usage_minutes", billingInfo.getUsageMinutes())
                .field("paused_minutes", billingInfo.getPausedMinutes())
                .field("run_price", run.getPricePerHour().unscaledValue().longValue())
                .field("compute_price", scaled(run.getComputePricePerHour()))
                .field("disk_price", scaled(run.getDiskPricePerHour()))
                .field("cloudRegionId", run.getInstance().getCloudRegionId())
                .field("created_date", billingInfo.getDate());
            buildUserContent(container.getOwner(), jsonBuilder);
            jsonBuilder.endObject();
            return jsonBuilder;
        } catch (IOException e) {
            throw new IllegalArgumentException("Failed to create elasticsearch document for pipeline run: ", e);
        }
    }

    public  RunBillingMapper(@Value("${sync.billing.center.key}") final String billingCenterKey);

}