Search in sources :

Example 1 with ApiResponse

use of com.cloudera.api.swagger.client.ApiResponse in project cloudbreak by hortonworks.

the class SyncApiCommandRetrieverTest method createApiCommandListResponse.

private ApiResponse<ApiCommandList> createApiCommandListResponse(int statusCode) {
    ApiCommandList commandList = new ApiCommandList();
    ApiCommand command1 = new ApiCommand();
    command1.setId(new BigDecimal(4L));
    command1.setName("DeployClusterClientConfig");
    command1.setSuccess(true);
    command1.setStartTime(new DateTime(2000, 1, 1, 1, 1, 1).toString());
    ApiCommand command2 = new ApiCommand();
    command2.setId(new BigDecimal(5L));
    command2.setName("DeployClusterClientConfig");
    command2.setSuccess(true);
    command2.setStartTime(new DateTime(2000, 1, 1, 1, 1, 2).toString());
    ApiCommand command3 = new ApiCommand();
    command3.setId(new BigDecimal(6L));
    command3.setName("RestartServices");
    command3.setSuccess(true);
    command3.setStartTime(new DateTime(2000, 1, 1, 1, 1, 3).toString());
    commandList.addItemsItem(command1);
    commandList.addItemsItem(command2);
    commandList.addItemsItem(command3);
    return new ApiResponse<>(statusCode, emptyHeaders, commandList);
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiCommandList(com.cloudera.api.swagger.model.ApiCommandList) BigDecimal(java.math.BigDecimal) DateTime(org.joda.time.DateTime) ApiResponse(com.cloudera.api.swagger.client.ApiResponse)

Example 2 with ApiResponse

use of com.cloudera.api.swagger.client.ApiResponse in project cloudbreak by hortonworks.

the class ClouderaManagerMgmtTelemetryServiceTest method testSetupTelemetry.

@Test
public void testSetupTelemetry() throws ApiException {
    // GIVEN
    Stack stack = new Stack();
    stack.setType(StackType.WORKLOAD);
    User user = new User();
    user.setUserCrn("crn:cdp:iam:us-west-1:accountId:user:name");
    stack.setCreator(user);
    stack.setResourceCrn("crn:cdp:datahub:us-west-1:accountId:cluster:name");
    WorkloadAnalytics wa = new WorkloadAnalytics();
    Telemetry telemetry = new Telemetry();
    telemetry.setWorkloadAnalytics(wa);
    ApiConfigList apiConfigList = new ApiConfigList();
    ApiResponse response = new ApiResponse<>(0, null, apiConfigList);
    AltusCredential credential = new AltusCredential("accessKey", "secretKey".toCharArray());
    when(entitlementService.useDataBusCNameEndpointEnabled(anyString())).thenReturn(false);
    when(dataBusEndpointProvider.getDataBusEndpoint(anyString(), anyBoolean())).thenReturn("https://dbusapi.us-west-1.sigma.altus.cloudera.com");
    when(apiClient.execute(any(), any())).thenReturn(response);
    when(clouderaManagerDatabusService.getAltusCredential(stack, SDX_STACK_CRN)).thenReturn(credential);
    when(clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient)).thenReturn(cmResourceApi);
    when(cmResourceApi.updateConfig(anyString(), any())).thenReturn(apiConfigList);
    // WHEN
    underTest.setupTelemetryRole(stack, apiClient, null, new ApiRoleList(), telemetry, SDX_STACK_CRN);
    // THEN
    verify(externalAccountService, times(1)).createExternalAccount(anyString(), anyString(), anyString(), anyMap(), any(ApiClient.class));
    verify(clouderaManagerDatabusService, times(1)).getAltusCredential(stack, SDX_STACK_CRN);
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) User(com.sequenceiq.cloudbreak.workspace.model.User) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) ApiRoleList(com.cloudera.api.swagger.model.ApiRoleList) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiResponse(com.cloudera.api.swagger.client.ApiResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Aggregations

ApiResponse (com.cloudera.api.swagger.client.ApiResponse)2 ApiClient (com.cloudera.api.swagger.client.ApiClient)1 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)1 ApiCommandList (com.cloudera.api.swagger.model.ApiCommandList)1 ApiConfigList (com.cloudera.api.swagger.model.ApiConfigList)1 ApiRoleList (com.cloudera.api.swagger.model.ApiRoleList)1 AltusCredential (com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 User (com.sequenceiq.cloudbreak.workspace.model.User)1 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)1 WorkloadAnalytics (com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)1 BigDecimal (java.math.BigDecimal)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1