use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response in project cloudbreak by hortonworks.
the class ImageCatalogV4Controller method getByCrn.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG)
public ImageCatalogV4Response getByCrn(Long workspaceId, @ResourceCrn String crn, Boolean withImages) {
ImageCatalog catalog = imageCatalogService.getImageCatalogByName(NameOrCrn.ofCrn(crn), restRequestThreadLocalService.getRequestedWorkspaceId());
ImageCatalogV4Response imageCatalogResponse = imageCatalogToImageCatalogV4ResponseConverter.convert(catalog);
Images images = imageCatalogService.propagateImagesIfRequested(restRequestThreadLocalService.getRequestedWorkspaceId(), catalog.getName(), withImages);
if (images != null) {
imageCatalogResponse.setImages(imagesToImagesV4ResponseConverter.convert(images));
}
return imageCatalogResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response in project cloudbreak by hortonworks.
the class ImageCatalogV4Controller method getByName.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG)
public ImageCatalogV4Response getByName(Long workspaceId, @ResourceName String name, Boolean withImages) {
ImageCatalog catalog = imageCatalogService.getImageCatalogByName(NameOrCrn.ofName(name), restRequestThreadLocalService.getRequestedWorkspaceId());
ImageCatalogV4Response imageCatalogResponse = imageCatalogToImageCatalogV4ResponseConverter.convert(catalog);
Images images = imageCatalogService.propagateImagesIfRequested(restRequestThreadLocalService.getRequestedWorkspaceId(), name, withImages);
if (images != null) {
imageCatalogResponse.setImages(imagesToImagesV4ResponseConverter.convert(images));
}
return imageCatalogResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response in project cloudbreak by hortonworks.
the class ImageCatalogCreateRetryAction method action.
@Override
public ImageCatalogTestDto action(TestContext testContext, ImageCatalogTestDto testDto, CloudbreakClient client) throws Exception {
Log.whenJson(LOGGER, format(" Image catalog post request with retry: %n"), testDto.getRequest());
ImageCatalogV4Response response = null;
Exception exc = null;
int counter = 0;
do {
try {
response = client.getDefaultClient().imageCatalogV4Endpoint().create(client.getWorkspaceId(), testDto.getRequest());
} catch (Exception e) {
Log.when(LOGGER, "Image catalog could not created - retry");
exc = e;
Thread.sleep(2000);
if (counter++ > 30) {
break;
}
}
} while (response == null);
if (response != null) {
testDto.setResponse(response);
} else {
throw new TestException("Image catalog could not created 30 times ", exc);
}
Log.whenJson(LOGGER, format(" Image catalog created successfully:%n"), testDto.getResponse());
return testDto;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response in project cloudbreak by hortonworks.
the class ImageCatalogTest method testUpdateImageCatalog.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "image catalog update request", when = "calling update request with new url", then = "the image catalog list should contains the new url")
public void testUpdateImageCatalog(MockedTestContext testContext) {
String imgCatalogName = resourcePropertyProvider().getName();
testContext.given(imgCatalogName, ImageCatalogTestDto.class).withName(imgCatalogName).withUrl(getImageCatalogMockServerSetup().getImageCatalogUrl()).when(imageCatalogTestClient.createV4(), key(imgCatalogName)).select(ImageCatalogTestDto::getResponse, key(imgCatalogName)).when((testContext1, entity, cloudbreakClient) -> {
ImageCatalogV4Response originalResponse = entity.getResponse();
UpdateImageCatalogV4Request updateRequest = new UpdateImageCatalogV4Request();
updateRequest.setCrn(originalResponse.getCrn());
updateRequest.setName(originalResponse.getName());
updateRequest.setUrl(IMG_CATALOG_URL);
ImageCatalogV4Response updateResponse = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().update(cloudbreakClient.getWorkspaceId(), updateRequest);
entity.setResponse(updateResponse);
return entity;
}, key(imgCatalogName)).then((testContext1, entity, cloudbreakClient) -> {
ImageCatalogV4Response originalRepsonse = testContext1.getSelected(imgCatalogName);
if (originalRepsonse.getUrl().equals(entity.getResponse().getUrl())) {
throw new IllegalArgumentException("The catalog URL should not be the same after update.");
}
return entity;
}, key(imgCatalogName)).validate();
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response in project cloudbreak by hortonworks.
the class ImageCatalogV4Controller method getByNameInternal.
@Override
@InternalOnly
public ImageCatalogV4Response getByNameInternal(Long workspaceId, @ResourceName String name, Boolean withImages, @InitiatorUserCrn String initiatorUserCrn) {
ImageCatalog catalog = imageCatalogService.getImageCatalogByName(NameOrCrn.ofName(name), restRequestThreadLocalService.getRequestedWorkspaceId());
ImageCatalogV4Response imageCatalogResponse = imageCatalogToImageCatalogV4ResponseConverter.convert(catalog);
Images images = imageCatalogService.propagateImagesIfRequested(restRequestThreadLocalService.getRequestedWorkspaceId(), name, withImages);
if (images != null) {
imageCatalogResponse.setImages(imagesToImagesV4ResponseConverter.convert(images));
}
return imageCatalogResponse;
}
Aggregations