Compare commits

...

1 Commits

Author SHA1 Message Date
Sameh Abouel-saad
b02101bd42 Implement rfs-client 2025-06-24 16:10:39 +03:00
147 changed files with 5756 additions and 0 deletions

2
rfs-client/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target/
**/*.rs.bk

18
rfs-client/Cargo.toml Normal file
View File

@ -0,0 +1,18 @@
[package]
name = "rfs-client"
version = "0.1.0"
edition = "2021"
description = "Client library for RFS (Remote File System) server"
license = "MIT"
[dependencies]
openapi = { path = "./openapi" }
thiserror = "1.0"
url = "2.4"
reqwest = { version = "^0.12", features = ["json", "multipart"] }
tokio = { version = "1.28", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
log = "0.4"
bytes = "1.4"
futures = "0.3"

195
rfs-client/README.md Normal file
View File

@ -0,0 +1,195 @@
# RFS Client
A Rust client library for interacting with the Remote File System (RFS) server.
## Overview
This client library provides a user-friendly wrapper around the OpenAPI-generated client code. It offers high-level abstractions for common operations such as:
- Authentication and session management
- File uploads and downloads with progress tracking
- Block-level operations and verification
- FList creation, monitoring, and management
- Timeout configuration and error handling
## Structure
The library is organized as follows:
- `client.rs`: Main client implementation with methods for interacting with the RFS server
- `error.rs`: Error types and handling
- `types.rs`: Type definitions and utilities
## Quick Start
```rust
use rfs_client::RfsClient;
use rfs_client::types::{ClientConfig, Credentials};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with custom configuration
let config = ClientConfig {
base_url: "http://localhost:8080".to_string(),
credentials: Some(Credentials {
username: "user".to_string(),
password: "password".to_string(),
}),
timeout_seconds: 60,
};
let mut client = RfsClient::new(config);
// Authenticate
client.authenticate().await?;
println!("Authentication successful");
// Upload a file
let file_path = "/path/to/file.txt";
let file_hash = client.upload_file(file_path, None).await?;
println!("File uploaded with hash: {}", file_hash);
// Download the file
let output_path = "/path/to/output.txt";
client.download_file(&file_hash, output_path, None).await?;
println!("File downloaded to {}", output_path);
Ok(())
}
```
## Feature Examples
### Authentication
```rust
// Create a client with authentication
let config = ClientConfig {
base_url: "http://localhost:8080".to_string(),
credentials: Some(Credentials {
username: "user".to_string(),
password: "password".to_string(),
}),
timeout_seconds: 30,
};
let mut client = RfsClient::new(config);
// Authenticate with the server
client.authenticate().await?;
if client.is_authenticated() {
println!("Authentication successful");
}
```
### File Management
```rust
// Upload a file with options
let upload_options = UploadOptions {
chunk_size: Some(1024 * 1024), // 1MB chunks
verify: true,
};
let file_hash = client.upload_file("/path/to/file.txt", Some(upload_options)).await?;
// Download the file
let download_options = DownloadOptions {
verify: true,
};
client.download_file(&file_hash, "/path/to/output.txt", Some(download_options)).await?;
```
### FList Operations
```rust
// Create an FList from a Docker image
let options = FlistOptions {
auth: None,
username: None,
password: None,
email: None,
server_address: Some("docker.io".to_string()),
identity_token: None,
registry_token: None,
};
let job_id = client.create_flist("alpine:latest", Some(options)).await?;
// Wait for FList creation with progress tracking
let wait_options = WaitOptions {
timeout_seconds: 60,
poll_interval_ms: 1000,
progress_callback: Some(Box::new(|state| {
println!("Progress: FList state is now {:?}", state);
})),
};
let final_state = client.wait_for_flist_creation(&job_id, Some(wait_options)).await?;
// List available FLists
let flists = client.list_flists().await?;
// Preview an FList
let preview = client.preview_flist("flists/user/alpine-latest.fl").await?;
// Download an FList
client.download_flist("flists/user/alpine-latest.fl", "/tmp/downloaded_flist.fl").await?;
```
### Block Management
```rust
// List blocks
let blocks_list = client.list_blocks(None).await?;
// Check if a block exists
let exists = client.check_block("block_hash").await?;
// Get block content
let block_content = client.get_block("block_hash").await?;
// Upload a block
let block_hash = client.upload_block("file_hash", 0, data).await?;
// Verify blocks
let request = VerifyBlocksRequest { blocks: verify_blocks };
let verify_result = client.verify_blocks(request).await?;
```
## Complete Examples
For more detailed examples, check the `examples` directory:
- `authentication.rs`: Authentication and health check examples
- `file_management.rs`: File upload and download with verification
- `flist_operations.rs`: Complete FList creation, monitoring, listing, preview, and download
- `block_management.rs`: Block-level operations including listing, verification, and upload
- `wait_for_flist.rs`: Advanced FList creation with progress monitoring
Run an example with:
```bash
cargo run --example flist_operations
```
## Development
This library wraps the OpenAPI-generated client located in the `openapi` directory. The OpenAPI client was generated using the OpenAPI Generator CLI.
To build the library:
```bash
cargo build
```
To run tests:
```bash
cargo test
```
## License
MIT

View File

@ -0,0 +1,42 @@
use rfs_client::RfsClient;
use rfs_client::types::{ClientConfig, Credentials};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with authentication credentials
let config = ClientConfig {
base_url: "http://localhost:8080".to_string(),
credentials: Some(Credentials {
username: "user".to_string(),
password: "password".to_string(),
}),
timeout_seconds: 30,
};
let mut client = RfsClient::new(config);
println!("Client created with authentication credentials");
// Authenticate with the server
client.authenticate().await?;
if client.is_authenticated() {
println!("Authentication successful");
} else {
println!("Authentication failed");
}
// Create a client without authentication
let config_no_auth = ClientConfig {
base_url: "http://localhost:8080".to_string(),
credentials: None,
timeout_seconds: 30,
};
let client_no_auth = RfsClient::new(config_no_auth);
println!("Client created without authentication credentials");
// Check health endpoint (doesn't require authentication)
let health = client_no_auth.health_check().await?;
println!("Server health: {:?}", health);
Ok(())
}

View File

@ -0,0 +1,128 @@
use rfs_client::RfsClient;
use rfs_client::types::{ClientConfig, Credentials};
use openapi::models::{VerifyBlock, VerifyBlocksRequest};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with authentication
let config = ClientConfig {
base_url: "http://localhost:8080".to_string(),
credentials: Some(Credentials {
username: "user".to_string(),
password: "password".to_string(),
}),
timeout_seconds: 60,
};
let mut client = RfsClient::new(config);
// Authenticate with the server
client.authenticate().await?;
println!("Authentication successful");
// Create a test file to upload for block testing
let test_file_path = "/tmp/block_test.txt";
let test_content = "This is a test file for RFS client block management";
std::fs::write(test_file_path, test_content)?;
println!("Created test file at {}", test_file_path);
// Upload the file to get blocks
println!("Uploading file to get blocks...");
let file_hash = client.upload_file(test_file_path, None).await?;
println!("File uploaded with hash: {}", file_hash);
// Get blocks by file hash
println!("Getting blocks for file hash: {}", file_hash);
let blocks = client.get_blocks_by_hash(&file_hash).await?;
println!("Found {} blocks for the file", blocks.blocks.len());
// Print block information
for (i, block_data) in blocks.blocks.iter().enumerate() {
println!("Block {}: Hash={}, Index={}", i, block_data.hash, block_data.index);
}
// Verify blocks with complete information
println!("Verifying blocks...");
// Create a list of VerifyBlock objects with complete information
let verify_blocks = blocks.blocks.iter().map(|block| {
VerifyBlock {
block_hash: block.hash.clone(),
block_index: block.index,
file_hash: file_hash.clone(), // Using the actual file hash
}
}).collect::<Vec<_>>();
// Create the request with the complete block information
for block in verify_blocks.iter() {
println!("Block: {}", block.block_hash);
println!("Block index: {}", block.block_index);
println!("File hash: {}", block.file_hash);
}
let request = VerifyBlocksRequest { blocks: verify_blocks };
// Send the verification request
let verify_result = client.verify_blocks(request).await?;
println!("Verification result: {} missing blocks", verify_result.missing.len());
for block in verify_result.missing.iter() {
println!("Missing block: {}", block);
}
// List blocks (list_blocks_handler)
println!("\n1. Listing all blocks with pagination...");
let blocks_list = client.list_blocks(None).await?;
println!("Server has {} blocks in total", blocks_list.len());
if !blocks_list.is_empty() {
let first_few = blocks_list.iter().take(3)
.map(|s| s.as_str())
.collect::<Vec<_>>()
.join(", ");
println!("First few blocks: {}", first_few);
}
// Check if a block exists (check_block_handler)
if !blocks.blocks.is_empty() {
let block_to_check = &blocks.blocks[0].hash;
println!("\n2. Checking if block exists: {}", block_to_check);
let exists = client.check_block(block_to_check).await?;
println!("Block exists: {}", exists);
}
// Get block downloads statistics (get_block_downloads_handler)
if !blocks.blocks.is_empty() {
let block_to_check = &blocks.blocks[0].hash;
println!("\n3. Getting download statistics for block: {}", block_to_check);
let downloads = client.get_block_downloads(block_to_check).await?;
println!("Block has been downloaded {} times", downloads.downloads_count);
}
// Get a specific block content (get_block_handler)
if !blocks.blocks.is_empty() {
let block_to_get = &blocks.blocks[0].hash;
println!("\n4. Getting content for block: {}", block_to_get);
let block_content = client.get_block(block_to_get).await?;
println!("Retrieved block with {} bytes", block_content.len());
}
// Get user blocks (get_user_blocks_handler)
println!("\n6. Listing user blocks...");
let user_blocks = client.get_user_blocks(Some(1), Some(10)).await?;
println!("User has {} blocks (showing page 1 with 10 per page)", user_blocks.total);
for block in user_blocks.blocks.iter().take(3) {
println!(" - Block: {}, Index: {}", block.hash, block.index);
}
// Upload a block (upload_block_handler)
println!("\n7. Uploading a new test block...");
let test_block_data = b"This is test block data for direct block upload";
let new_file_hash = "test_file_hash_for_block_upload";
let block_index = 0;
let block_hash = client.upload_block(new_file_hash, block_index, test_block_data.to_vec()).await?;
println!("Uploaded block with hash: {}", block_hash);
// Clean up
std::fs::remove_file(test_file_path)?;
println!("Test file cleaned up");
Ok(())
}

View File

@ -0,0 +1,64 @@
use rfs_client::RfsClient;
use rfs_client::types::{ClientConfig, Credentials, UploadOptions, DownloadOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with authentication
let config = ClientConfig {
base_url: "http://localhost:8080".to_string(),
credentials: Some(Credentials {
username: "user".to_string(),
password: "password".to_string(),
}),
timeout_seconds: 60,
};
let mut client = RfsClient::new(config);
// Authenticate with the server
client.authenticate().await?;
println!("Authentication successful");
// Create a test file to upload
let test_file_path = "/tmp/test_upload.txt";
std::fs::write(test_file_path, "This is a test file for RFS client upload")?;
println!("Created test file at {}", test_file_path);
// Upload the file with options
println!("Uploading file...");
let upload_options = UploadOptions {
chunk_size: Some(1024 * 1024), // 1MB chunks
verify: true,
};
let file_hash = client.upload_file(test_file_path, Some(upload_options)).await?;
println!("File uploaded with hash: {}", file_hash);
// Download the file
let download_path = "/tmp/test_download.txt";
println!("Downloading file to {}...", download_path);
let download_options = DownloadOptions {
verify: true,
};
client.download_file(&file_hash, download_path, Some(download_options)).await?;
println!("File downloaded to {}", download_path);
// Verify the downloaded file matches the original
let original_content = std::fs::read_to_string(test_file_path)?;
let downloaded_content = std::fs::read_to_string(download_path)?;
if original_content == downloaded_content {
println!("File contents match! Download successful.");
} else {
println!("ERROR: File contents do not match!");
}
// Clean up test files
std::fs::remove_file(test_file_path)?;
std::fs::remove_file(download_path)?;
println!("Test files cleaned up");
Ok(())
}

View File

@ -0,0 +1,171 @@
use rfs_client::RfsClient;
use rfs_client::types::{ClientConfig, Credentials, FlistOptions, WaitOptions};
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let parent_dir = "flists";
// Create a client with authentication
let config = ClientConfig {
base_url: "http://localhost:8080".to_string(),
credentials: Some(Credentials {
username: "user".to_string(),
password: "password".to_string(),
}),
timeout_seconds: 60,
};
let mut client = RfsClient::new(config);
// Authenticate with the server
client.authenticate().await?;
println!("Authentication successful");
println!("\n1. CREATE FLIST - Creating an FList from a Docker image");
let image_name = "alpine:latest";
println!("Creating FList for image: {}", image_name);
// Use FlistOptions to specify additional parameters
let options = FlistOptions {
auth: None,
username: None,
password: None,
email: None,
server_address: Some("docker.io".to_string()),
identity_token: None,
registry_token: None,
};
// Create the FList and handle potential conflict error
let job_id = match client.create_flist(&image_name, Some(options)).await {
Ok(id) => {
println!("FList creation started with job ID: {}", id);
Some(id)
},
Err(e) => {
if e.to_string().contains("Conflict") {
println!("FList already exists");
None
} else {
return Err(e.into());
}
}
};
// 2. Check FList state if we have a job ID
if let Some(job_id) = &job_id {
println!("\n2. GET FLIST STATE - Checking FList creation state");
let state = client.get_flist_state(job_id).await?;
println!("Current FList state: {:?}", state.flist_state);
// 3. Wait for FList creation with progress reporting
println!("\n3. WAIT FOR FLIST CREATION - Waiting for FList to be created with progress reporting");
let wait_options = WaitOptions {
timeout_seconds: 60, // Shorter timeout for the example
poll_interval_ms: 1000,
progress_callback: Some(Box::new(|state| {
println!("Progress: FList state is now {:?}", state);
// No return value needed (returns unit type)
})),
};
// Wait for the FList to be created (with a timeout)
match client.wait_for_flist_creation(job_id, Some(wait_options)).await {
Ok(final_state) => {
println!("FList creation completed with state: {:?}", final_state);
},
Err(e) => {
println!("Error waiting for FList creation: {}", e);
// Continue with the example even if waiting fails
}
};
}
// 4. List all available FLists
println!("\n4. LIST FLISTS - Listing all available FLists");
// Variable to store the FList path for preview and download
let mut flist_path_for_preview: Option<String> = None;
match client.list_flists().await {
Ok(flists) => {
println!("Found {} FList categories", flists.len());
for (category, files) in &flists {
println!("Category: {}", category);
for file in files.iter().take(2) { // Show only first 2 files per category
println!(" - {} (size: {} bytes)", file.name, file.size);
// Save the first FList path for preview
if flist_path_for_preview.is_none() {
let path = format!("{}/{}/{}", parent_dir, category, file.name);
flist_path_for_preview = Some(path);
}
}
if files.len() > 2 {
println!(" - ... and {} more files", files.len() - 2);
}
}
// 5. Preview an FList if we found one
if let Some(ref flist_path) = flist_path_for_preview {
println!("\n5. PREVIEW FLIST - Previewing FList: {}", flist_path);
match client.preview_flist(flist_path).await {
Ok(preview) => {
println!("FList preview for {}:", flist_path);
println!(" - Checksum: {}", preview.checksum);
println!(" - Metadata: {}", preview.metadata);
// Display content (list of strings)
if !preview.content.is_empty() {
println!(" - Content entries:");
for (i, entry) in preview.content.iter().enumerate().take(5) {
println!(" {}. {}", i+1, entry);
}
if preview.content.len() > 5 {
println!(" ... and {} more entries", preview.content.len() - 5);
}
}
},
Err(e) => println!("Error previewing FList: {}", e),
}
} else {
println!("No FLists available for preview");
}
},
Err(e) => println!("Error listing FLists: {}", e),
}
// 6. DOWNLOAD FLIST - Downloading an FList to a local file
if let Some(ref flist_path) = flist_path_for_preview {
println!("\n6. DOWNLOAD FLIST - Downloading FList: {}", flist_path);
// Create a temporary output path for the downloaded FList
let output_path = "/tmp/downloaded_flist.fl";
match client.download_flist(flist_path, output_path).await {
Ok(_) => {
println!("FList successfully downloaded to {}", output_path);
// Get file size
match std::fs::metadata(output_path) {
Ok(metadata) => println!("Downloaded file size: {} bytes", metadata.len()),
Err(e) => println!("Error getting file metadata: {}", e),
}
},
Err(e) => println!("Error downloading FList: {}", e),
}
} else {
println!("\n6. DOWNLOAD FLIST - No FList available for download");
}
println!("\nAll FList operations demonstrated:");
println!("1. create_flist - Create a new FList from a Docker image");
println!("2. get_flist_state - Check the state of an FList creation job");
println!("3. wait_for_flist_creation - Wait for an FList to be created with progress reporting");
println!("4. list_flists - List all available FLists");
println!("5. preview_flist - Preview the content of an FList");
println!("6. download_flist - Download an FList to a local file");
Ok(())
}

View File

@ -0,0 +1,61 @@
use rfs_client::RfsClient;
use rfs_client::types::{ClientConfig, Credentials, WaitOptions};
use openapi::models::FlistState;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with authentication
let config = ClientConfig {
base_url: "http://localhost:8080".to_string(),
credentials: Some(Credentials {
username: "user".to_string(),
password: "password".to_string(),
}),
timeout_seconds: 60,
};
let mut client = RfsClient::new(config);
// Authenticate with the server
client.authenticate().await?;
println!("Authentication successful");
// Create an FList from a Docker image
let image_name = "redis:latest";
println!("Creating FList for image: {}", image_name);
let job_id = client.create_flist(&image_name, None).await?;
println!("FList creation started with job ID: {}", job_id);
// Set up options for waiting with progress reporting
let options = WaitOptions {
timeout_seconds: 600, // 10 minutes timeout
poll_interval_ms: 2000, // Check every 2 seconds
progress_callback: Some(Box::new(|state| {
match state {
FlistState::FlistStateInProgress(info) => {
println!("Progress: {:.1}% - {}", info.in_progress.progress, info.in_progress.msg);
},
FlistState::FlistStateStarted(_) => {
println!("FList creation started...");
},
FlistState::FlistStateAccepted(_) => {
println!("FList creation request accepted...");
},
_ => println!("State: {:?}", state),
}
})),
};
// Wait for the FList to be created
println!("Waiting for FList creation to complete...");
// Use ? operator to propagate errors properly
let state = client.wait_for_flist_creation(&job_id, Some(options)).await
.map_err(|e| -> Box<dyn std::error::Error> { Box::new(e) })?;
println!("FList created successfully!");
println!("Final state: {:?}", state);
Ok(())
}

1
rfs-client/openapi.json Normal file

File diff suppressed because one or more lines are too long

3
rfs-client/openapi/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/target/
**/*.rs.bk
Cargo.lock

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,123 @@
.gitignore
.travis.yml
Cargo.toml
README.md
docs/AuthenticationApi.md
docs/BlockDownloadsResponse.md
docs/BlockInfo.md
docs/BlockManagementApi.md
docs/BlockUploadedResponse.md
docs/BlocksResponse.md
docs/DirListTemplate.md
docs/DirLister.md
docs/ErrorTemplate.md
docs/FileDownloadRequest.md
docs/FileInfo.md
docs/FileManagementApi.md
docs/FileUploadResponse.md
docs/FlistBody.md
docs/FlistManagementApi.md
docs/FlistState.md
docs/FlistStateAccepted.md
docs/FlistStateCreated.md
docs/FlistStateInProgress.md
docs/FlistStateInfo.md
docs/FlistStateResponse.md
docs/FlistStateStarted.md
docs/HealthResponse.md
docs/Job.md
docs/ListBlocksParams.md
docs/ListBlocksResponse.md
docs/PreviewResponse.md
docs/ResponseError.md
docs/ResponseErrorBadRequest.md
docs/ResponseErrorConflict.md
docs/ResponseErrorForbidden.md
docs/ResponseErrorNotFound.md
docs/ResponseErrorTemplateError.md
docs/ResponseErrorUnauthorized.md
docs/ResponseResult.md
docs/ResponseResultBlockUploaded.md
docs/ResponseResultDirTemplate.md
docs/ResponseResultFileUploaded.md
docs/ResponseResultFlistCreated.md
docs/ResponseResultFlistState.md
docs/ResponseResultFlists.md
docs/ResponseResultPreviewFlist.md
docs/ResponseResultRes.md
docs/ResponseResultSignedIn.md
docs/SignInBody.md
docs/SignInResponse.md
docs/SystemApi.md
docs/TemplateErr.md
docs/TemplateErrBadRequest.md
docs/TemplateErrInternalServerError.md
docs/TemplateErrNotFound.md
docs/UploadBlockParams.md
docs/UserBlocksResponse.md
docs/VerifyBlock.md
docs/VerifyBlocksRequest.md
docs/VerifyBlocksResponse.md
docs/WebsiteServingApi.md
git_push.sh
src/apis/authentication_api.rs
src/apis/block_management_api.rs
src/apis/configuration.rs
src/apis/file_management_api.rs
src/apis/flist_management_api.rs
src/apis/mod.rs
src/apis/system_api.rs
src/apis/website_serving_api.rs
src/lib.rs
src/models/block_downloads_response.rs
src/models/block_info.rs
src/models/block_uploaded_response.rs
src/models/blocks_response.rs
src/models/dir_list_template.rs
src/models/dir_lister.rs
src/models/error_template.rs
src/models/file_download_request.rs
src/models/file_info.rs
src/models/file_upload_response.rs
src/models/flist_body.rs
src/models/flist_state.rs
src/models/flist_state_accepted.rs
src/models/flist_state_created.rs
src/models/flist_state_in_progress.rs
src/models/flist_state_info.rs
src/models/flist_state_response.rs
src/models/flist_state_started.rs
src/models/health_response.rs
src/models/job.rs
src/models/list_blocks_params.rs
src/models/list_blocks_response.rs
src/models/mod.rs
src/models/preview_response.rs
src/models/response_error.rs
src/models/response_error_bad_request.rs
src/models/response_error_conflict.rs
src/models/response_error_forbidden.rs
src/models/response_error_not_found.rs
src/models/response_error_template_error.rs
src/models/response_error_unauthorized.rs
src/models/response_result.rs
src/models/response_result_block_uploaded.rs
src/models/response_result_dir_template.rs
src/models/response_result_file_uploaded.rs
src/models/response_result_flist_created.rs
src/models/response_result_flist_state.rs
src/models/response_result_flists.rs
src/models/response_result_preview_flist.rs
src/models/response_result_res.rs
src/models/response_result_signed_in.rs
src/models/sign_in_body.rs
src/models/sign_in_response.rs
src/models/template_err.rs
src/models/template_err_bad_request.rs
src/models/template_err_internal_server_error.rs
src/models/template_err_not_found.rs
src/models/upload_block_params.rs
src/models/user_blocks_response.rs
src/models/verify_block.rs
src/models/verify_blocks_request.rs
src/models/verify_blocks_response.rs

