From 990f62953f8ca3181333140f50d1607478c2abf9 Mon Sep 17 00:00:00 2001 From: dhaneshbs Date: Mon, 6 Jan 2025 17:26:32 +0530 Subject: [PATCH] add create connection method --- src/connection.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/connection.ts b/src/connection.ts index 4ec011a..d1a1972 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -2,7 +2,8 @@ import { PromiseClient } from '@connectrpc/connect'; import GrpcConnect from './connect'; import CoreClient from './core'; import { ConnectionService } from './pkg/grpc/scalekit/v1/connections/connections_connect'; -import { GetConnectionResponse, ToggleConnectionResponse, ListConnectionsResponse } from './pkg/grpc/scalekit/v1/connections/connections_pb'; +import { CreateConnection, CreateConnectionResponse, GetConnectionResponse, ToggleConnectionResponse, ListConnectionsResponse } from './pkg/grpc/scalekit/v1/connections/connections_pb'; + export default class ConnectionClient { private client: PromiseClient; @@ -13,6 +14,22 @@ export default class ConnectionClient { this.client = this.grpcConncet.createClient(ConnectionService); } + /** + * Create a new connection + * @param organizationId The organization id + * @param connection The data for the new connection + * @returns {Promise} The created connection + */ +async createConnection(organizationId: string, connection: CreateConnection): Promise { + return this.coreClient.connectExec( + this.client.createConnection, + { + organizationId, + connection + }, + ); +} + /** * Get a connection by id and organization id * @param organizationId The organization id