Search in sources :

Example 1 with ImageCatalogV4Response

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;
}
Also used : Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) ImageCatalogV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 2 with ImageCatalogV4Response

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;
}
Also used : Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) ImageCatalogV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 3 with ImageCatalogV4Response

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;
}
Also used : TestException(org.testng.TestException) ImageCatalogV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response) TestException(org.testng.TestException)

Example 4 with ImageCatalogV4Response

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();
}
Also used : UpdateImageCatalogV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.UpdateImageCatalogV4Request) ImageCatalogTestClient(com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) Test(org.testng.annotations.Test) ImageCatalogV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Responses) UpdateImageCatalogV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.UpdateImageCatalogV4Request) StackTestClient(com.sequenceiq.it.cloudbreak.client.StackTestClient) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) NotFoundException(javax.ws.rs.NotFoundException) ImageCatalogV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.ImageCatalogV4Request) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) ImageCatalogV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response) EnvironmentTestClient(com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient) ImageCatalogGetImagesByNameAction(com.sequenceiq.it.cloudbreak.action.v4.imagecatalog.ImageCatalogGetImagesByNameAction) BadRequestException(javax.ws.rs.BadRequestException) ImagesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response) RunningParameter.expectedMessage(com.sequenceiq.it.cloudbreak.context.RunningParameter.expectedMessage) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) ImageCatalogV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 5 with ImageCatalogV4Response

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;
}
Also used : Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) ImageCatalogV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) InternalOnly(com.sequenceiq.authorization.annotation.InternalOnly)

Aggregations

ImageCatalogV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response)7 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)3 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)3 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)1 InternalOnly (com.sequenceiq.authorization.annotation.InternalOnly)1 ImageCatalogV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.ImageCatalogV4Endpoint)1 ImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.ImageCatalogV4Request)1 UpdateImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.UpdateImageCatalogV4Request)1 ImageCatalogV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Responses)1 ImagesV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 ImageCatalogGetImagesByNameAction (com.sequenceiq.it.cloudbreak.action.v4.imagecatalog.ImageCatalogGetImagesByNameAction)1 EnvironmentTestClient (com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient)1 ImageCatalogTestClient (com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient)1 StackTestClient (com.sequenceiq.it.cloudbreak.client.StackTestClient)1 Description (com.sequenceiq.it.cloudbreak.context.Description)1 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)1 RunningParameter.expectedMessage (com.sequenceiq.it.cloudbreak.context.RunningParameter.expectedMessage)1 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)1