View File

@ -0,0 +1 @@
7.13.0

View File

@ -0,0 +1 @@
language: rust

View File

@ -0,0 +1,15 @@
[package]
name = "openapi"
version = "0.2.0"
authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
license = ""
edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart"] }

View File

@ -0,0 +1,113 @@
# Rust API client for openapi
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
- API version: 0.2.0
- Package version: 0.2.0
- Generator version: 7.13.0
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`
## Installation
Put the package under your project folder in a directory named `openapi` and add the following to `Cargo.toml` under `[dependencies]`:
```
openapi = { path = "./openapi" }
```
## Documentation for API Endpoints
All URIs are relative to *http://localhost*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AuthenticationApi* | [**sign_in_handler**](docs/AuthenticationApi.md#sign_in_handler) | **POST** /api/v1/signin |
*BlockManagementApi* | [**check_block_handler**](docs/BlockManagementApi.md#check_block_handler) | **HEAD** /api/v1/block/{hash} | Checks a block by its hash.
*BlockManagementApi* | [**get_block_downloads_handler**](docs/BlockManagementApi.md#get_block_downloads_handler) | **GET** /api/v1/block/{hash}/downloads | Retrieve the number of times a block has been downloaded.
*BlockManagementApi* | [**get_block_handler**](docs/BlockManagementApi.md#get_block_handler) | **GET** /api/v1/block/{hash} | Retrieve a block by its hash.
*BlockManagementApi* | [**get_blocks_by_hash_handler**](docs/BlockManagementApi.md#get_blocks_by_hash_handler) | **GET** /api/v1/blocks/{hash} | Retrieve blocks by hash (file hash or block hash).
*BlockManagementApi* | [**get_user_blocks_handler**](docs/BlockManagementApi.md#get_user_blocks_handler) | **GET** /api/v1/user/blocks | Retrieve all blocks uploaded by a specific user.
*BlockManagementApi* | [**list_blocks_handler**](docs/BlockManagementApi.md#list_blocks_handler) | **GET** /api/v1/blocks | List all block hashes in the server with pagination
*BlockManagementApi* | [**upload_block_handler**](docs/BlockManagementApi.md#upload_block_handler) | **POST** /api/v1/block | Upload a block to the server.
*BlockManagementApi* | [**verify_blocks_handler**](docs/BlockManagementApi.md#verify_blocks_handler) | **POST** /api/v1/block/verify | Verify if multiple blocks exist on the server.
*FileManagementApi* | [**get_file_handler**](docs/FileManagementApi.md#get_file_handler) | **GET** /api/v1/file/{hash} | Retrieve a file by its hash from path, with optional custom filename in request body.
*FileManagementApi* | [**upload_file_handler**](docs/FileManagementApi.md#upload_file_handler) | **POST** /api/v1/file | Upload a file to the server.
*FlistManagementApi* | [**create_flist_handler**](docs/FlistManagementApi.md#create_flist_handler) | **POST** /api/v1/fl |
*FlistManagementApi* | [**get_flist_state_handler**](docs/FlistManagementApi.md#get_flist_state_handler) | **GET** /api/v1/fl/{job_id} |
*FlistManagementApi* | [**list_flists_handler**](docs/FlistManagementApi.md#list_flists_handler) | **GET** /api/v1/fl |
*FlistManagementApi* | [**preview_flist_handler**](docs/FlistManagementApi.md#preview_flist_handler) | **GET** /api/v1/fl/preview/{flist_path} |
*FlistManagementApi* | [**serve_flists**](docs/FlistManagementApi.md#serve_flists) | **GET** /{path} | Serve flist files from the server's filesystem
*SystemApi* | [**health_check_handler**](docs/SystemApi.md#health_check_handler) | **GET** /api/v1 |
*WebsiteServingApi* | [**serve_website_handler**](docs/WebsiteServingApi.md#serve_website_handler) | **GET** /api/v1/website/{website_hash}/{path} |
## Documentation For Models
- [BlockDownloadsResponse](docs/BlockDownloadsResponse.md)
- [BlockInfo](docs/BlockInfo.md)
- [BlockUploadedResponse](docs/BlockUploadedResponse.md)
- [BlocksResponse](docs/BlocksResponse.md)
- [DirListTemplate](docs/DirListTemplate.md)
- [DirLister](docs/DirLister.md)
- [ErrorTemplate](docs/ErrorTemplate.md)
- [FileDownloadRequest](docs/FileDownloadRequest.md)
- [FileInfo](docs/FileInfo.md)
- [FileUploadResponse](docs/FileUploadResponse.md)
- [FlistBody](docs/FlistBody.md)
- [FlistState](docs/FlistState.md)
- [FlistStateAccepted](docs/FlistStateAccepted.md)
- [FlistStateCreated](docs/FlistStateCreated.md)
- [FlistStateInProgress](docs/FlistStateInProgress.md)
- [FlistStateInfo](docs/FlistStateInfo.md)
- [FlistStateResponse](docs/FlistStateResponse.md)
- [FlistStateStarted](docs/FlistStateStarted.md)
- [HealthResponse](docs/HealthResponse.md)
- [Job](docs/Job.md)
- [ListBlocksParams](docs/ListBlocksParams.md)
- [ListBlocksResponse](docs/ListBlocksResponse.md)
- [PreviewResponse](docs/PreviewResponse.md)
- [ResponseError](docs/ResponseError.md)
- [ResponseErrorBadRequest](docs/ResponseErrorBadRequest.md)
- [ResponseErrorConflict](docs/ResponseErrorConflict.md)
- [ResponseErrorForbidden](docs/ResponseErrorForbidden.md)
- [ResponseErrorNotFound](docs/ResponseErrorNotFound.md)
- [ResponseErrorTemplateError](docs/ResponseErrorTemplateError.md)
- [ResponseErrorUnauthorized](docs/ResponseErrorUnauthorized.md)
- [ResponseResult](docs/ResponseResult.md)
- [ResponseResultBlockUploaded](docs/ResponseResultBlockUploaded.md)
- [ResponseResultDirTemplate](docs/ResponseResultDirTemplate.md)
- [ResponseResultFileUploaded](docs/ResponseResultFileUploaded.md)
- [ResponseResultFlistCreated](docs/ResponseResultFlistCreated.md)
- [ResponseResultFlistState](docs/ResponseResultFlistState.md)
- [ResponseResultFlists](docs/ResponseResultFlists.md)
- [ResponseResultPreviewFlist](docs/ResponseResultPreviewFlist.md)
- [ResponseResultRes](docs/ResponseResultRes.md)
- [ResponseResultSignedIn](docs/ResponseResultSignedIn.md)
- [SignInBody](docs/SignInBody.md)
- [SignInResponse](docs/SignInResponse.md)
- [TemplateErr](docs/TemplateErr.md)
- [TemplateErrBadRequest](docs/TemplateErrBadRequest.md)
- [TemplateErrInternalServerError](docs/TemplateErrInternalServerError.md)
- [TemplateErrNotFound](docs/TemplateErrNotFound.md)
- [UploadBlockParams](docs/UploadBlockParams.md)
- [UserBlocksResponse](docs/UserBlocksResponse.md)
- [VerifyBlock](docs/VerifyBlock.md)
- [VerifyBlocksRequest](docs/VerifyBlocksRequest.md)
- [VerifyBlocksResponse](docs/VerifyBlocksResponse.md)
To get access to the crate's generated documentation, use:
```
cargo doc --open
```
## Author

View File

@ -0,0 +1,37 @@
# \AuthenticationApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**sign_in_handler**](AuthenticationApi.md#sign_in_handler) | **POST** /api/v1/signin |
## sign_in_handler
> models::SignInResponse sign_in_handler(sign_in_body)
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**sign_in_body** | [**SignInBody**](SignInBody.md) | | [required] |
### Return type
[**models::SignInResponse**](SignInResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,14 @@
# Block
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**data** | [**std::path::PathBuf**](std::path::PathBuf.md) | |
**hash** | **String** | |
**index** | **i64** | |
**size** | **i32** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# BlockDownloadsResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**block_hash** | **String** | Block hash |
**block_size** | **i64** | Size of the block in bytes |
**downloads_count** | **i64** | Number of times the block has been downloaded |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# BlockInfo
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**hash** | **String** | Block hash |
**index** | **i64** | Block index within the file |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,250 @@
# \BlockManagementApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**check_block_handler**](BlockManagementApi.md#check_block_handler) | **HEAD** /api/v1/block/{hash} | Checks a block by its hash.
[**get_block_downloads_handler**](BlockManagementApi.md#get_block_downloads_handler) | **GET** /api/v1/block/{hash}/downloads | Retrieve the number of times a block has been downloaded.
[**get_block_handler**](BlockManagementApi.md#get_block_handler) | **GET** /api/v1/block/{hash} | Retrieve a block by its hash.
[**get_blocks_by_hash_handler**](BlockManagementApi.md#get_blocks_by_hash_handler) | **GET** /api/v1/blocks/{hash} | Retrieve blocks by hash (file hash or block hash).
[**get_user_blocks_handler**](BlockManagementApi.md#get_user_blocks_handler) | **GET** /api/v1/user/blocks | Retrieve all blocks uploaded by a specific user.
[**list_blocks_handler**](BlockManagementApi.md#list_blocks_handler) | **GET** /api/v1/blocks | List all block hashes in the server with pagination
[**upload_block_handler**](BlockManagementApi.md#upload_block_handler) | **POST** /api/v1/block | Upload a block to the server.
[**verify_blocks_handler**](BlockManagementApi.md#verify_blocks_handler) | **POST** /api/v1/block/verify | Verify if multiple blocks exist on the server.
## check_block_handler
> check_block_handler(hash)
Checks a block by its hash.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**hash** | **String** | Block hash | [required] |
### Return type
(empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## get_block_downloads_handler
> models::BlockDownloadsResponse get_block_downloads_handler(hash)
Retrieve the number of times a block has been downloaded.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**hash** | **String** | Block hash | [required] |
### Return type
[**models::BlockDownloadsResponse**](BlockDownloadsResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## get_block_handler
> std::path::PathBuf get_block_handler(hash)
Retrieve a block by its hash.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**hash** | **String** | Block hash | [required] |
### Return type
[**std::path::PathBuf**](std::path::PathBuf.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/octet-stream, application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## get_blocks_by_hash_handler
> models::BlocksResponse get_blocks_by_hash_handler(hash)
Retrieve blocks by hash (file hash or block hash).
If the hash is a file hash, returns all blocks with their block index related to that file. If the hash is a block hash, returns the block itself.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**hash** | **String** | File hash or block hash | [required] |
### Return type
[**models::BlocksResponse**](BlocksResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## get_user_blocks_handler
> models::UserBlocksResponse get_user_blocks_handler(page, per_page)
Retrieve all blocks uploaded by a specific user.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**page** | Option<**i32**> | Page number (1-indexed) | |
**per_page** | Option<**i32**> | Number of items per page | |
### Return type
[**models::UserBlocksResponse**](UserBlocksResponse.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## list_blocks_handler
> models::ListBlocksResponse list_blocks_handler(page, per_page)
List all block hashes in the server with pagination
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**page** | Option<**i32**> | Page number (1-indexed) | |
**per_page** | Option<**i32**> | Number of items per page | |
### Return type
[**models::ListBlocksResponse**](ListBlocksResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## upload_block_handler
> models::BlockUploadedResponse upload_block_handler(file_hash, idx, body)
Upload a block to the server.
If the block already exists, the server will return a 200 OK response. If the block is new, the server will return a 201 Created response.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**file_hash** | **String** | File hash associated with the block | [required] |
**idx** | **i64** | Block index within the file | [required] |
**body** | **std::path::PathBuf** | Block data to upload | [required] |
### Return type
[**models::BlockUploadedResponse**](BlockUploadedResponse.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/octet-stream
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## verify_blocks_handler
> models::VerifyBlocksResponse verify_blocks_handler(verify_blocks_request)
Verify if multiple blocks exist on the server.
Returns a list of missing blocks.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**verify_blocks_request** | [**VerifyBlocksRequest**](VerifyBlocksRequest.md) | List of block hashes to verify | [required] |
### Return type
[**models::VerifyBlocksResponse**](VerifyBlocksResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# BlockUploadedResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**hash** | **String** | |
**message** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# BlocksResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**blocks** | [**Vec<models::BlockInfo>**](BlockInfo.md) | List of blocks with their indices |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# DirListTemplate
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**cur_path** | **String** | |
**lister** | [**models::DirLister**](DirLister.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# DirLister
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**files** | [**Vec<models::FileInfo>**](FileInfo.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# ErrorTemplate
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**cur_path** | **String** | |
**err** | [**models::TemplateErr**](TemplateErr.md) | |
**message** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# File
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file_content** | [**std::path::PathBuf**](std::path::PathBuf.md) | |
**file_hash** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FileDownloadRequest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file_name** | **String** | The custom filename to use for download |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,16 @@
# FileInfo
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**is_file** | **bool** | |
**last_modified** | **i64** | |
**name** | **String** | |
**path_uri** | **String** | |
**progress** | **f32** | |
**size** | **i64** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,71 @@
# \FileManagementApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**get_file_handler**](FileManagementApi.md#get_file_handler) | **GET** /api/v1/file/{hash} | Retrieve a file by its hash from path, with optional custom filename in request body.
[**upload_file_handler**](FileManagementApi.md#upload_file_handler) | **POST** /api/v1/file | Upload a file to the server.
## get_file_handler
> std::path::PathBuf get_file_handler(hash, file_download_request)
Retrieve a file by its hash from path, with optional custom filename in request body.
The file will be reconstructed from its blocks.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**hash** | **String** | File hash | [required] |
**file_download_request** | [**FileDownloadRequest**](FileDownloadRequest.md) | Optional custom filename for download | [required] |
### Return type
[**std::path::PathBuf**](std::path::PathBuf.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/octet-stream, application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## upload_file_handler
> models::FileUploadResponse upload_file_handler(body)
Upload a file to the server.
The file will be split into blocks and stored in the database.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**body** | **std::path::PathBuf** | File data to upload | [required] |
### Return type
[**models::FileUploadResponse**](FileUploadResponse.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/octet-stream
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# FileUploadResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file_hash** | **String** | The file hash |
**message** | **String** | Message indicating success |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,18 @@
# FlistBody
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**auth** | Option<**String**> | | [optional]
**email** | Option<**String**> | | [optional]
**identity_token** | Option<**String**> | | [optional]
**image_name** | **String** | |
**password** | Option<**String**> | | [optional]
**registry_token** | Option<**String**> | | [optional]
**server_address** | Option<**String**> | | [optional]
**username** | Option<**String**> | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,150 @@
# \FlistManagementApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**create_flist_handler**](FlistManagementApi.md#create_flist_handler) | **POST** /api/v1/fl |
[**get_flist_state_handler**](FlistManagementApi.md#get_flist_state_handler) | **GET** /api/v1/fl/{job_id} |
[**list_flists_handler**](FlistManagementApi.md#list_flists_handler) | **GET** /api/v1/fl |
[**preview_flist_handler**](FlistManagementApi.md#preview_flist_handler) | **GET** /api/v1/fl/preview/{flist_path} |
[**serve_flists**](FlistManagementApi.md#serve_flists) | **GET** /{path} | Serve flist files from the server's filesystem
## create_flist_handler
> models::Job create_flist_handler(flist_body)
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**flist_body** | [**FlistBody**](FlistBody.md) | | [required] |
### Return type
[**models::Job**](Job.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## get_flist_state_handler
> models::FlistStateResponse get_flist_state_handler(job_id)
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**job_id** | **String** | flist job id | [required] |
### Return type
[**models::FlistStateResponse**](FlistStateResponse.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## list_flists_handler
> std::collections::HashMap<String, Vec<models::FileInfo>> list_flists_handler()
### Parameters
This endpoint does not need any parameter.
### Return type
[**std::collections::HashMap<String, Vec<models::FileInfo>>**](Vec.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## preview_flist_handler
> models::PreviewResponse preview_flist_handler(flist_path)
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**flist_path** | **String** | flist file path | [required] |
### Return type
[**models::PreviewResponse**](PreviewResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
## serve_flists
> std::path::PathBuf serve_flists(path)
Serve flist files from the server's filesystem
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**path** | **String** | Path to the flist file or directory to serve | [required] |
### Return type
[**std::path::PathBuf**](std::path::PathBuf.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/octet-stream, application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,37 @@
# \FlistServingApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**serve_flists**](FlistServingApi.md#serve_flists) | **GET** /{path} | Serve flist files from the server's filesystem
## serve_flists
> models::ResponseResult serve_flists(path)
Serve flist files from the server's filesystem
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**path** | **String** | Path to the flist file or directory to serve | [required] |
### Return type
[**models::ResponseResult**](ResponseResult.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,15 @@
# FlistState
## Enum Variants
| Name | Description |
|---- | -----|
| FlistStateAccepted | |
| FlistStateCreated | |
| FlistStateInProgress | |
| FlistStateStarted | |
| String | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FlistStateAccepted
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**accepted** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FlistStateCreated
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**created** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FlistStateInProgress
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**in_progress** | [**models::FlistStateInfo**](FlistStateInfo.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# FlistStateInfo
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**msg** | **String** | |
**progress** | **f32** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FlistStateResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**flist_state** | [**models::FlistState**](FlistState.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FlistStateStarted
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**started** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# HealthResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**msg** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# Job
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# ListBlocksParams
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**page** | Option<**i32**> | Page number (1-indexed) | [optional][default to 1]
**per_page** | Option<**i32**> | Number of items per page | [optional][default to 50]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,14 @@
# ListBlocksResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**blocks** | **Vec<String>** | List of block hashes |
**page** | **i32** | Current page number |
**per_page** | **i32** | Number of items per page |
**total** | **i64** | Total number of blocks |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# PreviewResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**checksum** | **String** | |
**content** | **Vec<String>** | |
**metadata** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,17 @@
# ResponseError
## Enum Variants
| Name | Description |
|---- | -----|
| ResponseErrorBadRequest | |
| ResponseErrorConflict | |
| ResponseErrorForbidden | |
| ResponseErrorNotFound | |
| ResponseErrorTemplateError | |
| ResponseErrorUnauthorized | |
| String | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseErrorBadRequest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bad_request** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseErrorConflict
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**conflict** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseErrorForbidden
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**forbidden** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseErrorNotFound
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**not_found** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseErrorTemplateError
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**template_error** | [**models::ErrorTemplate**](ErrorTemplate.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseErrorUnauthorized
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**unauthorized** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,20 @@
# ResponseResult
## Enum Variants
| Name | Description |
|---- | -----|
| ResponseResultBlockUploaded | |
| ResponseResultDirTemplate | |
| ResponseResultFileUploaded | |
| ResponseResultFlistCreated | |
| ResponseResultFlistState | |
| ResponseResultFlists | |
| ResponseResultPreviewFlist | |
| ResponseResultRes | |
| ResponseResultSignedIn | |
| String | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultBlockUploaded
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**block_uploaded** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultDirTemplate
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**dir_template** | [**models::DirListTemplate**](DirListTemplate.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultFileUploaded
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file_uploaded** | [**models::FileUploadResponse**](FileUploadResponse.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultFlistCreated
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**flist_created** | [**models::Job**](Job.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultFlistState
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**flist_state** | [**models::FlistState**](FlistState.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultFlists
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**flists** | [**std::collections::HashMap<String, Vec<models::FileInfo>>**](Vec.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultPreviewFlist
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**preview_flist** | [**models::PreviewResponse**](PreviewResponse.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultRes
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**res** | [**std::path::PathBuf**](std::path::PathBuf.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# ResponseResultSignedIn
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**signed_in** | [**models::SignInResponse**](SignInResponse.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# SignInBody
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**password** | **String** | |
**username** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# SignInResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**access_token** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,34 @@
# \SystemApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**health_check_handler**](SystemApi.md#health_check_handler) | **GET** /api/v1 |
## health_check_handler
> models::HealthResponse health_check_handler()
### Parameters
This endpoint does not need any parameter.
### Return type
[**models::HealthResponse**](HealthResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# TemplateErr
## Enum Variants
| Name | Description |
|---- | -----|
| TemplateErrBadRequest | |
| TemplateErrInternalServerError | |
| TemplateErrNotFound | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# TemplateErrBadRequest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bad_request** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# TemplateErrInternalServerError
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**internal_server_error** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# TemplateErrNotFound
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**not_found** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# UploadBlockParams
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file_hash** | **String** | File hash associated with the block |
**idx** | **i64** | Block index within the file |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# UserBlocksResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**all_blocks** | **i64** | Total number of all blocks |
**blocks** | [**Vec<models::BlockInfo>**](BlockInfo.md) | List of blocks with their indices |
**total** | **i64** | Total number of blocks |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# VerifyBlock
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**block_hash** | **String** | Block hash to verify |
**block_index** | **i64** | Block index within the file |
**file_hash** | **String** | File hash associated with the block |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# VerifyBlocksRequest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**blocks** | [**Vec<models::VerifyBlock>**](VerifyBlock.md) | List of blocks to verify |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# VerifyBlocksResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**missing** | **Vec<String>** | List of block hashes that are missing on the server |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,38 @@
# \WebsiteServingApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**serve_website_handler**](WebsiteServingApi.md#serve_website_handler) | **GET** /api/v1/website/{website_hash}/{path} |
## serve_website_handler
> std::path::PathBuf serve_website_handler(website_hash, path)
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**website_hash** | **String** | flist hash of the website directory | [required] |
**path** | **String** | Path to the file within the website directory, defaults to index.html if empty | [required] |
### Return type
[**std::path::PathBuf**](std::path::PathBuf.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/octet-stream, application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,57 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4
if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -0,0 +1,64 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`sign_in_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SignInHandlerError {
Status401(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
pub async fn sign_in_handler(configuration: &configuration::Configuration, sign_in_body: models::SignInBody) -> Result<models::SignInResponse, Error<SignInHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_sign_in_body = sign_in_body;
let uri_str = format!("{}/api/v1/signin", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_sign_in_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SignInResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SignInResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SignInHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}

View File

@ -0,0 +1,385 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`check_block_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CheckBlockHandlerError {
Status404(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_block_downloads_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBlockDownloadsHandlerError {
Status404(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_block_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBlockHandlerError {
Status404(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_blocks_by_hash_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBlocksByHashHandlerError {
Status404(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_blocks_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserBlocksHandlerError {
Status401(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_blocks_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBlocksHandlerError {
Status400(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`upload_block_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UploadBlockHandlerError {
Status400(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify_blocks_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum VerifyBlocksHandlerError {
Status400(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
pub async fn check_block_handler(configuration: &configuration::Configuration, hash: &str) -> Result<(), Error<CheckBlockHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_hash = hash;
let uri_str = format!("{}/api/v1/block/{hash}", configuration.base_path, hash=crate::apis::urlencode(p_hash));
let mut req_builder = configuration.client.request(reqwest::Method::HEAD, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<CheckBlockHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_block_downloads_handler(configuration: &configuration::Configuration, hash: &str) -> Result<models::BlockDownloadsResponse, Error<GetBlockDownloadsHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_hash = hash;
let uri_str = format!("{}/api/v1/block/{hash}/downloads", configuration.base_path, hash=crate::apis::urlencode(p_hash));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BlockDownloadsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BlockDownloadsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBlockDownloadsHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_block_handler(configuration: &configuration::Configuration, hash: &str) -> Result<reqwest::Response, Error<GetBlockHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_hash = hash;
let uri_str = format!("{}/api/v1/block/{hash}", configuration.base_path, hash=crate::apis::urlencode(p_hash));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<GetBlockHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// If the hash is a file hash, returns all blocks with their block index related to that file. If the hash is a block hash, returns the block itself.
pub async fn get_blocks_by_hash_handler(configuration: &configuration::Configuration, hash: &str) -> Result<models::BlocksResponse, Error<GetBlocksByHashHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_hash = hash;
let uri_str = format!("{}/api/v1/blocks/{hash}", configuration.base_path, hash=crate::apis::urlencode(p_hash));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BlocksResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BlocksResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBlocksByHashHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_user_blocks_handler(configuration: &configuration::Configuration, page: Option<i32>, per_page: Option<i32>) -> Result<models::UserBlocksResponse, Error<GetUserBlocksHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_page = page;
let p_per_page = per_page;
let uri_str = format!("{}/api/v1/user/blocks", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_page {
req_builder = req_builder.query(&[("page", &param_value.to_string())]);
}
if let Some(ref param_value) = p_per_page {
req_builder = req_builder.query(&[("per_page", &param_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserBlocksResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserBlocksResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUserBlocksHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_blocks_handler(configuration: &configuration::Configuration, page: Option<i32>, per_page: Option<i32>) -> Result<models::ListBlocksResponse, Error<ListBlocksHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_page = page;
let p_per_page = per_page;
let uri_str = format!("{}/api/v1/blocks", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_page {
req_builder = req_builder.query(&[("page", &param_value.to_string())]);
}
if let Some(ref param_value) = p_per_page {
req_builder = req_builder.query(&[("per_page", &param_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListBlocksResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListBlocksResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBlocksHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// If the block already exists, the server will return a 200 OK response. If the block is new, the server will return a 201 Created response.
pub async fn upload_block_handler(configuration: &configuration::Configuration, file_hash: &str, idx: i64, body: std::path::PathBuf) -> Result<models::BlockUploadedResponse, Error<UploadBlockHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_file_hash = file_hash;
let p_idx = idx;
let p_body = body;
let uri_str = format!("{}/api/v1/block", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("file_hash", &p_file_hash.to_string())]);
req_builder = req_builder.query(&[("idx", &p_idx.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let file_content = std::fs::read(&p_body).map_err(|e| Error::Io(e))?;
req_builder = req_builder.body(file_content);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BlockUploadedResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BlockUploadedResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UploadBlockHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns a list of missing blocks.
pub async fn verify_blocks_handler(configuration: &configuration::Configuration, verify_blocks_request: models::VerifyBlocksRequest) -> Result<models::VerifyBlocksResponse, Error<VerifyBlocksHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_verify_blocks_request = verify_blocks_request;
let uri_str = format!("{}/api/v1/block/verify", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_verify_blocks_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifyBlocksResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerifyBlocksResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<VerifyBlocksHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}

View File

@ -0,0 +1,51 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
#[derive(Debug, Clone)]
pub struct Configuration {
pub base_path: String,
pub user_agent: Option<String>,
pub client: reqwest::Client,
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
}
pub type BasicAuth = (String, Option<String>);
#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}
impl Configuration {
pub fn new() -> Configuration {
Configuration::default()
}
}
impl Default for Configuration {
fn default() -> Self {
Configuration {
base_path: "http://localhost".to_owned(),
user_agent: Some("OpenAPI-Generator/0.2.0/rust".to_owned()),
client: reqwest::Client::new(),
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
}
}
}

View File

@ -0,0 +1,106 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`get_file_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFileHandlerError {
Status404(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`upload_file_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UploadFileHandlerError {
Status400(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// The file will be reconstructed from its blocks.
pub async fn get_file_handler(configuration: &configuration::Configuration, hash: &str, file_download_request: models::FileDownloadRequest) -> Result<reqwest::Response, Error<GetFileHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_hash = hash;
let p_file_download_request = file_download_request;
let uri_str = format!("{}/api/v1/file/{hash}", configuration.base_path, hash=crate::apis::urlencode(p_hash));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_file_download_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<GetFileHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// The file will be split into blocks and stored in the database.
pub async fn upload_file_handler(configuration: &configuration::Configuration, body: std::path::PathBuf) -> Result<models::FileUploadResponse, Error<UploadFileHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body = body;
let uri_str = format!("{}/api/v1/file", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let file_content = std::fs::read(&p_body).map_err(|e| Error::Io(e))?;
req_builder = req_builder.body(file_content);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileUploadResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileUploadResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UploadFileHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}

View File

@ -0,0 +1,244 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`create_flist_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateFlistHandlerError {
Status401(models::ResponseError),
Status403(models::ResponseError),
Status409(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_flist_state_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFlistStateHandlerError {
Status401(models::ResponseError),
Status403(models::ResponseError),
Status404(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_flists_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListFlistsHandlerError {
Status401(models::ResponseError),
Status403(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`preview_flist_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PreviewFlistHandlerError {
Status400(models::ResponseError),
Status401(models::ResponseError),
Status403(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`serve_flists`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ServeFlistsError {
Status404(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
pub async fn create_flist_handler(configuration: &configuration::Configuration, flist_body: models::FlistBody) -> Result<models::Job, Error<CreateFlistHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_flist_body = flist_body;
let uri_str = format!("{}/api/v1/fl", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_flist_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Job`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Job`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateFlistHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_flist_state_handler(configuration: &configuration::Configuration, job_id: &str) -> Result<models::FlistStateResponse, Error<GetFlistStateHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_job_id = job_id;
let uri_str = format!("{}/api/v1/fl/{job_id}", configuration.base_path, job_id=crate::apis::urlencode(p_job_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlistStateResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FlistStateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFlistStateHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_flists_handler(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, Vec<models::FileInfo>>, Error<ListFlistsHandlerError>> {
let uri_str = format!("{}/api/v1/fl", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, Vec&lt;models::FileInfo&gt;&gt;`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, Vec&lt;models::FileInfo&gt;&gt;`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListFlistsHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn preview_flist_handler(configuration: &configuration::Configuration, flist_path: &str) -> Result<models::PreviewResponse, Error<PreviewFlistHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_flist_path = flist_path;
let uri_str = format!("{}/api/v1/fl/preview/{flist_path}", configuration.base_path, flist_path=crate::apis::urlencode(p_flist_path));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PreviewResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PreviewResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PreviewFlistHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn serve_flists(configuration: &configuration::Configuration, path: &str) -> Result<reqwest::Response, Error<ServeFlistsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path = path;
let uri_str = format!("{}/{path}", configuration.base_path, path=crate::apis::urlencode(p_path));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<ServeFlistsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}

View File

@ -0,0 +1,63 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`serve_flists`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ServeFlistsError {
Status404(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
pub async fn serve_flists(configuration: &configuration::Configuration, path: &str) -> Result<models::ResponseResult, Error<ServeFlistsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path = path;
let uri_str = format!("{}/{path}", configuration.base_path, path=crate::apis::urlencode(p_path));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResponseResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ResponseResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ServeFlistsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}

View File

@ -0,0 +1,121 @@
use std::error;
use std::fmt;
#[derive(Debug, Clone)]
pub struct ResponseContent<T> {
pub status: reqwest::StatusCode,
pub content: String,
pub entity: Option<T>,
}
#[derive(Debug)]
pub enum Error<T> {
Reqwest(reqwest::Error),
Serde(serde_json::Error),
Io(std::io::Error),
ResponseError(ResponseContent<T>),
}
impl <T> fmt::Display for Error<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (module, e) = match self {
Error::Reqwest(e) => ("reqwest", e.to_string()),
Error::Serde(e) => ("serde", e.to_string()),
Error::Io(e) => ("IO", e.to_string()),
Error::ResponseError(e) => ("response", format!("status code {}", e.status)),
};
write!(f, "error in {}: {}", module, e)
}
}
impl <T: fmt::Debug> error::Error for Error<T> {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
Some(match self {
Error::Reqwest(e) => e,
Error::Serde(e) => e,
Error::Io(e) => e,
Error::ResponseError(_) => return None,
})
}
}
impl <T> From<reqwest::Error> for Error<T> {
fn from(e: reqwest::Error) -> Self {
Error::Reqwest(e)
}
}
impl <T> From<serde_json::Error> for Error<T> {
fn from(e: serde_json::Error) -> Self {
Error::Serde(e)
}
}
impl <T> From<std::io::Error> for Error<T> {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
pub fn urlencode<T: AsRef<str>>(s: T) -> String {
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
}
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
if let serde_json::Value::Object(object) = value {
let mut params = vec![];
for (key, value) in object {
match value {
serde_json::Value::Object(_) => params.append(&mut parse_deep_object(
&format!("{}[{}]", prefix, key),
value,
)),
serde_json::Value::Array(array) => {
for (i, value) in array.iter().enumerate() {
params.append(&mut parse_deep_object(
&format!("{}[{}][{}]", prefix, key, i),
value,
));
}
},
serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())),
_ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
}
}
return params;
}
unimplemented!("Only objects are supported with style=deepObject")
}
/// Internal use only
/// A content type supported by this client.
#[allow(dead_code)]
enum ContentType {
Json,
Text,
Unsupported(String)
}
impl From<&str> for ContentType {
fn from(content_type: &str) -> Self {
if content_type.starts_with("application") && content_type.contains("json") {
return Self::Json;
} else if content_type.starts_with("text/plain") {
return Self::Text;
} else {
return Self::Unsupported(content_type.to_string());
}
}
}
pub mod authentication_api;
pub mod block_management_api;
pub mod file_management_api;
pub mod flist_management_api;
pub mod system_api;
pub mod website_serving_api;
pub mod configuration;

View File

@ -0,0 +1,59 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`health_check_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum HealthCheckHandlerError {
UnknownValue(serde_json::Value),
}
pub async fn health_check_handler(configuration: &configuration::Configuration, ) -> Result<models::HealthResponse, Error<HealthCheckHandlerError>> {
let uri_str = format!("{}/api/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HealthResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::HealthResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<HealthCheckHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}

View File

@ -0,0 +1,53 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`serve_website_handler`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ServeWebsiteHandlerError {
Status404(models::ResponseError),
Status500(models::ResponseError),
UnknownValue(serde_json::Value),
}
pub async fn serve_website_handler(configuration: &configuration::Configuration, website_hash: &str, path: &str) -> Result<reqwest::Response, Error<ServeWebsiteHandlerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_website_hash = website_hash;
let p_path = path;
let uri_str = format!("{}/api/v1/website/{website_hash}/{path}", configuration.base_path, website_hash=crate::apis::urlencode(p_website_hash), path=crate::apis::urlencode(p_path));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<ServeWebsiteHandlerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}

View File

@ -0,0 +1,11 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;
extern crate reqwest;
pub mod apis;
pub mod models;

View File

@ -0,0 +1,36 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Block {
#[serde(rename = "data")]
pub data: std::path::PathBuf,
#[serde(rename = "hash")]
pub hash: String,
#[serde(rename = "index")]
pub index: i64,
#[serde(rename = "size")]
pub size: i32,
}
impl Block {
pub fn new(data: std::path::PathBuf, hash: String, index: i64, size: i32) -> Block {
Block {
data,
hash,
index,
size,
}
}
}

View File

@ -0,0 +1,38 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// BlockDownloadsResponse : Response for block downloads endpoint
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BlockDownloadsResponse {
/// Block hash
#[serde(rename = "block_hash")]
pub block_hash: String,
/// Size of the block in bytes
#[serde(rename = "block_size")]
pub block_size: i64,
/// Number of times the block has been downloaded
#[serde(rename = "downloads_count")]
pub downloads_count: i64,
}
impl BlockDownloadsResponse {
/// Response for block downloads endpoint
pub fn new(block_hash: String, block_size: i64, downloads_count: i64) -> BlockDownloadsResponse {
BlockDownloadsResponse {
block_hash,
block_size,
downloads_count,
}
}
}

View File

@ -0,0 +1,34 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// BlockInfo : Block information with hash and index
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BlockInfo {
/// Block hash
#[serde(rename = "hash")]
pub hash: String,
/// Block index within the file
#[serde(rename = "index")]
pub index: i64,
}
impl BlockInfo {
/// Block information with hash and index
pub fn new(hash: String, index: i64) -> BlockInfo {
BlockInfo {
hash,
index,
}
}
}

View File

@ -0,0 +1,30 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BlockUploadedResponse {
#[serde(rename = "hash")]
pub hash: String,
#[serde(rename = "message")]
pub message: String,
}
impl BlockUploadedResponse {
pub fn new(hash: String, message: String) -> BlockUploadedResponse {
BlockUploadedResponse {
hash,
message,
}
}
}

View File

@ -0,0 +1,30 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// BlocksResponse : Response for blocks by hash endpoint
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BlocksResponse {
/// List of blocks with their indices
#[serde(rename = "blocks")]
pub blocks: Vec<models::BlockInfo>,
}
impl BlocksResponse {
/// Response for blocks by hash endpoint
pub fn new(blocks: Vec<models::BlockInfo>) -> BlocksResponse {
BlocksResponse {
blocks,
}
}
}

View File

@ -0,0 +1,30 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct DirListTemplate {
#[serde(rename = "cur_path")]
pub cur_path: String,
#[serde(rename = "lister")]
pub lister: Box<models::DirLister>,
}
impl DirListTemplate {
pub fn new(cur_path: String, lister: models::DirLister) -> DirListTemplate {
DirListTemplate {
cur_path,
lister: Box::new(lister),
}
}
}

View File

@ -0,0 +1,27 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct DirLister {
#[serde(rename = "files")]
pub files: Vec<models::FileInfo>,
}
impl DirLister {
pub fn new(files: Vec<models::FileInfo>) -> DirLister {
DirLister {
files,
}
}
}

View File

@ -0,0 +1,33 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ErrorTemplate {
#[serde(rename = "cur_path")]
pub cur_path: String,
#[serde(rename = "err")]
pub err: Box<models::TemplateErr>,
#[serde(rename = "message")]
pub message: String,
}
impl ErrorTemplate {
pub fn new(cur_path: String, err: models::TemplateErr, message: String) -> ErrorTemplate {
ErrorTemplate {
cur_path,
err: Box::new(err),
message,
}
}
}

View File

@ -0,0 +1,30 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct File {
#[serde(rename = "file_content")]
pub file_content: std::path::PathBuf,
#[serde(rename = "file_hash")]
pub file_hash: String,
}
impl File {
pub fn new(file_content: std::path::PathBuf, file_hash: String) -> File {
File {
file_content,
file_hash,
}
}
}

View File

@ -0,0 +1,30 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// FileDownloadRequest : Request for file download with custom filename
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FileDownloadRequest {
/// The custom filename to use for download
#[serde(rename = "file_name")]
pub file_name: String,
}
impl FileDownloadRequest {
/// Request for file download with custom filename
pub fn new(file_name: String) -> FileDownloadRequest {
FileDownloadRequest {
file_name,
}
}
}

View File

@ -0,0 +1,42 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FileInfo {
#[serde(rename = "is_file")]
pub is_file: bool,
#[serde(rename = "last_modified")]
pub last_modified: i64,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "path_uri")]
pub path_uri: String,
#[serde(rename = "progress")]
pub progress: f32,
#[serde(rename = "size")]
pub size: i64,
}
impl FileInfo {
pub fn new(is_file: bool, last_modified: i64, name: String, path_uri: String, progress: f32, size: i64) -> FileInfo {
FileInfo {
is_file,
last_modified,
name,
path_uri,
progress,
size,
}
}
}

View File

@ -0,0 +1,34 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// FileUploadResponse : Response for file upload
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FileUploadResponse {
/// The file hash
#[serde(rename = "file_hash")]
pub file_hash: String,
/// Message indicating success
#[serde(rename = "message")]
pub message: String,
}
impl FileUploadResponse {
/// Response for file upload
pub fn new(file_hash: String, message: String) -> FileUploadResponse {
FileUploadResponse {
file_hash,
message,
}
}
}

View File

@ -0,0 +1,48 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FlistBody {
#[serde(rename = "auth", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub auth: Option<Option<String>>,
#[serde(rename = "email", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub email: Option<Option<String>>,
#[serde(rename = "identity_token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub identity_token: Option<Option<String>>,
#[serde(rename = "image_name")]
pub image_name: String,
#[serde(rename = "password", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub password: Option<Option<String>>,
#[serde(rename = "registry_token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub registry_token: Option<Option<String>>,
#[serde(rename = "server_address", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub server_address: Option<Option<String>>,
#[serde(rename = "username", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub username: Option<Option<String>>,
}
impl FlistBody {
pub fn new(image_name: String) -> FlistBody {
FlistBody {
auth: None,
email: None,
identity_token: None,
image_name,
password: None,
registry_token: None,
server_address: None,
username: None,
}
}
}

Some files were not shown because too many files have changed in this diff Show More