User Permission
DearDiary.get_userpermission — Function
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.
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.
DearDiary.get_userpermissions — Function
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).
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).
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.
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.
DearDiary.create_userpermission — Function
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,
nothingis returned. - An
UpsertResult.Createdif the record was successfully created,Duplicateif the record already exists,Unprocessableif the record violates a constraint, andErrorif an error occurred while creating the record.
create_userpermission(client::Client, user_id, project_id, create, read, update, delete)::Int64Insert a UserPermission row via POST /userpermission/user/{user_id}/project/{project_id}. Admin-only. Returns the new permission id.
DearDiary.update_userpermission — Function
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.
update_userpermission(client::Client, id::Integer; create_permission=nothing, read_permission=nothing, update_permission=nothing, delete_permission=nothing)::NothingPatch a UserPermission row via PATCH /userpermission/{id}. Any keyword left as nothing is left untouched server-side. Admin-only.
DearDiary.delete_userpermission — Function
delete_userpermission(id::Integer)::BoolDelete a UserPermission.
Arguments
id::Integer: The id of the user permission to delete.
Returns
true if the record was successfully deleted, false otherwise.
delete_userpermission(client::Client, id::Integer)::NothingDelete a UserPermission row via DELETE /userpermission/{id}. Admin-only. Raises ClientError on failure.
DearDiary.has_permission — Function
has_permission(permission::UserPermission, ::Type{<:PermissionAction})::BoolReturn 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.