Skip to content

Commit f0c6daa

Browse files
Add ApplicationClient (with tests and docs) (#92)
Add ApplicationClient implementation Add ApplicationClient integration tests Add ApplicationClient documentation Add missing export for ServiceRegistryClient
1 parent cfa3dba commit f0c6daa

File tree

8 files changed

+1759
-4
lines changed

8 files changed

+1759
-4
lines changed

README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ Show support for the Conductor OSS. Please help spread the awareness by starrin
7070
- [Step 3: Publish Events](#step-3-publish-events)
7171
- [Step 4: Monitor Event Processing](#step-4-monitor-event-processing)
7272
- [Step 5: Manage Event Handlers](#step-5-manage-event-handlers)
73+
- [Applications](#applications)
74+
- [The ApplicationClient](#the-applicationclient)
75+
- [Quick Start: Managing Applications](#quick-start-managing-applications)
76+
- [Step 1: Create an ApplicationClient](#step-1-create-an-applicationclient)
77+
- [Step 2: Create an Application](#step-2-create-an-application)
78+
- [Step 3: Generate Access Keys](#step-3-generate-access-keys)
79+
- [Step 4: Manage Application Roles](#step-4-manage-application-roles)
80+
- [Step 5: Manage Applications](#step-5-manage-applications)
7381
- [Human Tasks](#human-tasks)
7482
- [The HumanExecutor and TemplateClient](#the-humanexecutor-and-templateclient)
7583
- [Quick Start: Creating and Managing a Human Task](#quick-start-creating-and-managing-a-human-task)
@@ -828,6 +836,144 @@ Event handlers support various actions:
828836

829837
For a complete method reference, see the [EventClient API Reference](docs/api-reference/event-client.md).
830838

839+
## Applications
840+
841+
Applications in Conductor are security entities that enable programmatic access to the Conductor API. Each application can have multiple access keys for authentication and can be assigned roles to control what operations it can perform.
842+
843+
### The ApplicationClient
844+
845+
The `ApplicationClient` manages applications, access keys, and roles. For a complete method reference, see the [ApplicationClient API Reference](docs/api-reference/application-client.md).
846+
847+
### Quick Start: Managing Applications
848+
849+
Here's how to create and manage applications in Conductor:
850+
851+
#### Step 1: Create an ApplicationClient
852+
853+
First, create an instance of the `ApplicationClient`:
854+
855+
```typescript
856+
import { ApplicationClient, ApplicationRole } from "@io-orkes/conductor-javascript";
857+
858+
const appClient = new ApplicationClient(client);
859+
```
860+
861+
#### Step 2: Create an Application
862+
863+
Create a new application to represent your service or integration:
864+
865+
```typescript
866+
// Create a new application
867+
const app = await appClient.createApplication("payment-service");
868+
console.log(`Created application: ${app.id}`);
869+
```
870+
871+
#### Step 3: Generate Access Keys
872+
873+
Create access keys for the application to authenticate API requests:
874+
875+
```typescript
876+
// Create an access key
877+
const accessKey = await appClient.createAccessKey(app.id);
878+
console.log(`Key ID: ${accessKey.id}`);
879+
console.log(`Key Secret: ${accessKey.secret}`); // Save this immediately!
880+
881+
// The secret is only shown once - store it securely
882+
// Use these credentials to create authenticated clients
883+
const authenticatedClient = await orkesConductorClient({
884+
serverUrl: "https://play.orkes.io/api",
885+
keyId: accessKey.id,
886+
keySecret: accessKey.secret
887+
});
888+
```
889+
890+
#### Step 4: Manage Application Roles
891+
892+
Grant the application permissions by adding roles:
893+
894+
```typescript
895+
import { ApplicationRole } from "@io-orkes/conductor-javascript";
896+
897+
// Add roles to the application
898+
await appClient.addApplicationRole(app.id, "WORKFLOW_MANAGER");
899+
await appClient.addApplicationRole(app.id, "WORKER");
900+
901+
console.log("Application can now execute workflows and run workers");
902+
```
903+
904+
**Available Roles:**
905+
906+
The SDK provides an `ApplicationRole` type with the following options:
907+
908+
- `ADMIN` - Full administrative access to all resources
909+
- `WORKFLOW_MANAGER` - Start and manage workflow executions
910+
- `WORKER` - Poll for and execute assigned tasks
911+
- `UNRESTRICTED_WORKER` - Can execute any task without restrictions
912+
- `METADATA_MANAGER` - Manage workflow and task definitions
913+
- `APPLICATION_MANAGER` - Manage applications and access keys
914+
- `APPLICATION_CREATOR` - Can create new applications
915+
- `USER` - Standard user access
916+
- `USER_READ_ONLY` - Read-only access to resources
917+
- `METADATA_API` - API access to metadata operations
918+
- `PROMPT_MANAGER` - Can manage AI prompts and templates
919+
920+
#### Step 5: Manage Applications
921+
922+
Manage the lifecycle of your applications:
923+
924+
```typescript
925+
// List all applications
926+
const applications = await appClient.getAllApplications();
927+
console.log(`Total applications: ${applications.length}`);
928+
929+
// Get a specific application
930+
const myApp = await appClient.getApplication(app.id);
931+
console.log(`Application name: ${myApp.name}`);
932+
933+
// Update application name
934+
await appClient.updateApplication(app.id, "payment-service-v2");
935+
936+
// Get all access keys for an application
937+
const keys = await appClient.getAccessKeys(app.id);
938+
console.log(`Application has ${keys.length} access keys`);
939+
940+
// Toggle access key status (ACTIVE/INACTIVE)
941+
await appClient.toggleAccessKeyStatus(app.id, accessKey.id);
942+
943+
// Remove a role from the application
944+
await appClient.removeRoleFromApplicationUser(app.id, "WORKER");
945+
946+
// Delete an access key
947+
await appClient.deleteAccessKey(app.id, accessKey.id);
948+
949+
// Delete the application
950+
await appClient.deleteApplication(app.id);
951+
```
952+
953+
**Tagging Applications:**
954+
955+
Organize applications with tags for better management:
956+
957+
```typescript
958+
// Add tags to an application
959+
await appClient.addApplicationTags(app.id, [
960+
{ key: "environment", value: "production" },
961+
{ key: "team", value: "payments" },
962+
{ key: "cost-center", value: "engineering" }
963+
]);
964+
965+
// Get application tags
966+
const tags = await appClient.getApplicationTags(app.id);
967+
968+
// Delete specific tags
969+
await appClient.deleteApplicationTag(app.id, {
970+
key: "cost-center",
971+
value: "engineering"
972+
});
973+
```
974+
975+
For a complete method reference, see the [ApplicationClient API Reference](docs/api-reference/application-client.md).
976+
831977
## Human Tasks
832978

833979
Human tasks integrate human interaction into your automated workflows. They pause a workflow until a person provides input, such as an approval, a correction, or additional information.

0 commit comments

Comments
 (0)