chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigCreateApplicationContract } from '@/lib/api/contracts/tools/aws/appconfig-create-application'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, createApplication } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigCreateApplicationAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigCreateApplicationContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Creating AppConfig application ${params.name}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await createApplication(client, params.name, params.description)
|
||||
logger.info(`[${requestId}] Created application ${result.id}`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to create application:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to create application: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,60 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigCreateConfigurationProfileContract } from '@/lib/api/contracts/tools/aws/appconfig-create-configuration-profile'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, createConfigurationProfile } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigCreateConfigurationProfileAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigCreateConfigurationProfileContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Creating AppConfig configuration profile ${params.name}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await createConfigurationProfile(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.name,
|
||||
params.locationUri,
|
||||
params.description,
|
||||
params.retrievalRoleArn,
|
||||
params.type
|
||||
)
|
||||
logger.info(`[${requestId}] Created configuration profile ${result.id}`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to create configuration profile:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to create configuration profile: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,57 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigCreateEnvironmentContract } from '@/lib/api/contracts/tools/aws/appconfig-create-environment'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, createEnvironment } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigCreateEnvironmentAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigCreateEnvironmentContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Creating AppConfig environment ${params.name}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await createEnvironment(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.name,
|
||||
params.description
|
||||
)
|
||||
logger.info(`[${requestId}] Created environment ${result.id}`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to create environment:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to create environment: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,64 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigCreateHostedConfigurationVersionContract } from '@/lib/api/contracts/tools/aws/appconfig-create-hosted-configuration-version'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, createHostedConfigurationVersion } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigCreateHostedConfigurationVersionAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(
|
||||
awsAppConfigCreateHostedConfigurationVersionContract,
|
||||
request,
|
||||
{ errorFormat: 'details', logger }
|
||||
)
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Creating hosted configuration version for profile ${params.configurationProfileId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await createHostedConfigurationVersion(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.configurationProfileId,
|
||||
params.content,
|
||||
params.contentType,
|
||||
params.description,
|
||||
params.latestVersionNumber,
|
||||
params.versionLabel
|
||||
)
|
||||
logger.info(`[${requestId}] Created hosted configuration version ${result.versionNumber}`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to create hosted configuration version:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to create hosted configuration version: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigDeleteApplicationContract } from '@/lib/api/contracts/tools/aws/appconfig-delete-application'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, deleteApplication } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigDeleteApplicationAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigDeleteApplicationContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Deleting AppConfig application ${params.applicationId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await deleteApplication(client, params.applicationId)
|
||||
logger.info(`[${requestId}] Deleted application`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to delete application:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to delete application: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,58 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigDeleteConfigurationProfileContract } from '@/lib/api/contracts/tools/aws/appconfig-delete-configuration-profile'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, deleteConfigurationProfile } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigDeleteConfigurationProfileAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigDeleteConfigurationProfileContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Deleting AppConfig configuration profile ${params.configurationProfileId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await deleteConfigurationProfile(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.configurationProfileId
|
||||
)
|
||||
logger.info(`[${requestId}] Deleted configuration profile`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to delete configuration profile:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to delete configuration profile: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigDeleteEnvironmentContract } from '@/lib/api/contracts/tools/aws/appconfig-delete-environment'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, deleteEnvironment } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigDeleteEnvironmentAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigDeleteEnvironmentContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Deleting AppConfig environment ${params.environmentId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await deleteEnvironment(client, params.applicationId, params.environmentId)
|
||||
logger.info(`[${requestId}] Deleted environment`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to delete environment:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to delete environment: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,60 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigDeleteHostedConfigurationVersionContract } from '@/lib/api/contracts/tools/aws/appconfig-delete-hosted-configuration-version'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, deleteHostedConfigurationVersion } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigDeleteHostedConfigurationVersionAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(
|
||||
awsAppConfigDeleteHostedConfigurationVersionContract,
|
||||
request,
|
||||
{ errorFormat: 'details', logger }
|
||||
)
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Deleting hosted configuration version ${params.versionNumber} for profile ${params.configurationProfileId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await deleteHostedConfigurationVersion(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.configurationProfileId,
|
||||
params.versionNumber
|
||||
)
|
||||
logger.info(`[${requestId}] Deleted hosted configuration version`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to delete hosted configuration version:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to delete hosted configuration version: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigGetApplicationContract } from '@/lib/api/contracts/tools/aws/appconfig-get-application'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, getApplication } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigGetApplicationAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigGetApplicationContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Getting AppConfig application ${params.applicationId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await getApplication(client, params.applicationId)
|
||||
logger.info(`[${requestId}] Retrieved application`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to get application:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to get application: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,58 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigGetConfigurationProfileContract } from '@/lib/api/contracts/tools/aws/appconfig-get-configuration-profile'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, getConfigurationProfile } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigGetConfigurationProfileAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigGetConfigurationProfileContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Getting AppConfig configuration profile ${params.configurationProfileId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await getConfigurationProfile(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.configurationProfileId
|
||||
)
|
||||
logger.info(`[${requestId}] Retrieved configuration profile`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to get configuration profile:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to get configuration profile: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,59 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigGetConfigurationContract } from '@/lib/api/contracts/tools/aws/appconfig-get-configuration'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigDataClient, getConfiguration } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigGetConfigurationAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigGetConfigurationContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Retrieving AppConfig configuration for ${params.applicationId}/${params.environmentId}/${params.configurationProfileId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigDataClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await getConfiguration(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.environmentId,
|
||||
params.configurationProfileId
|
||||
)
|
||||
logger.info(`[${requestId}] Retrieved configuration`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to retrieve configuration:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to retrieve configuration: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,59 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigGetDeploymentContract } from '@/lib/api/contracts/tools/aws/appconfig-get-deployment'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, getDeployment } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigGetDeploymentAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigGetDeploymentContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Getting AppConfig deployment ${params.deploymentNumber} in env ${params.environmentId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await getDeployment(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.environmentId,
|
||||
params.deploymentNumber
|
||||
)
|
||||
logger.info(`[${requestId}] Retrieved deployment`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to get deployment:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to get deployment: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigGetEnvironmentContract } from '@/lib/api/contracts/tools/aws/appconfig-get-environment'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, getEnvironment } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigGetEnvironmentAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigGetEnvironmentContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Getting AppConfig environment ${params.environmentId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await getEnvironment(client, params.applicationId, params.environmentId)
|
||||
logger.info(`[${requestId}] Retrieved environment`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to get environment:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to get environment: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,60 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigGetHostedConfigurationVersionContract } from '@/lib/api/contracts/tools/aws/appconfig-get-hosted-configuration-version'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, getHostedConfigurationVersion } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigGetHostedConfigurationVersionAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(
|
||||
awsAppConfigGetHostedConfigurationVersionContract,
|
||||
request,
|
||||
{ errorFormat: 'details', logger }
|
||||
)
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Getting hosted configuration version ${params.versionNumber} for profile ${params.configurationProfileId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await getHostedConfigurationVersion(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.configurationProfileId,
|
||||
params.versionNumber
|
||||
)
|
||||
logger.info(`[${requestId}] Retrieved hosted configuration version`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to get hosted configuration version:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to get hosted configuration version: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigListApplicationsContract } from '@/lib/api/contracts/tools/aws/appconfig-list-applications'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, listApplications } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigListApplicationsAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigListApplicationsContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Listing AppConfig applications`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await listApplications(client, params.maxResults, params.nextToken)
|
||||
logger.info(`[${requestId}] Listed ${result.count} applications`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to list applications:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to list applications: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,59 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigListConfigurationProfilesContract } from '@/lib/api/contracts/tools/aws/appconfig-list-configuration-profiles'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, listConfigurationProfiles } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigListConfigurationProfilesAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigListConfigurationProfilesContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Listing AppConfig configuration profiles for ${params.applicationId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await listConfigurationProfiles(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.maxResults,
|
||||
params.nextToken
|
||||
)
|
||||
logger.info(`[${requestId}] Listed ${result.count} configuration profiles`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to list configuration profiles:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to list configuration profiles: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigListDeploymentStrategiesContract } from '@/lib/api/contracts/tools/aws/appconfig-list-deployment-strategies'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, listDeploymentStrategies } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigListDeploymentStrategiesAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigListDeploymentStrategiesContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Listing AppConfig deployment strategies`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await listDeploymentStrategies(client, params.maxResults, params.nextToken)
|
||||
logger.info(`[${requestId}] Listed ${result.count} deployment strategies`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to list deployment strategies:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to list deployment strategies: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,58 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigListDeploymentsContract } from '@/lib/api/contracts/tools/aws/appconfig-list-deployments'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, listDeployments } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigListDeploymentsAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigListDeploymentsContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Listing AppConfig deployments in env ${params.environmentId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await listDeployments(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.environmentId,
|
||||
params.maxResults,
|
||||
params.nextToken
|
||||
)
|
||||
logger.info(`[${requestId}] Listed ${result.count} deployments`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to list deployments:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to list deployments: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,57 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigListEnvironmentsContract } from '@/lib/api/contracts/tools/aws/appconfig-list-environments'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, listEnvironments } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigListEnvironmentsAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigListEnvironmentsContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Listing AppConfig environments for ${params.applicationId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await listEnvironments(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.maxResults,
|
||||
params.nextToken
|
||||
)
|
||||
logger.info(`[${requestId}] Listed ${result.count} environments`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to list environments:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to list environments: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,61 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigListHostedConfigurationVersionsContract } from '@/lib/api/contracts/tools/aws/appconfig-list-hosted-configuration-versions'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, listHostedConfigurationVersions } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigListHostedConfigurationVersionsAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(
|
||||
awsAppConfigListHostedConfigurationVersionsContract,
|
||||
request,
|
||||
{ errorFormat: 'details', logger }
|
||||
)
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Listing AppConfig hosted configuration versions for profile ${params.configurationProfileId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await listHostedConfigurationVersions(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.configurationProfileId,
|
||||
params.maxResults,
|
||||
params.nextToken
|
||||
)
|
||||
logger.info(`[${requestId}] Listed ${result.count} hosted configuration versions`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to list hosted configuration versions:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to list hosted configuration versions: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,60 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigStartDeploymentContract } from '@/lib/api/contracts/tools/aws/appconfig-start-deployment'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, startDeployment } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigStartDeploymentAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigStartDeploymentContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Starting AppConfig deployment in env ${params.environmentId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await startDeployment(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.environmentId,
|
||||
params.deploymentStrategyId,
|
||||
params.configurationProfileId,
|
||||
params.configurationVersion,
|
||||
params.description
|
||||
)
|
||||
logger.info(`[${requestId}] Started deployment ${result.deploymentNumber}`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to start deployment:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to start deployment: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,59 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigStopDeploymentContract } from '@/lib/api/contracts/tools/aws/appconfig-stop-deployment'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, stopDeployment } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigStopDeploymentAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigStopDeploymentContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Stopping AppConfig deployment ${params.deploymentNumber} in env ${params.environmentId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await stopDeployment(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.environmentId,
|
||||
params.deploymentNumber
|
||||
)
|
||||
logger.info(`[${requestId}] Stopped deployment ${result.deploymentNumber}`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to stop deployment:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to stop deployment: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,57 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigUpdateApplicationContract } from '@/lib/api/contracts/tools/aws/appconfig-update-application'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, updateApplication } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigUpdateApplicationAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigUpdateApplicationContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Updating AppConfig application ${params.applicationId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await updateApplication(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.name,
|
||||
params.description
|
||||
)
|
||||
logger.info(`[${requestId}] Updated application`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to update application:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to update application: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,61 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigUpdateConfigurationProfileContract } from '@/lib/api/contracts/tools/aws/appconfig-update-configuration-profile'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, updateConfigurationProfile } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigUpdateConfigurationProfileAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigUpdateConfigurationProfileContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Updating AppConfig configuration profile ${params.configurationProfileId}`
|
||||
)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await updateConfigurationProfile(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.configurationProfileId,
|
||||
params.name,
|
||||
params.description,
|
||||
params.retrievalRoleArn
|
||||
)
|
||||
logger.info(`[${requestId}] Updated configuration profile`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to update configuration profile:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to update configuration profile: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,58 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { awsAppConfigUpdateEnvironmentContract } from '@/lib/api/contracts/tools/aws/appconfig-update-environment'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createAppConfigClient, updateEnvironment } from '../utils'
|
||||
|
||||
const logger = createLogger('AppConfigUpdateEnvironmentAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(awsAppConfigUpdateEnvironmentContract, request, {
|
||||
errorFormat: 'details',
|
||||
logger,
|
||||
})
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(`[${requestId}] Updating AppConfig environment ${params.environmentId}`)
|
||||
|
||||
const client = createAppConfigClient({
|
||||
region: params.region,
|
||||
accessKeyId: params.accessKeyId,
|
||||
secretAccessKey: params.secretAccessKey,
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await updateEnvironment(
|
||||
client,
|
||||
params.applicationId,
|
||||
params.environmentId,
|
||||
params.name,
|
||||
params.description
|
||||
)
|
||||
logger.info(`[${requestId}] Updated environment`)
|
||||
return NextResponse.json(result)
|
||||
} finally {
|
||||
client.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Failed to update environment:`, error)
|
||||
return NextResponse.json(
|
||||
{ error: `Failed to update environment: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,681 @@
|
||||
import {
|
||||
AppConfigClient,
|
||||
CreateApplicationCommand,
|
||||
CreateConfigurationProfileCommand,
|
||||
CreateEnvironmentCommand,
|
||||
CreateHostedConfigurationVersionCommand,
|
||||
DeleteApplicationCommand,
|
||||
DeleteConfigurationProfileCommand,
|
||||
DeleteEnvironmentCommand,
|
||||
DeleteHostedConfigurationVersionCommand,
|
||||
GetApplicationCommand,
|
||||
GetConfigurationProfileCommand,
|
||||
GetDeploymentCommand,
|
||||
GetEnvironmentCommand,
|
||||
GetHostedConfigurationVersionCommand,
|
||||
ListApplicationsCommand,
|
||||
ListConfigurationProfilesCommand,
|
||||
ListDeploymentStrategiesCommand,
|
||||
ListDeploymentsCommand,
|
||||
ListEnvironmentsCommand,
|
||||
ListHostedConfigurationVersionsCommand,
|
||||
StartDeploymentCommand,
|
||||
StopDeploymentCommand,
|
||||
UpdateApplicationCommand,
|
||||
UpdateConfigurationProfileCommand,
|
||||
UpdateEnvironmentCommand,
|
||||
} from '@aws-sdk/client-appconfig'
|
||||
import {
|
||||
AppConfigDataClient,
|
||||
GetLatestConfigurationCommand,
|
||||
StartConfigurationSessionCommand,
|
||||
} from '@aws-sdk/client-appconfigdata'
|
||||
import type { AppConfigConnectionConfig } from '@/tools/appconfig/types'
|
||||
|
||||
export function createAppConfigClient(config: AppConfigConnectionConfig): AppConfigClient {
|
||||
return new AppConfigClient({
|
||||
region: config.region,
|
||||
credentials: {
|
||||
accessKeyId: config.accessKeyId,
|
||||
secretAccessKey: config.secretAccessKey,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function createAppConfigDataClient(config: AppConfigConnectionConfig): AppConfigDataClient {
|
||||
return new AppConfigDataClient({
|
||||
region: config.region,
|
||||
credentials: {
|
||||
accessKeyId: config.accessKeyId,
|
||||
secretAccessKey: config.secretAccessKey,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const textDecoder = new TextDecoder()
|
||||
|
||||
function decodeContent(content?: Uint8Array): string {
|
||||
if (!content || content.length === 0) return ''
|
||||
return textDecoder.decode(content)
|
||||
}
|
||||
|
||||
export async function listApplications(
|
||||
client: AppConfigClient,
|
||||
maxResults?: number | null,
|
||||
nextToken?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new ListApplicationsCommand({
|
||||
...(maxResults ? { MaxResults: maxResults } : {}),
|
||||
...(nextToken ? { NextToken: nextToken } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
const applications = (response.Items ?? []).map((item) => ({
|
||||
id: item.Id ?? '',
|
||||
name: item.Name ?? '',
|
||||
description: item.Description ?? null,
|
||||
}))
|
||||
|
||||
return {
|
||||
applications,
|
||||
nextToken: response.NextToken ?? null,
|
||||
count: applications.length,
|
||||
}
|
||||
}
|
||||
|
||||
export async function createApplication(
|
||||
client: AppConfigClient,
|
||||
name: string,
|
||||
description?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new CreateApplicationCommand({
|
||||
Name: name,
|
||||
...(description ? { Description: description } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Application "${response.Name ?? name}" created`,
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
description: response.Description ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function listEnvironments(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
maxResults?: number | null,
|
||||
nextToken?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new ListEnvironmentsCommand({
|
||||
ApplicationId: applicationId,
|
||||
...(maxResults ? { MaxResults: maxResults } : {}),
|
||||
...(nextToken ? { NextToken: nextToken } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
const environments = (response.Items ?? []).map((item) => ({
|
||||
applicationId: item.ApplicationId ?? '',
|
||||
id: item.Id ?? '',
|
||||
name: item.Name ?? '',
|
||||
description: item.Description ?? null,
|
||||
state: item.State ?? null,
|
||||
}))
|
||||
|
||||
return {
|
||||
environments,
|
||||
nextToken: response.NextToken ?? null,
|
||||
count: environments.length,
|
||||
}
|
||||
}
|
||||
|
||||
export async function createEnvironment(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
name: string,
|
||||
description?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new CreateEnvironmentCommand({
|
||||
ApplicationId: applicationId,
|
||||
Name: name,
|
||||
...(description ? { Description: description } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Environment "${response.Name ?? name}" created`,
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
state: response.State ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function listConfigurationProfiles(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
maxResults?: number | null,
|
||||
nextToken?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new ListConfigurationProfilesCommand({
|
||||
ApplicationId: applicationId,
|
||||
...(maxResults ? { MaxResults: maxResults } : {}),
|
||||
...(nextToken ? { NextToken: nextToken } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
const configurationProfiles = (response.Items ?? []).map((item) => ({
|
||||
applicationId: item.ApplicationId ?? '',
|
||||
id: item.Id ?? '',
|
||||
name: item.Name ?? '',
|
||||
description: null,
|
||||
locationUri: item.LocationUri ?? null,
|
||||
retrievalRoleArn: null,
|
||||
type: item.Type ?? null,
|
||||
validatorTypes: item.ValidatorTypes ?? [],
|
||||
}))
|
||||
|
||||
return {
|
||||
configurationProfiles,
|
||||
nextToken: response.NextToken ?? null,
|
||||
count: configurationProfiles.length,
|
||||
}
|
||||
}
|
||||
|
||||
export async function createConfigurationProfile(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
name: string,
|
||||
locationUri: string,
|
||||
description?: string | null,
|
||||
retrievalRoleArn?: string | null,
|
||||
type?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new CreateConfigurationProfileCommand({
|
||||
ApplicationId: applicationId,
|
||||
Name: name,
|
||||
LocationUri: locationUri,
|
||||
...(description ? { Description: description } : {}),
|
||||
...(retrievalRoleArn ? { RetrievalRoleArn: retrievalRoleArn } : {}),
|
||||
...(type ? { Type: type } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Configuration profile "${response.Name ?? name}" created`,
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
locationUri: response.LocationUri ?? null,
|
||||
type: response.Type ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function createHostedConfigurationVersion(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
configurationProfileId: string,
|
||||
content: string,
|
||||
contentType: string,
|
||||
description?: string | null,
|
||||
latestVersionNumber?: number | null,
|
||||
versionLabel?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new CreateHostedConfigurationVersionCommand({
|
||||
ApplicationId: applicationId,
|
||||
ConfigurationProfileId: configurationProfileId,
|
||||
Content: new TextEncoder().encode(content),
|
||||
ContentType: contentType,
|
||||
...(description ? { Description: description } : {}),
|
||||
...(latestVersionNumber != null ? { LatestVersionNumber: latestVersionNumber } : {}),
|
||||
...(versionLabel ? { VersionLabel: versionLabel } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Hosted configuration version ${response.VersionNumber ?? ''} created`,
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
configurationProfileId: response.ConfigurationProfileId ?? configurationProfileId,
|
||||
versionNumber: response.VersionNumber ?? null,
|
||||
contentType: response.ContentType ?? null,
|
||||
versionLabel: response.VersionLabel ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getHostedConfigurationVersion(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
configurationProfileId: string,
|
||||
versionNumber: number
|
||||
) {
|
||||
const response = await client.send(
|
||||
new GetHostedConfigurationVersionCommand({
|
||||
ApplicationId: applicationId,
|
||||
ConfigurationProfileId: configurationProfileId,
|
||||
VersionNumber: versionNumber,
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
configurationProfileId: response.ConfigurationProfileId ?? configurationProfileId,
|
||||
versionNumber: response.VersionNumber ?? null,
|
||||
description: response.Description ?? null,
|
||||
content: decodeContent(response.Content),
|
||||
contentType: response.ContentType ?? null,
|
||||
versionLabel: response.VersionLabel ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function listHostedConfigurationVersions(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
configurationProfileId: string,
|
||||
maxResults?: number | null,
|
||||
nextToken?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new ListHostedConfigurationVersionsCommand({
|
||||
ApplicationId: applicationId,
|
||||
ConfigurationProfileId: configurationProfileId,
|
||||
...(maxResults ? { MaxResults: maxResults } : {}),
|
||||
...(nextToken ? { NextToken: nextToken } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
const versions = (response.Items ?? []).map((item) => ({
|
||||
applicationId: item.ApplicationId ?? null,
|
||||
configurationProfileId: item.ConfigurationProfileId ?? null,
|
||||
versionNumber: item.VersionNumber ?? null,
|
||||
description: item.Description ?? null,
|
||||
contentType: item.ContentType ?? null,
|
||||
versionLabel: item.VersionLabel ?? null,
|
||||
}))
|
||||
|
||||
return {
|
||||
versions,
|
||||
nextToken: response.NextToken ?? null,
|
||||
count: versions.length,
|
||||
}
|
||||
}
|
||||
|
||||
export async function listDeploymentStrategies(
|
||||
client: AppConfigClient,
|
||||
maxResults?: number | null,
|
||||
nextToken?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new ListDeploymentStrategiesCommand({
|
||||
...(maxResults ? { MaxResults: maxResults } : {}),
|
||||
...(nextToken ? { NextToken: nextToken } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
const deploymentStrategies = (response.Items ?? []).map((item) => ({
|
||||
id: item.Id ?? '',
|
||||
name: item.Name ?? '',
|
||||
description: item.Description ?? null,
|
||||
deploymentDurationInMinutes: item.DeploymentDurationInMinutes ?? null,
|
||||
growthType: item.GrowthType ?? null,
|
||||
growthFactor: item.GrowthFactor ?? null,
|
||||
finalBakeTimeInMinutes: item.FinalBakeTimeInMinutes ?? null,
|
||||
replicateTo: item.ReplicateTo ?? null,
|
||||
}))
|
||||
|
||||
return {
|
||||
deploymentStrategies,
|
||||
nextToken: response.NextToken ?? null,
|
||||
count: deploymentStrategies.length,
|
||||
}
|
||||
}
|
||||
|
||||
export async function startDeployment(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
environmentId: string,
|
||||
deploymentStrategyId: string,
|
||||
configurationProfileId: string,
|
||||
configurationVersion: string,
|
||||
description?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new StartDeploymentCommand({
|
||||
ApplicationId: applicationId,
|
||||
EnvironmentId: environmentId,
|
||||
DeploymentStrategyId: deploymentStrategyId,
|
||||
ConfigurationProfileId: configurationProfileId,
|
||||
ConfigurationVersion: configurationVersion,
|
||||
...(description ? { Description: description } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Deployment ${response.DeploymentNumber ?? ''} started`,
|
||||
deploymentNumber: response.DeploymentNumber ?? null,
|
||||
state: response.State ?? null,
|
||||
percentageComplete: response.PercentageComplete ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getDeployment(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
environmentId: string,
|
||||
deploymentNumber: number
|
||||
) {
|
||||
const response = await client.send(
|
||||
new GetDeploymentCommand({
|
||||
ApplicationId: applicationId,
|
||||
EnvironmentId: environmentId,
|
||||
DeploymentNumber: deploymentNumber,
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
environmentId: response.EnvironmentId ?? environmentId,
|
||||
deploymentStrategyId: response.DeploymentStrategyId ?? '',
|
||||
configurationProfileId: response.ConfigurationProfileId ?? '',
|
||||
deploymentNumber: response.DeploymentNumber ?? null,
|
||||
configurationName: response.ConfigurationName ?? null,
|
||||
configurationVersion: response.ConfigurationVersion ?? null,
|
||||
description: response.Description ?? null,
|
||||
state: response.State ?? null,
|
||||
percentageComplete: response.PercentageComplete ?? null,
|
||||
startedAt: response.StartedAt?.toISOString() ?? null,
|
||||
completedAt: response.CompletedAt?.toISOString() ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function listDeployments(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
environmentId: string,
|
||||
maxResults?: number | null,
|
||||
nextToken?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new ListDeploymentsCommand({
|
||||
ApplicationId: applicationId,
|
||||
EnvironmentId: environmentId,
|
||||
...(maxResults ? { MaxResults: maxResults } : {}),
|
||||
...(nextToken ? { NextToken: nextToken } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
const deployments = (response.Items ?? []).map((item) => ({
|
||||
deploymentNumber: item.DeploymentNumber ?? null,
|
||||
configurationName: item.ConfigurationName ?? null,
|
||||
configurationVersion: item.ConfigurationVersion ?? null,
|
||||
deploymentDurationInMinutes: item.DeploymentDurationInMinutes ?? null,
|
||||
growthType: item.GrowthType ?? null,
|
||||
growthFactor: item.GrowthFactor ?? null,
|
||||
finalBakeTimeInMinutes: item.FinalBakeTimeInMinutes ?? null,
|
||||
state: item.State ?? null,
|
||||
percentageComplete: item.PercentageComplete ?? null,
|
||||
startedAt: item.StartedAt?.toISOString() ?? null,
|
||||
completedAt: item.CompletedAt?.toISOString() ?? null,
|
||||
versionLabel: item.VersionLabel ?? null,
|
||||
}))
|
||||
|
||||
return {
|
||||
deployments,
|
||||
nextToken: response.NextToken ?? null,
|
||||
count: deployments.length,
|
||||
}
|
||||
}
|
||||
|
||||
export async function stopDeployment(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
environmentId: string,
|
||||
deploymentNumber: number
|
||||
) {
|
||||
const response = await client.send(
|
||||
new StopDeploymentCommand({
|
||||
ApplicationId: applicationId,
|
||||
EnvironmentId: environmentId,
|
||||
DeploymentNumber: deploymentNumber,
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Deployment ${response.DeploymentNumber ?? deploymentNumber} stopped`,
|
||||
deploymentNumber: response.DeploymentNumber ?? null,
|
||||
state: response.State ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getConfiguration(
|
||||
client: AppConfigDataClient,
|
||||
applicationId: string,
|
||||
environmentId: string,
|
||||
configurationProfileId: string
|
||||
) {
|
||||
const session = await client.send(
|
||||
new StartConfigurationSessionCommand({
|
||||
ApplicationIdentifier: applicationId,
|
||||
EnvironmentIdentifier: environmentId,
|
||||
ConfigurationProfileIdentifier: configurationProfileId,
|
||||
})
|
||||
)
|
||||
|
||||
const response = await client.send(
|
||||
new GetLatestConfigurationCommand({
|
||||
ConfigurationToken: session.InitialConfigurationToken,
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
configuration: decodeContent(response.Configuration),
|
||||
contentType: response.ContentType ?? null,
|
||||
versionLabel: response.VersionLabel ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getApplication(client: AppConfigClient, applicationId: string) {
|
||||
const response = await client.send(new GetApplicationCommand({ ApplicationId: applicationId }))
|
||||
|
||||
return {
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
description: response.Description ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateApplication(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
name?: string | null,
|
||||
description?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new UpdateApplicationCommand({
|
||||
ApplicationId: applicationId,
|
||||
...(name ? { Name: name } : {}),
|
||||
...(description != null ? { Description: description } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Application "${response.Name ?? applicationId}" updated`,
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
description: response.Description ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteApplication(client: AppConfigClient, applicationId: string) {
|
||||
await client.send(new DeleteApplicationCommand({ ApplicationId: applicationId }))
|
||||
|
||||
return {
|
||||
message: `Application ${applicationId} deleted`,
|
||||
id: applicationId,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getEnvironment(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
environmentId: string
|
||||
) {
|
||||
const response = await client.send(
|
||||
new GetEnvironmentCommand({ ApplicationId: applicationId, EnvironmentId: environmentId })
|
||||
)
|
||||
|
||||
return {
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
description: response.Description ?? null,
|
||||
state: response.State ?? null,
|
||||
monitors: (response.Monitors ?? []).map((monitor) => ({
|
||||
alarmArn: monitor.AlarmArn ?? '',
|
||||
alarmRoleArn: monitor.AlarmRoleArn ?? null,
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateEnvironment(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
environmentId: string,
|
||||
name?: string | null,
|
||||
description?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new UpdateEnvironmentCommand({
|
||||
ApplicationId: applicationId,
|
||||
EnvironmentId: environmentId,
|
||||
...(name ? { Name: name } : {}),
|
||||
...(description != null ? { Description: description } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Environment "${response.Name ?? environmentId}" updated`,
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
state: response.State ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteEnvironment(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
environmentId: string
|
||||
) {
|
||||
await client.send(
|
||||
new DeleteEnvironmentCommand({ ApplicationId: applicationId, EnvironmentId: environmentId })
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Environment ${environmentId} deleted`,
|
||||
applicationId,
|
||||
id: environmentId,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getConfigurationProfile(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
configurationProfileId: string
|
||||
) {
|
||||
const response = await client.send(
|
||||
new GetConfigurationProfileCommand({
|
||||
ApplicationId: applicationId,
|
||||
ConfigurationProfileId: configurationProfileId,
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
description: response.Description ?? null,
|
||||
locationUri: response.LocationUri ?? null,
|
||||
retrievalRoleArn: response.RetrievalRoleArn ?? null,
|
||||
type: response.Type ?? null,
|
||||
validators: (response.Validators ?? []).map((validator) => ({
|
||||
type: validator.Type ?? '',
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateConfigurationProfile(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
configurationProfileId: string,
|
||||
name?: string | null,
|
||||
description?: string | null,
|
||||
retrievalRoleArn?: string | null
|
||||
) {
|
||||
const response = await client.send(
|
||||
new UpdateConfigurationProfileCommand({
|
||||
ApplicationId: applicationId,
|
||||
ConfigurationProfileId: configurationProfileId,
|
||||
...(name ? { Name: name } : {}),
|
||||
...(description != null ? { Description: description } : {}),
|
||||
...(retrievalRoleArn != null ? { RetrievalRoleArn: retrievalRoleArn } : {}),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Configuration profile "${response.Name ?? configurationProfileId}" updated`,
|
||||
applicationId: response.ApplicationId ?? applicationId,
|
||||
id: response.Id ?? '',
|
||||
name: response.Name ?? '',
|
||||
description: response.Description ?? null,
|
||||
type: response.Type ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteConfigurationProfile(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
configurationProfileId: string
|
||||
) {
|
||||
await client.send(
|
||||
new DeleteConfigurationProfileCommand({
|
||||
ApplicationId: applicationId,
|
||||
ConfigurationProfileId: configurationProfileId,
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Configuration profile ${configurationProfileId} deleted`,
|
||||
applicationId,
|
||||
id: configurationProfileId,
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteHostedConfigurationVersion(
|
||||
client: AppConfigClient,
|
||||
applicationId: string,
|
||||
configurationProfileId: string,
|
||||
versionNumber: number
|
||||
) {
|
||||
await client.send(
|
||||
new DeleteHostedConfigurationVersionCommand({
|
||||
ApplicationId: applicationId,
|
||||
ConfigurationProfileId: configurationProfileId,
|
||||
VersionNumber: versionNumber,
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
message: `Hosted configuration version ${versionNumber} deleted`,
|
||||
applicationId,
|
||||
configurationProfileId,
|
||||
versionNumber,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user