Skip to content

Examples ‐ Registrar Endpoints

Nguyen Nguyen edited this page Nov 3, 2023 · 1 revision

Enabled / disable auto enrollment

Request

curl --location --request PUT 'http://localhost:5000/api/auto-enrollment/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImFjY2Vzcy10b2tlbi1rZXkifQ.eyJhdWQiOiJrcmFrZW5kLmxvY2FsLmdkIiwiZXhwIjoxNjk4OTcxMDIzLCJmaXJzdF9uYW1lIjoiTmF0aGFuIiwiaXNzIjoiYXV0aC5sb2NhbC5nZCIsImp0aSI6IjIiLCJsYXN0X25hbWUiOiJOZ3V5ZW4iLCJyb2xlcyI6WyJTdHVkZW50IiwiSW5zdHJ1Y3RvciIsIlJlZ2lzdHJhIl0sInN1YiI6Im5hdGhhbiJ9.a3dYEi4sdD0v5wIQIdnfD2ta0NllyYnCeIJ5VXdjONWM86XY1GL8RbQKw8KIXcnKIX2WLu2vsOXN7c7hmjSjlJAmoIpN3BdMKklFGkd7a7KfSn8GsolTpr66-8w6YuiGZjB4ZrD8ZTUDV25WE1HGBjl3xbj4vyM7xZ-Mc_1in2FVJUz1p9ZO2T_6eqwELHaT6I9SIz4u1sFP3pwtbO85nTl-o4PiLuTAAWYtlnXC2bseyXqRgUv-_3q77eyQeUEgEUx7sBkrmUoAaXe1KXTJewMgWBP-VeD9U0RsLhgwzO-GM90vr6zPJ7s83xGqAqw1DtHGXQDRqRm_2QAaZTX1aw' \
--data '{
    "enabled": true
}'

Response

{
    "enabled": true
}

Create a new course

Request

curl --location 'http://localhost:5000/api/courses/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImFjY2Vzcy10b2tlbi1rZXkifQ.eyJhdWQiOiJrcmFrZW5kLmxvY2FsLmdkIiwiZXhwIjoxNjk4OTcyMzY1LCJmaXJzdF9uYW1lIjoiTmF0aGFuIiwiaXNzIjoiYXV0aC5sb2NhbC5nZCIsImp0aSI6IjIiLCJsYXN0X25hbWUiOiJOZ3V5ZW4iLCJyb2xlcyI6WyJTdHVkZW50IiwiSW5zdHJ1Y3RvciIsIlJlZ2lzdHJhIl0sInN1YiI6Im5hdGhhbiJ9.UGxuGV_E9OccalTtcSOVvrhEQ8o8nM-Yo0Ok2EhwCovy_deQArqP3IY57aE3x4BzcFdCQNmRDCkKAJy9YEJbiqmMDCTi_u7peuzGL9OMoR0HX796ZREl04QUOMSbZ5JT5LpeWm9Ef58xgVwFf0kdlzZ8E7cbGnqPwgLS4yoMa0jTuqW5by5SyRKQWBaNpR337Yfc4g3UQxqnogZUrHy4l1k8mffke_R5ztOghkKephUuTV1uwensXbtxxtJnI-Nzi05EC2eaw84uy9JrStTtDBGq3lYd8O3md-nZObm0H3XdMrJg296meAvXeNFjYsBLSkYmLSRo9Kk87MsHcGod4A' \
--data '{
    "department_code": "CPSC",
    "course_no": 999,
    "title": "TEST TEST"
}'

Response

{
    "course_no": 999,
    "department_code": "CPSC",
    "title": "TEST TEST"
}

Create a new class

Request

curl --location 'http://localhost:5000/api/classes/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImFjY2Vzcy10b2tlbi1rZXkifQ.eyJhdWQiOiJrcmFrZW5kLmxvY2FsLmdkIiwiZXhwIjoxNjk4OTcyMzY1LCJmaXJzdF9uYW1lIjoiTmF0aGFuIiwiaXNzIjoiYXV0aC5sb2NhbC5nZCIsImp0aSI6IjIiLCJsYXN0X25hbWUiOiJOZ3V5ZW4iLCJyb2xlcyI6WyJTdHVkZW50IiwiSW5zdHJ1Y3RvciIsIlJlZ2lzdHJhIl0sInN1YiI6Im5hdGhhbiJ9.UGxuGV_E9OccalTtcSOVvrhEQ8o8nM-Yo0Ok2EhwCovy_deQArqP3IY57aE3x4BzcFdCQNmRDCkKAJy9YEJbiqmMDCTi_u7peuzGL9OMoR0HX796ZREl04QUOMSbZ5JT5LpeWm9Ef58xgVwFf0kdlzZ8E7cbGnqPwgLS4yoMa0jTuqW5by5SyRKQWBaNpR337Yfc4g3UQxqnogZUrHy4l1k8mffke_R5ztOghkKephUuTV1uwensXbtxxtJnI-Nzi05EC2eaw84uy9JrStTtDBGq3lYd8O3md-nZObm0H3XdMrJg296meAvXeNFjYsBLSkYmLSRo9Kk87MsHcGod4A' \
--data '{
"dept_code": "SOC",
"course_num": 301,
"section_no": 2,
"academic_year": 2024,
"semester": "FA",
"instructor_id": 1,
"room_num": 205,
"room_capacity": 40,
"course_start_date": "2023-06-12",
"enrollment_start": "2023-06-01 09:00:00",
"enrollment_end": "2024-06-15 17:00:00"
}'

