Skip to content
Merged
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
2 changes: 0 additions & 2 deletions gateway/gateway-controller/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3459,8 +3459,6 @@ components:
type: string
description: Unique id of a deployed llm provider
example: wso2-openai-provider
accessControl:
$ref: '#/components/schemas/LLMAccessControl'
policies:
type: array
description: List of policies applied only to this operation (overrides or adds to API-level policies)
Expand Down
2 changes: 0 additions & 2 deletions gateway/gateway-controller/pkg/api/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions platform-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ RUN mkdir -p /app/data && \
COPY src/internal/database/schema.sql ./schema.sql
COPY src/internal/database/schema.postgres.sql ./schema.postgres.sql
COPY src/internal/database/schema.sqlite.sql ./schema.sqlite.sql
COPY src/resources/default-llm-provider-templates ./default-llm-provider-templates

ARG PORT
EXPOSE ${PORT}

ENV DRIVER=sqlite3
ENV LOG_LEVEL=INFO
ENV DB_SCHEMA_PATH=./schema.sql
ENV LLM_TEMPLATE_DEFINITIONS_PATH=./default-llm-provider-templates
# For SQLite: configured via DATABASE_DB_PATH to avoid clashing with OS PATH
ENV DATABASE_DB_PATH=/app/data/api_platform.db
ENV PORT=${PORT}
Expand Down
3 changes: 3 additions & 0 deletions platform-api/src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type Server struct {
Database Database `envconfig:"DATABASE"`
DBSchemaPath string `envconfig:"DB_SCHEMA_PATH" default:"./internal/database/schema.sql"`

// LLM provider template bootstrap (used to seed defaults into the DB)
LLMTemplateDefinitionsPath string `envconfig:"LLM_TEMPLATE_DEFINITIONS_PATH" default:"./resources/default-llm-provider-templates"`

// JWT Authentication configurations
JWT JWT `envconfig:"JWT"`

Expand Down
21 changes: 15 additions & 6 deletions platform-api/src/internal/constants/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,21 @@ var (
ErrWSO2ArtifactNotFound = errors.New("WSO2 API artifact not found")
)

var (
ErrLLMProviderTemplateExists = errors.New("llm provider template already exists")
ErrLLMProviderTemplateNotFound = errors.New("llm provider template not found")
ErrLLMProviderExists = errors.New("llm provider already exists")
ErrLLMProviderNotFound = errors.New("llm provider not found")
ErrLLMProxyExists = errors.New("llm proxy already exists")
ErrLLMProxyNotFound = errors.New("llm proxy not found")
)

var (
// API Key errors
ErrAPIKeyNotFound = errors.New("api key not found")
ErrAPIKeyAlreadyExists = errors.New("api key already exists")
ErrInvalidAPIKey = errors.New("invalid api key")
ErrGatewayUnavailable = errors.New("gateway unavailable")
ErrAPIKeyEventDelivery = errors.New("failed to deliver api key event to gateway")
ErrAPIKeyHashingFailed = errors.New("failed to hash api key")
ErrAPIKeyNotFound = errors.New("api key not found")
ErrAPIKeyAlreadyExists = errors.New("api key already exists")
ErrInvalidAPIKey = errors.New("invalid api key")
ErrGatewayUnavailable = errors.New("gateway unavailable")
ErrAPIKeyEventDelivery = errors.New("failed to deliver api key event to gateway")
ErrAPIKeyHashingFailed = errors.New("failed to hash api key")
)
77 changes: 77 additions & 0 deletions platform-api/src/internal/database/schema.postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,74 @@ CREATE TABLE IF NOT EXISTS api_publications (
UNIQUE (api_uuid, devportal_uuid, organization_uuid)
);

-- LLM Provider Templates table
CREATE TABLE IF NOT EXISTS llm_provider_templates (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(253) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
configuration TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
UNIQUE(organization_uuid, handle)
);

-- LLM Providers table
CREATE TABLE IF NOT EXISTS llm_providers (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(100) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
version VARCHAR(30) NOT NULL,
context VARCHAR(200) DEFAULT '/',
vhost VARCHAR(253),
template VARCHAR(255) NOT NULL,
upstream_url TEXT NOT NULL,
upstream_auth TEXT,
openapi_spec TEXT,
model_list TEXT,
rate_limiting TEXT,
access_control TEXT,
policies TEXT,
security TEXT,
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
FOREIGN KEY (organization_uuid, template) REFERENCES llm_provider_templates(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
UNIQUE(organization_uuid, handle)
);

-- LLM Proxies table
CREATE TABLE IF NOT EXISTS llm_proxies (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
project_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(253) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
version VARCHAR(30) NOT NULL,
context VARCHAR(200) DEFAULT '/',
vhost VARCHAR(253),
provider VARCHAR(255) NOT NULL,
openapi_spec TEXT,
policies TEXT,
security TEXT,
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
FOREIGN KEY (project_uuid) REFERENCES projects(uuid) ON DELETE CASCADE,
FOREIGN KEY (organization_uuid, provider) REFERENCES llm_providers(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
UNIQUE(organization_uuid, handle)
);

-- Indexes for better performance
CREATE INDEX IF NOT EXISTS idx_projects_organization_id ON projects(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_organizations_handle ON organizations(handle);
Expand Down Expand Up @@ -379,3 +447,12 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_devportals_default_per_org ON devportals(o
CREATE INDEX IF NOT EXISTS idx_api_associations_api_resource_type ON api_associations(api_uuid, association_type, organization_uuid);
CREATE INDEX IF NOT EXISTS idx_api_associations_resource ON api_associations(association_type, resource_uuid, organization_uuid);
CREATE INDEX IF NOT EXISTS idx_api_associations_org ON api_associations(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_org ON llm_provider_templates(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_handle ON llm_provider_templates(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_providers_org ON llm_providers(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_providers_handle ON llm_providers(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_providers_template ON llm_providers(organization_uuid, template);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_org ON llm_proxies(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_project ON llm_proxies(organization_uuid, project_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_handle ON llm_proxies(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_provider ON llm_proxies(organization_uuid, provider);
77 changes: 77 additions & 0 deletions platform-api/src/internal/database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,74 @@ CREATE TABLE IF NOT EXISTS api_publications (
UNIQUE (api_uuid, devportal_uuid, organization_uuid)
);

-- LLM Provider Templates table
CREATE TABLE IF NOT EXISTS llm_provider_templates (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(253) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
configuration TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
UNIQUE(organization_uuid, handle)
);

-- LLM Providers table
CREATE TABLE IF NOT EXISTS llm_providers (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(100) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
version VARCHAR(30) NOT NULL,
context VARCHAR(200) DEFAULT '/',
vhost VARCHAR(253),
template VARCHAR(255) NOT NULL,
upstream_url TEXT NOT NULL,
upstream_auth TEXT,
openapi_spec TEXT,
model_list TEXT,
rate_limiting TEXT,
access_control TEXT,
policies TEXT,
security TEXT,
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
FOREIGN KEY (organization_uuid, template) REFERENCES llm_provider_templates(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
UNIQUE(organization_uuid, handle)
);

-- LLM Proxies table
CREATE TABLE IF NOT EXISTS llm_proxies (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
project_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(253) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
version VARCHAR(30) NOT NULL,
context VARCHAR(200) DEFAULT '/',
vhost VARCHAR(253),
provider VARCHAR(255) NOT NULL,
openapi_spec TEXT,
policies TEXT,
security TEXT,
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
FOREIGN KEY (project_uuid) REFERENCES projects(uuid) ON DELETE CASCADE,
FOREIGN KEY (organization_uuid, provider) REFERENCES llm_providers(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
UNIQUE(organization_uuid, handle)
);

-- Indexes for better performance
CREATE INDEX IF NOT EXISTS idx_projects_organization_id ON projects(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_organizations_handle ON organizations(handle);
Expand Down Expand Up @@ -377,3 +445,12 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_devportals_default_per_org ON devportals(o
CREATE INDEX IF NOT EXISTS idx_api_associations_api_resource_type ON api_associations(api_uuid, association_type, organization_uuid);
CREATE INDEX IF NOT EXISTS idx_api_associations_resource ON api_associations(association_type, resource_uuid, organization_uuid);
CREATE INDEX IF NOT EXISTS idx_api_associations_org ON api_associations(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_org ON llm_provider_templates(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_handle ON llm_provider_templates(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_providers_org ON llm_providers(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_providers_handle ON llm_providers(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_providers_template ON llm_providers(organization_uuid, template);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_org ON llm_proxies(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_project ON llm_proxies(organization_uuid, project_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_handle ON llm_proxies(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_provider ON llm_proxies(organization_uuid, provider);
77 changes: 77 additions & 0 deletions platform-api/src/internal/database/schema.sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,74 @@ CREATE TABLE IF NOT EXISTS api_publications (
UNIQUE (api_uuid, devportal_uuid, organization_uuid)
);

-- LLM Provider Templates table
CREATE TABLE IF NOT EXISTS llm_provider_templates (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(253) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
configuration TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
UNIQUE(organization_uuid, handle)
);

-- LLM Providers table
CREATE TABLE IF NOT EXISTS llm_providers (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(100) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
version VARCHAR(30) NOT NULL,
context VARCHAR(200) DEFAULT '/',
vhost VARCHAR(253),
template VARCHAR(255) NOT NULL,
upstream_url TEXT NOT NULL,
upstream_auth TEXT,
openapi_spec TEXT,
model_list TEXT,
rate_limiting TEXT,
access_control TEXT,
policies TEXT,
security TEXT,
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
FOREIGN KEY (organization_uuid, template) REFERENCES llm_provider_templates(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
UNIQUE(organization_uuid, handle)
);

-- LLM Proxies table
CREATE TABLE IF NOT EXISTS llm_proxies (
uuid VARCHAR(40) PRIMARY KEY,
organization_uuid VARCHAR(40) NOT NULL,
project_uuid VARCHAR(40) NOT NULL,
handle VARCHAR(255) NOT NULL,
name VARCHAR(253) NOT NULL,
description VARCHAR(1023),
created_by VARCHAR(255),
version VARCHAR(30) NOT NULL,
context VARCHAR(200) DEFAULT '/',
vhost VARCHAR(253),
provider VARCHAR(255) NOT NULL,
openapi_spec TEXT,
policies TEXT,
security TEXT,
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
FOREIGN KEY (project_uuid) REFERENCES projects(uuid) ON DELETE CASCADE,
FOREIGN KEY (organization_uuid, provider) REFERENCES llm_providers(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
UNIQUE(organization_uuid, handle)
);

-- Indexes for better performance
CREATE INDEX IF NOT EXISTS idx_projects_organization_id ON projects(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_organizations_handle ON organizations(handle);
Expand Down Expand Up @@ -378,3 +446,12 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_devportals_default_per_org ON devportals(o
CREATE INDEX IF NOT EXISTS idx_api_associations_api_resource_type ON api_associations(api_uuid, association_type, organization_uuid);
CREATE INDEX IF NOT EXISTS idx_api_associations_resource ON api_associations(association_type, resource_uuid, organization_uuid);
CREATE INDEX IF NOT EXISTS idx_api_associations_org ON api_associations(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_org ON llm_provider_templates(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_handle ON llm_provider_templates(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_providers_org ON llm_providers(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_providers_handle ON llm_providers(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_providers_template ON llm_providers(organization_uuid, template);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_org ON llm_proxies(organization_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_project ON llm_proxies(organization_uuid, project_uuid);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_handle ON llm_proxies(organization_uuid, handle);
CREATE INDEX IF NOT EXISTS idx_llm_proxies_provider ON llm_proxies(organization_uuid, provider);
Loading
Loading