Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description = "Command line interface client for PersonalMediaVault"
edition = "2021"
license = "MIT"
name = "pmv-cli"
version = "1.8.0"
version = "2.0.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023-2024 Agustin San Roman
Copyright (c) 2023-2025 Agustin San Roman

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
176 changes: 174 additions & 2 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pmv-cli [OPTIONS] <COMMAND>
| [invites](#command-invites) | Manages invites |
| [batch](#command-batch) | Applies a batch operation to a list of media assets |
| [get-server-information](#command-get-server-information) | Gets server information, like the version it is using |
| [get-disk-usage](#command-get-disk-usage) | Gets server disk usage |

<ins>**Options:**</ins>

Expand Down Expand Up @@ -54,6 +55,7 @@ pmv-cli login [OPTIONS]
| `-U, --username <USERNAME>` | Vault username. You can also specify the credentials in the URL |
| `-D, --duration <DURATION>` | Session duration. Can be: day, week, month or year |
| `-I, --invite-code <INVITE_CODE>` | Invite code. Setting this option will ignore the credentials and use the code |
| `-T, --tfa-code <TFA_CODE>` | Two factor authentication code |
| `-h, --help` | Print help |

## Command: logout
Expand Down Expand Up @@ -89,7 +91,12 @@ pmv-cli account <COMMAND>
| [context](#command-account-context) | Prints account context to the standard output |
| [change-username](#command-account-change-username) | Changes username (only for root account) |
| [change-password](#command-account-change-password) | Changes account password |
| [list](#command-account-list) | List accounts |
| [get-security-settings](#command-account-get-security-settings) | Gets account security settings |
| [set-auth-confirmation](#command-account-set-auth-confirmation) | Sets auth confirmation options |
| [get-totp-settings](#command-account-get-totp-settings) | Gets TOTP settings in order to enable two factor authentication |
| [enable-tfa](#command-account-enable-tfa) | Enables two factor authentication |
| [disable-tfa](#command-account-disable-tfa) | Disables two factor authentication |
| [list](#command-account-list) | Lists accounts |
| [create](#command-account-create) | Creates new account |
| [update](#command-account-update) | Updates an account |
| [delete](#command-account-delete) | Deletes an existing account |
Expand Down Expand Up @@ -154,9 +161,112 @@ pmv-cli account change-password
| --- | --- |
| `-h, --help` | Print help |

### Command: account get-security-settings

Gets account security settings

<ins>**Usage:**</ins>

```
pmv-cli account get-security-settings
```

<ins>**Options:**</ins>

| Option | Description |
| --- | --- |
| `-h, --help` | Print help |

### Command: account set-auth-confirmation

Sets auth confirmation options

<ins>**Usage:**</ins>

```
pmv-cli account set-auth-confirmation [OPTIONS] <AUTH_CONFIRMATION>
```

<ins>**Arguments:**</ins>

| Argument | Description |
| --- | --- |
| `<AUTH_CONFIRMATION>` | Set to 'true' to enable auth confirmation, Set it to 'false' to disable it |

<ins>**Options:**</ins>

| Option | Description |
| --- | --- |
| `--prefer-password` | |
| `Prefer using the account password instead of two factor authentication` | |
| `--period-seconds <PERIOD_SECONDS>` | |
| `Period (seconds) to remember the last auth confirmation` | |
| `-h, --help` | |
| `Print help` | |

### Command: account get-totp-settings

Gets TOTP settings in order to enable two factor authentication

<ins>**Usage:**</ins>

```
pmv-cli account get-totp-settings [OPTIONS]
```

<ins>**Options:**</ins>

| Option | Description |
| --- | --- |
| `--issuer <ISSUER>` | TOTP issuer (to be added th the URL) |
| `--account <ACCOUNT>` | TOTP account (to be added th the URL) |
| `--algorithm <ALGORITHM>` | Hashing algorithm (sha-1, sha-256 or sha-512) |
| `--period <PERIOD>` | TOTP period (30s, 60s or 120s) |
| `--allow-skew` | Allows clock skew of 1 period |
| `-h, --help` | Print help |

### Command: account enable-tfa

Enables two factor authentication

<ins>**Usage:**</ins>

```
pmv-cli account enable-tfa <METHOD> <SECRET>
```

<ins>**Arguments:**</ins>

| Argument | Description |
| --- | --- |
| `<METHOD>` | Two factor authentication method (from the settings command result) |
| `<SECRET>` | Two factor authentication secret |

<ins>**Options:**</ins>

| Option | Description |
| --- | --- |
| `-h, --help` | Print help |

### Command: account disable-tfa

Disables two factor authentication

<ins>**Usage:**</ins>

```
pmv-cli account disable-tfa
```

<ins>**Options:**</ins>

| Option | Description |
| --- | --- |
| `-h, --help` | Print help |

### Command: account list

List accounts
Lists accounts

<ins>**Usage:**</ins>

Expand Down Expand Up @@ -1467,6 +1577,8 @@ pmv-cli config <COMMAND>
| [set-max-tasks](#command-config-set-max-tasks) | Sets max tasks in parallel |
| [set-encoding-threads](#command-config-set-encoding-threads) | Sets number of encoding threads to use |
| [set-video-previews-interval](#command-config-set-video-previews-interval) | Sets the video previews interval in seconds |
| [set-max-invites](#command-config-set-max-invites) | Sets the max number of invited sessions by user |
| [set-preserve-originals](#command-config-set-preserve-originals) | Sets the option to preserve original files, before encoding, as an attachment |
| [set-css](#command-config-set-css) | Sets custom CSS for the vault |
| [clear-css](#command-config-clear-css) | Clears custom CSS for the vault |
| [add-video-resolution](#command-config-add-video-resolution) | Adds video resolution |
Expand Down Expand Up @@ -1600,6 +1712,50 @@ pmv-cli config set-video-previews-interval <INTERVAL_SECONDS>
| --- | --- |
| `-h, --help` | Print help |

### Command: config set-max-invites

Sets the max number of invited sessions by user

<ins>**Usage:**</ins>

```
pmv-cli config set-max-invites <INVITE_LIMIT>
```

<ins>**Arguments:**</ins>

| Argument | Description |
| --- | --- |
| `<INVITE_LIMIT>` | Max number of invited sessions by user |

<ins>**Options:**</ins>

| Option | Description |
| --- | --- |
| `-h, --help` | Print help |

### Command: config set-preserve-originals

Sets the option to preserve original files, before encoding, as an attachment

<ins>**Usage:**</ins>

```
pmv-cli config set-preserve-originals [PRESERVE_ORIGINALS]
```

<ins>**Arguments:**</ins>

| Argument | Description |
| --- | --- |
| `[PRESERVE_ORIGINALS]` | Preserve original media, before encoding, as an attachment? |

<ins>**Options:**</ins>

| Option | Description |
| --- | --- |
| `-h, --help` | Print help |

### Command: config set-css

Sets custom CSS for the vault
Expand Down Expand Up @@ -2094,3 +2250,19 @@ pmv-cli get-server-information
| Option | Description |
| --- | --- |
| `-h, --help` | Print help |

## Command: get-disk-usage

Gets server disk usage

<ins>**Usage:**</ins>

```
pmv-cli get-disk-usage
```

<ins>**Options:**</ins>

| Option | Description |
| --- | --- |
| `-h, --help` | Print help |
2 changes: 2 additions & 0 deletions build-production.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@echo off

call cargo build --release

call cp -f target/release/pmv-cli.exe pmv-cli.exe
20 changes: 19 additions & 1 deletion src/api/about.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// About API

use crate::{
models::ServerInformation,
models::{ServerDiskUsage, ServerInformation},
tools::{do_get_request, RequestError, VaultURI},
};

Expand All @@ -22,3 +22,21 @@ pub async fn api_call_about(

Ok(parsed_body.unwrap())
}

pub async fn api_call_disk_usage(
url: &VaultURI,
debug: bool,
) -> Result<ServerDiskUsage, RequestError> {
let body_str = do_get_request(url, "/api/about/disk_usage".to_string(), debug).await?;

let parsed_body: Result<ServerDiskUsage, _> = serde_json::from_str(&body_str);

if parsed_body.is_err() {
return Err(RequestError::Json {
message: parsed_body.err().unwrap().to_string(),
body: body_str,
});
}

Ok(parsed_body.unwrap())
}
Loading