Package com.redhat.parodos.sdkutils
Class SdkUtils
java.lang.Object
com.redhat.parodos.sdkutils.SdkUtils
A utility class to ease the writing of new examples.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic ApiClientCreates and configures the APIClient using the configuration properties available in `sdk-config.yml`static ProjectResponseDTOgetProjectAsync(ApiClient apiClient, String projectName, String projectDescription) Checks if a project with {projectName} and {projectDescription} exists.static ProjectResponseDTOgetProjectByNameAndDescription(List<ProjectResponseDTO> projects, String projectName, String projectDescription) Finds a project with @see #projectName and @see #projectDescriptionstatic Stringstatic <T> TExecutes a @see FuncExecutor.static voidwaitProjectStart(ProjectApi projectApi) Invokes @see com.redhat.parodos.sdk.api.ProjectAPI#getProjectsAsync(ApiCallback<List>) and retries for 60 seconds. static WorkFlowStatusResponseDTOwaitWorkflowStatusAsync(WorkflowApi workflowApi, UUID workFlowExecutionId) Invokes @see com.redhat.parodos.sdk.api.WorkflowApi#getStatusAsync(String, ApiCallback) and retries for 60 seconds. static WorkFlowStatusResponseDTOwaitWorkflowStatusAsync(WorkflowApi workflowApi, UUID workFlowExecutionId, WorkFlowStatusResponseDTO.StatusEnum status) Invokes @see com.redhat.parodos.sdk.api.WorkflowApi#getStatusAsync(String, ApiCallback) and retries for 60 seconds.
-
Method Details
-
getParodosAPiClient
public static ApiClient getParodosAPiClient() throws ApiException, org.springframework.core.env.MissingRequiredPropertiesException, InterruptedExceptionCreates and configures the APIClient using the configuration properties available in `sdk-config.yml`- Returns:
- the ApiClient
- Throws:
ApiExceptionorg.springframework.core.env.MissingRequiredPropertiesExceptionInterruptedException
-
waitAsyncResponse
public static <T> T waitAsyncResponse(SdkUtils.FuncExecutor<T> f) throws ApiException, InterruptedException Executes a @see FuncExecutor. Waits at most 60 seconds for a successful result of an async API invocation.- Type Parameters:
T- the type of the function executor- Parameters:
f- the @see FuncExecutor- Returns:
- Throws:
ApiException- if the api invocation failsInterruptedException- If the async call reaches the waiting timeout- See Also:
-
SdkUtils.AsyncResult
-
waitProjectStart
public static void waitProjectStart(ProjectApi projectApi) throws ApiException, InterruptedException Invokes @see com.redhat.parodos.sdk.api.ProjectAPI#getProjectsAsync(ApiCallback<List>) and retries for 60 seconds. - Parameters:
projectApi- the Project API- Throws:
InterruptedException- If the async call reaches the waiting timeoutApiException- If the API method invocation fails
-
waitWorkflowStatusAsync
public static WorkFlowStatusResponseDTO waitWorkflowStatusAsync(WorkflowApi workflowApi, UUID workFlowExecutionId) throws InterruptedException, ApiException Invokes @see com.redhat.parodos.sdk.api.WorkflowApi#getStatusAsync(String, ApiCallback) and retries for 60 seconds. - Parameters:
workflowApi- the WorkflowAPIworkFlowExecutionId- the workflow execution Id to monitor, as {String}- Returns:
- the workflow status if it's equal to @see com.redhat.parodos.workflows.work.WorkStatus#COMPLETED
- Throws:
InterruptedException- If the async call reaches the waiting timeoutApiException- If the API method invocation fails
-
waitWorkflowStatusAsync
public static WorkFlowStatusResponseDTO waitWorkflowStatusAsync(WorkflowApi workflowApi, UUID workFlowExecutionId, WorkFlowStatusResponseDTO.StatusEnum status) throws InterruptedException, ApiException Invokes @see com.redhat.parodos.sdk.api.WorkflowApi#getStatusAsync(String, ApiCallback) and retries for 60 seconds. - Parameters:
workflowApi- the WorkflowAPIworkFlowExecutionId- the workflow execution Id to monitor, as {String}status- the status to wait for- Returns:
- the workflow status if it's equal to @see com.redhat.parodos.workflows.work.WorkStatus#COMPLETED
- Throws:
InterruptedException- If the async call reaches the waiting timeoutApiException- If the API method invocation fails
-
getProjectByNameAndDescription
@Nullable public static ProjectResponseDTO getProjectByNameAndDescription(List<ProjectResponseDTO> projects, String projectName, String projectDescription) Finds a project with @see #projectName and @see #projectDescription- Parameters:
projects- List to of project to analyzeprojectName- the {String} project name to findprojectDescription- the {String} project decription to find- Returns:
- the {ProjectResponse} if the project exists, {null} otherwise
-
getProjectAsync
public static ProjectResponseDTO getProjectAsync(ApiClient apiClient, String projectName, String projectDescription) throws ApiException Checks if a project with {projectName} and {projectDescription} exists. Creates a new project, if it doesn't exist and asserts that it has been successfully created.Returns the {ProjectAPI} response for the project with {projectName} and {projectDescription}.
- Parameters:
apiClient- the API clientprojectName- the project nameprojectDescription- the project description- Returns:
- The ProjectApiResponse
- Throws:
InterruptedException- If the async call reaches the waiting timeoutApiException- If the API methods invocations fail
-
getServerIp
-