pub struct Client { /* private fields */ }
Expand description
Freta Client
Implementations§
source§impl Client
impl Client
sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Create a new client for the Freta service
Errors
This function will return an error if creating the backend REST API client fails
sourcepub async fn with_config(config: Config) -> Result<Self>
pub async fn with_config(config: Config) -> Result<Self>
Create a new client for the Freta service with a configuration
Errors
This function will return an error if creating the backend REST API client fails
sourcepub async fn logout() -> Result<()>
pub async fn logout() -> Result<()>
logout of the service
Errors
This function will return an error if deleting the authentication cache fails
sourcepub async fn user_config_get(&self) -> Result<UserConfig>
pub async fn user_config_get(&self) -> Result<UserConfig>
Retrieve user configuration settings
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to get their configuration
sourcepub async fn user_config_update(
&self,
eula_accepted: Option<String>,
include_samples: bool
) -> Result<UserConfigUpdateResponse>
pub async fn user_config_update( &self, eula_accepted: Option<String>, include_samples: bool ) -> Result<UserConfigUpdateResponse>
Update user configuration settings
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to update their configuration
sourcepub async fn eula(&self) -> Result<Bytes>
pub async fn eula(&self) -> Result<Bytes>
Get the latest EULA required to use the service
Note, all API requests to the service will return the EULA as part of the error in the HTTP Error response if the EULA has not been accepted.
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
sourcepub async fn info(&self) -> Result<Info>
pub async fn info(&self) -> Result<Info>
Retrieve information about the service
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to get the service information
sourcepub fn images_list(
&self,
image_id: Option<ImageId>,
owner_id: Option<OwnerId>,
state: Option<ImageState>,
include_samples: bool
) -> Pin<Box<impl Stream<Item = Result<Image, Error>> + Send + '_>>
pub fn images_list( &self, image_id: Option<ImageId>, owner_id: Option<OwnerId>, state: Option<ImageState>, include_samples: bool ) -> Pin<Box<impl Stream<Item = Result<Image, Error>> + Send + '_>>
List available images
Example
use futures::StreamExt;
let mut stream = client.images_list(None, None, None, true);
while let Some(image) = stream.next().await {
let image = image?;
println!("{image:?}");
}
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission
sourcepub async fn images_create<T, K, V>(
&self,
format: ImageFormat,
tags: T
) -> Result<Image>where
T: IntoIterator<Item = (K, V)>,
K: Into<String>,
V: Into<String>,
pub async fn images_create<T, K, V>( &self, format: ImageFormat, tags: T ) -> Result<Image>where T: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,
Create a new image entry
The resulting Image.image_url
is a time-limited
SAS URL
that can be used to upload a memory snapshot to Freta via tools such as
azcopy
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to create images.
sourcepub async fn images_upload<P, T, K, V>(
&self,
format: ImageFormat,
tags: T,
path: P
) -> Result<Image>where
P: AsRef<Path>,
T: IntoIterator<Item = (K, V)>,
K: Into<String>,
V: Into<String>,
pub async fn images_upload<P, T, K, V>( &self, format: ImageFormat, tags: T, path: P ) -> Result<Image>where P: AsRef<Path>, T: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,
Create and upload an image to Freta
Errors
This function will return an error in the following cases:
- Creating the image in Freta fails
- Uploading the blob to Azure Storage fails
sourcepub async fn images_get(&self, image_id: ImageId) -> Result<Image>
pub async fn images_get(&self, image_id: ImageId) -> Result<Image>
Get information on an image
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to read the specified image
sourcepub async fn images_delete(
&self,
image_id: ImageId
) -> Result<ImageDeleteResponse>
pub async fn images_delete( &self, image_id: ImageId ) -> Result<ImageDeleteResponse>
Delete an image
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to delete the specified image
sourcepub async fn images_update<T, K, V>(
&self,
image_id: ImageId,
tags: Option<T>,
shareable: Option<bool>
) -> Result<Image>where
T: IntoIterator<Item = (K, V)>,
K: Into<String>,
V: Into<String>,
pub async fn images_update<T, K, V>( &self, image_id: ImageId, tags: Option<T>, shareable: Option<bool> ) -> Result<Image>where T: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,
Update metadata for an image
If tags
is not None, then the tags are overwritten.
If shareable
is not None, then the shareable value is overwritten.
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to update metadata for the specified image
sourcepub async fn images_reanalyze(
&self,
image_id: ImageId
) -> Result<ImageReanalyzeResponse>
pub async fn images_reanalyze( &self, image_id: ImageId ) -> Result<ImageReanalyzeResponse>
Reanalyze an image
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to reanalyze the specified image
sourcepub async fn images_download<P>(
&self,
image_id: ImageId,
output: P
) -> Result<()>where
P: AsRef<Path>,
pub async fn images_download<P>( &self, image_id: ImageId, output: P ) -> Result<()>where P: AsRef<Path>,
Download an image to a file
NOTE: The service only allows downloading images that have been analyzed successfully.
Errors
This function will return an error in the follow cases:
- The user does not have permission to access the specified image
- The image was not successfully analyzed
- Downloading the image fails
Example
client.images_download(image_id, "/tmp/image.lime").await?;
sourcepub fn artifacts_list(
&self,
image_id: ImageId
) -> Pin<Box<impl Stream<Item = Result<String, Error>> + Send + '_>>
pub fn artifacts_list( &self, image_id: ImageId ) -> Pin<Box<impl Stream<Item = Result<String, Error>> + Send + '_>>
List the artifacts extracted from the image
Errors
This function will return an error in the follow cases:
- Getting the artifacts SAS URL for the image fails
- Listing the blobs from the Azure Storage fails
Example
use futures::StreamExt;
let mut stream = client.artifacts_list(image_id);
while let Some(entry) = stream.next().await {
let entry = entry?;
println!("{entry}");
}
sourcepub async fn artifacts_get<N>(
&self,
image_id: ImageId,
name: N
) -> Result<Vec<u8>>where
N: Into<String>,
pub async fn artifacts_get<N>( &self, image_id: ImageId, name: N ) -> Result<Vec<u8>>where N: Into<String>,
sourcepub async fn artifacts_download<P, N>(
&self,
image_id: ImageId,
name: N,
output: P
) -> Result<()>where
P: AsRef<Path>,
N: Into<String>,
pub async fn artifacts_download<P, N>( &self, image_id: ImageId, name: N, output: P ) -> Result<()>where P: AsRef<Path>, N: Into<String>,
sourcepub async fn images_monitor(&self, image_id: ImageId) -> Result<Image>
pub async fn images_monitor(&self, image_id: ImageId) -> Result<Image>
sourcepub fn webhooks_list(
&self
) -> Pin<Box<impl Stream<Item = Result<Webhook, Error>> + Send + '_>>
pub fn webhooks_list( &self ) -> Pin<Box<impl Stream<Item = Result<Webhook, Error>> + Send + '_>>
List the configured webhooks
Errors
This function will return an error in the follow cases:
- The connection to the Service fails
- The user does not have permission to get their webhooks
Example
let mut stream = client.webhooks_list();
while let Some(entry) = stream.next().await {
let entry = entry?;
println!("{:?}", entry);
}
sourcepub async fn webhook_get(&self, webhook_id: WebhookId) -> Result<Webhook>
pub async fn webhook_get(&self, webhook_id: WebhookId) -> Result<Webhook>
Get information on a webhook
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to read the specified webhook
sourcepub async fn webhook_delete(
&self,
webhook_id: WebhookId
) -> Result<WebhookBoolResponse>
pub async fn webhook_delete( &self, webhook_id: WebhookId ) -> Result<WebhookBoolResponse>
Delete a webhook
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to delete the specified webhook
sourcepub async fn webhook_update<S>(
&self,
webhook_id: WebhookId,
url: Url,
event_types: BTreeSet<WebhookEventType>,
hmac_token: Option<S>
) -> Result<Webhook>where
S: Into<Secret>,
pub async fn webhook_update<S>( &self, webhook_id: WebhookId, url: Url, event_types: BTreeSet<WebhookEventType>, hmac_token: Option<S> ) -> Result<Webhook>where S: Into<Secret>,
Update a webhook
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to update the specified webhook
sourcepub async fn webhook_ping(&self, webhook_id: WebhookId) -> Result<Bytes>
pub async fn webhook_ping(&self, webhook_id: WebhookId) -> Result<Bytes>
Ping a webhook
This generates a synthetic event for a given webhook to test that it works as expected without having to analyze an image.
Note: This service provides the raw response from the Freta service to enable the developers of webhook receivers to validate their HMAC calculation works as expected.
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to update the specified webhook
sourcepub async fn webhook_resend(
&self,
webhook_id: WebhookId,
webhook_event_id: WebhookEventId
) -> Result<WebhookEvent>
pub async fn webhook_resend( &self, webhook_id: WebhookId, webhook_event_id: WebhookEventId ) -> Result<WebhookEvent>
Resend a webhook event
This resends a specific event to the webhook.
Note: If the event already pending being sent to the webhook endpoint, this will be a NOOP.
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to resend the specified webhook event
sourcepub async fn webhook_create<S>(
&self,
url: Url,
event_types: BTreeSet<WebhookEventType>,
hmac_token: Option<S>
) -> Result<Webhook>where
S: Into<Secret>,
pub async fn webhook_create<S>( &self, url: Url, event_types: BTreeSet<WebhookEventType>, hmac_token: Option<S> ) -> Result<Webhook>where S: Into<Secret>,
Create a webhook
Errors
This function will return an error in the following conditions:
- The connection to the Service fails
- The user does not have permission to create a webhook
sourcepub fn webhooks_logs(
&self,
webhook_id: WebhookId
) -> Pin<Box<impl Stream<Item = Result<WebhookLog, Error>> + Send + '_>>
pub fn webhooks_logs( &self, webhook_id: WebhookId ) -> Pin<Box<impl Stream<Item = Result<WebhookLog, Error>> + Send + '_>>
List the logs for a specific webhook
Errors
This function will return an error in the follow cases:
- The connection to the Service fails
- The user does not have permission to get their webhooks
Example
let mut stream = client.webhooks_logs(webhook_id);
while let Some(entry) = stream.next().await {
let entry = entry?;
println!("{entry:?}");
}