use of alien4cloud.rest.service.model.PatchServiceResourceRequest in project alien4cloud by alien4cloud.
the class ServiceStepDefinitions method iSetThePropertyToForTheService.
@And("^I set the property \"([^\"]*)\" to \"([^\"]*)\" for the service \"([^\"]*)\"$")
public void iSetThePropertyToForTheService(String propertyName, String propertyValue, String serviceName) throws Throwable {
String serviceId = Context.getInstance().getServiceId(serviceName);
PatchServiceResourceRequest request = new PatchServiceResourceRequest();
NodeInstanceDTO nodeInstance = new NodeInstanceDTO();
nodeInstance.setProperties(Maps.newHashMap());
nodeInstance.getProperties().put(propertyName, new ScalarPropertyValue(propertyValue));
request.setNodeInstance(nodeInstance);
Context.getInstance().registerRestResponse(Context.getRestClientInstance().patchJSon("/rest/v1/services/" + serviceId, JsonUtil.toString(request)));
}
use of alien4cloud.rest.service.model.PatchServiceResourceRequest in project alien4cloud by alien4cloud.
the class ServiceStepDefinitions method iAuthorizeTheseLocationsToUseTheService.
@When("^I authorize these locations to use the service \"([^\"]*)\"$")
public void iAuthorizeTheseLocationsToUseTheService(String serviceName, List<String> locations) throws Throwable {
PatchServiceResourceRequest request = new PatchServiceResourceRequest();
request.setLocationIds(locations.stream().map(name -> {
String orchestratorId = Context.getInstance().getOrchestratorId(name.split("/")[0].trim());
if (orchestratorId == null) {
return nullAsString(null);
}
String locationName = name.split("/")[1].trim();
return nullAsString(Context.getInstance().getLocationId(orchestratorId, locationName));
}).toArray(String[]::new));
String serviceId = Context.getInstance().getServiceId(serviceName);
String response = Context.getRestClientInstance().patchJSon("/rest/v1/services/" + nullAsString(serviceId), JsonUtil.toString(request));
Context.getInstance().registerRestResponse(response);
}
use of alien4cloud.rest.service.model.PatchServiceResourceRequest in project alien4cloud by alien4cloud.
the class ServiceStepDefinitions method iStartTheService.
@And("^I (successfully\\s)?start the service \"([^\"]*)\"$")
public void iStartTheService(String successfully, String serviceName) throws Throwable {
String serviceId = Context.getInstance().getServiceId(serviceName);
PatchServiceResourceRequest request = new PatchServiceResourceRequest();
NodeInstanceDTO nodeInstance = new NodeInstanceDTO();
nodeInstance.setAttributeValues(Maps.newHashMap());
nodeInstance.getAttributeValues().put("state", "started");
request.setNodeInstance(nodeInstance);
Context.getInstance().registerRestResponse(Context.getRestClientInstance().patchJSon("/rest/v1/services/" + serviceId, JsonUtil.toString(request)));
CommonStepDefinitions.validateIfNeeded(StringUtils.isNotBlank(successfully));
}
Aggregations