use of com.thoughtworks.go.api.base.OutputWriter in project gocd by gocd.
the class MessageJson method toString.
public String toString() {
StringWriter buffer = new StringWriter(1024);
new JsonOutputWriter(buffer, null).forTopLevelObject((OutputWriter writer) -> {
writer.add("message", message);
if (data != null) {
writer.add("data", data);
}
});
return buffer.toString();
}
use of com.thoughtworks.go.api.base.OutputWriter in project gocd by gocd.
the class TriggerWithOptionsViewRepresenter method toJSON.
public static void toJSON(OutputWriter writer, TriggerOptions triggerOptions) {
PipelineInstanceModel pipelineInstanceModel = triggerOptions.getPipelineInstanceModel();
writer.addLinks(outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", Routes.Pipeline.DOC_TRIGGER_OPTIONS).addLink("self", Routes.Pipeline.triggerOptions(pipelineInstanceModel.getName())).addLink("schedule", Routes.Pipeline.schedule(pipelineInstanceModel.getName()))).addChildList("variables", outputListWriter -> triggerOptions.getVariables().forEach(env -> outputListWriter.addChild(envWriter -> {
envWriter.add("name", env.getName()).add("secure", env.isSecure());
if (!env.isSecure()) {
envWriter.add("value", env.getValue());
}
}))).addChildList("materials", outputListWriter -> pipelineInstanceModel.getMaterials().forEach(material -> outputListWriter.addChild(material(material, pipelineInstanceModel.findCurrentMaterialRevisionForUI(material)))));
}
use of com.thoughtworks.go.api.base.OutputWriter in project gocd by gocd.
the class PipelineRepresenter method toJSON.
public static void toJSON(OutputWriter jsonOutputWriter, GoDashboardPipeline model, Username username) {
String usernameString = username.getUsername().toString();
jsonOutputWriter.addLinks(linksWriter -> addLinks(linksWriter, model)).add("name", model.name().toString()).add("last_updated_timestamp", model.getLastUpdatedTimeStamp()).add("locked", model.model().getLatestPipelineInstance().isCurrentlyLocked()).addChild("pause_info", getPauseInfoNEW(model)).add("can_operate", model.isPipelineOperator(usernameString)).add("can_administer", model.canBeAdministeredBy(usernameString)).add("can_unlock", model.canBeOperatedBy(usernameString)).add("can_pause", model.canBeOperatedBy(usernameString)).add("from_config_repo", !model.isLocal());
if (model.getTrackingTool().isPresent()) {
TrackingTool trackingTool = model.getTrackingTool().get();
jsonOutputWriter.addChild("tracking_tool", childWriter -> {
childWriter.add("regex", trackingTool.getRegex()).add("link", trackingTool.getLink());
});
}
jsonOutputWriter.addChild("_embedded", childWriter -> {
childWriter.addChildList("instances", writeInstances(model));
});
}
Aggregations