diff --git a/apitest/radar_camera.yaml b/apitest/radar_camera.yaml new file mode 100644 index 0000000..da704b4 --- /dev/null +++ b/apitest/radar_camera.yaml @@ -0,0 +1,166 @@ +fixtures: + - ConfigFixture + - SampleDataFixture + +defaults: + ssl: False + request_headers: + content-type: application/json + accept: application/json + +vars: + - &username 'gabbi_user' + - &password 'dandelion' + +tests: + - name: create_user + url: /api/v1/users + method: POST + data: + username: *username + password: *password + is_active: true + status: 200 + response_json_paths: + $.username: *username + + - name: user_login + url: /api/v1/login + method: POST + data: + username: *username + password: *password + status: 200 + response_json_paths: + $.token_type: bearer + + - name: create_rsu_model + url: /api/v1/rsu_models + method: POST + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + data: + name: 蓝天SD726 + manufacturer: 蓝天科技 + desc: 蓝天726 + status: 201 + response_json_paths: + $.name: 蓝天SD726 + $.manufacturer: 蓝天科技 + $.desc: 蓝天726 + + - name: create_rsu + url: /api/v1/rsus + method: POST + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + data: + rsuId: 'RSU_ID_01' + rsuName: 'RSU_NAME_01' + rsuEsn: 'RSU_ESN01' + rsuIP: '192.168.0.101' + rsuModelId: $HISTORY['create_rsu_model'].$RESPONSE['$.id'] + desc: 'test_rsu' + lon: 118.8213963998263 + lat: 31.934846637757847 + status: 201 + response_json_paths: + $.rsuId: 'RSU_ID_01' + $.rsuName: 'RSU_NAME_01' + $.rsuEsn: 'RSU_ESN01' + $.rsuIP: '192.168.0.101' + $.rsuModelId: $HISTORY['create_rsu_model'].$RESPONSE['$.id'] + + - name: create_radar_camera + url: /api/v1/radar_cameras + method: POST + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + data: + name: 'RadarCamera_NAME_01' + sn: 'RadarCamera_SN_01' + lng: 118.79576 + lat: 32.051433 + elevation: "1" + towards: "90" + point: "1" + pole: "1" + radarCameraIP: '1.1.1.1' + videoStreamAddress: "http://127.0.0.1:28300/" + rsuID: $HISTORY['create_rsu'].$RESPONSE['$.id'] + desc: 'test_radar_camera' + status: 201 + + - name: radar_camera_list + url: /api/v1/radar_cameras + method: GET + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + data: + sn: "RadarCamera_SN_01" + name: "RadarCamera_NAME_01" + pageNum: 1 + pageSize: 10 + status: 200 + + - name: radar_camera_info + url: /api/v1/radar_cameras/$HISTORY['create_radar_camera'].$RESPONSE['$.id'] + method: GET + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + status: 200 + response_json_paths: + $.sn: 'RadarCamera_SN_01' + $.name: 'RadarCamera_NAME_01' + $.rsuID: $HISTORY['create_rsu'].$RESPONSE['$.id'] + $.radarCameraIP: '1.1.1.1' + + - name: update_radar_camera + url: /api/v1/radar_cameras/$HISTORY['create_radar_camera'].$RESPONSE['$.id'] + method: PATCH + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + data: + sn: 'RadarCamera_SN_03' + name: 'RadarCamera_NAME_02' + radarCameraIP: '192.168.0.102' + lng: 117.79576 + lat: 33.051433 + elevation: 0 + towards: 90 + rsuID: $HISTORY['create_rsu'].$RESPONSE['$.id'] + desc: 'test_update_radar_camera' + status: 200 + response_json_paths: + $.sn: 'RadarCamera_SN_03' + $.name: 'RadarCamera_NAME_02' + $.radarCameraIP: '192.168.0.102' + $.desc: 'test_update_radar_camera' + + - name: delete_radar + url: /api/v1/radar_cameras/$HISTORY['create_radar_camera'].$RESPONSE['$.id'] + method: DELETE + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + status: 204 + + - name: delete_rsu + url: /api/v1/rsus/$HISTORY['create_rsu'].$RESPONSE['$.id'] + method: DELETE + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + status: 204 + + - name: delete_rsu_model + url: /api/v1/rsu_models/$HISTORY['create_rsu_model'].$RESPONSE['$.id'] + method: DELETE + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + status: 204 + + - name: delete_user + url: /api/v1/users/$HISTORY['create_user'].$RESPONSE['$.id'] + method: DELETE + request_headers: + Authorization: Bearer $HISTORY['user_login'].$RESPONSE['$.access_token'] + status: 204 diff --git a/dandelion/alembic/versions/26c910b0342f_radar_camera.py b/dandelion/alembic/versions/26c910b0342f_radar_camera.py new file mode 100644 index 0000000..6ff8832 --- /dev/null +++ b/dandelion/alembic/versions/26c910b0342f_radar_camera.py @@ -0,0 +1,56 @@ +"""radar_camera + +Revision ID: 26c910b0342f +Revises: 556f61d01468 +Create Date: 2023-04-17 11:21:52.089414 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "26c910b0342f" +down_revision = "556f61d01468" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "radar_camera", + sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), + sa.Column("create_time", sa.DateTime(), nullable=False), + sa.Column("update_time", sa.DateTime(), nullable=False), + sa.Column("name", sa.String(length=64), nullable=False), + sa.Column("sn", sa.String(length=64), nullable=False), + sa.Column("lng", sa.Float(), nullable=False), + sa.Column("lat", sa.Float(), nullable=False), + sa.Column("elevation", sa.Float(), nullable=False), + sa.Column("towards", sa.Float(), nullable=False), + sa.Column("point", sa.String(length=15), nullable=False), + sa.Column("pole", sa.String(length=15), nullable=False), + sa.Column("video_stream_address", sa.String(length=255), nullable=False), + sa.Column("radar_camera_ip", sa.String(length=15), nullable=False), + sa.Column("rsu_id", sa.Integer(), nullable=True), + sa.Column("status", sa.Boolean(), nullable=False), + sa.Column("desc", sa.String(length=255), nullable=False), + sa.ForeignKeyConstraint( + ["rsu_id"], + ["rsu.id"], + ), + sa.PrimaryKeyConstraint("id"), + ) + op.create_index(op.f("ix_radar_camera_id"), "radar_camera", ["id"], unique=False) + op.create_index(op.f("ix_radar_camera_name"), "radar_camera", ["name"], unique=True) + op.create_index(op.f("ix_radar_camera_sn"), "radar_camera", ["sn"], unique=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f("ix_radar_camera_sn"), table_name="radar_camera") + op.drop_index(op.f("ix_radar_camera_name"), table_name="radar_camera") + op.drop_index(op.f("ix_radar_camera_id"), table_name="radar_camera") + op.drop_table("radar_camera") + # ### end Alembic commands ### diff --git a/dandelion/api/api_v1/api.py b/dandelion/api/api_v1/api.py index 877ba75..43ff201 100644 --- a/dandelion/api/api_v1/api.py +++ b/dandelion/api/api_v1/api.py @@ -35,6 +35,7 @@ mngs, osw, provinces, + radar_cameras, radars, rdw, rsi_clcs, @@ -75,6 +76,7 @@ api_router.include_router(map_rsus.router, prefix="/maps", tags=["Map"]) api_router.include_router(maps.router, prefix="/maps", tags=["Map"]) api_router.include_router(radars.router, prefix="/radars", tags=["Radar"]) +api_router.include_router(radar_cameras.router, prefix="/radar_cameras", tags=["RadarCamera"]) api_router.include_router(spats.router, prefix="/spats", tags=["Spat"]) api_router.include_router(lidars.router, prefix="/lidars", tags=["Lidar"]) diff --git a/dandelion/api/api_v1/endpoints/algos.py b/dandelion/api/api_v1/endpoints/algos.py index e04016b..7de63f6 100644 --- a/dandelion/api/api_v1/endpoints/algos.py +++ b/dandelion/api/api_v1/endpoints/algos.py @@ -41,13 +41,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.AlgoVersion, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -112,14 +106,7 @@ def create( description=""" Delete a version. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -151,12 +138,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.AlgoNames, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -185,12 +167,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.AlgoVersions, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all_version( @@ -225,12 +202,7 @@ def get_all_version( """, responses={ status.HTTP_200_OK: {"model": List[schemas.AlgoNameEdit], "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -283,12 +255,7 @@ def update( """, responses={ status.HTTP_200_OK: {"model": List[Dict[str, Any]], "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all_module_algo( diff --git a/dandelion/api/api_v1/endpoints/areas.py b/dandelion/api/api_v1/endpoints/areas.py index 5fc5700..f5cbb31 100644 --- a/dandelion/api/api_v1/endpoints/areas.py +++ b/dandelion/api/api_v1/endpoints/areas.py @@ -38,12 +38,7 @@ """, responses={ status.HTTP_200_OK: {"model": List[schemas.Area], "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/cameras.py b/dandelion/api/api_v1/endpoints/cameras.py index 680cd27..6c42094 100644 --- a/dandelion/api/api_v1/endpoints/cameras.py +++ b/dandelion/api/api_v1/endpoints/cameras.py @@ -39,13 +39,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.Camera, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -67,14 +61,7 @@ def create( description=""" Delete a Camera. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -98,12 +85,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.Camera, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -126,12 +108,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.Cameras, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -168,12 +145,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.Camera, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( diff --git a/dandelion/api/api_v1/endpoints/cgw.py b/dandelion/api/api_v1/endpoints/cgw.py index 6e7a7f7..ec348fe 100644 --- a/dandelion/api/api_v1/endpoints/cgw.py +++ b/dandelion/api/api_v1/endpoints/cgw.py @@ -35,12 +35,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.CGWs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/cities.py b/dandelion/api/api_v1/endpoints/cities.py index 1726216..6dae008 100644 --- a/dandelion/api/api_v1/endpoints/cities.py +++ b/dandelion/api/api_v1/endpoints/cities.py @@ -38,12 +38,7 @@ """, responses={ status.HTTP_200_OK: {"model": List[schemas.City], "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/cloud_homes.py b/dandelion/api/api_v1/endpoints/cloud_homes.py index 5ae6063..b3598f8 100644 --- a/dandelion/api/api_v1/endpoints/cloud_homes.py +++ b/dandelion/api/api_v1/endpoints/cloud_homes.py @@ -39,12 +39,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.OnlineRate, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def online_rate( @@ -101,12 +96,7 @@ def online_rate( """, responses={ status.HTTP_200_OK: {"model": schemas.RouteInfo, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def route_info( diff --git a/dandelion/api/api_v1/endpoints/countries.py b/dandelion/api/api_v1/endpoints/countries.py index 1de9a60..8a31cb7 100644 --- a/dandelion/api/api_v1/endpoints/countries.py +++ b/dandelion/api/api_v1/endpoints/countries.py @@ -39,12 +39,7 @@ """, responses={ status.HTTP_200_OK: {"model": List[schemas.Country], "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/edge_nodes.py b/dandelion/api/api_v1/endpoints/edge_nodes.py index fe393d4..4c73db2 100644 --- a/dandelion/api/api_v1/endpoints/edge_nodes.py +++ b/dandelion/api/api_v1/endpoints/edge_nodes.py @@ -35,12 +35,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.EdgeNodes, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/edge_site.py b/dandelion/api/api_v1/endpoints/edge_site.py index 5da071a..93d4077 100644 --- a/dandelion/api/api_v1/endpoints/edge_site.py +++ b/dandelion/api/api_v1/endpoints/edge_site.py @@ -40,12 +40,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.EdgeSites, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -73,13 +68,7 @@ def get_all( """, responses={ status.HTTP_201_CREATED: {"model": schemas.EdgeSite, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -126,12 +115,7 @@ def create( """, responses={ status.HTTP_200_OK: {"model": schemas.EdgeSite, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -159,14 +143,7 @@ def update( description=""" Delete a Edge Site. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) diff --git a/dandelion/api/api_v1/endpoints/endpoint_metadatas.py b/dandelion/api/api_v1/endpoints/endpoint_metadatas.py index b46192a..2dfcd92 100644 --- a/dandelion/api/api_v1/endpoints/endpoint_metadatas.py +++ b/dandelion/api/api_v1/endpoints/endpoint_metadatas.py @@ -44,13 +44,7 @@ "model": schemas.EndpointMetadataCreateAll, "description": "Created", }, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -87,14 +81,7 @@ def create( description=""" Delete a endpoint_metadata. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -114,14 +101,7 @@ def delete( description=""" get a endpoint_metadata by ID. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_model=schemas.EndpointMetadataGET, response_description="OK", ) @@ -146,12 +126,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.EndpointMetadataGET, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -186,12 +161,7 @@ def update( """, responses={ status.HTTP_200_OK: {"model": schemas.EndpointMetadatas, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/endpoints.py b/dandelion/api/api_v1/endpoints/endpoints.py index 755edb0..255bed3 100644 --- a/dandelion/api/api_v1/endpoints/endpoints.py +++ b/dandelion/api/api_v1/endpoints/endpoints.py @@ -41,13 +41,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.EndpointCreateAll, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -84,14 +78,7 @@ def create( description=""" Delete a endpoint. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -111,14 +98,7 @@ def delete( description=""" get a endpoint by ID. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_model=schemas.EndpointGET, response_description="OK", ) @@ -143,12 +123,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.EndpointGET, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -178,12 +153,7 @@ def update( """, responses={ status.HTTP_200_OK: {"model": schemas.Endpoints, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/lidars.py b/dandelion/api/api_v1/endpoints/lidars.py index 31eed22..d1e1a06 100644 --- a/dandelion/api/api_v1/endpoints/lidars.py +++ b/dandelion/api/api_v1/endpoints/lidars.py @@ -39,13 +39,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.Lidar, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -67,14 +61,7 @@ def create( description=""" Delete a Lidar. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -98,12 +85,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.Lidar, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -126,12 +108,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.Lidars, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -168,12 +145,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.Lidar, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( diff --git a/dandelion/api/api_v1/endpoints/map_rsus.py b/dandelion/api/api_v1/endpoints/map_rsus.py index 620fcfe..f658ced 100644 --- a/dandelion/api/api_v1/endpoints/map_rsus.py +++ b/dandelion/api/api_v1/endpoints/map_rsus.py @@ -39,13 +39,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.MapRSU, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -86,14 +80,7 @@ def create( description=""" Delete a Map RSU. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -121,12 +108,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.MapRSUs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/maps.py b/dandelion/api/api_v1/endpoints/maps.py index e081752..d53f4ed 100644 --- a/dandelion/api/api_v1/endpoints/maps.py +++ b/dandelion/api/api_v1/endpoints/maps.py @@ -42,12 +42,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.Map, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -70,12 +65,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.Maps, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -101,12 +91,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.Map, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -140,12 +125,7 @@ def update( """, responses={ status.HTTP_200_OK: {"model": Dict[str, Any], "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def data( @@ -166,12 +146,7 @@ def data( """, responses={ status.HTTP_200_OK: {"description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def add_bitmap( @@ -200,12 +175,7 @@ def add_bitmap( """, responses={ status.HTTP_200_OK: {"description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_bitmap( diff --git a/dandelion/api/api_v1/endpoints/mngs.py b/dandelion/api/api_v1/endpoints/mngs.py index d2e26ae..37e9850 100644 --- a/dandelion/api/api_v1/endpoints/mngs.py +++ b/dandelion/api/api_v1/endpoints/mngs.py @@ -42,12 +42,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.MNGs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -76,12 +71,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.MNG, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -109,12 +99,7 @@ def update( """, responses={ status.HTTP_200_OK: {"model": schemas.Message, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def down( @@ -141,12 +126,7 @@ def down( """, responses={ status.HTTP_200_OK: {"model": schemas.Message, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def copy( diff --git a/dandelion/api/api_v1/endpoints/osw.py b/dandelion/api/api_v1/endpoints/osw.py index 193cbce..3deec1b 100644 --- a/dandelion/api/api_v1/endpoints/osw.py +++ b/dandelion/api/api_v1/endpoints/osw.py @@ -33,12 +33,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.OSWs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/provinces.py b/dandelion/api/api_v1/endpoints/provinces.py index 15a7451..40bf734 100644 --- a/dandelion/api/api_v1/endpoints/provinces.py +++ b/dandelion/api/api_v1/endpoints/provinces.py @@ -38,12 +38,7 @@ """, responses={ status.HTTP_200_OK: {"model": List[schemas.Province], "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/radar_cameras.py b/dandelion/api/api_v1/endpoints/radar_cameras.py new file mode 100644 index 0000000..b3795af --- /dev/null +++ b/dandelion/api/api_v1/endpoints/radar_cameras.py @@ -0,0 +1,170 @@ +# Copyright 2022 99Cloud, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +from logging import LoggerAdapter +from typing import Optional + +from fastapi import APIRouter, Depends, Query, Response, status +from oslo_log import log +from sqlalchemy import exc as sql_exc +from sqlalchemy.orm import Session + +from dandelion import crud, models, schemas +from dandelion.api import deps +from dandelion.api.deps import error_handle + +router = APIRouter() +LOG: LoggerAdapter = log.getLogger(__name__) + + +@router.post( + "", + response_model=schemas.RadarCamera, + status_code=status.HTTP_201_CREATED, + description=""" +Create a new RadarCamera. +""", + responses={ + status.HTTP_201_CREATED: {"model": schemas.RadarCamera, "description": "Created"}, + **deps.RESPONSE_ERROR, + }, +) +def create( + radar_camera_in: schemas.RadarCameraCreate, + *, + db: Session = Depends(deps.get_db), + current_user: models.User = Depends(deps.get_current_user), +) -> schemas.RadarCamera: + try: + radar_in_db = crud.radar_camera.create(db, obj_in=radar_camera_in) + except (sql_exc.IntegrityError, sql_exc.DataError) as ex: + raise error_handle(ex, "sn or name", f"{radar_camera_in.sn} or {radar_camera_in.name}") + return radar_in_db.to_all_dict() + + +@router.delete( + "/{radar_camera_id}", + status_code=status.HTTP_204_NO_CONTENT, + description=""" +Delete a RadarCamera. +""", + responses=deps.RESPONSE_ERROR, + response_class=Response, + response_description="No Content", +) +def delete( + radar_camera_id: int, + *, + db: Session = Depends(deps.get_db), + current_user: models.User = Depends(deps.get_current_user), +) -> Response: + crud.radar_camera.remove(db, id=radar_camera_id) + return Response(content=None, status_code=status.HTTP_204_NO_CONTENT) + + +@router.get( + "/{radar_camera_id}", + response_model=schemas.RadarCamera, + status_code=status.HTTP_200_OK, + description=""" +Get a RadarCamera. +""", + responses={ + status.HTTP_200_OK: {"model": schemas.RadarCamera, "description": "OK"}, + **deps.RESPONSE_ERROR, + }, +) +def get( + radar_camera_id: int, + *, + db: Session = Depends(deps.get_db), + current_user: models.User = Depends(deps.get_current_user), +) -> schemas.RadarCamera: + radar_in_db = deps.crud_get( + db=db, obj_id=radar_camera_id, crud_model=crud.radar_camera, detail="RadarCamera" + ) + return radar_in_db.to_all_dict() + + +@router.get( + "", + response_model=schemas.RadarCameras, + status_code=status.HTTP_200_OK, + summary="List RadarCamera", + description=""" +Get all RadarCameras. +""", + responses={ + status.HTTP_200_OK: {"model": schemas.RadarCameras, "description": "OK"}, + **deps.RESPONSE_ERROR, + }, +) +def get_all( + sn: Optional[str] = Query( + None, alias="sn", description="Filter by sn. Fuzzy prefix query is supported" + ), + name: Optional[str] = Query( + None, alias="name", description="Filter by name. Fuzzy prefix query is supported" + ), + rsu_id: Optional[int] = Query(None, alias="rsuID", description="Filter by rsuID"), + page_num: int = Query(1, alias="pageNum", ge=1, description="Page number"), + page_size: int = Query(10, alias="pageSize", ge=-1, description="Page size"), + db: Session = Depends(deps.get_db), + current_user: models.User = Depends(deps.get_current_user), +) -> schemas.RadarCameras: + skip = page_size * (page_num - 1) + total, data = crud.radar_camera.get_multi_with_total( + db, + skip=skip, + limit=page_size, + sn=sn, + name=name, + rsu_id=rsu_id, + ) + return schemas.RadarCameras( + total=total, data=[radar_camera.to_all_dict() for radar_camera in data] + ) + + +@router.patch( + "/{radar_camera_id}", + response_model=schemas.RadarCamera, + status_code=status.HTTP_200_OK, + description=""" +Update a RadarCamera. +""", + responses={ + status.HTTP_200_OK: {"model": schemas.RadarCamera, "description": "OK"}, + **deps.RESPONSE_ERROR, + }, +) +def update( + radar_camera_id: int, + radar_camera_in: schemas.RadarCameraUpdate, + *, + db: Session = Depends(deps.get_db), + current_user: models.User = Depends(deps.get_current_user), +) -> schemas.RadarCamera: + radar_camera_in_db = deps.crud_get( + db=db, obj_id=radar_camera_id, crud_model=crud.radar_camera, detail="RadarCamera" + ) + try: + new_radar_camera_in_db = crud.radar_camera.update( + db, db_obj=radar_camera_in_db, obj_in=radar_camera_in + ) + except (sql_exc.DataError, sql_exc.IntegrityError) as ex: + raise error_handle(ex, "sn or name", f"{radar_camera_in.sn} or {radar_camera_in.name}") + return new_radar_camera_in_db.to_all_dict() diff --git a/dandelion/api/api_v1/endpoints/radars.py b/dandelion/api/api_v1/endpoints/radars.py index 9f1fc9d..5057079 100644 --- a/dandelion/api/api_v1/endpoints/radars.py +++ b/dandelion/api/api_v1/endpoints/radars.py @@ -39,13 +39,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.Radar, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -67,14 +61,7 @@ def create( description=""" Delete a Radar. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -98,12 +85,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.Radar, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -126,12 +108,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.Radars, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -168,12 +145,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.Radar, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( diff --git a/dandelion/api/api_v1/endpoints/rdw.py b/dandelion/api/api_v1/endpoints/rdw.py index 1973c4f..e53f2c7 100644 --- a/dandelion/api/api_v1/endpoints/rdw.py +++ b/dandelion/api/api_v1/endpoints/rdw.py @@ -33,12 +33,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.RDWs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/rsi_clcs.py b/dandelion/api/api_v1/endpoints/rsi_clcs.py index 5934494..a2d92d1 100644 --- a/dandelion/api/api_v1/endpoints/rsi_clcs.py +++ b/dandelion/api/api_v1/endpoints/rsi_clcs.py @@ -36,12 +36,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.RSICLCs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/rsi_cwms.py b/dandelion/api/api_v1/endpoints/rsi_cwms.py index c313800..7bb9ce3 100644 --- a/dandelion/api/api_v1/endpoints/rsi_cwms.py +++ b/dandelion/api/api_v1/endpoints/rsi_cwms.py @@ -36,12 +36,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.RSICWMs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/rsi_dnps.py b/dandelion/api/api_v1/endpoints/rsi_dnps.py index 75f38d6..61678cc 100644 --- a/dandelion/api/api_v1/endpoints/rsi_dnps.py +++ b/dandelion/api/api_v1/endpoints/rsi_dnps.py @@ -36,12 +36,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.RSIDNPs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/rsi_events.py b/dandelion/api/api_v1/endpoints/rsi_events.py index bf8fc83..ffcfd02 100644 --- a/dandelion/api/api_v1/endpoints/rsi_events.py +++ b/dandelion/api/api_v1/endpoints/rsi_events.py @@ -38,12 +38,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.RSIEvent, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( diff --git a/dandelion/api/api_v1/endpoints/rsi_sdss.py b/dandelion/api/api_v1/endpoints/rsi_sdss.py index 9049fb7..fc2d92f 100644 --- a/dandelion/api/api_v1/endpoints/rsi_sdss.py +++ b/dandelion/api/api_v1/endpoints/rsi_sdss.py @@ -36,12 +36,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.RSISDSs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/rsm_participants.py b/dandelion/api/api_v1/endpoints/rsm_participants.py index ad60505..e76b116 100644 --- a/dandelion/api/api_v1/endpoints/rsm_participants.py +++ b/dandelion/api/api_v1/endpoints/rsm_participants.py @@ -39,12 +39,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.RSMParticipants, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/rsu_configs.py b/dandelion/api/api_v1/endpoints/rsu_configs.py index 2ba3a9f..4c3b4a8 100644 --- a/dandelion/api/api_v1/endpoints/rsu_configs.py +++ b/dandelion/api/api_v1/endpoints/rsu_configs.py @@ -40,13 +40,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.RSUConfig, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -87,14 +81,7 @@ def create( description=""" Delete a RSUConfig. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -123,12 +110,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUConfigWithRSUs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -156,12 +138,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUConfigs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -187,12 +164,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUConfig, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( diff --git a/dandelion/api/api_v1/endpoints/rsu_logs.py b/dandelion/api/api_v1/endpoints/rsu_logs.py index 7f3cc33..2f5f8f7 100644 --- a/dandelion/api/api_v1/endpoints/rsu_logs.py +++ b/dandelion/api/api_v1/endpoints/rsu_logs.py @@ -39,13 +39,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.RSULog, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -79,14 +73,7 @@ def create( description=""" Delete a RSULog. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -110,12 +97,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.RSULog, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -140,12 +122,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.RSULogs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -168,12 +145,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.RSULog, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( diff --git a/dandelion/api/api_v1/endpoints/rsu_models.py b/dandelion/api/api_v1/endpoints/rsu_models.py index bb30c03..118849e 100644 --- a/dandelion/api/api_v1/endpoints/rsu_models.py +++ b/dandelion/api/api_v1/endpoints/rsu_models.py @@ -39,13 +39,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.RSUModel, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -67,14 +61,7 @@ def create( description=""" Delete a RSU Model. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -103,12 +90,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUModel, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -136,12 +118,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUModels, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -174,12 +151,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUModel, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( diff --git a/dandelion/api/api_v1/endpoints/rsu_queries.py b/dandelion/api/api_v1/endpoints/rsu_queries.py index fd898cb..8a33fb3 100644 --- a/dandelion/api/api_v1/endpoints/rsu_queries.py +++ b/dandelion/api/api_v1/endpoints/rsu_queries.py @@ -38,13 +38,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.RSUQuery, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -79,12 +73,7 @@ def create( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUQueryDetail, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -112,12 +101,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUQueries, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -140,14 +124,7 @@ def get_all( description=""" Delete a RSU Query. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) diff --git a/dandelion/api/api_v1/endpoints/rsu_tmps.py b/dandelion/api/api_v1/endpoints/rsu_tmps.py index a74a34c..658daf1 100644 --- a/dandelion/api/api_v1/endpoints/rsu_tmps.py +++ b/dandelion/api/api_v1/endpoints/rsu_tmps.py @@ -38,12 +38,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.RSUTMPs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -69,14 +64,7 @@ def get_all( description=""" Delete a TMP RSU. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) diff --git a/dandelion/api/api_v1/endpoints/rsus.py b/dandelion/api/api_v1/endpoints/rsus.py index 4d04561..0909ba9 100644 --- a/dandelion/api/api_v1/endpoints/rsus.py +++ b/dandelion/api/api_v1/endpoints/rsus.py @@ -42,13 +42,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.RSU, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -85,12 +79,7 @@ def create( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -133,12 +122,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.RSUDetail, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -179,12 +163,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.RSU, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -208,14 +187,7 @@ def update( description=""" Delete a RSU. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -244,12 +216,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.RSULocation, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_location( @@ -276,12 +243,7 @@ def get_location( """, responses={ status.HTTP_200_OK: {"model": schemas.RSURunning, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_running( diff --git a/dandelion/api/api_v1/endpoints/service_types.py b/dandelion/api/api_v1/endpoints/service_types.py index 44dc298..b859f32 100644 --- a/dandelion/api/api_v1/endpoints/service_types.py +++ b/dandelion/api/api_v1/endpoints/service_types.py @@ -41,13 +41,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.ServiceTypeCreateAll, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -82,14 +76,7 @@ def create( description=""" Delete a service type. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -109,14 +96,7 @@ def delete( description=""" get a service type by ID. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_model=schemas.ServiceTypeGET, response_description="OK", ) @@ -141,12 +121,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.ServiceTypeGET, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -178,12 +153,7 @@ def update( """, responses={ status.HTTP_200_OK: {"model": schemas.ServiceTypes, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/services.py b/dandelion/api/api_v1/endpoints/services.py index f4e49d6..53da912 100644 --- a/dandelion/api/api_v1/endpoints/services.py +++ b/dandelion/api/api_v1/endpoints/services.py @@ -41,13 +41,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.ServiceCreateAll, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -85,14 +79,7 @@ def create( description=""" Delete a service. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -112,14 +99,7 @@ def delete( description=""" get a service by ID. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_model=schemas.ServiceGET, response_description="OK", ) @@ -144,12 +124,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.ServiceGET, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( @@ -179,12 +154,7 @@ def update( """, responses={ status.HTTP_200_OK: {"model": schemas.Services, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/spats.py b/dandelion/api/api_v1/endpoints/spats.py index 2451968..3d55d1b 100644 --- a/dandelion/api/api_v1/endpoints/spats.py +++ b/dandelion/api/api_v1/endpoints/spats.py @@ -41,13 +41,7 @@ """, responses={ status.HTTP_201_CREATED: {"model": schemas.Spat, "description": "Created"}, - status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -86,14 +80,7 @@ def create( description=""" Delete a Spat. """, - responses={ - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, - }, + responses=deps.RESPONSE_ERROR, response_class=Response, response_description="No Content", ) @@ -117,12 +104,7 @@ def delete( """, responses={ status.HTTP_200_OK: {"model": schemas.Spat, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -145,12 +127,7 @@ def get( """, responses={ status.HTTP_200_OK: {"model": schemas.Spats, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( @@ -189,12 +166,7 @@ def get_all( """, responses={ status.HTTP_200_OK: {"model": schemas.Spat, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def update( diff --git a/dandelion/api/api_v1/endpoints/ssw.py b/dandelion/api/api_v1/endpoints/ssw.py index c329d08..16c3d71 100644 --- a/dandelion/api/api_v1/endpoints/ssw.py +++ b/dandelion/api/api_v1/endpoints/ssw.py @@ -33,12 +33,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.SSWs, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get_all( diff --git a/dandelion/api/api_v1/endpoints/system_configs.py b/dandelion/api/api_v1/endpoints/system_configs.py index 8283c5d..2d242bd 100644 --- a/dandelion/api/api_v1/endpoints/system_configs.py +++ b/dandelion/api/api_v1/endpoints/system_configs.py @@ -14,6 +14,8 @@ from __future__ import annotations +from typing import Dict + from fastapi import APIRouter, Depends, status from oslo_config import cfg from sqlalchemy.orm import Session @@ -38,12 +40,7 @@ """, responses={ status.HTTP_200_OK: {"model": schemas.SystemConfig, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def create( @@ -83,12 +80,7 @@ def create( """, responses={ status.HTTP_200_OK: {"model": schemas.SystemConfig, "description": "OK"}, - status.HTTP_401_UNAUTHORIZED: { - "model": schemas.ErrorMessage, - "description": "Unauthorized", - }, - status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, - status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, + **deps.RESPONSE_ERROR, }, ) def get( @@ -105,3 +97,20 @@ def get( ) system_config.mode = mode_conf.mode return system_config.to_dict() + + +@router.get( + "/edge/mqtt_config", + response_model=Dict, + status_code=status.HTTP_200_OK, + description=""" +Get edge site mqtt config. +""", +) +def get_edge_mqtt_config( + current_user: models.User = Depends(deps.get_current_user), +) -> Dict: + return { + "username": CONF.mqtt.username, + "password": CONF.mqtt.password, + } diff --git a/dandelion/api/deps.py b/dandelion/api/deps.py index 8930f4f..19cfd2a 100644 --- a/dandelion/api/deps.py +++ b/dandelion/api/deps.py @@ -39,6 +39,17 @@ reusable_oauth2 = OAuth2PasswordBearer(tokenUrl=f"{constants.API_V1_STR}/login/access-token") +RESPONSE_ERROR: Dict = { + status.HTTP_400_BAD_REQUEST: {"model": schemas.ErrorMessage, "description": "Bad Request"}, + status.HTTP_401_UNAUTHORIZED: { + "model": schemas.ErrorMessage, + "description": "Unauthorized", + }, + status.HTTP_403_FORBIDDEN: {"model": schemas.ErrorMessage, "description": "Forbidden"}, + status.HTTP_404_NOT_FOUND: {"model": schemas.ErrorMessage, "description": "Not Found"}, +} + + class OpenV2XHTTPException(HTTPException): def __init__( self, diff --git a/dandelion/crud/__init__.py b/dandelion/crud/__init__.py index cb0749e..10bb694 100644 --- a/dandelion/crud/__init__.py +++ b/dandelion/crud/__init__.py @@ -32,6 +32,7 @@ from .crud_osw import osw from .crud_province import province from .crud_radar import radar +from .crud_radar_camera import radar_camera from .crud_rdw import rdw from .crud_rsi_clc import rsi_clc from .crud_rsi_cwm import rsi_cwm @@ -98,4 +99,5 @@ "service_type", "ssw", "edge_site", + "radar_camera", ] diff --git a/dandelion/crud/crud_radar_camera.py b/dandelion/crud/crud_radar_camera.py new file mode 100644 index 0000000..d54945d --- /dev/null +++ b/dandelion/crud/crud_radar_camera.py @@ -0,0 +1,62 @@ +# Copyright 2022 99Cloud, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +from typing import List, Optional, Tuple + +from fastapi.encoders import jsonable_encoder +from sqlalchemy.orm import Session + +from dandelion.crud.base import CRUDBase +from dandelion.models import RadarCamera +from dandelion.schemas import RadarCameraCreate, RadarCameraUpdate + + +class CRUDRadarCamera(CRUDBase[RadarCamera, RadarCameraCreate, RadarCameraUpdate]): + """""" + + def create(self, db: Session, *, obj_in: RadarCameraCreate) -> RadarCamera: + obj_in_data = jsonable_encoder(obj_in, by_alias=False) + db_obj = self.model(**obj_in_data) + db.add(db_obj) + db.commit() + db.refresh(db_obj) + return db_obj + + def get_multi_with_total( + self, + db: Session, + *, + skip: int = 0, + limit: int = 10, + sn: Optional[str] = None, + name: Optional[str] = None, + rsu_id: Optional[int] = None, + ) -> Tuple[int, List[RadarCamera]]: + query_ = db.query(self.model) + if sn is not None: + query_ = self.fuzz_filter(query_, self.model.sn, sn) + if name is not None: + query_ = self.fuzz_filter(query_, self.model.name, name) + if rsu_id is not None: + query_ = query_.filter(self.model.rsu_id == rsu_id) + total = query_.count() + if limit != -1: + query_ = query_.offset(skip).limit(limit) + data = query_.all() + return total, data + + +radar_camera = CRUDRadarCamera(RadarCamera) diff --git a/dandelion/db/base_class.py b/dandelion/db/base_class.py index f3f9e4f..e65350f 100644 --- a/dandelion/db/base_class.py +++ b/dandelion/db/base_class.py @@ -17,7 +17,7 @@ from datetime import datetime from sqlalchemy import Column, DateTime, Integer -from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import declarative_base Base = declarative_base() diff --git a/dandelion/main.py b/dandelion/main.py index b36f688..c812dde 100644 --- a/dandelion/main.py +++ b/dandelion/main.py @@ -18,6 +18,7 @@ import uuid from logging import LoggerAdapter +import uvicorn from apscheduler.executors.pool import ThreadPoolExecutor from apscheduler.jobstores.memory import MemoryJobStore from apscheduler.schedulers.background import BackgroundScheduler @@ -130,3 +131,6 @@ async def add_request_id_header(request: Request, call_next): app.include_router(api_router, prefix=constants.API_V1_STR) + +if __name__ == "__main__": + uvicorn.run(app=app, port=28300, host="0.0.0.0") diff --git a/dandelion/models/__init__.py b/dandelion/models/__init__.py index ad844e1..406a7ed 100644 --- a/dandelion/models/__init__.py +++ b/dandelion/models/__init__.py @@ -32,6 +32,7 @@ from .osw import OSW from .province import Province from .radar import Radar +from .radar_camera import RadarCamera from .rdw import RDW from .rsi_clc import RSICLC from .rsi_cwm import RSICWM diff --git a/dandelion/models/radar_camera.py b/dandelion/models/radar_camera.py new file mode 100644 index 0000000..bbaad59 --- /dev/null +++ b/dandelion/models/radar_camera.py @@ -0,0 +1,62 @@ +# Copyright 2022 99Cloud, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +from sqlalchemy import Boolean, Column, Float, ForeignKey, Integer, String + +from dandelion.db.base_class import Base, DandelionBase +from dandelion.util import Optional as Optional_util + + +class RadarCamera(Base, DandelionBase): + __tablename__ = "radar_camera" + + name = Column(String(64), nullable=False, index=True, unique=True) + sn = Column(String(64), nullable=False, index=True, unique=True) + lng = Column(Float, nullable=False) + lat = Column(Float, nullable=False) + elevation = Column(Float, nullable=False) + towards = Column(Float, nullable=False) + point = Column(String(15), nullable=False, doc="点位") + pole = Column(String(15), nullable=False, doc="杆位") + video_stream_address = Column(String(255), nullable=False, doc="视频流地址") + radar_camera_ip = Column(String(15), nullable=False, default="") + rsu_id = Column(Integer, ForeignKey("rsu.id")) + + status = Column(Boolean, nullable=False, default=False) + desc = Column(String(255), nullable=False, default="") + + def __repr__(self) -> str: + return f"" + + def to_all_dict(self): + return dict( + id=self.id, + name=self.name, + sn=self.sn, + lng=self.lng, + lat=self.lat, + elevation=self.elevation, + towards=self.towards, + point=self.point, + pole=self.pole, + videoStreamAddress=self.video_stream_address, + radarCameraIP=self.radar_camera_ip, + rsuID=self.rsu_id, + status=self.status, + rsuName=Optional_util.none(self.rsu).map(lambda v: v.rsu_name).get(), + desc=self.desc, + createTime=self.create_time, + ) diff --git a/dandelion/models/rsu.py b/dandelion/models/rsu.py index 42f874a..608215c 100644 --- a/dandelion/models/rsu.py +++ b/dandelion/models/rsu.py @@ -57,6 +57,7 @@ class RSU(Base, DandelionBase): radars = relationship("Radar", backref="rsu") lidars = relationship("Lidar", backref="rsu") spats = relationship("Spat", backref="rsu") + radar_carmeras = relationship("RadarCamera", backref="rsu") def __repr__(self) -> str: return f"" diff --git a/dandelion/schemas/__init__.py b/dandelion/schemas/__init__.py index 0ad29d0..31300a1 100644 --- a/dandelion/schemas/__init__.py +++ b/dandelion/schemas/__init__.py @@ -56,6 +56,7 @@ from .osw import OSW, OSWCreate, OSWs, OSWUpdate from .province import Province, ProvinceCreate, ProvinceUpdate from .radar import Radar, RadarCreate, Radars, RadarUpdate +from .radar_camera import RadarCamera, RadarCameraCreate, RadarCameras, RadarCameraUpdate from .rdw import RDW, RDWCreate, RDWs, RDWUpdate from .rsi_clc import RSICLCCreate, RSICLCs from .rsi_cwm import RSICWMCreate, RSICWMs diff --git a/dandelion/schemas/radar_camera.py b/dandelion/schemas/radar_camera.py new file mode 100644 index 0000000..81ebd1b --- /dev/null +++ b/dandelion/schemas/radar_camera.py @@ -0,0 +1,84 @@ +# Copyright 2022 99Cloud, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +from datetime import datetime +from typing import List, Optional + +from pydantic import BaseModel, Field + + +# Shared properties +class RadarCameraBase(BaseModel): + """""" + + name: str = Field(..., alias="name", description="RadarCamera Name") + sn: str = Field(..., alias="sn", description="RadarCamera SN") + lng: str = Field(..., alias="lng", description="Longitude") + lat: str = Field(..., alias="lat", description="Latitude") + elevation: str = Field(..., alias="elevation", description="Elevation") + towards: str = Field(..., alias="towards", description="Towards") + point: str = Field(..., alias="point", description="point") + pole: str = Field(..., alias="pole", description="pole") + radar_camera_ip: str = Field(..., alias="radarCameraIP", description="RadarCamera IP") + video_stream_address: str = Field( + ..., alias="videoStreamAddress", description="video stream address" + ) + rsu_id: Optional[int] = Field(None, alias="rsuID", description="RSU ID") + desc: Optional[str] = Field("", alias="desc", description="Description") + + +# Properties to receive via API on creation +class RadarCameraCreate(RadarCameraBase): + """""" + + +# Properties to receive via API on update +class RadarCameraUpdate(BaseModel): + name: Optional[str] = Field(None, alias="name", description="RadarCamera Name") + sn: Optional[str] = Field(None, alias="sn", description="RadarCamera SN") + lng: Optional[str] = Field(None, alias="lng", description="Longitude") + lat: Optional[str] = Field(None, alias="lat", description="Latitude") + elevation: Optional[str] = Field(None, alias="elevation", description="Elevation") + towards: Optional[str] = Field(None, alias="towards", description="Towards") + point: Optional[str] = Field(None, alias="point", description="point") + pole: Optional[str] = Field(None, alias="pole", description="pole") + radar_camera_ip: Optional[str] = Field( + None, alias="radarCameraIP", description="RadarCamera IP" + ) + video_stream_address: Optional[str] = Field( + None, alias="videoStreamAddress", description="video stream address" + ) + rsu_id: Optional[int] = Field(None, alias="rsuID", description="RSU ID") + desc: Optional[str] = Field("", alias="desc", description="Description") + + +class RadarCameraInDBBase(RadarCameraBase): + id: int = Field(..., alias="id", description="RadarCamera ID") + + class Config: + orm_mode = True + + +# Additional properties to return via API +class RadarCamera(RadarCameraInDBBase): + status: bool = Field(..., alias="status", description="Status") + rsu_name: Optional[str] = Field(None, alias="rsuName", description="RSU Name") + create_time: datetime = Field(..., alias="createTime", description="Create Time") + + +class RadarCameras(BaseModel): + total: int = Field(..., alias="total", description="Total") + data: List[RadarCamera] = Field(..., alias="data", description="Data") diff --git a/swagger.json b/swagger.json index 23c9be9..dcb6b66 100644 --- a/swagger.json +++ b/swagger.json @@ -425,6 +425,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -509,6 +519,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -593,6 +613,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -677,6 +707,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -805,6 +845,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -968,6 +1018,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1037,6 +1097,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1123,6 +1193,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1203,6 +1283,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1270,6 +1360,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1425,6 +1525,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1513,6 +1623,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1591,6 +1711,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1685,6 +1815,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1789,6 +1929,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -1965,6 +2115,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2043,6 +2203,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2129,6 +2299,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2235,6 +2415,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2314,6 +2504,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2392,6 +2592,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2463,6 +2673,16 @@ "200": { "description": "OK" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2591,6 +2811,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2754,6 +2984,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2823,6 +3063,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -2909,8 +3159,8 @@ } } }, - "401": { - "description": "Unauthorized", + "400": { + "description": "Bad Request", "content": { "application/json": { "schema": { @@ -2919,8 +3169,504 @@ } } }, - "403": { - "description": "Forbidden", + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "OAuth2PasswordBearer": [] + } + ] + } + }, + "/api/v1/radar_cameras": { + "get": { + "tags": [ + "RadarCamera" + ], + "summary": "List RadarCamera", + "description": "Get all RadarCameras.", + "operationId": "get_all_api_v1_radar_cameras_get", + "parameters": [ + { + "description": "Filter by sn. Fuzzy prefix query is supported", + "required": false, + "schema": { + "title": "Sn", + "type": "string", + "description": "Filter by sn. Fuzzy prefix query is supported" + }, + "name": "sn", + "in": "query" + }, + { + "description": "Filter by name. Fuzzy prefix query is supported", + "required": false, + "schema": { + "title": "Name", + "type": "string", + "description": "Filter by name. Fuzzy prefix query is supported" + }, + "name": "name", + "in": "query" + }, + { + "description": "Filter by rsuID", + "required": false, + "schema": { + "title": "Rsuid", + "type": "integer", + "description": "Filter by rsuID" + }, + "name": "rsuID", + "in": "query" + }, + { + "description": "Page number", + "required": false, + "schema": { + "title": "Pagenum", + "minimum": 1.0, + "type": "integer", + "description": "Page number", + "default": 1 + }, + "name": "pageNum", + "in": "query" + }, + { + "description": "Page size", + "required": false, + "schema": { + "title": "Pagesize", + "minimum": -1.0, + "type": "integer", + "description": "Page size", + "default": 10 + }, + "name": "pageSize", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RadarCameras" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "OAuth2PasswordBearer": [] + } + ] + }, + "post": { + "tags": [ + "RadarCamera" + ], + "summary": "Create", + "description": "Create a new RadarCamera.", + "operationId": "create_api_v1_radar_cameras_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RadarCameraCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RadarCamera" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "OAuth2PasswordBearer": [] + } + ] + } + }, + "/api/v1/radar_cameras/{radar_camera_id}": { + "get": { + "tags": [ + "RadarCamera" + ], + "summary": "Get", + "description": "Get a RadarCamera.", + "operationId": "get_api_v1_radar_cameras__radar_camera_id__get", + "parameters": [ + { + "required": true, + "schema": { + "title": "Radar Camera Id", + "type": "integer" + }, + "name": "radar_camera_id", + "in": "path" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RadarCamera" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "OAuth2PasswordBearer": [] + } + ] + }, + "delete": { + "tags": [ + "RadarCamera" + ], + "summary": "Delete", + "description": "Delete a RadarCamera.", + "operationId": "delete_api_v1_radar_cameras__radar_camera_id__delete", + "parameters": [ + { + "required": true, + "schema": { + "title": "Radar Camera Id", + "type": "integer" + }, + "name": "radar_camera_id", + "in": "path" + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "OAuth2PasswordBearer": [] + } + ] + }, + "patch": { + "tags": [ + "RadarCamera" + ], + "summary": "Update", + "description": "Update a RadarCamera.", + "operationId": "update_api_v1_radar_cameras__radar_camera_id__patch", + "parameters": [ + { + "required": true, + "schema": { + "title": "Radar Camera Id", + "type": "integer" + }, + "name": "radar_camera_id", + "in": "path" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RadarCameraUpdate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RadarCamera" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "403": { + "description": "Forbidden", "content": { "application/json": { "schema": { @@ -3037,6 +3783,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -3200,6 +3956,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -3269,6 +4035,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -3355,6 +4131,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -3483,6 +4269,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -3646,6 +4442,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -3715,6 +4521,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -3801,6 +4617,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -3879,6 +4705,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4121,6 +4957,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4227,6 +5073,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4390,6 +5246,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4476,6 +5342,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4545,6 +5421,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4640,6 +5526,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4803,6 +5699,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4889,6 +5795,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -4958,6 +5874,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5075,6 +6001,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5238,6 +6174,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5324,6 +6270,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5393,6 +6349,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5499,6 +6465,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5662,6 +6638,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5731,6 +6717,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5848,6 +6844,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -5919,6 +6925,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6069,6 +7085,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6232,6 +7258,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6301,6 +7337,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6387,6 +7433,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6465,6 +7521,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6543,6 +7609,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6620,6 +7696,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6698,6 +7784,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6746,6 +7842,34 @@ ] } }, + "/api/v1/system_configs/edge/mqtt_config": { + "get": { + "tags": [ + "System Config" + ], + "summary": "Get Edge Mqtt Config", + "description": "Get edge site mqtt config.", + "operationId": "get_edge_mqtt_config_api_v1_system_configs_edge_mqtt_config_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "title": "Response Get Edge Mqtt Config Api V1 System Configs Edge Mqtt Config Get", + "type": "object" + } + } + } + } + }, + "security": [ + { + "OAuth2PasswordBearer": [] + } + ] + } + }, "/api/v1/rsi_dnps": { "get": { "tags": [ @@ -6819,6 +7943,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -6951,6 +8085,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -7072,6 +8216,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -7193,6 +8347,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -7299,6 +8463,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -7389,7 +8563,17 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RDWs" + "$ref": "#/components/schemas/RDWs" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" } } } @@ -7489,6 +8673,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -7584,6 +8778,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -7697,6 +8901,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -7853,6 +9067,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -7939,6 +9163,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8052,6 +9286,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8132,6 +9376,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8288,6 +9542,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8368,6 +9632,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8451,6 +9725,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8522,6 +9806,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8579,6 +9873,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8732,6 +10036,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8818,6 +10132,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8887,6 +10211,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -8954,6 +10288,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9107,6 +10451,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9193,6 +10547,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9262,6 +10626,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9329,6 +10703,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9482,6 +10866,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9568,6 +10962,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9637,6 +11041,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9704,6 +11118,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -9852,7 +11276,17 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ServiceTypeGET" + "$ref": "#/components/schemas/ServiceTypeGET" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" } } } @@ -9943,6 +11377,16 @@ } } }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -10012,6 +11456,16 @@ "204": { "description": "No Content" }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, "401": { "description": "Unauthorized", "content": { @@ -14601,6 +16055,278 @@ } } }, + "RadarCamera": { + "title": "RadarCamera", + "required": [ + "name", + "sn", + "lng", + "lat", + "elevation", + "towards", + "point", + "pole", + "radarCameraIP", + "videoStreamAddress", + "id", + "status", + "createTime" + ], + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "RadarCamera Name" + }, + "sn": { + "title": "Sn", + "type": "string", + "description": "RadarCamera SN" + }, + "lng": { + "title": "Lng", + "type": "string", + "description": "Longitude" + }, + "lat": { + "title": "Lat", + "type": "string", + "description": "Latitude" + }, + "elevation": { + "title": "Elevation", + "type": "string", + "description": "Elevation" + }, + "towards": { + "title": "Towards", + "type": "string", + "description": "Towards" + }, + "point": { + "title": "Point", + "type": "string", + "description": "point" + }, + "pole": { + "title": "Pole", + "type": "string", + "description": "pole" + }, + "radarCameraIP": { + "title": "Radarcameraip", + "type": "string", + "description": "RadarCamera IP" + }, + "videoStreamAddress": { + "title": "Videostreamaddress", + "type": "string", + "description": "video stream address" + }, + "rsuID": { + "title": "Rsuid", + "type": "integer", + "description": "RSU ID" + }, + "desc": { + "title": "Desc", + "type": "string", + "description": "Description", + "default": "" + }, + "id": { + "title": "Id", + "type": "integer", + "description": "RadarCamera ID" + }, + "status": { + "title": "Status", + "type": "boolean", + "description": "Status" + }, + "rsuName": { + "title": "Rsuname", + "type": "string", + "description": "RSU Name" + }, + "createTime": { + "title": "Createtime", + "type": "string", + "description": "Create Time", + "format": "date-time" + } + } + }, + "RadarCameraCreate": { + "title": "RadarCameraCreate", + "required": [ + "name", + "sn", + "lng", + "lat", + "elevation", + "towards", + "point", + "pole", + "radarCameraIP", + "videoStreamAddress" + ], + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "RadarCamera Name" + }, + "sn": { + "title": "Sn", + "type": "string", + "description": "RadarCamera SN" + }, + "lng": { + "title": "Lng", + "type": "string", + "description": "Longitude" + }, + "lat": { + "title": "Lat", + "type": "string", + "description": "Latitude" + }, + "elevation": { + "title": "Elevation", + "type": "string", + "description": "Elevation" + }, + "towards": { + "title": "Towards", + "type": "string", + "description": "Towards" + }, + "point": { + "title": "Point", + "type": "string", + "description": "point" + }, + "pole": { + "title": "Pole", + "type": "string", + "description": "pole" + }, + "radarCameraIP": { + "title": "Radarcameraip", + "type": "string", + "description": "RadarCamera IP" + }, + "videoStreamAddress": { + "title": "Videostreamaddress", + "type": "string", + "description": "video stream address" + }, + "rsuID": { + "title": "Rsuid", + "type": "integer", + "description": "RSU ID" + }, + "desc": { + "title": "Desc", + "type": "string", + "description": "Description", + "default": "" + } + } + }, + "RadarCameraUpdate": { + "title": "RadarCameraUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "RadarCamera Name" + }, + "sn": { + "title": "Sn", + "type": "string", + "description": "RadarCamera SN" + }, + "lng": { + "title": "Lng", + "type": "string", + "description": "Longitude" + }, + "lat": { + "title": "Lat", + "type": "string", + "description": "Latitude" + }, + "elevation": { + "title": "Elevation", + "type": "string", + "description": "Elevation" + }, + "towards": { + "title": "Towards", + "type": "string", + "description": "Towards" + }, + "point": { + "title": "Point", + "type": "string", + "description": "point" + }, + "pole": { + "title": "Pole", + "type": "string", + "description": "pole" + }, + "radarCameraIP": { + "title": "Radarcameraip", + "type": "string", + "description": "RadarCamera IP" + }, + "videoStreamAddress": { + "title": "Videostreamaddress", + "type": "string", + "description": "video stream address" + }, + "rsuID": { + "title": "Rsuid", + "type": "integer", + "description": "RSU ID" + }, + "desc": { + "title": "Desc", + "type": "string", + "description": "Description", + "default": "" + } + } + }, + "RadarCameras": { + "title": "RadarCameras", + "required": [ + "total", + "data" + ], + "type": "object", + "properties": { + "total": { + "title": "Total", + "type": "integer", + "description": "Total" + }, + "data": { + "title": "Data", + "type": "array", + "items": { + "$ref": "#/components/schemas/RadarCamera" + }, + "description": "Data" + } + } + }, "RadarCreate": { "title": "RadarCreate", "required": [