Response

{
    "detail": "Success",
    "inserted_id": 17
}

Update a class

Applies partial modifications to a class. You can update any combinations of these items:

section_no: Optional[int]
instructor_id: Optional[int]
room_num: Optional[int]
room_capacity: Optional[int]
course_start_date: Optional[str]
enrollment_start: Optional[str]
enrollment_end: Optional[str]

Request

curl --location --request PATCH 'http://localhost:5000/api/classes/17' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImFjY2Vzcy10b2tlbi1rZXkifQ.eyJhdWQiOiJrcmFrZW5kLmxvY2FsLmdkIiwiZXhwIjoxNjk4OTcyMzY1LCJmaXJzdF9uYW1lIjoiTmF0aGFuIiwiaXNzIjoiYXV0aC5sb2NhbC5nZCIsImp0aSI6IjIiLCJsYXN0X25hbWUiOiJOZ3V5ZW4iLCJyb2xlcyI6WyJTdHVkZW50IiwiSW5zdHJ1Y3RvciIsIlJlZ2lzdHJhIl0sInN1YiI6Im5hdGhhbiJ9.UGxuGV_E9OccalTtcSOVvrhEQ8o8nM-Yo0Ok2EhwCovy_deQArqP3IY57aE3x4BzcFdCQNmRDCkKAJy9YEJbiqmMDCTi_u7peuzGL9OMoR0HX796ZREl04QUOMSbZ5JT5LpeWm9Ef58xgVwFf0kdlzZ8E7cbGnqPwgLS4yoMa0jTuqW5by5SyRKQWBaNpR337Yfc4g3UQxqnogZUrHy4l1k8mffke_R5ztOghkKephUuTV1uwensXbtxxtJnI-Nzi05EC2eaw84uy9JrStTtDBGq3lYd8O3md-nZObm0H3XdMrJg296meAvXeNFjYsBLSkYmLSRo9Kk87MsHcGod4A' \
--data '{
    "instructor_id": 7,
    "section_no":3,
    "room_num": 22,
    "semester": "FA"
}'

Response

{
    "message": "Item updated successfully"
}

Delete a class

Request

curl --location --request DELETE 'http://localhost:5000/api/classes/17' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImFjY2Vzcy10b2tlbi1rZXkifQ.eyJhdWQiOiJrcmFrZW5kLmxvY2FsLmdkIiwiZXhwIjoxNjk4OTcyMzY1LCJmaXJzdF9uYW1lIjoiTmF0aGFuIiwiaXNzIjoiYXV0aC5sb2NhbC5nZCIsImp0aSI6IjIiLCJsYXN0X25hbWUiOiJOZ3V5ZW4iLCJyb2xlcyI6WyJTdHVkZW50IiwiSW5zdHJ1Y3RvciIsIlJlZ2lzdHJhIl0sInN1YiI6Im5hdGhhbiJ9.UGxuGV_E9OccalTtcSOVvrhEQ8o8nM-Yo0Ok2EhwCovy_deQArqP3IY57aE3x4BzcFdCQNmRDCkKAJy9YEJbiqmMDCTi_u7peuzGL9OMoR0HX796ZREl04QUOMSbZ5JT5LpeWm9Ef58xgVwFf0kdlzZ8E7cbGnqPwgLS4yoMa0jTuqW5by5SyRKQWBaNpR337Yfc4g3UQxqnogZUrHy4l1k8mffke_R5ztOghkKephUuTV1uwensXbtxxtJnI-Nzi05EC2eaw84uy9JrStTtDBGq3lYd8O3md-nZObm0H3XdMrJg296meAvXeNFjYsBLSkYmLSRo9Kk87MsHcGod4A'

Response

{
    "detail": "Item deleted successfully"
}