use of com.cloudera.api.swagger.model.ApiBatchRequestElement in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityServiceTest method verifyBatchRequest.
private void verifyBatchRequest(ApiBatchRequest batchRequest, String subAltName, String... urlsExpected) {
assertThat(batchRequest).isNotNull();
List<ApiBatchRequestElement> batchRequestElements = batchRequest.getItems();
assertThat(batchRequestElements).isNotNull();
if (urlsExpected == null) {
assertThat(batchRequestElements).isEmpty();
} else {
assertThat(batchRequestElements).hasSize(urlsExpected.length);
for (int i = 0; i < urlsExpected.length; i++) {
ApiBatchRequestElement batchRequestElement = batchRequestElements.get(i);
assertThat(batchRequestElement).isNotNull();
assertThat(batchRequestElement.getUrl()).isEqualTo(urlsExpected[i]);
ApiGenerateHostCertsArguments apiGenerateHostCertsArguments = (ApiGenerateHostCertsArguments) batchRequestElement.getBody();
if (subAltName == null) {
assertNull(apiGenerateHostCertsArguments.getSubjectAltName());
} else {
assertThat(apiGenerateHostCertsArguments.getSubjectAltName().get(0)).isEqualTo(subAltName);
}
}
}
}
use of com.cloudera.api.swagger.model.ApiBatchRequestElement in project cloudbreak by hortonworks.
the class ClouderaManagerModificationServiceTest method verifyRackIdBatch.
private void verifyRackIdBatch(ApiBatchRequest batchRequest, String hostIdExpected, String rackIdExpected) {
assertThat(batchRequest).isNotNull();
List<ApiBatchRequestElement> batchRequestElements = batchRequest.getItems();
assertThat(batchRequestElements).isNotNull();
assertThat(batchRequestElements).hasSize(1);
ApiBatchRequestElement batchRequestElement = batchRequestElements.get(0);
assertThat(batchRequestElement.getMethod()).isEqualTo(HTTPMethod.PUT);
assertThat(batchRequestElement.getUrl()).isEqualTo("/api/v31/hosts/" + hostIdExpected);
assertThat(batchRequestElement.getAcceptType()).isEqualTo("application/json");
assertThat(batchRequestElement.getContentType()).isEqualTo("application/json");
assertThat(batchRequestElement.getBody()).isInstanceOf(ApiHost.class);
ApiHost host = (ApiHost) batchRequestElement.getBody();
assertThat(host.getRackId()).isEqualTo(rackIdExpected);
}
use of com.cloudera.api.swagger.model.ApiBatchRequestElement in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method createHostCertsBatchRequest.
private ApiBatchRequest createHostCertsBatchRequest(ApiHostList hostList, String sshUser, KeyPair sshKeyPair, String subAltName) {
ApiGenerateHostCertsArguments apiGenerateHostCertsArguments = createApiGenerateHostCertsArguments(sshUser, sshKeyPair, subAltName);
List<ApiBatchRequestElement> batchRequestElements = hostList.getItems().stream().filter(host -> host.getClusterRef() != null).map(host -> new ApiBatchRequestElement().method(HTTPMethod.POST).url(ClouderaManagerApiClientProvider.API_V_31 + "/hosts/" + URLUtils.encodeString(host.getHostId()) + "/commands/generateHostCerts").body(apiGenerateHostCertsArguments).acceptType("application/json").contentType("application/json")).collect(Collectors.toList());
return new ApiBatchRequest().items(batchRequestElements);
}
Aggregations