From 06ca3c8c01c1daf52234d3ae7522100a37d8b15e Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 12 Sep 2023 22:29:29 +0530 Subject: [PATCH] Missing secret tags api and refactoring. --- .../conductor/client/AuthorizationClient.java | 6 +- .../conductor/client/SchedulerClient.java | 6 +- .../orkes/conductor/client/SecretClient.java | 5 +- .../client/http/OrkesAuthorizationClient.java | 6 +- .../client/http/OrkesSchedulerClient.java | 6 +- .../client/http/OrkesSecretClient.java | 12 +- .../client/http/api/SecretResourceApi.java | 174 ++++++++++++++++++ .../client/api/SecretClientTests.java | 2 +- 8 files changed, 202 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/orkes/conductor/client/AuthorizationClient.java b/src/main/java/io/orkes/conductor/client/AuthorizationClient.java index 06b9833c..db5ea1e1 100644 --- a/src/main/java/io/orkes/conductor/client/AuthorizationClient.java +++ b/src/main/java/io/orkes/conductor/client/AuthorizationClient.java @@ -82,9 +82,9 @@ public interface AuthorizationClient { ConductorApplication updateApplication(CreateOrUpdateApplicationRequest createOrUpdateApplicationRequest, String id); - void putTagForApplication(List body, String applicationId); + void setApplicationTags(List body, String applicationId); - List getTagsForApplication(String applicationId); + List getApplicationTags(String applicationId); - void deleteTagForApplication(List body, String applicationId); + void deleteApplicationTags(List body, String applicationId); } diff --git a/src/main/java/io/orkes/conductor/client/SchedulerClient.java b/src/main/java/io/orkes/conductor/client/SchedulerClient.java index b99033e9..86eb1137 100644 --- a/src/main/java/io/orkes/conductor/client/SchedulerClient.java +++ b/src/main/java/io/orkes/conductor/client/SchedulerClient.java @@ -44,10 +44,10 @@ List getNextFewSchedules( SearchResultWorkflowScheduleExecutionModel searchV22( Integer start, Integer size, String sort, String freeText, String query); - void putTagForSchedule(List body, String name); + void setSchedulerTags(List body, String name); - void deleteTagForSchedule(List body, String name); + void deleteSchedulerTags(List body, String name); - List getTagsForSchedule(String name); + List getSchedulerTags(String name); } diff --git a/src/main/java/io/orkes/conductor/client/SecretClient.java b/src/main/java/io/orkes/conductor/client/SecretClient.java index 58745f6d..69314d10 100644 --- a/src/main/java/io/orkes/conductor/client/SecretClient.java +++ b/src/main/java/io/orkes/conductor/client/SecretClient.java @@ -29,5 +29,8 @@ public interface SecretClient { void putSecret(String value, String key); boolean secretExists(String key); - void putTagForSecret(List tags, String key); + void setSecretTags(List tags, String key); + + void deleteSecretTags(List body, String key); + List getSecretTags(String key); } diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java index 63ac59e6..8b866f64 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java @@ -187,17 +187,17 @@ public ConductorApplication updateApplication(CreateOrUpdateApplicationRequest c } @Override - public void putTagForApplication(List tags, String applicationId) { + public void setApplicationTags(List tags, String applicationId) { applicationResourceApi.putTagForApplication(tags, applicationId); } @Override - public List getTagsForApplication(String applicationId) { + public List getApplicationTags(String applicationId) { return applicationResourceApi.getTagsForApplication(applicationId); } @Override - public void deleteTagForApplication(List tags, String applicationId) { + public void deleteApplicationTags(List tags, String applicationId) { applicationResourceApi.deleteTagForApplication(tags, applicationId); } } diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java index c57f84c9..5b42c0d1 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java @@ -92,17 +92,17 @@ public SearchResultWorkflowScheduleExecutionModel searchV22( } @Override - public void putTagForSchedule(List body, String name) { + public void setSchedulerTags(List body, String name) { schedulerResourceApi.putTagForSchedule(body, name); } @Override - public void deleteTagForSchedule(List body, String name) { + public void deleteSchedulerTags(List body, String name) { schedulerResourceApi.deleteTagForSchedule(body, name); } @Override - public List getTagsForSchedule(String name) { + public List getSchedulerTags(String name) { return schedulerResourceApi.getTagsForSchedule(name); } } diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesSecretClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesSecretClient.java index 285acca1..3d0428d4 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesSecretClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesSecretClient.java @@ -61,7 +61,17 @@ public boolean secretExists(String key) throws ApiException { } @Override - public void putTagForSecret(List tags, String key) { + public void setSecretTags(List tags, String key) { secretResourceApi.putTagForSecret(tags, key); } + + @Override + public void deleteSecretTags(List tags, String key) { + secretResourceApi.deleteTagForSecret(tags, key); + } + + @Override + public List getSecretTags(String key) { + return secretResourceApi.getTags(key); + } } diff --git a/src/main/java/io/orkes/conductor/client/http/api/SecretResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/SecretResourceApi.java index fc64e6f6..09436a73 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/SecretResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/SecretResourceApi.java @@ -808,4 +808,178 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } + /** + * Delete tags of the secret + * + * @param body (required) + * @param key (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void deleteTagForSecret(List body, String key) throws ApiException { + deleteTagForSecretWithHttpInfo(body, key); + } + + /** + * Delete tags of the secret + * + * @param body (required) + * @param key (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + private ApiResponse deleteTagForSecretWithHttpInfo(List body, String key) throws ApiException { + com.squareup.okhttp.Call call = deleteTagForSecretValidateBeforeCall(body, key, null, null); + return apiClient.execute(call); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call deleteTagForSecretValidateBeforeCall(List body, String key, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling deleteTagForSecret(Async)"); + } + // verify the required parameter 'key' is set + if (key == null) { + throw new ApiException("Missing the required parameter 'key' when calling deleteTagForSecret(Async)"); + } + + com.squareup.okhttp.Call call = deleteTagForSecretCall(body, key, progressListener, progressRequestListener); + return call; + } + /** + * Build call for deleteTagForSecret + * @param body (required) + * @param key (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private com.squareup.okhttp.Call deleteTagForSecretCall(List body, String key, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/secrets/{key}/tags" + .replaceAll("\\{" + "key" + "\\}", apiClient.escapeString(key.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * Get tags by secret + * + * @param key (required) + * @return List<TagObject> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public List getTags(String key) throws ApiException { + ApiResponse> resp = getTagsWithHttpInfo(key); + return resp.getData(); + } + + /** + * Get tags by secret + * + * @param key (required) + * @return ApiResponse<List<TagObject>> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + private ApiResponse> getTagsWithHttpInfo(String key) throws ApiException { + com.squareup.okhttp.Call call = getTagsValidateBeforeCall(key, null, null); + Type localVarReturnType = new TypeReference>(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getTagsValidateBeforeCall(String key, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + // verify the required parameter 'key' is set + if (key == null) { + throw new ApiException("Missing the required parameter 'key' when calling getTags(Async)"); + } + + com.squareup.okhttp.Call call = getTagsCall(key, progressListener, progressRequestListener); + return call; + } + + /** + * Build call for getTags + * @param key (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private com.squareup.okhttp.Call getTagsCall(String key, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/secrets/{key}/tags" + .replaceAll("\\{" + "key" + "\\}", apiClient.escapeString(key.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } } diff --git a/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java b/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java index 696d7b3e..0c8e195c 100644 --- a/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java +++ b/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java @@ -43,7 +43,7 @@ void testMethods() { } } secretClient.putSecret(SECRET_NAME, SECRET_KEY); - secretClient.putTagForSecret(List.of(getTagObject()), SECRET_KEY); + secretClient.setSecretTags(List.of(getTagObject()), SECRET_KEY); assertTrue(secretClient.listSecretsThatUserCanGrantAccessTo().contains(SECRET_KEY)); assertTrue(secretClient.listAllSecretNames().contains(SECRET_KEY)); assertEquals(SECRET_NAME, secretClient.getSecret(SECRET_KEY));