Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public OrkesTokenClient getTokenClient() {
return new OrkesTokenClient(client);
}

public OrkesSharedResourceClient getSharedResourceClient() {
return new OrkesSharedResourceClient(client);
}

public OrkesWebhookClient getWebhookClient() {
return new OrkesWebhookClient(client);
}

public IntegrationClient getIntegrationClient() {
return new OrkesIntegrationClient(client);
}
Expand Down
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();
}
}
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();
Copy link
Contributor

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.

}
}

/**
* 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;
}
}
}
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();
}
}
Loading
Loading