spiral-sdk 0.1.11

Rust SDK for Spiral resource and table APIs
Documentation
// Generated by tools/service-contracts/rust.py. Do not edit.
#![doc = "Transport-independent service interface for local and remote calls."]

use async_trait::async_trait;
use spiral_contract::auth::AuthHeader;
use spiral_contract::call::CallError;

use crate::api::organization::objects::*;
/// Service implementations authenticate Authorization headers and enforce resource permissions.
#[async_trait]
pub trait OrganizationApi: Send + Sync + 'static {
    /// Create an Organization for the authenticated user. Existing Organization membership prevents
    /// creating another.
    async fn create_organization(
        &self,
        auth_header: AuthHeader,
        request: CreateOrganizationRequest,
    ) -> Result<CreateOrganizationResponse, CallError<OrganizationError>>;
    /// Open an account administration setting with Organization configure permission.
    async fn create_portal_link(
        &self,
        auth_header: AuthHeader,
        request: PortalLinkRequest,
    ) -> Result<PortalLink, CallError<OrganizationError>>;
    /// Deactivate a membership with manage-users permission. The last owner cannot be deactivated.
    async fn deactivate_member(
        &self,
        auth_header: AuthHeader,
        user_id: String,
    ) -> Result<(), CallError<OrganizationError>>;
    /// Deactivate an Organization with platform administer permission.
    async fn deactivate_organization(
        &self,
        auth_header: AuthHeader,
        organization_id: String,
    ) -> Result<(), CallError<OrganizationError>>;
    /// Invite a user to the active Organization with invite permission.
    async fn invite_member(
        &self,
        auth_header: AuthHeader,
        request: InviteMemberRequest,
    ) -> Result<InvitationResponse, CallError<OrganizationError>>;
    /// List the active Organization invitations with invite permission. Page size defaults to 10
    /// and must be 1..=100.
    async fn list_invitations(
        &self,
        auth_header: AuthHeader,
        request: ListMembersRequest,
    ) -> Result<InvitationPage, CallError<OrganizationError>>;
    /// List the active Organization members with list-users permission. Each page reauthorizes the
    /// caller.
    async fn list_members(
        &self,
        auth_header: AuthHeader,
        request: ListMembersRequest,
    ) -> Result<MemberPage, CallError<OrganizationError>>;
    /// List the authenticated user memberships in ascending Organization ID order. Requires a
    /// first-party user credential.
    async fn list_memberships(
        &self,
        auth_header: AuthHeader,
        request: ListMembershipsRequest,
    ) -> Result<MembershipPage, CallError<OrganizationError>>;
    /// List Organization records in ascending ID order with platform administer permission.
    async fn list_organizations(
        &self,
        auth_header: AuthHeader,
        request: ListOrganizationsRequest,
    ) -> Result<OrganizationPage, CallError<OrganizationError>>;
    /// Reactivate an Organization with platform administer permission.
    async fn reactivate_organization(
        &self,
        auth_header: AuthHeader,
        organization_id: String,
    ) -> Result<(), CallError<OrganizationError>>;
    /// Read the active Organization storage default with Organization configure permission.
    async fn read_config(
        &self,
        auth_header: AuthHeader,
    ) -> Result<OrganizationConfig, CallError<OrganizationError>>;
    /// Read the authenticated user identity and active Organization. Workload, service and
    /// delegated credentials are refused.
    async fn read_identity(
        &self,
        auth_header: AuthHeader,
    ) -> Result<Identity, CallError<OrganizationError>>;
    /// Resend an invitation owned by the active Organization with invite permission.
    async fn resend_invitation(
        &self,
        auth_header: AuthHeader,
        invitation_id: String,
    ) -> Result<InvitationResponse, CallError<OrganizationError>>;
    /// Revoke an invitation owned by the active Organization with invite permission.
    async fn revoke_invitation(
        &self,
        auth_header: AuthHeader,
        invitation_id: String,
    ) -> Result<(), CallError<OrganizationError>>;
    /// Set a member role with manage-users permission. The last owner cannot be demoted.
    async fn set_member_role(
        &self,
        auth_header: AuthHeader,
        user_id: String,
        request: SetMemberRoleRequest,
    ) -> Result<(), CallError<OrganizationError>>;
    /// Synchronize one provider page of memberships for the specified Organization with platform
    /// administer permission. Only active memberships are stored; an empty result can still have a
    /// continuation. Page size defaults to 10 and must be 1..=100.
    async fn sync_memberships(
        &self,
        auth_header: AuthHeader,
        organization_id: String,
        request: ListMembersRequest,
    ) -> Result<MembershipPage, CallError<OrganizationError>>;
    /// Synchronize one live provider page with platform administer permission. Page size defaults
    /// to 10 and must be 1..=100. Repeat with the continuation until absent.
    async fn sync_organizations(
        &self,
        auth_header: AuthHeader,
        request: ListMembersRequest,
    ) -> Result<OrganizationIdPage, CallError<OrganizationError>>;
    /// Set the active Organization storage default with Organization configure permission.
    /// Plaintext storage keys are vaulted before persistence.
    async fn write_config(
        &self,
        auth_header: AuthHeader,
        request: OrganizationConfig,
    ) -> Result<OrganizationConfig, CallError<OrganizationError>>;
}