files_sdk/
lib.rs

1//! Files.com Rust SDK
2//!
3//! A comprehensive Rust client for the [Files.com](https://files.com) REST API, providing full access to
4//! file operations, user management, sharing, automation, and administrative features.
5//!
6//! ## Features
7//!
8//! - **File Operations**: Upload, download, copy, move, delete files and folders
9//! - **User & Access Management**: Users, groups, permissions, API keys, sessions
10//! - **Sharing**: Bundles (share links), file requests, inbox uploads
11//! - **Automation**: Webhooks, behaviors, remote servers, automations
12//! - **Administration**: Site settings, history, notifications, billing
13//!
14//! ## Quick Start
15//!
16//! ```rust,no_run
17//! use files_sdk::{FilesClient, files::FileHandler};
18//!
19//! #[tokio::main]
20//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
21//!     // Create client with API key
22//!     let client = FilesClient::builder()
23//!         .api_key("your-api-key")
24//!         .build()?;
25//!
26//!     // Use handlers for typed operations
27//!     let file_handler = FileHandler::new(client.clone());
28//!
29//!     // Upload a file
30//!     let data = b"Hello, Files.com!";
31//!     file_handler.upload_file("/path/to/file.txt", data).await?;
32//!
33//!     Ok(())
34//! }
35//! ```
36//!
37//! ## Core Usage Patterns
38//!
39//! ### Client Creation
40//!
41//! The client uses a builder pattern for flexible configuration:
42//!
43//! ```rust,no_run
44//! use files_sdk::FilesClient;
45//!
46//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
47//! // Basic client with default settings
48//! let client = FilesClient::builder()
49//!     .api_key("your-api-key")
50//!     .build()?;
51//!
52//! // Custom configuration
53//! let client = FilesClient::builder()
54//!     .api_key("your-api-key")
55//!     .base_url("https://app.files.com/api/rest/v1".to_string())
56//!     .timeout(std::time::Duration::from_secs(60))
57//!     .build()?;
58//! # Ok(())
59//! # }
60//! ```
61//!
62//! ### File Upload (Two-Stage Process)
63//!
64//! Files.com uses a two-stage upload process:
65//!
66//! ```rust,no_run
67//! use files_sdk::{FilesClient, files::{FileActionHandler, FileHandler}};
68//!
69//! # #[tokio::main]
70//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
71//! let client = FilesClient::builder()
72//!     .api_key("your-api-key")
73//!     .build()?;
74//!
75//! // Stage 1: Begin upload to get upload URLs
76//! let file_action = FileActionHandler::new(client.clone());
77//! let upload_info = file_action
78//!     .begin_upload("/uploads/myfile.txt", Some(1024), true)
79//!     .await?;
80//!
81//! // Stage 2: Upload file data (simplified - see FileHandler for complete implementation)
82//! let file_handler = FileHandler::new(client.clone());
83//! let data = b"file contents";
84//! file_handler.upload_file("/uploads/myfile.txt", data).await?;
85//! # Ok(())
86//! # }
87//! ```
88//!
89//! ## Error Handling
90//!
91//! The SDK provides comprehensive error handling:
92//!
93//! ```rust,no_run
94//! use files_sdk::{FilesClient, FilesError, files::FileHandler};
95//!
96//! # #[tokio::main]
97//! # async fn main() {
98//! let client = FilesClient::builder()
99//!     .api_key("test-key")
100//!     .build()
101//!     .unwrap();
102//!
103//! let handler = FileHandler::new(client);
104//!
105//! match handler.download_file("/path/to/file.txt").await {
106//!     Ok(file) => println!("Downloaded: {:?}", file),
107//!     Err(FilesError::NotFound { message, .. }) => {
108//!         println!("File not found: {}", message);
109//!     }
110//!     Err(FilesError::AuthenticationFailed { message, .. }) => {
111//!         println!("Invalid API key: {}", message);
112//!     }
113//!     Err(e) => println!("Other error: {}", e),
114//! }
115//! # }
116//! ```
117//!
118//! ## Authentication
119//!
120//! Files.com uses API key authentication via the `X-FilesAPI-Key` header.
121//! API keys can be obtained from the Files.com web interface under Account Settings.
122
123// Core modules
124pub mod client;
125pub mod error;
126pub mod types;
127pub mod utils;
128
129// Domain modules
130pub mod admin;
131pub mod as2;
132pub mod automation;
133pub mod developers;
134pub mod files;
135pub mod integrations;
136pub mod logs;
137pub mod messages;
138pub mod security;
139pub mod sharing;
140pub mod storage;
141pub mod users;
142
143// Misc (to be moved or removed)
144pub mod webhook_tests;
145
146// Re-export client types
147pub use client::{FilesClient, FilesClientBuilder};
148
149// Re-export error types
150pub use error::{FilesError, Result};
151
152// Re-export common types
153pub use types::{FileEntity, FileUploadPartEntity, FolderEntity, PaginationInfo};
154
155// Re-export all handlers for backward compatibility
156pub use admin::{
157    ActionNotificationExportHandler, ActionNotificationExportResultHandler,
158    ChildSiteManagementPolicyHandler, DnsRecordHandler, HistoryExportHandler2,
159    HistoryExportResultHandler2, HistoryHandler, HolidayRegionHandler, InvoiceHandler,
160    PaymentHandler, SiteHandler, StyleHandler,
161};
162pub use as2::{
163    As2IncomingMessageHandler, As2OutgoingMessageHandler, As2PartnerHandler, As2StationHandler,
164};
165pub use automation::{
166    AutomationHandler, AutomationRunHandler, BehaviorHandler, RemoteMountBackendHandler,
167    RemoteServerHandler, SyncHandler, SyncRunHandler,
168};
169pub use developers::AppHandler;
170pub use files::{
171    FileActionHandler, FileCommentHandler, FileCommentReactionHandler, FileHandler,
172    FileMigrationHandler, FileMigrationLogHandler, FolderHandler,
173};
174pub use integrations::SiemHttpDestinationHandler;
175pub use logs::{
176    ApiRequestLogHandler, AutomationLogHandler, EmailIncomingMessageHandler, EmailLogHandler,
177    ExavaultApiRequestLogHandler, ExternalEventHandler, FtpActionLogHandler,
178    OutboundConnectionLogHandler, PublicHostingRequestLogHandler, SettingsChangeHandler,
179    SftpActionLogHandler, SyncLogHandler, WebDavActionLogHandler,
180};
181pub use messages::{
182    MessageCommentHandler, MessageCommentReactionHandler, MessageHandler, MessageReactionHandler,
183    NotificationHandler,
184};
185pub use security::{ClickwrapHandler, GpgKeyHandler, IpAddressHandler, SftpHostKeyHandler};
186pub use sharing::{
187    BundleActionHandler, BundleDownloadHandler, BundleHandler, BundleNotificationHandler,
188    BundleRecipientHandler, BundleRegistrationHandler, FormFieldSetHandler, InboxRecipientHandler,
189    InboxRegistrationHandler2, InboxUploadHandler, RequestHandler, ShareGroupHandler,
190};
191pub use storage::{
192    BandwidthSnapshotHandler, LockHandler, PriorityHandler, ProjectHandler,
193    RemoteBandwidthSnapshotHandler, RestoreHandler, SnapshotHandler, UsageDailySnapshotHandler,
194    UsageSnapshotHandler,
195};
196pub use users::{
197    ApiKeyCurrentHandler, ApiKeyHandler, CurrentUserHandler, GroupHandler, GroupUserHandler,
198    PermissionHandler, PublicKeyHandler, SessionHandler, SsoStrategyHandler, UserCipherUseHandler,
199    UserHandler, UserLifecycleRuleHandler, UserRequestHandler, UserSftpClientUseHandler,
200};
201
202// Error types are now in the error module