Problem
As an Naap user,
I can use the Developer API Manager plugin to create projects to organize my Developer API Keys. Each user will begin with a Default Project which will be used when no project is selected. Each API Key must belong to a project and a billing provider.
Each Developer API Key will be valid for a single billing provider (i.e. DayDream) so that my livepeer-python-gateway can authenticate with a billing provider when streaming to the Livepeer network
Proposed Solution
Database changes
Add alongside the existing DevApi models:
model DevApiProject {
id String @id @default(uuid())
userId String
name String
isDefault Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
apiKeys DevApiKey[]
@@unique([userId, name])
@@index([userId])
@@schema("plugin_developer_api")
}
- Modify
DevApiKey table
model DevApiKey {
id String @id @default(uuid())
userId String
projectId String
project DevApiProject @relation(fields: [projectId], references: [id], onDelete: Cascade)
billingProviderKeyId String
billingProviderKey BillingProviderKey @relation(fields: [billingProviderKeyId], references: [id], onDelete: Restrict)
modelId String
model DevApiAIModel @relation(fields: [modelId], references: [id], onDelete: Cascade)
gatewayOfferId String?
gatewayOffer DevApiGatewayOffer? @relation(fields: [gatewayOfferId], references: [id], onDelete: SetNull)
keyHash String @unique
keyPrefix String
status DevApiKeyStatus @default(ACTIVE)
createdAt DateTime @default(now())
lastUsedAt DateTime?
revokedAt DateTime?
usageLogs DevApiUsageLog[]
@@index([userId])
@@index([projectId])
@@index([billingProviderKeyId])
@@index([modelId])
@@index([status])
@@index([keyHash])
@@schema("plugin_developer_api")
}
Note: billingProviderKeyId uses onDelete: Restrict -- you cannot delete a billing provider key if API keys are still linked to it.
UI Changes
Link Billing Provider

Create a new API Key

Retrieve API Key

Note The format of the API Key needs to still be determined. OpenID connect and JWT identifiers for the NaaP user might be more helpful (simply enriching the billing provider's token with assertion of the NaaP user identity)
List API Keys by Project and Revoke

Alternatives Considered
Scope
Problem
As an Naap user,
I can use the Developer API Manager plugin to create projects to organize my Developer API Keys. Each user will begin with a Default Project which will be used when no project is selected. Each API Key must belong to a project and a billing provider.
Each Developer API Key will be valid for a single billing provider (i.e. DayDream) so that my livepeer-python-gateway can authenticate with a billing provider when streaming to the Livepeer network
Proposed Solution
Database changes
Add alongside the existing DevApi models:
DevApiKeytableNote:
billingProviderKeyIdusesonDelete: Restrict-- you cannot delete a billing provider key if API keys are still linked to it.UI Changes
Link Billing Provider

Create a new API Key

Retrieve API Key

List API Keys by Project and Revoke

Alternatives Considered
Scope
developer-api