use of io.jenkins.blueocean.commons.stapler.TreeResponse in project blueocean-plugin by jenkinsci.
the class BluePipeline method update.
/**
* Updates this pipeline using {@link BluePipelineUpdateRequest}
* @param staplerRequest stapler request
* @return Updated BluePipeline instance
* @throws IOException throws IOException in certain cases
*/
@PUT
@WebMethod(name = "")
@TreeResponse
public BluePipeline update(StaplerRequest staplerRequest) throws IOException {
JSONObject body = JSONObject.fromObject(IOUtils.toString(staplerRequest.getReader()));
if (body.get("$class") == null) {
throw new ServiceException.BadRequestExpception("$class is required element");
}
BluePipelineUpdateRequest request = staplerRequest.bindJSON(BluePipelineUpdateRequest.class, body);
return update(request);
}
use of io.jenkins.blueocean.commons.stapler.TreeResponse in project blueocean-plugin by jenkinsci.
the class PipelineMetadataService method doAgentMetadata.
/**
* Function to return all {@link DeclarativeAgent}s present in the system when accessed through the REST API
*/
@GET
@TreeResponse
public ExportedDescribableModel[] doAgentMetadata() {
List<ExportedDescribableModel> models = new ArrayList<>();
for (DeclarativeAgentDescriptor d : DeclarativeAgentDescriptor.all()) {
try {
DescribableModel<? extends DeclarativeAgent> model = new DescribableModel<>(d.clazz);
String symbol = symbolForObject(d);
if ("label".equals(symbol)) {
// Label has 2 symbols, but we need "node"
symbol = "node";
}
models.add(new ExportedDescribableModel(model, symbol));
} catch (NoStaplerConstructorException e) {
// Ignore!
}
}
return models.toArray(new ExportedDescribableModel[models.size()]);
}
use of io.jenkins.blueocean.commons.stapler.TreeResponse in project blueocean-plugin by jenkinsci.
the class PipelineMetadataService method doToolMetadata.
/**
* Function to return all {@link ExportedToolDescriptor}s present in the system when accessed through the REST API,
* pipeline scripts need: symbol and name to specify tools
*/
@GET
@TreeResponse
public ExportedToolDescriptor[] doToolMetadata() {
List<ExportedToolDescriptor> models = new ArrayList<>();
for (ToolDescriptor<? extends ToolInstallation> d : ToolInstallation.all()) {
ExportedToolDescriptor descriptor = new ExportedToolDescriptor(d.getDisplayName(), symbolForObject(d), d.getClass());
models.add(descriptor);
for (ToolInstallation installation : d.getInstallations()) {
descriptor.addInstallation(new ExportedToolDescriptor.ExportedToolInstallation(installation.getName(), installation.getClass()));
}
}
return models.toArray(new ExportedToolDescriptor[models.size()]);
}
use of io.jenkins.blueocean.commons.stapler.TreeResponse in project blueocean-plugin by jenkinsci.
the class PipelineMetadataService method doPipelineStepMetadata.
/**
* Function to return all step descriptors present in the system when accessed through the REST API
*/
@GET
@TreeResponse
public ExportedPipelineFunction[] doPipelineStepMetadata() {
List<ExportedPipelineFunction> pd = new ArrayList<>();
for (StepDescriptor d : StepDescriptor.all()) {
if (includeStep(d)) {
ExportedPipelineStep step = getStepMetadata(d);
if (step != null) {
pd.add(step);
}
}
}
List<Descriptor<?>> metaStepDescriptors = new ArrayList<Descriptor<?>>();
populateMetaSteps(metaStepDescriptors, Builder.class);
populateMetaSteps(metaStepDescriptors, Publisher.class);
for (Descriptor<?> d : metaStepDescriptors) {
ExportedPipelineFunction metaStep = getStepMetadata(d);
if (metaStep != null) {
pd.add(metaStep);
}
}
return pd.toArray(new ExportedPipelineFunction[pd.size()]);
}
use of io.jenkins.blueocean.commons.stapler.TreeResponse in project blueocean-plugin by jenkinsci.
the class PipelineMetadataService method doBuildConditions.
/**
* Function to return the names of all build conditions present in the system when accessed through the REST API
*/
@GET
@TreeResponse
public ExportedBuildCondition[] doBuildConditions() {
List<ExportedBuildCondition> exported = new ArrayList<>();
for (BuildCondition c : BuildCondition.all()) {
exported.add(new ExportedBuildCondition(symbolForObject(c), c.getDescription()));
}
Collections.sort(exported, new Comparator<ExportedBuildCondition>() {
@Override
public int compare(ExportedBuildCondition o1, ExportedBuildCondition o2) {
return o1.getName().compareTo(o2.getName());
}
});
return exported.toArray(new ExportedBuildCondition[exported.size()]);
}
Aggregations