spiral-sdk 0.1.10

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::apps::objects::*;
/// Service implementations authenticate Authorization headers and enforce resource permissions.
#[async_trait]
pub trait AppsApi: Send + Sync + 'static {
    /// Approve the latest request of an installation. Only an Organization owner can approve. The
    /// Application must have a background identity.
    async fn approve_installation(
        &self,
        auth_header: AuthHeader,
        installation_id: String,
    ) -> Result<Installation, CallError<AppsError>>;
    /// Create an active Application in a Project. The service generates the client ID of the
    /// Application. Only a Project administrator can create an Application.
    async fn create_application(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: ApplicationConfiguration,
    ) -> Result<Application, CallError<AppsError>>;
    /// Decide this user authorization. Required installation access must be active before approval.
    /// Return the browser to redirectTo to complete OAuth.
    async fn decide_consent(
        &self,
        auth_header: AuthHeader,
        challenge: String,
        request: ConsentDecision,
    ) -> Result<ConsentRedirect, CallError<AppsError>>;
    /// Permanently delete an Application and uninstall it from every Organization. Only a Project
    /// administrator can delete an Application. When the response is `RegistrationUnavailable`,
    /// send the same request again. Access tokens that were issued before the deletion stay valid
    /// until they expire.
    async fn delete_application(
        &self,
        auth_header: AuthHeader,
        application_id: String,
    ) -> Result<Application, CallError<AppsError>>;
    /// Read an Application. A viewer of the Application's Project can read it.
    async fn get_application(
        &self,
        auth_header: AuthHeader,
        application_id: String,
    ) -> Result<Application, CallError<AppsError>>;
    /// Read the authorization bound to the authenticated first-party user and Organization.
    async fn get_consent_request(
        &self,
        auth_header: AuthHeader,
        challenge: String,
    ) -> Result<ConsentRequest, CallError<AppsError>>;
    /// Requires an installation token. Returns current metadata even when suspended; this does not
    /// grant project access.
    async fn get_current_installation(
        &self,
        auth_header: AuthHeader,
    ) -> Result<InstallationDetails, CallError<AppsError>>;
    /// Requires an Organization member. Shows a public Application, an Application owned by the
    /// Organization, or one already installed there. Does not grant access or permit viewing the
    /// developer's credentials or callbacks.
    async fn get_installable_application(
        &self,
        auth_header: AuthHeader,
        application_id: String,
    ) -> Result<InstallableApplication, CallError<AppsError>>;
    /// Read an installation in your Organization. Any member of the Organization can read it.
    async fn get_installation(
        &self,
        auth_header: AuthHeader,
        installation_id: String,
    ) -> Result<Installation, CallError<AppsError>>;
    /// Read which Applications and MCP clients the users of your Organization can sign in to. Only
    /// an Organization owner can read it.
    async fn get_organization_app_access(
        &self,
        auth_header: AuthHeader,
    ) -> Result<OrganizationAppAccess, CallError<AppsError>>;
    /// Requires an app token obtained with private-key client authentication or a trusted issuer
    /// JWT-bearer exchange. It grants no customer data access.
    async fn get_self(&self, auth_header: AuthHeader) -> Result<Application, CallError<AppsError>>;
    /// Requires an app token. Installations belonging to another app return NotFound.
    async fn get_self_installation(
        &self,
        auth_header: AuthHeader,
        installation_id: String,
    ) -> Result<InstallationDetails, CallError<AppsError>>;
    /// Requires a delegated user token with projects:read and current Organization membership. The
    /// app and Organization come from the credential.
    async fn get_user_installation(
        &self,
        auth_header: AuthHeader,
    ) -> Result<UserInstallation, CallError<AppsError>>;
    /// List the Organizations where your Application is installed. A viewer of the Application's
    /// Project can list them.
    async fn list_application_installations(
        &self,
        auth_header: AuthHeader,
        application_id: String,
        request: ListApplicationsRequest,
    ) -> Result<InstallationPage, CallError<AppsError>>;
    /// List the Applications of a Project. The list includes suspended and deleted Applications. A
    /// Project viewer can list them.
    async fn list_applications(
        &self,
        auth_header: AuthHeader,
        project_id: String,
        request: ListApplicationsRequest,
    ) -> Result<ApplicationPage, CallError<AppsError>>;
    /// Requires an installation token and approved projects:read. Returns only currently authorized
    /// live projects. Pending or inactive grants return no projects.
    async fn list_installation_projects(
        &self,
        auth_header: AuthHeader,
        request: ListApplicationsRequest,
    ) -> Result<InstallationProjectPage, CallError<AppsError>>;
    /// List the installations in your Organization. Any member of the Organization can list them.
    async fn list_installations(
        &self,
        auth_header: AuthHeader,
        request: ListApplicationsRequest,
    ) -> Result<InstallationPage, CallError<AppsError>>;
    /// List the resource scopes that an Application can request. Each scope has a description that
    /// you can show to users.
    async fn list_scopes(
        &self,
        auth_header: AuthHeader,
    ) -> Result<ApplicationScopes, CallError<AppsError>>;
    /// Requires an app token. Includes only this app's requested, active and suspended
    /// installations.
    async fn list_self_installations(
        &self,
        auth_header: AuthHeader,
        request: ListApplicationsRequest,
    ) -> Result<InstallationPage, CallError<AppsError>>;
    /// Requires a delegated user token with projects:read. The installation must belong to its app
    /// and Organization. Returns the intersection of current user and approved installation project
    /// access.
    async fn list_user_installation_projects(
        &self,
        auth_header: AuthHeader,
        installation_id: String,
        request: ListApplicationsRequest,
    ) -> Result<InstallationProjectPage, CallError<AppsError>>;
    /// Replace the configuration of an Application. The Application stays in its Project. Only a
    /// Project administrator can update an Application. When the response is
    /// `RegistrationUnavailable`, the Application does not change; send the same request again.
    async fn put_application(
        &self,
        auth_header: AuthHeader,
        application_id: String,
        request: ApplicationConfiguration,
    ) -> Result<Application, CallError<AppsError>>;
    /// Replace which Applications and MCP clients the users of your Organization can sign in to.
    /// Only an Organization owner can set it. Sign-in and refresh apply the new setting from their
    /// next request.
    async fn put_organization_app_access(
        &self,
        auth_header: AuthHeader,
        request: OrganizationAppAccess,
    ) -> Result<OrganizationAppAccess, CallError<AppsError>>;
    /// Request that an Application be installed in your Organization, or request more scopes or
    /// Projects for an existing installation. Any member of the Organization can send a request.
    /// The scopes must be registered on the Application. Until an owner approves the request, the
    /// installation keeps its earlier approval.
    async fn request_installation(
        &self,
        auth_header: AuthHeader,
        request: InstallationRequest,
    ) -> Result<Installation, CallError<AppsError>>;
    /// Only an Organization owner can approve or decline the displayed request. Returns Conflict if
    /// it changed. Declining an update preserves current access; declining a new installation
    /// removes it. The response describes the reviewed installation.
    async fn review_installation(
        &self,
        auth_header: AuthHeader,
        installation_id: String,
        request: InstallationReview,
    ) -> Result<Installation, CallError<AppsError>>;
    /// Suspend or resume an approved installation. Only an Organization owner can change it. A
    /// suspended installation stops at its next request, even with an unexpired token.
    async fn set_installation_status(
        &self,
        auth_header: AuthHeader,
        installation_id: String,
        request: InstallationStatusChange,
    ) -> Result<Installation, CallError<AppsError>>;
    /// Remove an installation and all of its access. Only an Organization owner can uninstall.
    /// Tokens that were already issued stop working at their next request.
    async fn uninstall(
        &self,
        auth_header: AuthHeader,
        installation_id: String,
    ) -> Result<Installation, CallError<AppsError>>;
}