1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
//! Files.com Rust SDK
//!
//! A comprehensive Rust client for the [Files.com](https://files.com) REST API, providing full access to
//! file operations, user management, sharing, automation, and administrative features.
//!
//! ## Features
//!
//! - **File Operations**: Upload, download, copy, move, delete files and folders
//! - **User & Access Management**: Users, groups, permissions, API keys, sessions
//! - **Sharing**: Bundles (share links), file requests, inbox uploads
//! - **Automation**: Webhooks, behaviors, remote servers, automations
//! - **Administration**: Site settings, history, notifications, billing
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use files_sdk::{FilesClient, files::FileHandler};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create client with API key
//! let client = FilesClient::builder()
//! .api_key("your-api-key")
//! .build()?;
//!
//! // Use handlers for typed operations
//! let file_handler = FileHandler::new(client.clone());
//!
//! // Upload a file
//! let data = b"Hello, Files.com!";
//! file_handler.upload_file("/path/to/file.txt", data).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Core Usage Patterns
//!
//! ### Client Creation
//!
//! The client uses a builder pattern for flexible configuration:
//!
//! ```rust,no_run
//! use files_sdk::FilesClient;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Basic client with default settings
//! let client = FilesClient::builder()
//! .api_key("your-api-key")
//! .build()?;
//!
//! // Custom configuration
//! let client = FilesClient::builder()
//! .api_key("your-api-key")
//! .base_url("https://app.files.com/api/rest/v1".to_string())
//! .timeout(std::time::Duration::from_secs(60))
//! .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Middleware with Tower (Optional)
//!
//! For retry logic, rate limiting, and observability, use the optional `tower` feature:
//!
//! ```toml
//! [dependencies]
//! files-sdk = { version = "0.3", features = ["tower"] }
//! tower = "0.5"
//! tower-http = { version = "0.6", features = ["retry", "trace"] }
//! ```
//!
//! See the `tower_*` examples in the examples directory for complete working code.
//!
//! **Benefits of Tower middleware:**
//! - **Composable**: Mix and match middleware layers
//! - **Battle-tested**: Use proven crates from the tower ecosystem
//! - **Customizable**: Full control over retry, rate limiting, tracing
//! - **Reusable**: Share middleware across different HTTP clients
//!
//! ### File Upload (Two-Stage Process)
//!
//! Files.com uses a two-stage upload process:
//!
//! ```rust,no_run
//! use files_sdk::{FilesClient, files::{FileActionHandler, FileHandler}};
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = FilesClient::builder()
//! .api_key("your-api-key")
//! .build()?;
//!
//! // Stage 1: Begin upload to get upload URLs
//! let file_action = FileActionHandler::new(client.clone());
//! let upload_info = file_action
//! .begin_upload("/uploads/myfile.txt", Some(1024), true)
//! .await?;
//!
//! // Stage 2: Upload file data (simplified - see FileHandler for complete implementation)
//! let file_handler = FileHandler::new(client.clone());
//! let data = b"file contents";
//! file_handler.upload_file("/uploads/myfile.txt", data).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Error Handling
//!
//! The SDK provides comprehensive error handling:
//!
//! ```rust,no_run
//! use files_sdk::{FilesClient, FilesError, files::FileHandler};
//!
//! # #[tokio::main]
//! # async fn main() {
//! let client = FilesClient::builder()
//! .api_key("test-key")
//! .build()
//! .unwrap();
//!
//! let handler = FileHandler::new(client);
//!
//! match handler.download_file("/path/to/file.txt").await {
//! Ok(file) => println!("Downloaded: {:?}", file),
//! Err(FilesError::NotFound { message, .. }) => {
//! println!("File not found: {}", message);
//! }
//! Err(FilesError::AuthenticationFailed { message, .. }) => {
//! println!("Invalid API key: {}", message);
//! }
//! Err(e) => println!("Other error: {}", e),
//! }
//! # }
//! ```
//!
//! ## Authentication
//!
//! Files.com uses API key authentication via the `X-FilesAPI-Key` header.
//! API keys can be obtained from the Files.com web interface under Account Settings.
// Core modules
// Domain modules
// Misc (to be moved or removed)
// Re-export client types
pub use ;
// Re-export error types
pub use ;
// Re-export common types
pub use ;
// Re-export all handlers for backward compatibility
pub use ;
pub use ;
pub use ;
pub use AppHandler;
pub use ;
pub use SiemHttpDestinationHandler;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Error types are now in the error module