Skip to content

Commit

Permalink
feat: add radar_camera api (#202)
Browse files Browse the repository at this point in the history
Co-authored-by: 99cloud <qiao.lei@99cloud.net>
  • Loading branch information
qiaolei1 and 99cloud committed Apr 19, 2023
1 parent 0801eb2 commit a56fea1
Show file tree
Hide file tree
Showing 51 changed files with 2,484 additions and 725 deletions.
166 changes: 166 additions & 0 deletions apitest/radar_camera.yaml
Original file line number Diff line number Diff line change
@@ -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
56 changes: 56 additions & 0 deletions dandelion/alembic/versions/26c910b0342f_radar_camera.py
Original file line number Diff line number Diff line change
@@ -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 ###
2 changes: 2 additions & 0 deletions dandelion/api/api_v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
mngs,
osw,
provinces,
radar_cameras,
radars,
rdw,
rsi_clcs,
Expand Down Expand Up @@ -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"])
Expand Down
45 changes: 6 additions & 39 deletions dandelion/api/api_v1/endpoints/algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 1 addition & 6 deletions dandelion/api/api_v1/endpoints/areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading

0 comments on commit a56fea1

Please sign in to comment.