package
0.0.0-20241113013825-d1b96a2b6c10
Repository: https://github.com/renorris/openfsd.git
Documentation: pkg.go.dev

# README

openfsd REST Specification /api/v1

User Management:

Object types:

User Ratings:

RatingValue
Inactive-1
Suspended0
Observer1
Student 12
Student 23
Student 34
Controller 15
Controller 26
Controller 37
Instructor 18
Instructor 29
Instructor 310
Supervisor11
Administrator12

Pilot Ratings:

RatingValue
Basic Member0
Private Pilot License1
Instrument Rating3
Commercial Multi-Engine License7
Airline Transport Pilot License15
Flight Instructor31
Flight Examiner63

User Record:

FieldTypeDescription
cidintegerCertificate ID
emailstringEmail
first_namestringFirst name
last_namestringLast name
passwordstringPrimary account password
fsd_passwordstringFSD password (a precaution as FSD is plaintext.)
network_ratingintegerNetwork (Controller) Rating
pilot_ratingintegerPilot Rating
updated_atintegerLast modified time (epoch seconds)
created_atintegerCreation time (epoch seconds)

Methods:

The client must send a valid token in the Authorization header when making requests:

Authorization: Bearer <token>

Response value

All /api/v1/users calls returning status 200 provide an application/json response body:

{
  "msg": <response status message>,
  "user": <user record of concern>
}

Error Response Codes

Error codes for user API calls are as follows:

CodeDescription
400Bad request
401Invalid authorization
403Insufficient permission
500Server error

POST /api/v1/users

Create a user record

JSON Parameters:

FieldTypeDescription
userUser RecordUser Record to create (cid omitted. It is automatically assigned.)

Returns:

CodeDescription
200Success

Example:

POST /api/v1/users
{
    user: {
        password: "12345",
        rating: 1,
        ... rest of params
    }
}

GET /api/v1/users/{cid}

Fetch a user record

Path Request Parameter:

FieldTypeDescription
cidintegerCID to query

Returns:

CodeDescription
200Success
404User not found

JSON Response Payload:

FieldTypeDescription
userUser Recordreturned user record

Example:

GET /api/v1/users/100000

{
    user: {
        cid: 100000,
        rating: 12,
        created_at: "2024-09-22T23:21:05Z"
        ... rest of params
    }
}

PUT /api/v1/users

Update a user record.

All fields must be set as per PUT convention, except for password and fsd_password, which are optional.

JSON Parameters:

FieldTypeDescription
userUser RecordUser record to update

Returns:

CodeDescription
201Success
404CID not found
PUT /api/v1/users

{
    user: {
        cid: 100002, // CID to update
        password: "12345", // New password
        rating: 10, // Changed rating
        ... rest of params (ALL REQUIRED)
    }
}

{
    msg: "success",
    user: {
        ... updated user
    }
}

DELETE /api/v1/users

Delete a user record

JSON Request Parameters:

FieldTypeDescription
cidintegerCID to delete

Returns:

CodeDescription
204Success
404User not found

Example:

DELETE /api/v1/users

Request payload:
{
    "cid": 100002
}