public static void toJSON(OutputWriter writer, List<Role> roles) { writer.addLinks( outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", Routes.Roles.DOC) .addLink("find", Routes.Roles.find()) .addLink("self", Routes.Roles.BASE)) .addChild("_embedded", embeddedWriter -> embeddedWriter.addChildList("roles", rolesWriter -> roles.forEach(role -> rolesWriter.addChild(roleWriter -> RoleRepresenter.toJSON(roleWriter, role))))); } }
public static void toJSON(OutputWriter writer, List<Role> roles) { writer.addLinks( outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", Routes.Roles.DOC) .addLink("find", Routes.Roles.find()) .addLink("self", Routes.Roles.BASE)) .addChild("_embedded", embeddedWriter -> embeddedWriter.addChildList("roles", rolesWriter -> roles.forEach(role -> rolesWriter.addChild(roleWriter -> RoleRepresenter.toJSON(roleWriter, role))))); } }
public static void toJSON(OutputWriter jsonWriter, Role role) { jsonWriter.addLinks( outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", Routes.Roles.DOC) .addLink("self", Routes.Roles.name(role.getName().toString())) .addLink("find", Routes.Roles.find())) .add("name", role.getName().toString()) .add("type", getRoleType(role)); if (role.hasErrors()) { jsonWriter.addChild("errors", errorWriter -> new ErrorGetter(Collections.singletonMap("authConfigId", "auth_config_id")) .toJSON(errorWriter, role)); } if (role instanceof RoleConfig) { jsonWriter.addChild("attributes", attributeWriter -> GoCDRoleConfigRepresenter.toJSON(attributeWriter, (RoleConfig) role)); } else if (role instanceof PluginRoleConfig) { jsonWriter.addChild("attributes", attributeWriter -> PluginRoleConfigRepresenter.toJSON(attributeWriter, (PluginRoleConfig) role)); } }
public static void toJSON(OutputWriter jsonWriter, Role role) { jsonWriter.addLinks( outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", Routes.Roles.DOC) .addLink("self", Routes.Roles.name(role.getName().toString())) .addLink("find", Routes.Roles.find())) .add("name", role.getName().toString()) .add("type", getRoleType(role)); if (role.hasErrors()) { jsonWriter.addChild("errors", errorWriter -> new ErrorGetter(Collections.singletonMap("authConfigId", "auth_config_id")) .toJSON(errorWriter, role)); } if (role instanceof RoleConfig) { jsonWriter.addChild("attributes", attributeWriter -> GoCDRoleConfigRepresenter.toJSON(attributeWriter, (RoleConfig) role)); } else if (role instanceof PluginRoleConfig) { jsonWriter.addChild("attributes", attributeWriter -> PluginRoleConfigRepresenter.toJSON(attributeWriter, (PluginRoleConfig) role)); } }