Skip to content

Commit

Permalink
chg: [style] Reformat with black.
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricbonhomme committed Dec 19, 2023
1 parent 180200b commit 66852be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 6 additions & 2 deletions api/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ def create_tst(db: Session, data: schemas.TimeStampTokenCreate):
return db_tst


def get_tst(db: Session, skip: int = 0, limit: int = 100, scan_uuid = ""):
def get_tst(db: Session, skip: int = 0, limit: int = 100, scan_uuid=""):
"""Returns a list of TimeStampToken or filter TimeStampToken with the
UUID of a scan."""
if scan_uuid:
return db.query(models.TimeStampToken).filter(models.TimeStampToken.scan_uuid == scan_uuid).first()
return (
db.query(models.TimeStampToken)
.filter(models.TimeStampToken.scan_uuid == scan_uuid)
.first()
)
return db.query(models.TimeStampToken).offset(skip).limit(limit).all()


Expand Down
7 changes: 2 additions & 5 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ async def create_tst(
data: schemas.TimeStampTokenCreate, db: Session = db_session
) -> schemas.TimeStampToken:
"""Insert a TimeStampToken."""
dict_data = {
"scan_uuid": data.scan_uuid,
"tst": data.tst
}
dict_data = {"scan_uuid": data.scan_uuid, "tst": data.tst}
new_tst = crud.create_tst(db=db, data=dict_data)
return new_tst

