Search in sources :

Example 1 with AffinityLabel

use of org.ovirt.engine.api.model.AffinityLabel in project ovirt-engine by oVirt.

the class BackendAffinityLabelResource method update.

@Override
public AffinityLabel update(AffinityLabel incoming) {
    QueryIdResolver<Guid> labelResolver = new QueryIdResolver<>(QueryType.GetLabelById, IdQueryParameters.class);
    Label entity = getEntity(labelResolver, true);
    AffinityLabel label = performUpdate(incoming, entity, map(entity), labelResolver, ActionType.UpdateLabel, new UpdateParametersProvider());
    return label;
}
Also used : AffinityLabel(org.ovirt.engine.api.model.AffinityLabel) Label(org.ovirt.engine.core.common.businessentities.Label) AffinityLabel(org.ovirt.engine.api.model.AffinityLabel) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with AffinityLabel

use of org.ovirt.engine.api.model.AffinityLabel in project ovirt-engine by oVirt.

the class BackendAssignedAffinityLabelsResource method add.

@Override
public Response add(AffinityLabel label) {
    validateParameters(label, "id");
    IdQueryParameters parameters = new IdQueryParameters(GuidUtils.asGuid(label.getId()));
    org.ovirt.engine.core.common.businessentities.Label entity = getEntity(org.ovirt.engine.core.common.businessentities.Label.class, QueryType.GetLabelById, parameters, label.getId(), true);
    BusinessEntity<Guid> parent = constructor.create();
    parent.setId(GuidUtils.asGuid(parentId));
    org.ovirt.engine.core.common.businessentities.Label updatedLabel = new LabelBuilder(entity).entity(parent).build();
    // Add the affinity label using the backend "update" operation. As the backend will return the added label as
    // the result of the operation, we can fetch it using a simple "identity" resolver, that just returns the same
    // value it is passed.
    LabelActionParameters updateParams = new LabelActionParameters(updatedLabel);
    return performCreate(ActionType.UpdateLabel, updateParams, (IResolver<Label, Label>) result -> result);
}
Also used : AffinityLabels(org.ovirt.engine.api.model.AffinityLabels) QueryType(org.ovirt.engine.core.common.queries.QueryType) PathParam(javax.ws.rs.PathParam) Guid(org.ovirt.engine.core.compat.Guid) BusinessEntity(org.ovirt.engine.core.common.businessentities.BusinessEntity) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) LabelActionParameters(org.ovirt.engine.core.common.action.LabelActionParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GuidUtils(org.ovirt.engine.api.restapi.utils.GuidUtils) AssignedAffinityLabelsResource(org.ovirt.engine.api.resource.AssignedAffinityLabelsResource) ActionType(org.ovirt.engine.core.common.action.ActionType) List(java.util.List) AssignedAffinityLabelResource(org.ovirt.engine.api.resource.AssignedAffinityLabelResource) Response(javax.ws.rs.core.Response) Label(org.ovirt.engine.core.common.businessentities.Label) AffinityLabel(org.ovirt.engine.api.model.AffinityLabel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) LabelActionParameters(org.ovirt.engine.core.common.action.LabelActionParameters) Label(org.ovirt.engine.core.common.businessentities.Label) AffinityLabel(org.ovirt.engine.api.model.AffinityLabel) Label(org.ovirt.engine.core.common.businessentities.Label) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

AffinityLabel (org.ovirt.engine.api.model.AffinityLabel)2 Label (org.ovirt.engine.core.common.businessentities.Label)2 Guid (org.ovirt.engine.core.compat.Guid)2 List (java.util.List)1 PathParam (javax.ws.rs.PathParam)1 Response (javax.ws.rs.core.Response)1 AffinityLabels (org.ovirt.engine.api.model.AffinityLabels)1 AssignedAffinityLabelResource (org.ovirt.engine.api.resource.AssignedAffinityLabelResource)1 AssignedAffinityLabelsResource (org.ovirt.engine.api.resource.AssignedAffinityLabelsResource)1 GuidUtils (org.ovirt.engine.api.restapi.utils.GuidUtils)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 LabelActionParameters (org.ovirt.engine.core.common.action.LabelActionParameters)1 BusinessEntity (org.ovirt.engine.core.common.businessentities.BusinessEntity)1 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1