use of com.peterphi.servicemanager.service.rest.resource.type.ResourceInstanceDTO in project stdlib by petergeneric.
the class ResourceInstanceHelper method activeInstances.
/**
* Returns the number of active instances of the given template name
*
* @param service
* @param templateName
*
* @return
*/
public List<ResourceInstanceDTO> activeInstances(ServiceManagerResourceRestService service, String templateName) {
WebQuery wq = new WebQuery();
wq.eq("template.id", templateName);
wq.eq("state", ResourceInstanceState.TO_PROVISION, ResourceInstanceState.PROVISIONING, ResourceInstanceState.NOT_IN_SERVICE, ResourceInstanceState.IN_SERVICE);
List<ResourceInstanceDTO> instances = service.searchInstances(wq);
return instances;
}
use of com.peterphi.servicemanager.service.rest.resource.type.ResourceInstanceDTO in project stdlib by petergeneric.
the class ServiceManagerResourceMarshaller method marshal.
public ResourceInstanceDTO marshal(final ResourceInstanceEntity entity) {
ResourceInstanceDTO obj = new ResourceInstanceDTO();
obj.id = entity.getId();
obj.templateName = entity.getTemplate().getId();
obj.parameters = new ProvisionResourceParametersDTO();
obj.parameters.metadata = ResourceKVP.fromMap(entity.getMetadata());
obj.provider = entity.getProvider();
obj.providerInstanceId = entity.getProviderInstanceId();
obj.state = entity.getState();
obj.created = marshal(entity.getCreated());
obj.updated = marshal(entity.getUpdated());
return obj;
}
Aggregations