Expand All @@ -117,7 +114,7 @@ async def read_tsts(


@app.get("/tsts/{scan_uuid}", response_model=schemas.TimeStampToken)
def get_tst(scan_uuid = "", db: Session = db_session) -> schemas.TimeStampToken:
def get_tst(scan_uuid="", db: Session = db_session) -> schemas.TimeStampToken:
db_tst = crud.get_tst(db, scan_uuid=scan_uuid)
if db_tst is None:
raise HTTPException(status_code=404, detail="TimeStampToken not found")
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/openapi.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"openapi": "3.1.0", "info": {"title": "FastAPI", "version": "0.1.0"}, "paths": {"/items/": {"get": {"summary": "Read Items", "operationId": "read_items_items__get", "parameters": [{"name": "skip", "in": "query", "required": false, "schema": {"type": "integer", "default": 0, "title": "Skip"}}, {"name": "limit", "in": "query", "required": false, "schema": {"type": "integer", "default": 100, "title": "Limit"}}, {"name": "q", "in": "query", "required": false, "schema": {"type": "string", "default": "", "title": "Q"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/ItemBase"}, "title": "Response Read Items Items Get"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "post": {"summary": "Create Item", "description": "Insert a new item.", "operationId": "create_item_items__post", "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ScanDataCreate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ItemBase"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/items/{item_id}": {"get": {"summary": "Read Item", "operationId": "read_item_items__item_id__get", "parameters": [{"name": "item_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Item Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ItemBase"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/tst/": {"post": {"summary": "Create Tst", "description": "Insert a TimeStampToken.", "operationId": "create_tst_tst__post", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/TimeStampTokenCreate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/TimeStampTokenCreate"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/tsts/": {"get": {"summary": "Read Tsts", "operationId": "read_tsts_tsts__get", "parameters": [{"name": "skip", "in": "query", "required": false, "schema": {"type": "integer", "default": 0, "title": "Skip"}}, {"name": "limit", "in": "query", "required": false, "schema": {"type": "integer", "default": 100, "title": "Limit"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/TimeStampToken"}, "title": "Response Read Tsts Tsts Get"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/tsts/{scan_uuid}": {"get": {"summary": "Get Tst", "operationId": "get_tst_tsts__scan_uuid__get", "parameters": [{"name": "scan_uuid", "in": "path", "required": true, "schema": {"title": "Scan Uuid"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/TimeStampToken"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/system/stats/": {"get": {"summary": "Stats", "description": "Provides stats about the database.", "operationId": "stats_system_stats__get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/system/info/": {"get": {"summary": "System Info", "description": "Provides information about the instance.", "operationId": "system_info_system_info__get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}}, "components": {"schemas": {"HTTPValidationError": {"properties": {"detail": {"items": {"$ref": "#/components/schemas/ValidationError"}, "type": "array", "title": "Detail"}}, "type": "object", "title": "HTTPValidationError"}, "ItemBase": {"properties": {"scan_data": {"$ref": "#/components/schemas/ScanData"}}, "type": "object", "required": ["scan_data"], "title": "ItemBase"}, "Meta": {"properties": {"uuid": {"type": "string", "title": "Uuid"}, "ts": {"type": "integer", "title": "Ts"}, "type": {"type": "string", "title": "Type"}}, "type": "object", "required": ["uuid", "ts", "type"], "title": "Meta"}, "Payload": {"properties": {"row": {"type": "string", "title": "Row"}}, "type": "object", "required": ["row"], "title": "Payload"}, "ScanData": {"properties": {"version": {"type": "string", "title": "Version"}, "format": {"type": "string", "title": "Format"}, "meta": {"$ref": "#/components/schemas/Meta"}, "payload": {"$ref": "#/components/schemas/Payload"}}, "type": "object", "required": ["version", "format", "meta", "payload"], "title": "ScanData"}, "ScanDataCreate": {"properties": {"version": {"type": "string", "title": "Version"}, "format": {"type": "string", "title": "Format"}, "meta": {"$ref": "#/components/schemas/Meta"}, "payload": {"$ref": "#/components/schemas/Payload"}}, "type": "object", "required": ["version", "format", "meta", "payload"], "title": "ScanDataCreate"}, "TimeStampToken": {"properties": {"scan_uuid": {"type": "string", "format": "uuid", "title": "Scan Uuid"}, "tst": {"type": "string", "format": "binary", "title": "Tst"}}, "type": "object", "required": ["scan_uuid", "tst"], "title": "TimeStampToken"}, "TimeStampTokenCreate": {"properties": {"scan_uuid": {"type": "string", "format": "uuid", "title": "Scan Uuid"}, "tst": {"type": "string", "format": "binary", "title": "Tst"}}, "type": "object", "required": ["scan_uuid", "tst"], "title": "TimeStampTokenCreate"}, "ValidationError": {"properties": {"loc": {"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, "type": "array", "title": "Location"}, "msg": {"type": "string", "title": "Message"}, "type": {"type": "string", "title": "Error Type"}}, "type": "object", "required": ["loc", "msg", "type"], "title": "ValidationError"}}}}
{"openapi": "3.1.0", "info": {"title": "FastAPI", "version": "0.1.0"}, "paths": {"/items/": {"get": {"summary": "Read Items", "operationId": "read_items_items__get", "parameters": [{"name": "skip", "in": "query", "required": false, "schema": {"type": "integer", "default": 0, "title": "Skip"}}, {"name": "limit", "in": "query", "required": false, "schema": {"type": "integer", "default": 100, "title": "Limit"}}, {"name": "q", "in": "query", "required": false, "schema": {"type": "string", "default": "", "title": "Q"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/ItemBase"}, "title": "Response Read Items Items Get"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "post": {"summary": "Create Item", "description": "Insert a new item.", "operationId": "create_item_items__post", "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ScanDataCreate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ItemBase"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/items/{item_id}": {"get": {"summary": "Read Item", "operationId": "read_item_items__item_id__get", "parameters": [{"name": "item_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Item Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ItemBase"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/tst/": {"post": {"summary": "Create Tst", "description": "Insert a TimeStampToken.", "operationId": "create_tst_tst__post", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/TimeStampTokenCreate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/TimeStampTokenCreate"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/tsts/": {"get": {"summary": "Read Tsts", "operationId": "read_tsts_tsts__get", "parameters": [{"name": "skip", "in": "query", "required": false, "schema": {"type": "integer", "default": 0, "title": "Skip"}}, {"name": "limit", "in": "query", "required": false, "schema": {"type": "integer", "default": 100, "title": "Limit"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/TimeStampToken"}, "title": "Response Read Tsts Tsts Get"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/tsts/{scan_uuid}": {"get": {"summary": "Get Tst", "operationId": "get_tst_tsts__scan_uuid__get", "parameters": [{"name": "scan_uuid", "in": "path", "required": true, "schema": {"title": "Scan Uuid"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/TimeStampToken"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/system/stats/": {"get": {"summary": "Stats", "description": "Provides stats about the database.", "operationId": "stats_system_stats__get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/system/info/": {"get": {"summary": "System Info", "description": "Provides information about the instance.", "operationId": "system_info_system_info__get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}}, "components": {"schemas": {"HTTPValidationError": {"properties": {"detail": {"items": {"$ref": "#/components/schemas/ValidationError"}, "type": "array", "title": "Detail"}}, "type": "object", "title": "HTTPValidationError"}, "ItemBase": {"properties": {"scan_data": {"$ref": "#/components/schemas/ScanData"}}, "type": "object", "required": ["scan_data"], "title": "ItemBase"}, "Meta": {"properties": {"uuid": {"type": "string", "title": "Uuid"}, "ts": {"type": "integer", "title": "Ts"}, "type": {"type": "string", "title": "Type"}}, "type": "object", "required": ["uuid", "ts", "type"], "title": "Meta"}, "Payload": {"properties": {"row": {"type": "string", "title": "Row"}}, "type": "object", "required": ["row"], "title": "Payload"}, "ScanData": {"properties": {"version": {"type": "string", "title": "Version"}, "format": {"type": "string", "title": "Format"}, "meta": {"$ref": "#/components/schemas/Meta"}, "payload": {"$ref": "#/components/schemas/Payload"}}, "type": "object", "required": ["version", "format", "meta", "payload"], "title": "ScanData"}, "ScanDataCreate": {"properties": {"version": {"type": "string", "title": "Version"}, "format": {"type": "string", "title": "Format"}, "meta": {"$ref": "#/components/schemas/Meta"}, "payload": {"$ref": "#/components/schemas/Payload"}}, "type": "object", "required": ["version", "format", "meta", "payload"], "title": "ScanDataCreate"}, "TimeStampToken": {"properties": {"scan_uuid": {"type": "string", "format": "uuid", "title": "Scan Uuid"}, "tst": {"type": "string", "format": "binary", "title": "Tst"}}, "type": "object", "required": ["scan_uuid", "tst"], "title": "TimeStampToken"}, "TimeStampTokenCreate": {"properties": {"scan_uuid": {"type": "string", "format": "uuid", "title": "Scan Uuid"}, "tst": {"type": "string", "format": "binary", "title": "Tst"}}, "type": "object", "required": ["scan_uuid", "tst"], "title": "TimeStampTokenCreate"}, "ValidationError": {"properties": {"loc": {"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, "type": "array", "title": "Location"}, "msg": {"type": "string", "title": "Message"}, "type": {"type": "string", "title": "Error Type"}}, "type": "object", "required": ["loc", "msg", "type"], "title": "ValidationError"}}}}

0 comments on commit 66852be

Please sign in to comment.