Skip to content

Commit

Permalink
Missing secret tags api and refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
manan164 committed Sep 12, 2023
1 parent ea06e74 commit 06ca3c8
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public interface AuthorizationClient {

ConductorApplication updateApplication(CreateOrUpdateApplicationRequest createOrUpdateApplicationRequest, String id);

void putTagForApplication(List<TagObject> body, String applicationId);
void setApplicationTags(List<TagObject> body, String applicationId);

List<TagObject> getTagsForApplication(String applicationId);
List<TagObject> getApplicationTags(String applicationId);

void deleteTagForApplication(List<TagObject> body, String applicationId);
void deleteApplicationTags(List<TagObject> body, String applicationId);
}
6 changes: 3 additions & 3 deletions src/main/java/io/orkes/conductor/client/SchedulerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ List<Long> getNextFewSchedules(
SearchResultWorkflowScheduleExecutionModel searchV22(
Integer start, Integer size, String sort, String freeText, String query);

void putTagForSchedule(List<TagObject> body, String name);
void setSchedulerTags(List<TagObject> body, String name);

void deleteTagForSchedule(List<TagObject> body, String name);
void deleteSchedulerTags(List<TagObject> body, String name);

List<TagObject> getTagsForSchedule(String name);
List<TagObject> getSchedulerTags(String name);

}
5 changes: 4 additions & 1 deletion src/main/java/io/orkes/conductor/client/SecretClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ public interface SecretClient {
void putSecret(String value, String key);

boolean secretExists(String key);
void putTagForSecret(List<TagObject> tags, String key);
void setSecretTags(List<TagObject> tags, String key);

void deleteSecretTags(List<TagObject> body, String key);
List<TagObject> getSecretTags(String key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,17 @@ public ConductorApplication updateApplication(CreateOrUpdateApplicationRequest c
}

@Override
public void putTagForApplication(List<TagObject> tags, String applicationId) {
public void setApplicationTags(List<TagObject> tags, String applicationId) {
applicationResourceApi.putTagForApplication(tags, applicationId);
}

@Override
public List<TagObject> getTagsForApplication(String applicationId) {
public List<TagObject> getApplicationTags(String applicationId) {
return applicationResourceApi.getTagsForApplication(applicationId);
}

@Override
public void deleteTagForApplication(List<TagObject> tags, String applicationId) {
public void deleteApplicationTags(List<TagObject> tags, String applicationId) {
applicationResourceApi.deleteTagForApplication(tags, applicationId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ public SearchResultWorkflowScheduleExecutionModel searchV22(
}

@Override
public void putTagForSchedule(List<TagObject> body, String name) {
public void setSchedulerTags(List<TagObject> body, String name) {
schedulerResourceApi.putTagForSchedule(body, name);
}

@Override
public void deleteTagForSchedule(List<TagObject> body, String name) {
public void deleteSchedulerTags(List<TagObject> body, String name) {
schedulerResourceApi.deleteTagForSchedule(body, name);
}

@Override
public List<TagObject> getTagsForSchedule(String name) {
public List<TagObject> getSchedulerTags(String name) {
return schedulerResourceApi.getTagsForSchedule(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ public boolean secretExists(String key) throws ApiException {
}

@Override
public void putTagForSecret(List<TagObject> tags, String key) {
public void setSecretTags(List<TagObject> tags, String key) {
secretResourceApi.putTagForSecret(tags, key);
}

@Override
public void deleteSecretTags(List<TagObject> tags, String key) {
secretResourceApi.deleteTagForSecret(tags, key);
}

@Override
public List<TagObject> getSecretTags(String key) {
return secretResourceApi.getTags(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<TagObject> body, String key) throws ApiException {
deleteTagForSecretWithHttpInfo(body, key);
}

/**
* Delete tags of the secret
*
* @param body (required)
* @param key (required)
* @return ApiResponse&lt;Void&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
private ApiResponse<Void> deleteTagForSecretWithHttpInfo(List<TagObject> 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<TagObject> 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<TagObject> 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<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Map<String, Object> localVarFormParams = new HashMap<String, Object>();

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&lt;TagObject&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public List<TagObject> getTags(String key) throws ApiException {
ApiResponse<List<TagObject>> resp = getTagsWithHttpInfo(key);
return resp.getData();
}

/**
* Get tags by secret
*
* @param key (required)
* @return ApiResponse&lt;List&lt;TagObject&gt;&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
private ApiResponse<List<TagObject>> getTagsWithHttpInfo(String key) throws ApiException {
com.squareup.okhttp.Call call = getTagsValidateBeforeCall(key, null, null);
Type localVarReturnType = new TypeReference<List<TagObject>>(){}.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<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Map<String, Object> localVarFormParams = new HashMap<String, Object>();

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 06ca3c8

Please sign in to comment.