@@ -67,6 +67,174 @@ const swaggerOptions = {
|
|||||||
description: 'Development server'
|
description: 'Development server'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
paths: {
|
||||||
|
'/health': {
|
||||||
|
get: {
|
||||||
|
summary: 'Health check endpoint',
|
||||||
|
tags: ['System'],
|
||||||
|
responses: {
|
||||||
|
'200': {
|
||||||
|
description: 'Server is healthy',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: { $ref: '#/components/schemas/ApiResponse' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/api/kernels': {
|
||||||
|
post: {
|
||||||
|
summary: 'Create a new quantum kernel',
|
||||||
|
tags: ['Quantum Kernels'],
|
||||||
|
requestBody: {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: { $ref: '#/components/schemas/QuantumKernel' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'Kernel created successfully' },
|
||||||
|
'400': { description: 'Invalid request parameters' }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
get: {
|
||||||
|
summary: 'List all quantum kernels',
|
||||||
|
tags: ['Quantum Kernels'],
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'List of kernels retrieved successfully' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/api/gates': {
|
||||||
|
post: {
|
||||||
|
summary: 'Apply a quantum gate to a kernel',
|
||||||
|
tags: ['Quantum Gates'],
|
||||||
|
requestBody: {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: { $ref: '#/components/schemas/QuantumGate' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'Gate applied successfully' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/api/sample': {
|
||||||
|
post: {
|
||||||
|
summary: 'Sample quantum circuit measurements',
|
||||||
|
tags: ['Quantum Execution'],
|
||||||
|
requestBody: {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: { $ref: '#/components/schemas/SampleRequest' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'Sampling completed successfully' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/api/observe': {
|
||||||
|
post: {
|
||||||
|
summary: 'Calculate Hamiltonian expectation value',
|
||||||
|
tags: ['Quantum Execution'],
|
||||||
|
requestBody: {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: { $ref: '#/components/schemas/ObserveRequest' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'Expectation value calculated successfully' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/api/state/{kernelName}': {
|
||||||
|
get: {
|
||||||
|
summary: 'Get quantum state vector',
|
||||||
|
tags: ['Quantum Execution'],
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: 'path',
|
||||||
|
name: 'kernelName',
|
||||||
|
required: true,
|
||||||
|
schema: { type: 'string' }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'State vector retrieved successfully' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/api/targets': {
|
||||||
|
get: {
|
||||||
|
summary: 'List available quantum targets',
|
||||||
|
tags: ['Quantum Backends'],
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'Available targets retrieved successfully' }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
post: {
|
||||||
|
summary: 'Set quantum computing target',
|
||||||
|
tags: ['Quantum Backends'],
|
||||||
|
requestBody: {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: { $ref: '#/components/schemas/TargetRequest' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'Target set successfully' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/api/platform': {
|
||||||
|
get: {
|
||||||
|
summary: 'Get platform information',
|
||||||
|
tags: ['System'],
|
||||||
|
responses: {
|
||||||
|
'200': { description: 'Platform info retrieved successfully' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/api/events': {
|
||||||
|
get: {
|
||||||
|
summary: 'Server-Sent Events stream',
|
||||||
|
tags: ['Real-time'],
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: 'query',
|
||||||
|
name: 'topics',
|
||||||
|
schema: { type: 'string' },
|
||||||
|
description: 'Comma-separated list of topics to subscribe to'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
'200': {
|
||||||
|
description: 'SSE stream established',
|
||||||
|
content: {
|
||||||
|
'text/event-stream': {
|
||||||
|
schema: { type: 'string' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
schemas: {
|
schemas: {
|
||||||
QuantumKernel: {
|
QuantumKernel: {
|
||||||
@@ -165,7 +333,7 @@ const swaggerOptions = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
apis: ['./src/http-server.ts']
|
apis: [] // We define paths directly in the definition above
|
||||||
};
|
};
|
||||||
|
|
||||||
export class CudaQuantumHttpServer {
|
export class CudaQuantumHttpServer {
|
||||||
@@ -225,20 +393,6 @@ export class CudaQuantumHttpServer {
|
|||||||
*/
|
*/
|
||||||
private setupRoutes(): void {
|
private setupRoutes(): void {
|
||||||
// Health check
|
// Health check
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /health:
|
|
||||||
* get:
|
|
||||||
* summary: Health check endpoint
|
|
||||||
* tags: [System]
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Server is healthy
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: '#/components/schemas/ApiResponse'
|
|
||||||
*/
|
|
||||||
this.app.get('/health', (req, res) => {
|
this.app.get('/health', (req, res) => {
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
@@ -252,176 +406,23 @@ export class CudaQuantumHttpServer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Quantum Kernels
|
// Quantum Kernels
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/kernels:
|
|
||||||
* post:
|
|
||||||
* summary: Create a new quantum kernel
|
|
||||||
* tags: [Quantum Kernels]
|
|
||||||
* requestBody:
|
|
||||||
* required: true
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: '#/components/schemas/QuantumKernel'
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Kernel created successfully
|
|
||||||
* 400:
|
|
||||||
* description: Invalid request parameters
|
|
||||||
*/
|
|
||||||
this.app.post('/api/kernels', this.handleCreateKernel.bind(this));
|
this.app.post('/api/kernels', this.handleCreateKernel.bind(this));
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/kernels:
|
|
||||||
* get:
|
|
||||||
* summary: List all quantum kernels
|
|
||||||
* tags: [Quantum Kernels]
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: List of kernels retrieved successfully
|
|
||||||
*/
|
|
||||||
this.app.get('/api/kernels', this.handleListKernels.bind(this));
|
this.app.get('/api/kernels', this.handleListKernels.bind(this));
|
||||||
|
|
||||||
// Quantum Gates
|
// Quantum Gates
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/gates:
|
|
||||||
* post:
|
|
||||||
* summary: Apply a quantum gate to a kernel
|
|
||||||
* tags: [Quantum Gates]
|
|
||||||
* requestBody:
|
|
||||||
* required: true
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: '#/components/schemas/QuantumGate'
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Gate applied successfully
|
|
||||||
*/
|
|
||||||
this.app.post('/api/gates', this.handleApplyGate.bind(this));
|
this.app.post('/api/gates', this.handleApplyGate.bind(this));
|
||||||
|
|
||||||
// Quantum Execution
|
// Quantum Execution
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/sample:
|
|
||||||
* post:
|
|
||||||
* summary: Sample quantum circuit measurements
|
|
||||||
* tags: [Quantum Execution]
|
|
||||||
* requestBody:
|
|
||||||
* required: true
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: '#/components/schemas/SampleRequest'
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Sampling completed successfully
|
|
||||||
*/
|
|
||||||
this.app.post('/api/sample', this.handleSample.bind(this));
|
this.app.post('/api/sample', this.handleSample.bind(this));
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/observe:
|
|
||||||
* post:
|
|
||||||
* summary: Calculate Hamiltonian expectation value
|
|
||||||
* tags: [Quantum Execution]
|
|
||||||
* requestBody:
|
|
||||||
* required: true
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: '#/components/schemas/ObserveRequest'
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Expectation value calculated successfully
|
|
||||||
*/
|
|
||||||
this.app.post('/api/observe', this.handleObserve.bind(this));
|
this.app.post('/api/observe', this.handleObserve.bind(this));
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/state/{kernelName}:
|
|
||||||
* get:
|
|
||||||
* summary: Get quantum state vector
|
|
||||||
* tags: [Quantum Execution]
|
|
||||||
* parameters:
|
|
||||||
* - in: path
|
|
||||||
* name: kernelName
|
|
||||||
* required: true
|
|
||||||
* schema:
|
|
||||||
* type: string
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: State vector retrieved successfully
|
|
||||||
*/
|
|
||||||
this.app.get('/api/state/:kernelName', this.handleGetState.bind(this));
|
this.app.get('/api/state/:kernelName', this.handleGetState.bind(this));
|
||||||
|
|
||||||
// Quantum Backends
|
// Quantum Backends
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/targets:
|
|
||||||
* get:
|
|
||||||
* summary: List available quantum targets
|
|
||||||
* tags: [Quantum Backends]
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Available targets retrieved successfully
|
|
||||||
*/
|
|
||||||
this.app.get('/api/targets', this.handleGetTargets.bind(this));
|
this.app.get('/api/targets', this.handleGetTargets.bind(this));
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/targets:
|
|
||||||
* post:
|
|
||||||
* summary: Set quantum computing target
|
|
||||||
* tags: [Quantum Backends]
|
|
||||||
* requestBody:
|
|
||||||
* required: true
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: '#/components/schemas/TargetRequest'
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Target set successfully
|
|
||||||
*/
|
|
||||||
this.app.post('/api/targets', this.handleSetTarget.bind(this));
|
this.app.post('/api/targets', this.handleSetTarget.bind(this));
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/platform:
|
|
||||||
* get:
|
|
||||||
* summary: Get platform information
|
|
||||||
* tags: [System]
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Platform info retrieved successfully
|
|
||||||
*/
|
|
||||||
this.app.get('/api/platform', this.handleGetPlatform.bind(this));
|
this.app.get('/api/platform', this.handleGetPlatform.bind(this));
|
||||||
|
|
||||||
// Server-Sent Events
|
// Server-Sent Events
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /api/events:
|
|
||||||
* get:
|
|
||||||
* summary: Server-Sent Events stream
|
|
||||||
* tags: [Real-time]
|
|
||||||
* parameters:
|
|
||||||
* - in: query
|
|
||||||
* name: topics
|
|
||||||
* schema:
|
|
||||||
* type: string
|
|
||||||
* description: Comma-separated list of topics to subscribe to
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: SSE stream established
|
|
||||||
* content:
|
|
||||||
* text/event-stream:
|
|
||||||
* schema:
|
|
||||||
* type: string
|
|
||||||
*/
|
|
||||||
this.app.get('/api/events', this.handleSSE.bind(this));
|
this.app.get('/api/events', this.handleSSE.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Referencia en una nueva incidencia
Block a user