Skip to content

Commit

Permalink
added a catalog info and openapi schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Rose Yemelyanova committed May 11, 2023
1 parent a0ca2c0 commit 633283f
Show file tree
Hide file tree
Showing 10 changed files with 490 additions and 257 deletions.
28 changes: 28 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: bluesky-worker
title: bluesky-worker
description: Lightweight wrapper around bluesky services
spec:
type: service
lifecycle: production
owner: user:vid18871 # TODO: owner: DAQ-Core
# system: Athena # TODO: Define Athena system: presumably same location as DAQ-Core/DAQ?
providesApis:
- blueapi
- blueskydocument-to-scanmessage

---
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: blueapi
title: blueapi
description: REST API for getting plans/devices from the worker (and running tasks)
spec:
type: openapi
lifecycle: production
owner: user:vid18871
definition:
$text: ./openapi.json
323 changes: 323 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
{
"openapi": "3.0.2",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"paths": {
"/plans": {
"get": {
"summary": "Get Plans",
"operationId": "get_plans_plans_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PlanResponse"
}
}
}
}
}
}
},
"/plan/{name}": {
"get": {
"summary": "Get Plan By Name",
"operationId": "get_plan_by_name_plan__name__get",
"parameters": [
{
"required": true,
"schema": {
"title": "Name",
"type": "string"
},
"name": "name",
"in": "path"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PlanModel"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/devices": {
"get": {
"summary": "Get Devices",
"operationId": "get_devices_devices_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeviceResponse"
}
}
}
}
}
}
},
"/device/{name}": {
"get": {
"summary": "Get Device By Name",
"operationId": "get_device_by_name_device__name__get",
"parameters": [
{
"required": true,
"schema": {
"title": "Name",
"type": "string"
},
"name": "name",
"in": "path"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeviceModel"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/task/{name}": {
"put": {
"summary": "Execute Task",
"operationId": "execute_task_task__name__put",
"parameters": [
{
"required": true,
"schema": {
"title": "Name",
"type": "string"
},
"name": "name",
"in": "path"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RunPlan"
},
"example": {
"name": "count",
"params": {
"detectors": [
"x"
]
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"DeviceModel": {
"title": "DeviceModel",
"required": [
"name",
"protocols"
],
"type": "object",
"properties": {
"name": {
"title": "Name",
"type": "string",
"description": "Name of the device"
},
"protocols": {
"title": "Protocols",
"type": "array",
"items": {
"type": "string"
},
"description": "Protocols that a device conforms to, indicating its capabilities"
}
},
"description": "Representation of a device"
},
"DeviceResponse": {
"title": "DeviceResponse",
"required": [
"devices"
],
"type": "object",
"properties": {
"devices": {
"title": "Devices",
"type": "array",
"items": {
"$ref": "#/components/schemas/DeviceModel"
},
"description": "Devices available to use in plans"
}
},
"description": "Response to a query for devices"
},
"HTTPValidationError": {
"title": "HTTPValidationError",
"type": "object",
"properties": {
"detail": {
"title": "Detail",
"type": "array",
"items": {
"$ref": "#/components/schemas/ValidationError"
}
}
}
},
"PlanModel": {
"title": "PlanModel",
"required": [
"name"
],
"type": "object",
"properties": {
"name": {
"title": "Name",
"type": "string",
"description": "Name of the plan"
}
},
"description": "Representation of a plan"
},
"PlanResponse": {
"title": "PlanResponse",
"required": [
"plans"
],
"type": "object",
"properties": {
"plans": {
"title": "Plans",
"type": "array",
"items": {
"$ref": "#/components/schemas/PlanModel"
},
"description": "Plans available to use by a worker"
}
},
"description": "Response to a query for plans"
},
"RunPlan": {
"title": "RunPlan",
"required": [
"name"
],
"type": "object",
"properties": {
"name": {
"title": "Name",
"type": "string",
"description": "Name of plan to run"
},
"params": {
"title": "Params",
"type": "object",
"description": "Values for parameters to plan, if any"
}
},
"description": "Task that will run a plan"
},
"ValidationError": {
"title": "ValidationError",
"required": [
"loc",
"msg",
"type"
],
"type": "object",
"properties": {
"loc": {
"title": "Location",
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
"msg": {
"title": "Message",
"type": "string"
},
"type": {
"title": "Error Type",
"type": "string"
}
}
}
}
}
}
3 changes: 0 additions & 3 deletions src/blueapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from importlib.metadata import version
from blueapi.core.context import BlueskyContext

from blueapi.worker.reworker import RunEngineWorker

__version__ = version("blueapi")
del version
Expand Down
Empty file removed src/blueapi/rest/__init__.py
Empty file.
Loading

0 comments on commit 633283f

Please sign in to comment.