videosdk-server-sdk 0.1.0

Rust server SDK for the VideoSDK v2 REST APIs
Documentation
//! Rust server SDK for the [VideoSDK](https://videosdk.live) v2 REST APIs.
//!
//! # Getting started
//!
//! Construct a [`Client`] from your project credentials. It reads
//! `VIDEOSDK_API_KEY` and `VIDEOSDK_SECRET` from the environment when they are
//! not passed explicitly.
//!
//! ```no_run
//! # #[tokio::main]
//! # async fn main() -> Result<(), videosdk::Error> {
//! let client = videosdk::Client::builder()
//!     .api_key("my-key")
//!     .secret("my-secret")
//!     .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! # Authentication
//!
//! The client mints a short-lived HS256 JWT from your key and secret, attaches
//! it to every request, and refreshes it before it expires. Signing happens
//! locally — nothing is sent anywhere to authenticate. You never construct a
//! token or set a header yourself.
//!
//! To mint a token for a *participant* — to hand to a client-side SDK — use
//! [`Client::access_token`]:
//!
//! ```no_run
//! # use videosdk::Grant;
//! # use std::time::Duration;
//! # fn main() -> Result<(), videosdk::Error> {
//! # let client = videosdk::Client::new()?;
//! let token = client
//!     .access_token()?
//!     .set_participant("participant-1")
//!     .grant(Grant::AllowJoin)
//!     .for_room("room-1")
//!     .expires_in(Duration::from_secs(2 * 60 * 60))
//!     .to_jwt()?;
//! # Ok(())
//! # }
//! ```
//!
//! # Optional parameters
//!
//! Request parameters are plain structs whose optional fields are `Option<T>`.
//! Build them with struct-update syntax:
//!
//! ```ignore
//! let params = ListRoomsParams {
//!     page: Some(2),
//!     ..Default::default()
//! };
//! ```
//!
//! # Errors
//!
//! Every call returns [`Result<T>`]. Match on [`Error`], or use the predicates:
//!
//! ```no_run
//! # async fn f(client: &videosdk::Client) {
//! # let result: videosdk::Result<serde_json::Value> = Err(videosdk::Error::Validation("x".into()));
//! match result {
//!     Ok(room) => println!("{room}"),
//!     Err(err) if err.is_not_found() => println!("no such room"),
//!     Err(err) => eprintln!("failed: {err}"),
//! }
//! # }
//! ```
//!
//! # Retries
//!
//! Requests are retried up to [`ClientBuilder::max_retries`] times (2 by
//! default) with exponential backoff and jitter. A 429 is always retried, and
//! honors the server's `Retry-After`. Network errors, timeouts and 5xx
//! responses are retried only for idempotent methods, so a `POST` is never
//! replayed.
//!
//! # Pagination
//!
//! List endpoints return a [`Page`]. Walk it by hand with [`Page::next_page`],
//! or stream every item across every page with [`Page::into_stream`].

#![warn(missing_docs)]
#![warn(clippy::all)]
#![forbid(unsafe_code)]

mod builder;
mod client;
mod common;
mod error;
mod pagination;
mod query;
mod resources;
mod token;

#[cfg(test)]
mod decode_tests;
#[cfg(test)]
mod http_tests;
#[cfg(test)]
mod test_support;

pub use builder::{ClientBuilder, TokenOptions};
pub use client::{Api, Client, Expect, RawRequest, DEFAULT_BASE_URL, VERSION};
pub use common::{
    CompositionConfig, CompositionQuality, LayoutConfig, LayoutPriority, LayoutType,
    MessageResponse, OnFailureConfig, Orientation, ParticipantFileFormat, RecordingFile,
    RecordingFileFormat, Region, ResourceLinks, SummaryConfig, Theme, TrackFileFormat, TrackKind,
    TranscriptionConfig, WebhookDelivery, WebhookDeliverySummary,
};
pub use error::{ApiError, Error, ErrorKind, Result};
pub use pagination::{ListParams, Page, PageInfo};
pub use token::{
    decode_token, generate_token, parse_expires_in, verify_token, AccessTokenBuilder,
    GenerateTokenParams, Grant, TokenClaims, DEFAULT_TOKEN_TTL,
};

