pub struct PublicKeyHandler { /* private fields */ }
Expand description
Handler for public key operations
Implementations§
Source§impl PublicKeyHandler
impl PublicKeyHandler
Sourcepub fn new(client: FilesClient) -> Self
pub fn new(client: FilesClient) -> Self
Creates a new PublicKeyHandler
Sourcepub async fn list(
&self,
user_id: Option<i64>,
cursor: Option<String>,
per_page: Option<i64>,
) -> Result<(Vec<PublicKeyEntity>, PaginationInfo)>
pub async fn list( &self, user_id: Option<i64>, cursor: Option<String>, per_page: Option<i64>, ) -> Result<(Vec<PublicKeyEntity>, PaginationInfo)>
List public keys
§Arguments
user_id
- User ID (use 0 for current user, None for all users if admin)cursor
- Pagination cursorper_page
- Number of records per page
§Examples
let client = FilesClient::builder().api_key("key").build()?;
let handler = PublicKeyHandler::new(client);
// List keys for current user
let (keys, pagination) = handler.list(Some(0), None, None).await?;
for key in keys {
println!("{}: {}", key.title.unwrap_or_default(), key.fingerprint.unwrap_or_default());
}
Sourcepub async fn get(&self, id: i64) -> Result<PublicKeyEntity>
pub async fn get(&self, id: i64) -> Result<PublicKeyEntity>
Sourcepub async fn create(
&self,
user_id: i64,
title: &str,
public_key: &str,
) -> Result<PublicKeyEntity>
pub async fn create( &self, user_id: i64, title: &str, public_key: &str, ) -> Result<PublicKeyEntity>
Create a new public key by uploading an existing key
§Arguments
user_id
- User ID (use 0 for current user)title
- Internal reference for keypublic_key
- Actual contents of SSH key
Sourcepub async fn generate(
&self,
user_id: i64,
title: &str,
algorithm: &str,
length: Option<i64>,
password: Option<&str>,
) -> Result<PublicKeyEntity>
pub async fn generate( &self, user_id: i64, title: &str, algorithm: &str, length: Option<i64>, password: Option<&str>, ) -> Result<PublicKeyEntity>
Generate a new SSH key pair
§Arguments
user_id
- User ID (use 0 for current user)title
- Internal reference for keyalgorithm
- Type of key (rsa, dsa, ecdsa, ed25519)length
- Length of key (or signature size for ecdsa)password
- Password for the private key (optional)
Trait Implementations§
Source§impl Clone for PublicKeyHandler
impl Clone for PublicKeyHandler
Source§fn clone(&self) -> PublicKeyHandler
fn clone(&self) -> PublicKeyHandler
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for PublicKeyHandler
impl !RefUnwindSafe for PublicKeyHandler
impl Send for PublicKeyHandler
impl Sync for PublicKeyHandler
impl Unpin for PublicKeyHandler
impl !UnwindSafe for PublicKeyHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more