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 @@ -14,25 +14,29 @@
"type": "string",
"title": "Hostname or IP address",
"description": "Hostname or IP address of the remote file system server.",
"minLength": 1,
"ui:section": "Location"
},
"username": {
"type": "string",
"title": "Username",
"description": "Username used to authenticate.",
"minLength": 1,
"ui:section": "Authentication"
},
"private_key": {
"type": "string",
"title": "Private key",
"description": "PEM-encoded private key used for SSH authentication.",
"ui:section": "Authentication",
"format": "password"
"format": "password",
"minLength": 1,
"ui:section": "Authentication"
},
"remote_path": {
"type": "string",
"title": "Remote folder path",
"description": "Absolute path on the remote file system server to use as the content root (e.g. /data/documents).",
"minLength": 1,
"ui:section": "Location"
},
"allowed_extensions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@
"type": "string",
"title": "Bucket name",
"description": "Name of the S3 bucket to use as the content source.",
"minLength": 1,
"ui:section": "Location"
},
"access_key_id": {
"type": "string",
"title": "Access key ID",
"description": "S3-compatible access key identifier.",
"minLength": 1,
"ui:section": "Authentication"
},
"secret_access_key": {
"type": "string",
"title": "Secret access key",
"description": "S3-compatible secret access key.",
"format": "password",
"minLength": 1,
"ui:section": "Authentication"
},
"prefix": {
Expand Down
9 changes: 9 additions & 0 deletions ai-services/cmd/ai-services/cmd/catalog/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func buildAPIServerOptions(ctx context.Context, pool *pgxpool.Pool, secretKey, a
svcRepo := repository.NewServiceRepository(pool)
compRepo := repository.NewComponentRepository(pool)
svcDepRepo := repository.NewServiceDependencyRepository(pool)
connectorRepo := repository.NewConnectorRepository(pool)

catalogProvider, err := catalog.NewCatalogProvider(bundleRepo)
if err != nil {
Expand All @@ -97,6 +98,13 @@ func buildAPIServerOptions(ctx context.Context, pool *pgxpool.Pool, secretKey, a
}
syncService.Start(ctx)

datasourceSvc, err := apirepository.NewDatasourceService(connectorRepo, catalogProvider)
if err != nil {
syncService.Stop(ctx)

return apiserver.APIServerOptions{}, nil, fmt.Errorf("failed to initialize datasource service: %w", err)
}

tokenMgr := auth.NewTokenManager(secretKey, accessTTL, refreshTTL)
workerRepo := repository.NewWorkerRepository(pool)
workerReg := workerregistry.New(workerRepo)
Expand All @@ -117,6 +125,7 @@ func buildAPIServerOptions(ctx context.Context, pool *pgxpool.Pool, secretKey, a
TokenManager: tokenMgr,
Blacklist: blacklist,
ApplicationService: apirepository.NewApplicationService(appRepo, svcRepo, compRepo, svcDepRepo, catalogProvider, vars.RuntimeFactory.GetRuntimeType()),
DatasourceService: datasourceSvc,
BundleService: bundlesvc.NewBundleService(bundleRepo, svcRepo, compRepo, catalogProvider),
CatalogProvider: catalogProvider,
WorkerGatewayPort: workerGatewayPort,
Expand Down
108 changes: 108 additions & 0 deletions ai-services/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,81 @@ const docTemplate = `{
}
}
},
"/datasources": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Validates the request, tests the connection, encrypts credentials, and persists a new datasource connector. Returns 422 if the connection test fails.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Datasources"
],
"summary": "Create datasource connector",
"parameters": [
{
"description": "Datasource creation request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.CreateDatasourceRequest"
}
}
],
"responses": {
"201": {
"description": "Datasource created",
"schema": {
"$ref": "#/definitions/github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.CreateDatasourceResponse"
}
},
"400": {
"description": "Invalid request body or validation errors",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"404": {
"description": "Provider not found in catalog",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"409": {
"description": "Datasource name already exists",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"422": {
"description": "Connection test failed",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
}
}
}
},
"/resources": {
"get": {
"security": [
Expand Down Expand Up @@ -1805,6 +1880,39 @@ const docTemplate = `{
}
}
},
"github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.CreateDatasourceRequest": {
"type": "object",
"required": [
"name",
"params",
"provider_id"
],
"properties": {
"name": {
"description": "Name is the unique human-readable label for this connector.\nMust be 3–100 characters; only letters, digits, hyphens (-), and underscores (_) are\nallowed. Duplicate-name detection is case-insensitive (\"My-DB\" and \"my-db\" conflict).",
"type": "string",
"maxLength": 100,
"minLength": 3
},
"params": {
"description": "Params holds the provider-specific configuration. Sensitive fields (format: \"password\"\nin the JSON schema) are encrypted at rest; all other fields are stored in plain text.",
"type": "object",
"additionalProperties": {}
},
"provider_id": {
"description": "ProviderID identifies the provider implementation (e.g. \"object_storage\", \"file_system\").",
"type": "string"
}
}
},
"github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.CreateDatasourceResponse": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
"github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.Service": {
"type": "object",
"required": [
Expand Down
108 changes: 108 additions & 0 deletions ai-services/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,81 @@
}
}
},
"/datasources": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Validates the request, tests the connection, encrypts credentials, and persists a new datasource connector. Returns 422 if the connection test fails.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Datasources"
],
"summary": "Create datasource connector",
"parameters": [
{
"description": "Datasource creation request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.CreateDatasourceRequest"
}
}
],
"responses": {
"201": {
"description": "Datasource created",
"schema": {
"$ref": "#/definitions/github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.CreateDatasourceResponse"
}
},
"400": {
"description": "Invalid request body or validation errors",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"404": {
"description": "Provider not found in catalog",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"409": {
"description": "Datasource name already exists",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"422": {
"description": "Connection test failed",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/internal_pkg_catalog_apiserver_handlers.ErrorResponse"
}
}
}
}
},
"/resources": {
"get": {
"security": [
Expand Down Expand Up @@ -1799,6 +1874,39 @@
}
}
},
"github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.CreateDatasourceRequest": {
"type": "object",
"required": [
"name",
"params",
"provider_id"
],
"properties": {
"name": {
"description": "Name is the unique human-readable label for this connector.\nMust be 3–100 characters; only letters, digits, hyphens (-), and underscores (_) are\nallowed. Duplicate-name detection is case-insensitive (\"My-DB\" and \"my-db\" conflict).",
"type": "string",
"maxLength": 100,
"minLength": 3
},
"params": {
"description": "Params holds the provider-specific configuration. Sensitive fields (format: \"password\"\nin the JSON schema) are encrypted at rest; all other fields are stored in plain text.",
"type": "object",
"additionalProperties": {}
},
"provider_id": {
"description": "ProviderID identifies the provider implementation (e.g. \"object_storage\", \"file_system\").",
"type": "string"
}
}
},
"github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.CreateDatasourceResponse": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
"github_com_project-ai-services_ai-services_internal_pkg_catalog_apiserver_models.Service": {
"type": "object",
"required": [
Expand Down
Loading
Loading