-
Notifications
You must be signed in to change notification settings - Fork 4
Added more clients #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shaileshpadave
wants to merge
5
commits into
main
Choose a base branch
from
CCOR-12562-Few-More-Fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
orkes-client/src/main/java/io/orkes/conductor/client/http/OrkesSharedResourceClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Copyright 2022 Conductor Authors. | ||
| * <p> | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| */ | ||
| package io.orkes.conductor.client.http; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.netflix.conductor.client.http.ConductorClient; | ||
|
|
||
| import io.orkes.conductor.client.model.SharedResourceModel; | ||
|
|
||
| /** | ||
| * Client for managing shared resources in Orkes Conductor. | ||
| * Provides functionality to share various types of resources (workflows, tasks, secrets, etc.) | ||
| * with other users, groups, or applications within the Conductor ecosystem. | ||
| */ | ||
| public class OrkesSharedResourceClient { | ||
|
|
||
| private final SharedResource sharedResource; | ||
|
|
||
| /** | ||
| * Constructs a new OrkesSharedResourceClient with the specified ConductorClient. | ||
| * | ||
| * @param client the ConductorClient to use for making HTTP requests to the server | ||
| */ | ||
| public OrkesSharedResourceClient(ConductorClient client) { | ||
| this.sharedResource = new SharedResource(client); | ||
| } | ||
|
|
||
| /** | ||
| * Shares a resource with another user, group, or application. | ||
| * | ||
| * @param resourceType the type of resource to share (e.g., "WORKFLOW", "TASK", "SECRET") | ||
| * @param resourceName the name/identifier of the specific resource to share | ||
| * @param sharedWith the identifier of the entity to share with (user email, group name, or application ID) | ||
| */ | ||
| public void shareResource(String resourceType, String resourceName, String sharedWith) { | ||
| sharedResource.shareResource(resourceType, resourceName, sharedWith); | ||
| } | ||
|
|
||
| /** | ||
| * Removes sharing access for a resource from a specific entity. | ||
| * | ||
| * @param resourceType the type of resource to stop sharing (e.g., "WORKFLOW", "TASK", "SECRET") | ||
| * @param resourceName the name/identifier of the specific resource to stop sharing | ||
| * @param sharedWith the identifier of the entity to remove sharing from (user email, group name, or application ID) | ||
| */ | ||
| public void removeSharingResource(String resourceType, String resourceName, String sharedWith) { | ||
| sharedResource.removeSharingResource(resourceType, resourceName, sharedWith); | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves a list of all resources that are currently shared by or with the current user/application. | ||
| * | ||
| * @return a list of SharedResourceModel objects representing all shared resources | ||
| */ | ||
| public List<SharedResourceModel> getSharedResources() { | ||
| return sharedResource.getSharedResources(); | ||
| } | ||
| } |
166 changes: 166 additions & 0 deletions
166
orkes-client/src/main/java/io/orkes/conductor/client/http/OrkesWebhookClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| /* | ||
| * Copyright 2022 Conductor Authors. | ||
| * <p> | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| */ | ||
| package io.orkes.conductor.client.http; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.netflix.conductor.client.http.ConductorClient; | ||
| import com.netflix.conductor.client.http.ConductorClientResponse; | ||
|
|
||
| import io.orkes.conductor.client.model.Tag; | ||
| import io.orkes.conductor.client.model.WebhookConfig; | ||
|
|
||
| /** | ||
| * Client for managing webhook configurations in Orkes Conductor. | ||
| * Provides functionality to create, update, delete, and manage webhook configurations | ||
| * that can trigger workflows based on external events. | ||
| */ | ||
| public class OrkesWebhookClient { | ||
|
|
||
| private final WebhookResource webhookResource; | ||
|
|
||
| /** | ||
| * Constructs a new OrkesWebhookClient with the specified ConductorClient. | ||
| * | ||
| * @param client the ConductorClient to use for making HTTP requests to the server | ||
| */ | ||
| public OrkesWebhookClient(ConductorClient client) { | ||
| this.webhookResource = new WebhookResource(client); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new webhook configuration. | ||
| * | ||
| * @param webhookConfig the webhook configuration to create | ||
| * @return ConductorClientResponse containing the created webhook configuration | ||
| */ | ||
| public ConductorClientResponse<WebhookConfig> createWebhook(WebhookConfig webhookConfig) { | ||
| return webhookResource.createWebhook(webhookConfig); | ||
| } | ||
|
|
||
| /** | ||
| * Update an existing webhook configuration. | ||
| * | ||
| * @param id the webhook ID to update | ||
| * @param webhookConfig the updated webhook configuration | ||
| * @return ConductorClientResponse containing the updated webhook configuration | ||
| */ | ||
| public ConductorClientResponse<WebhookConfig> updateWebhook(String id, WebhookConfig webhookConfig) { | ||
| return webhookResource.updateWebhook(id, webhookConfig); | ||
| } | ||
|
|
||
| /** | ||
| * Delete a webhook configuration by ID. | ||
| * | ||
| * @param id the webhook ID to delete | ||
| * @return ConductorClientResponse for the delete operation | ||
| */ | ||
| public ConductorClientResponse<Void> deleteWebhook(String id) { | ||
| return webhookResource.deleteWebhook(id); | ||
| } | ||
|
|
||
| /** | ||
| * Get a webhook configuration by ID. | ||
| * | ||
| * @param id the webhook ID to retrieve | ||
| * @return ConductorClientResponse containing the webhook configuration | ||
| */ | ||
| public ConductorClientResponse<WebhookConfig> getWebhook(String id) { | ||
| return webhookResource.getWebhook(id); | ||
| } | ||
|
|
||
| /** | ||
| * Get all webhook configurations. | ||
| * | ||
| * @return ConductorClientResponse containing a list of all webhook configurations | ||
| */ | ||
| public ConductorClientResponse<List<WebhookConfig>> getAllWebhooks() { | ||
| return webhookResource.getAllWebhooks(); | ||
| } | ||
|
|
||
| /** | ||
| * Get tags for a webhook by ID. | ||
| * | ||
| * @param id the webhook ID | ||
| * @return ConductorClientResponse containing a list of tags | ||
| */ | ||
| public ConductorClientResponse<List<Tag>> getTagsForWebhook(String id) { | ||
| return webhookResource.getTagsForWebhook(id); | ||
| } | ||
|
|
||
| /** | ||
| * Put tags for a webhook by ID. | ||
| * | ||
| * @param id the webhook ID | ||
| * @param tags the tags to set | ||
| * @return ConductorClientResponse for the put operation | ||
| */ | ||
| public ConductorClientResponse<Void> putTagsForWebhook(String id, List<Tag> tags) { | ||
| return webhookResource.putTagsForWebhook(id, tags); | ||
| } | ||
|
|
||
| /** | ||
| * Delete tags for a webhook by ID. | ||
| * | ||
| * @param id the webhook ID | ||
| * @param tags the tags to remove | ||
| * @return ConductorClientResponse for the delete operation | ||
| */ | ||
| public ConductorClientResponse<Void> deleteTagsForWebhook(String id, List<Tag> tags) { | ||
| return webhookResource.deleteTagsForWebhook(id, tags); | ||
| } | ||
|
|
||
| /** | ||
| * Convenience method to get a webhook configuration directly without wrapper. | ||
| * | ||
| * @param id the webhook ID to retrieve | ||
| * @return WebhookConfig object or null if failed | ||
| */ | ||
| public WebhookConfig getWebhookConfig(String id) { | ||
| try { | ||
| ConductorClientResponse<WebhookConfig> response = getWebhook(id); | ||
| return response != null ? response.getData() : null; | ||
| } catch (Exception e) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Convenience method to get all webhook configurations directly without wrapper. | ||
| * | ||
| * @return List of WebhookConfig objects or empty list if failed | ||
| */ | ||
| public List<WebhookConfig> getWebhookConfigs() { | ||
| try { | ||
| ConductorClientResponse<List<WebhookConfig>> response = getAllWebhooks(); | ||
| return response != null && response.getData() != null ? response.getData() : List.of(); | ||
| } catch (Exception e) { | ||
| return List.of(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Check if a webhook exists by ID. | ||
| * | ||
| * @param id the webhook ID to check | ||
| * @return true if webhook exists, false otherwise | ||
| */ | ||
| public boolean webhookExists(String id) { | ||
| try { | ||
| ConductorClientResponse<WebhookConfig> response = getWebhook(id); | ||
| return response != null && response.getData() != null; | ||
| } catch (Exception e) { | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
67 changes: 67 additions & 0 deletions
67
orkes-client/src/main/java/io/orkes/conductor/client/http/SharedResource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Copyright 2022 Conductor Authors. | ||
| * <p> | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| */ | ||
| package io.orkes.conductor.client.http; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.netflix.conductor.client.http.ConductorClient; | ||
| import com.netflix.conductor.client.http.ConductorClientRequest; | ||
| import com.netflix.conductor.client.http.ConductorClientResponse; | ||
|
|
||
| import io.orkes.conductor.client.model.SharedResourceModel; | ||
|
|
||
| import com.fasterxml.jackson.core.type.TypeReference; | ||
|
|
||
| public class SharedResource { | ||
| private final ConductorClient client; | ||
|
|
||
| public SharedResource(ConductorClient client) { | ||
| this.client = client; | ||
| } | ||
|
|
||
| public void shareResource(String resourceType, String resourceName, String sharedWith) { | ||
| ConductorClientRequest request = ConductorClientRequest.builder() | ||
| .method(ConductorClientRequest.Method.POST) | ||
| .path("/share/shareResource") | ||
| .addQueryParam("resourceType", resourceType) | ||
| .addQueryParam("resourceName", resourceName) | ||
| .addQueryParam("sharedWith", sharedWith) | ||
| .build(); | ||
|
|
||
| client.execute(request); | ||
| } | ||
|
|
||
| public void removeSharingResource(String resourceType, String resourceName, String sharedWith) { | ||
| ConductorClientRequest request = ConductorClientRequest.builder() | ||
| .method(ConductorClientRequest.Method.DELETE) | ||
| .path("/share/removeSharingResource") | ||
| .addQueryParam("resourceType", resourceType) | ||
| .addQueryParam("resourceName", resourceName) | ||
| .addQueryParam("sharedWith", sharedWith) | ||
| .build(); | ||
|
|
||
| client.execute(request); | ||
| } | ||
|
|
||
| public List<SharedResourceModel> getSharedResources() { | ||
| ConductorClientRequest request = ConductorClientRequest.builder() | ||
| .method(ConductorClientRequest.Method.GET) | ||
| .path("/share/getSharedResources") | ||
| .build(); | ||
|
|
||
| ConductorClientResponse<List<SharedResourceModel>> resp = client.execute(request, new TypeReference<>() { | ||
| }); | ||
|
|
||
| return resp.getData(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional? For me as a developer it would be very confusing.