class InstanceSerializer {

    public static Slime identityToSlime(InstanceIdentity identity) {
        Slime slime = new Slime();
        Cursor root = slime.setObject();
        root.setString(PROVIDER_FIELD, identity.provider());
        root.setString(NAME_FIELD, identity.service());
        root.setString(INSTANCE_ID_FIELD, identity.instanceId());
        identity.x509Certificate()
                .map(X509CertificateUtils::toPem)
                .ifPresent(pem -> root.setString(X509_CERTIFICATE_FIELD, pem));
        return slime;
    }

    private  InstanceSerializer();

}