pub use resources::agents::{
    AgentComputeProfile, AgentDeployment, AgentDeploymentResource, AgentDeploymentVersion,
    AgentImage, AgentInitConfig, AgentLogEntry, AgentRoomOptions, AgentScaling, AgentsResource,
    DeployAgentParams, DeployImage, DeployedAgent, DispatchAgentParams, DispatchResult,
    GeneralDispatchAgentParams, ListDeploymentLogsParams, ListDeploymentsParams,
};
pub use resources::alert_rules::{
    AbsentDataAlert, AlertConditionOperator, AlertDomain, AlertMatchType, AlertReduceTo, AlertRule,
    AlertRuleCondition, AlertRuleConfig, AlertRuleEvaluation, AlertRuleFilter, AlertRuleGroupBy,
    AlertRuleHaving, AlertRuleQuery, AlertRuleStatus, AlertRulesResource, AlertSeverity,
    CreateAlertRuleParams, ListAlertRulesParams, UpdateAlertRuleParams,
};
pub use resources::batch_calls::{
    BatchCall, BatchCallCancelMode, BatchCallRecord, BatchCallRecordsResource,
    BatchCallRetryConfig, BatchCallRetryStatus, BatchCallStats, BatchCallStatus, BatchCallTiming,
    BatchCallWebhookConfig, BatchCallWebhookEvent, BatchCallsResource, CreateBatchCallParams,
    DeleteRecordsResult, ExportBatchCallRecordsParams, ListBatchCallRecordsParams,
    ListBatchCallsParams, UpdateBatchCallParams, UpdateBatchCallRecordParams,
    UploadBatchCallParams,
};
pub use resources::connectors::{
    Connector, ConnectorProvider, ConnectorsResource, CreateConnectorParams,
};
pub use resources::egress::{Composition, CompositionLayout, EgressHandle, EgressType, StopTarget};
pub use resources::hls::{
    HlsCaptureFormat, HlsCaptureParams, HlsCaptureResult, HlsListParams, HlsResource,
    HlsStartParams, HlsStream,
};
pub use resources::ingress::{
    CreateSocketIngressParams, CreateWhepParams, CreateWhipParams, SocketIngress,
    SocketIngressAgent, SocketIngressResource, WhepPlayback, WhepResource, WhepSource, WhipIngress,
    WhipResource,
};
pub use resources::participants::ParticipantsResource;
pub use resources::recordings::{
    CompositeParticipantSelector, CompositeRecording, CompositeRecordingListParams,
    CompositeRecordingStartParams, CompositeWatermark, IndividualRecording,
    IndividualRecordingListParams, MergeChannel, MergeChannelEntry, MergeRecording,
    MergeRecordingCreateParams, MergeRecordingListParams, MergeRecordingResource,
    MergeRecordingResult, ParticipantRecordingStartParams, Recording, RecordingCompositeResource,
    RecordingGetParams, RecordingListParams, RecordingParticipantResource, RecordingStartParams,
    RecordingTrackResource, RecordingsResource, TrackRecordingStartParams,
};
pub use resources::resource_pool::{
    AcquireResourceParams, ComposerType, ListResourcesParams, ReleaseResourceResult, ResourceMode,
    ResourcePoolResource, ResourceQuality, ResourceStatus, ResourceUnit,
};
pub use resources::rooms::{
    AutoCloseConfig, AutoCloseConfigInput, AutoCloseType, AutoStartConfig, MultiComposition, Room,
    RoomCreateParams, RoomListParams, RoomValidation, RoomWebhook, RoomWebhookInput, RoomsResource,
};
pub use resources::rtmp::{Livestream, RtmpListParams, RtmpResource, RtmpStartParams, RtmpStream};
pub use resources::sessions::{
    Participant, ParticipantTimelog, QualityStats, Session, SessionEndParams, SessionListParams,
    SessionRemoveParticipantParams, SessionStatus, SessionsResource,
};
pub use resources::sip::{
    CreateInboundTrunkParams, CreateOutboundTrunkParams, CreatePhoneNumbersParams,
    CreateRoutingRuleParams, CreateSipCallParams, CreateSipWebhookParams, InboundTrunkResource,
    OutboundTrunkResource, PhoneNumberInboundConfig, PhoneNumberInfo, PhoneNumberListParams,
    PhoneNumberOutboundConfig, PhoneNumberWithGateways, PhoneNumbersResource, RoutingRuleTarget,
    SipAuth, SipCall, SipCallListParams, SipCallStatus, SipCallsResource, SipDirection,
    SipIncludeHeaders, SipMediaEncryption, SipRegion, SipResource, SipRoomConfig, SipRoomPrefix,
    SipRoomType, SipRoutingRule, SipRoutingRuleListParams, SipRoutingRulesResource, SipTransport,
    SipTrunk, SipTrunkListParams, SipTrunksResource, SipWebhook, SipWebhookEvent,
    SipWebhookListParams, SipWebhooksResource, SwitchRoomParams, TransferSipCallParams,
    UpdateInboundTrunkParams, UpdateOutboundTrunkParams, UpdatePhoneNumberGatewayParams,
    UpdateRoutingRuleParams,
};
pub use resources::transcodings::{
    HlsToMp4Params, ListTranscodingsParams, MeetingRecordingMergeParams, MeetingRecordingRef,
    MergeTranscodingParams, Transcoding, TranscodingFile, TranscodingStatus, TranscodingStorage,
    TranscodingTask, TranscodingWatermark, TranscodingsResource,
};
pub use resources::transcription::{
    ListRealtimeTranscriptionsParams, RealtimeSummaryConfig, RealtimeTranscription,
    RealtimeTranscriptionExtension, RealtimeTranscriptionExtensionConfig,
    RealtimeTranscriptionResource, StartRealtimeTranscriptionParams, TranscriptionResource,
};

// Re-exported so callers can name the types used by the escape hatch without
// depending on the exact `reqwest` and `serde_json` versions themselves.
pub use reqwest::Method;
pub use serde_json::Value;