User Permission

DearDiary.get_userpermissionFunction
get_userpermission(user_id::Integer, project_id::Integer)::Optional{UserPermission}

Get a UserPermission by User id and Project IDs.

Arguments

  • user_id::Integer: The id of the user.
  • project_id::Integer: The id of the project.

Returns

A UserPermission object. If the record does not exist, return nothing.

source
get_userpermission(client::Client, user_id::Integer, project_id::Integer)::Optional{UserPermission}

Fetch the UserPermission row tying user_id to project_id via GET /userpermission/user/{user_id}/project/{project_id}. Returns nothing when the server replies 404 and raises ClientError for other failures. Admin-only route.

source
DearDiary.get_userpermissionsFunction
get_userpermissions(::Type{<:Project}, project_id::Integer)::Array{UserPermission,1}

List every UserPermission record granting access to the given Project.

Arguments

  • ::Type{<:Project}: Dispatch tag selecting the project-scoped listing.
  • project_id::Integer: The project whose members are being listed.

Returns

An array of UserPermission records (possibly empty).

source
get_userpermissions(::Type{<:User}, user_id::Integer)::Array{UserPermission,1}

List every UserPermission record held by the given User.

Arguments

  • ::Type{<:User}: Dispatch tag selecting the user-scoped listing.
  • user_id::Integer: The user whose project memberships are being listed.

Returns

An array of UserPermission records (possibly empty).

source
get_userpermissions(client::Client, ::Type{User}, user_id::Integer)::Array{UserPermission,1}

List every UserPermission that grants user_id access to some project, via GET /user/{user_id}/permissions. The viewer must be user_id or an admin.

source
get_userpermissions(client::Client, ::Type{Project}, project_id::Integer)::Array{UserPermission,1}

List every UserPermission row granting access to project_id, via GET /project/{project_id}/members. Requires ReadPermission on the project.

source
DearDiary.create_userpermissionFunction
create_userpermission(user_id::Integer, project_id::Integer, create_permission::Bool, read_permission::Bool, update_permission::Bool, delete_permission::Bool)::NamedTuple{id::Optional{<:Int64},status::DataType}

Create a UserPermission.

Arguments

  • user_id::Integer: The id of the user.
  • project_id::Integer: The id of the project.
  • create_permission::Bool: Whether the user has create permission.
  • read_permission::Bool: Whether the user has read permission.
  • update_permission::Bool: Whether the user has update permission.
  • delete_permission::Bool: Whether the user has delete permission.

Returns

  • The created userpermission 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_userpermission(client::Client, user_id, project_id, create, read, update, delete)::Int64

Insert a UserPermission row via POST /userpermission/user/{user_id}/project/{project_id}. Admin-only. Returns the new permission id.

source
DearDiary.update_userpermissionFunction
update_userpermission(id::Integer, create_permission::Optional{Bool}, read_permission::Optional{Bool}, update_permission::Optional{Bool}, delete_permission::Optional{Bool})::Type{<:UpsertResult}

Update a UserPermission.

Arguments

  • id::Integer: The id of the user permission to update.
  • create_permission::Optional{Bool}: The new create permission.
  • read_permission::Optional{Bool}: The new read permission.
  • update_permission::Optional{Bool}: The new update permission.
  • delete_permission::Optional{Bool}: The new delete permission.

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_userpermission(client::Client, id::Integer; create_permission=nothing, read_permission=nothing, update_permission=nothing, delete_permission=nothing)::Nothing

Patch a UserPermission row via PATCH /userpermission/{id}. Any keyword left as nothing is left untouched server-side. Admin-only.

source
DearDiary.delete_userpermissionFunction
delete_userpermission(id::Integer)::Bool

Delete a UserPermission.

Arguments

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

Returns

true if the record was successfully deleted, false otherwise.

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

Delete a UserPermission row via DELETE /userpermission/{id}. Admin-only. Raises ClientError on failure.

source
DearDiary.has_permissionFunction
has_permission(permission::UserPermission, ::Type{<:PermissionAction})::Bool

Return whether permission grants the given PermissionAction on its Project.

Arguments

  • permission::UserPermission: The user permission record.
  • ::Type{<:PermissionAction}: The CRUD action being requested, passed as a type tag.

Returns

true if the action is allowed by the permission, false otherwise.

source