Compare commits
2 Commits
b02101bd42
...
ba6f53a28a
Author | SHA1 | Date | |
---|---|---|---|
|
ba6f53a28a | ||
|
b81a0aa61c |
@ -11,17 +11,18 @@ categories = ["os", "filesystem", "api-bindings"]
|
||||
readme = "README.md"
|
||||
|
||||
[workspace]
|
||||
members = [".", "vault", "git", "redisclient", "mycelium", "text", "os", "net", "zinit_client", "process", "virt", "postgresclient", "rhai", "herodo"]
|
||||
members = [".", "vault", "git", "redisclient", "mycelium", "text", "os", "net", "zinit_client", "process", "virt", "postgresclient", "rhai", "herodo", "rfs-client"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.metadata]
|
||||
# Workspace-level metadata
|
||||
rust-version = "1.70.0"
|
||||
rust-version = "1.85.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
# Core shared dependencies with consistent versions
|
||||
anyhow = "1.0.98"
|
||||
base64 = "0.22.1"
|
||||
bytes = "1.4.0"
|
||||
dirs = "6.0.0"
|
||||
env_logger = "0.11.8"
|
||||
futures = "0.3.30"
|
||||
@ -84,3 +85,4 @@ sal-virt = { path = "virt" }
|
||||
sal-postgresclient = { path = "postgresclient" }
|
||||
sal-vault = { path = "vault" }
|
||||
sal-rhai = { path = "rhai" }
|
||||
sal-rfs-client = { path = "rfs-client" }
|
||||
|
@ -1,18 +1,21 @@
|
||||
[package]
|
||||
name = "rfs-client"
|
||||
name = "sal-rfs-client"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "Client library for RFS (Remote File System) server"
|
||||
license = "MIT"
|
||||
description = "SAL RFS Client - Client library for Remote File System server"
|
||||
repository = "https://git.threefold.info/herocode/sal"
|
||||
license = "Apache-2.0"
|
||||
keywords = ["rfs", "client", "filesystem", "remote"]
|
||||
categories = ["filesystem", "api-bindings"]
|
||||
|
||||
[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"
|
||||
thiserror.workspace = true
|
||||
url.workspace = true
|
||||
reqwest = { workspace = true, features = ["json", "multipart"] }
|
||||
tokio = { workspace = true, features = ["full"] }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json.workspace = true
|
||||
log.workspace = true
|
||||
bytes.workspace = true
|
||||
futures.workspace = true
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rfs_client::RfsClient;
|
||||
use rfs_client::types::{ClientConfig, Credentials};
|
||||
use sal_rfs_client::RfsClient;
|
||||
use sal_rfs_client::types::{ClientConfig, Credentials};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rfs_client::RfsClient;
|
||||
use rfs_client::types::{ClientConfig, Credentials};
|
||||
use sal_rfs_client::RfsClient;
|
||||
use sal_rfs_client::types::{ClientConfig, Credentials};
|
||||
use openapi::models::{VerifyBlock, VerifyBlocksRequest};
|
||||
|
||||
#[tokio::main]
|
||||
@ -109,7 +109,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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);
|
||||
println!(" - Block: {}, Size: {}", block.hash, block.size);
|
||||
}
|
||||
|
||||
// Upload a block (upload_block_handler)
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rfs_client::RfsClient;
|
||||
use rfs_client::types::{ClientConfig, Credentials, UploadOptions, DownloadOptions};
|
||||
use sal_rfs_client::RfsClient;
|
||||
use sal_rfs_client::types::{ClientConfig, Credentials, UploadOptions, DownloadOptions};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -1,6 +1,5 @@
|
||||
use rfs_client::RfsClient;
|
||||
use rfs_client::types::{ClientConfig, Credentials, FlistOptions, WaitOptions};
|
||||
use std::path::Path;
|
||||
use sal_rfs_client::RfsClient;
|
||||
use sal_rfs_client::types::{ClientConfig, Credentials, FlistOptions, WaitOptions};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rfs_client::RfsClient;
|
||||
use rfs_client::types::{ClientConfig, Credentials, WaitOptions};
|
||||
use sal_rfs_client::RfsClient;
|
||||
use sal_rfs_client::types::{ClientConfig, Credentials, WaitOptions};
|
||||
use openapi::models::FlistState;
|
||||
|
||||
#[tokio::main]
|
||||
|
File diff suppressed because one or more lines are too long
@ -54,6 +54,7 @@ docs/TemplateErrBadRequest.md
|
||||
docs/TemplateErrInternalServerError.md
|
||||
docs/TemplateErrNotFound.md
|
||||
docs/UploadBlockParams.md
|
||||
docs/UserBlockInfo.md
|
||||
docs/UserBlocksResponse.md
|
||||
docs/VerifyBlock.md
|
||||
docs/VerifyBlocksRequest.md
|
||||
@ -117,6 +118,7 @@ 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_block_info.rs
|
||||
src/models/user_blocks_response.rs
|
||||
src/models/verify_block.rs
|
||||
src/models/verify_blocks_request.rs
|
||||
|
@ -95,6 +95,7 @@ Class | Method | HTTP request | Description
|
||||
- [TemplateErrInternalServerError](docs/TemplateErrInternalServerError.md)
|
||||
- [TemplateErrNotFound](docs/TemplateErrNotFound.md)
|
||||
- [UploadBlockParams](docs/UploadBlockParams.md)
|
||||
- [UserBlockInfo](docs/UserBlockInfo.md)
|
||||
- [UserBlocksResponse](docs/UserBlocksResponse.md)
|
||||
- [VerifyBlock](docs/VerifyBlock.md)
|
||||
- [VerifyBlocksRequest](docs/VerifyBlocksRequest.md)
|
||||
|
12
rfs-client/openapi/docs/UserBlockInfo.md
Normal file
12
rfs-client/openapi/docs/UserBlockInfo.md
Normal file
@ -0,0 +1,12 @@
|
||||
# UserBlockInfo
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**hash** | **String** | Block hash |
|
||||
**size** | **i64** | Block size in bytes |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**all_blocks** | **i64** | Total number of all blocks |
|
||||
**blocks** | [**Vec<models::BlockInfo>**](BlockInfo.md) | List of blocks with their indices |
|
||||
**blocks** | [**Vec<models::UserBlockInfo>**](UserBlockInfo.md) | List of blocks with their sizes |
|
||||
**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)
|
||||
|
@ -92,6 +92,8 @@ pub mod template_err_not_found;
|
||||
pub use self::template_err_not_found::TemplateErrNotFound;
|
||||
pub mod upload_block_params;
|
||||
pub use self::upload_block_params::UploadBlockParams;
|
||||
pub mod user_block_info;
|
||||
pub use self::user_block_info::UserBlockInfo;
|
||||
pub mod user_blocks_response;
|
||||
pub use self::user_blocks_response::UserBlocksResponse;
|
||||
pub mod verify_block;
|
||||
|
34
rfs-client/openapi/src/models/user_block_info.rs
Normal file
34
rfs-client/openapi/src/models/user_block_info.rs
Normal 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};
|
||||
|
||||
/// UserBlockInfo : Block information with hash and size
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UserBlockInfo {
|
||||
/// Block hash
|
||||
#[serde(rename = "hash")]
|
||||
pub hash: String,
|
||||
/// Block size in bytes
|
||||
#[serde(rename = "size")]
|
||||
pub size: i64,
|
||||
}
|
||||
|
||||
impl UserBlockInfo {
|
||||
/// Block information with hash and size
|
||||
pub fn new(hash: String, size: i64) -> UserBlockInfo {
|
||||
UserBlockInfo {
|
||||
hash,
|
||||
size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ pub struct UserBlocksResponse {
|
||||
/// Total number of all blocks
|
||||
#[serde(rename = "all_blocks")]
|
||||
pub all_blocks: i64,
|
||||
/// List of blocks with their indices
|
||||
/// List of blocks with their sizes
|
||||
#[serde(rename = "blocks")]
|
||||
pub blocks: Vec<models::BlockInfo>,
|
||||
pub blocks: Vec<models::UserBlockInfo>,
|
||||
/// Total number of blocks
|
||||
#[serde(rename = "total")]
|
||||
pub total: i64,
|
||||
@ -27,7 +27,7 @@ pub struct UserBlocksResponse {
|
||||
|
||||
impl UserBlocksResponse {
|
||||
/// Response for user blocks endpoint
|
||||
pub fn new(all_blocks: i64, blocks: Vec<models::BlockInfo>, total: i64) -> UserBlocksResponse {
|
||||
pub fn new(all_blocks: i64, blocks: Vec<models::UserBlockInfo>, total: i64) -> UserBlocksResponse {
|
||||
UserBlocksResponse {
|
||||
all_blocks,
|
||||
blocks,
|
||||
|
@ -1,3 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "1.82.0"
|
||||
|
@ -12,8 +12,8 @@ use openapi::{
|
||||
},
|
||||
models::{
|
||||
SignInBody, ListBlocksParams,
|
||||
VerifyBlocksRequest, VerifyBlocksResponse, VerifyBlock, FlistBody, UserBlocksResponse, BlockDownloadsResponse,
|
||||
BlocksResponse, PreviewResponse, FileInfo, FlistState, ResponseResult, FlistStateResponse, BlockUploadedResponse, FileUploadResponse,
|
||||
VerifyBlocksRequest, VerifyBlocksResponse, FlistBody, UserBlocksResponse, BlockDownloadsResponse,
|
||||
BlocksResponse, PreviewResponse, FileInfo, FlistState, FlistStateResponse,
|
||||
},
|
||||
};
|
||||
|
||||
@ -122,12 +122,7 @@ impl RfsClient {
|
||||
.map_err(map_openapi_error)?;
|
||||
|
||||
// Extract the file hash from the response
|
||||
match result {
|
||||
FileUploadResponse { file_hash, .. } => {
|
||||
Ok(file_hash.clone())
|
||||
},
|
||||
_ => Err(RfsError::Other("Unexpected response type from file upload".to_string())),
|
||||
}
|
||||
Ok(result.file_hash.clone())
|
||||
}
|
||||
|
||||
/// Download a file from the RFS server
|
||||
|
3
rust-toolchain.toml
Normal file
3
rust-toolchain.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "1.85.0"
|
||||
|
@ -43,6 +43,7 @@ pub use sal_os as os;
|
||||
pub use sal_postgresclient as postgresclient;
|
||||
pub use sal_process as process;
|
||||
pub use sal_redisclient as redisclient;
|
||||
pub use sal_rfs_client as rfs_client;
|
||||
pub use sal_rhai as rhai;
|
||||
pub use sal_text as text;
|
||||
pub use sal_vault as vault;
|
||||
|
Loading…
Reference in New Issue
Block a user