User

DearDiary.get_userFunction
get_user(username::AbstractString)::Optional{User}

Get an User by username.

Arguments

  • username::AbstractString: The username of the user to query.

Returns

An User object. If the record does not exist, return nothing.

source
get_user(id::Integer)::Optional{User}

Get an User by id.

Arguments

  • id::Integer: The id of the user to query.

Returns

An User object. If the record does not exist, return nothing.

source
get_user(client::Client, id::Integer)::Optional{UserResponse}

Fetch a User (sanitized as UserResponse, no password hash) via GET /user/{id}. Returns nothing when the server replies 404 and raises ClientError for other failures. The viewer must be id or an admin.

The username-based local overload (get_user(name)) has no REST counterpart; iterate get_users and filter when a username lookup is required.

source
DearDiary.get_usersFunction
get_users()::Array{User, 1}

Get all User.

Returns

An array of User objects.

source
get_users(client::Client)::Array{UserResponse,1}

List every user via GET /user/. Admin-only route; the returned UserResponse values never include password hashes.

source
DearDiary.create_userFunction
create_user(first_name::AbstractString, last_name::AbstractString, username::AbstractString, password::AbstractString)::NamedTuple{id::Optional{<:Int64},status::DataType}

Create an User.

Arguments

  • first_name::AbstractString: The first name of the user.
  • last_name::AbstractString: The last name of the user.
  • username::AbstractString: The username of the user.
  • password::AbstractString: The password of the user.

Returns

  • The created user ID. If an error occurs, nothing is returned.
  • An UpsertResult. Created if the record was successfully created, Duplicate if the record already exists, Unprocessable if the record violates a constraint, and Error if an error occurred while creating the record.
source
create_user(client::Client, first_name, last_name, username, password)::Int64

Create a User via POST /user/. Admin-only. Returns the new user id. Raises ClientError with code "CONFLICT" when username is already taken.

source
DearDiary.update_userFunction
update_user(id::Integer, first_name::Optional{AbstractString}, last_name::Optional{AbstractString}, password::Optional{AbstractString}, is_admin::Optional{Bool})::Type{<:UpsertResult}

Update an User.

Arguments

  • id::Integer: The id of the user to update.
  • first_name::Optional{AbstractString}: The new first name of the user.
  • last_name::Optional{AbstractString}: The new last name of the user.
  • password::Optional{AbstractString}: The new password of the user.
  • is_admin::Optional{Bool}: The new admin status of the user.

Returns

An UpsertResult. Updated if the record was successfully updated (or no fields were changed), Unprocessable if the record violates a constraint or if no fields were provided to update, and Error if an error occurred while updating the record.

source
update_user(client::Client, id::Integer; first_name=nothing, last_name=nothing, password=nothing, is_admin=nothing)::Nothing

Patch a User via PATCH /user/{id}. Any keyword left as nothing is left untouched server-side. The viewer must be id or an admin.

source
DearDiary.delete_userFunction
delete_user(id::Integer)::Bool

Delete an User. Also deletes all associated UserPermission.

Arguments

  • id::Integer: The id of the user to delete.

Returns

true if the record was successfully deleted, false otherwise.

source
delete_user(client::Client, id::Integer)::Nothing

Delete a User via DELETE /user/{id}. The viewer must be id or an admin; the seeded default user cannot be removed (the server raises a SQLite trigger).

source