Search in sources :

Example 1 with ResourceInstanceDTO

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;
}
Also used : WebQuery(com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery) ResourceInstanceDTO(com.peterphi.servicemanager.service.rest.resource.type.ResourceInstanceDTO)

Example 2 with ResourceInstanceDTO

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;
}
Also used : ResourceInstanceDTO(com.peterphi.servicemanager.service.rest.resource.type.ResourceInstanceDTO) ProvisionResourceParametersDTO(com.peterphi.servicemanager.service.rest.resource.type.ProvisionResourceParametersDTO)

Aggregations

ResourceInstanceDTO (com.peterphi.servicemanager.service.rest.resource.type.ResourceInstanceDTO)2 ProvisionResourceParametersDTO (com.peterphi.servicemanager.service.rest.resource.type.ProvisionResourceParametersDTO)1 WebQuery (com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery)1