Skip to main content

OrganizationApi

Struct OrganizationApi 

Source
pub struct OrganizationApi<'a, A> { /* private fields */ }
Expand description

Calls the organization endpoints without HTTP.

create, add_member, has_permission and invitations_for_email act for the server and need no session. Every other method calls the route of the same name as the session in headers (their cookies, or whatever a session resolver reads), and answers what the route would, plus the cookies it sets.

Implementations§

Source§

impl<A: AuthInstance> OrganizationApi<'_, A>

Source

pub fn roles(&self) -> &Roles

The configured roles.

Source

pub async fn create( &self, user_id: &Id, input: CreateOrganizationInput, ) -> Result<OrganizationWithMembers, AuthError>

Creates an organization owned by user_id (which replaces input.user_id). Ignores allow_user_to_create_organization, but not organization_limit. Runs hooks on CreateOrganization and emits OrganizationCreated and MemberAdded.

Source

pub async fn add_member( &self, organization_id: &Id, user_id: &Id, role: &str, ) -> Result<Member, AuthError>

Adds a user to an organization without an invitation. role is one role or a comma-separated list; each must exist. Runs hooks on AddMember and emits MemberAdded.

Source

pub async fn has_permission( &self, organization_id: &Id, user_id: &Id, permissions: &[(&str, &[&str])], ) -> Result<bool, AuthError>

Whether the user’s role in the organization grants permissions; false when they aren’t a member.

Source

pub async fn invitations_for_email( &self, email: &str, ) -> Result<Vec<InvitationWithOrganization>, AuthError>

Pending invitations addressed to email, with their organizations’ names.

Source§

impl<A: AuthInstance> OrganizationApi<'_, A>

Source

pub async fn create_as( &self, headers: &HeaderMap, input: CreateOrganizationInput, ) -> Result<ApiResponse<OrganizationWithMembers>, AuthError>

POST /organization/create as the session in headers.

Source

pub async fn update( &self, headers: &HeaderMap, input: UpdateOrganizationInput, ) -> Result<ApiResponse<OrganizationRow>, AuthError>

POST /organization/update as the session in headers.

Source

pub async fn delete( &self, headers: &HeaderMap, input: DeleteOrganizationInput, ) -> Result<ApiResponse<OrganizationRow>, AuthError>

POST /organization/delete as the session in headers.

Source

pub async fn list( &self, headers: &HeaderMap, input: Empty, ) -> Result<ApiResponse<Vec<OrganizationRow>>, AuthError>

GET /organization/list as the session in headers.

Source

pub async fn get_full( &self, headers: &HeaderMap, input: GetFullOrganizationQuery, ) -> Result<ApiResponse<Option<FullOrganization>>, AuthError>

GET /organization/get-full-organization as the session in headers.

Source

pub async fn set_active( &self, headers: &HeaderMap, input: SetActiveOrganizationInput, ) -> Result<ApiResponse<Option<OrganizationRow>>, AuthError>

POST /organization/set-active as the session in headers.

Source

pub async fn check_slug( &self, headers: &HeaderMap, input: CheckSlugInput, ) -> Result<ApiResponse<Status>, AuthError>

POST /organization/check-slug as the session in headers.

Source

pub async fn invite_member( &self, headers: &HeaderMap, input: InviteMemberInput, ) -> Result<ApiResponse<Invitation>, AuthError>

POST /organization/invite-member as the session in headers.

Source

pub async fn accept_invitation( &self, headers: &HeaderMap, input: InvitationIdInput, ) -> Result<ApiResponse<InvitationResponse>, AuthError>

POST /organization/accept-invitation as the session in headers.

Source

pub async fn reject_invitation( &self, headers: &HeaderMap, input: InvitationIdInput, ) -> Result<ApiResponse<InvitationResponse>, AuthError>

POST /organization/reject-invitation as the session in headers.

Source

pub async fn cancel_invitation( &self, headers: &HeaderMap, input: InvitationIdInput, ) -> Result<ApiResponse<Invitation>, AuthError>

POST /organization/cancel-invitation as the session in headers.

Source

pub async fn get_invitation( &self, headers: &HeaderMap, input: InvitationIdQuery, ) -> Result<ApiResponse<InvitationDetails>, AuthError>

GET /organization/get-invitation as the session in headers.

Source

pub async fn list_invitations( &self, headers: &HeaderMap, input: OrganizationIdQuery, ) -> Result<ApiResponse<Vec<Invitation>>, AuthError>

GET /organization/list-invitations as the session in headers.

Source

pub async fn list_user_invitations( &self, headers: &HeaderMap, input: Empty, ) -> Result<ApiResponse<Vec<InvitationWithOrganization>>, AuthError>

GET /organization/list-user-invitations as the session in headers.

Source

pub async fn remove_member( &self, headers: &HeaderMap, input: RemoveMemberInput, ) -> Result<ApiResponse<RemoveMemberOutput>, AuthError>

POST /organization/remove-member as the session in headers.

Source

pub async fn update_member_role( &self, headers: &HeaderMap, input: UpdateMemberRoleInput, ) -> Result<ApiResponse<Member>, AuthError>

POST /organization/update-member-role as the session in headers.

Source

pub async fn leave( &self, headers: &HeaderMap, input: LeaveOrganizationInput, ) -> Result<ApiResponse<Member>, AuthError>

POST /organization/leave as the session in headers.

Source

pub async fn get_active_member( &self, headers: &HeaderMap, input: Empty, ) -> Result<ApiResponse<MemberWithUser>, AuthError>

GET /organization/get-active-member as the session in headers.

Source

pub async fn list_members( &self, headers: &HeaderMap, input: ListMembersQuery, ) -> Result<ApiResponse<ListMembersOutput>, AuthError>

GET /organization/list-members as the session in headers.

Source

pub async fn check_permission( &self, headers: &HeaderMap, input: HasPermissionInput, ) -> Result<ApiResponse<HasPermissionOutput>, AuthError>

POST /organization/has-permission as the session in headers.

Auto Trait Implementations§

§

impl<'a, A> Forget for OrganizationApi<'a, A>

§

impl<'a, A> Freeze for OrganizationApi<'a, A>
where &'a A: Freeze,

§

impl<'a, A> Move for OrganizationApi<'a, A>

§

impl<'a, A> RefUnwindSafe for OrganizationApi<'a, A>

§

impl<'a, A> Send for OrganizationApi<'a, A>
where &'a A: Send,

§

impl<'a, A> Sync for OrganizationApi<'a, A>
where &'a A: Sync,

§

impl<'a, A> Unpin for OrganizationApi<'a, A>
where &'a A: Unpin,

§

impl<'a, A> UnsafeUnpin for OrganizationApi<'a, A>

§

impl<'a, A> UnwindSafe for OrganizationApi<'a, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more