Struct warg_client::Client
source · pub struct Client<R, C, N>{ /* private fields */ }Expand description
A client for a Warg registry.
Implementations§
source§impl<R: RegistryStorage, C: ContentStorage, N: NamespaceMapStorage> Client<R, C, N>
impl<R: RegistryStorage, C: ContentStorage, N: NamespaceMapStorage> Client<R, C, N>
sourcepub fn new(
url: impl IntoUrl,
registry: R,
content: C,
namespace_map: N,
auth_token: Option<Secret<String>>
) -> ClientResult<Self>
pub fn new( url: impl IntoUrl, registry: R, content: C, namespace_map: N, auth_token: Option<Secret<String>> ) -> ClientResult<Self>
Creates a new client for the given URL, registry storage, and content storage.
sourcepub fn url(&self) -> &RegistryUrl
pub fn url(&self) -> &RegistryUrl
Gets the URL of the client.
sourcepub fn namespace_map(&self) -> &N
pub fn namespace_map(&self) -> &N
Gets the namespace map
sourcepub async fn store_namespace(
&self,
namespace: String,
registry_domain: RegistryDomain
) -> Result<()>
pub async fn store_namespace( &self, namespace: String, registry_domain: RegistryDomain ) -> Result<()>
Stores namespace mapping in local storage
sourcepub async fn reset_namespaces(&self) -> Result<()>
pub async fn reset_namespaces(&self) -> Result<()>
Resets the namespace map
sourcepub async fn reset_registry(&self, all_registries: bool) -> ClientResult<()>
pub async fn reset_registry(&self, all_registries: bool) -> ClientResult<()>
Reset client storage for the registry.
sourcepub async fn clear_content_cache(&self) -> ClientResult<()>
pub async fn clear_content_cache(&self) -> ClientResult<()>
Clear client content cache.
sourcepub async fn refresh_namespace(&mut self, namespace: &str) -> ClientResult<()>
pub async fn refresh_namespace(&mut self, namespace: &str) -> ClientResult<()>
Check operator log for namespace mapping
sourcepub fn get_warg_registry(&self) -> &Option<RegistryDomain>
pub fn get_warg_registry(&self) -> &Option<RegistryDomain>
Get warg-registry header value
sourcepub async fn lock_component(&self, info: &PackageInfo) -> ClientResult<Vec<u8>>
pub async fn lock_component(&self, info: &PackageInfo) -> ClientResult<Vec<u8>>
Locks component
sourcepub async fn bundle_component(
&self,
info: &PackageInfo
) -> ClientResult<Vec<u8>>
pub async fn bundle_component( &self, info: &PackageInfo ) -> ClientResult<Vec<u8>>
Bundles component
sourcepub async fn publish(&self, signing_key: &PrivateKey) -> ClientResult<RecordId>
pub async fn publish(&self, signing_key: &PrivateKey) -> ClientResult<RecordId>
Submits the publish information in client storage.
If there’s no publishing information in client storage, an error is returned.
Returns the identifier of the record that was published.
Use wait_for_publish to wait for the record to transition to the published state.
sourcepub async fn publish_with_info(
&self,
signing_key: &PrivateKey,
info: PublishInfo
) -> ClientResult<RecordId>
pub async fn publish_with_info( &self, signing_key: &PrivateKey, info: PublishInfo ) -> ClientResult<RecordId>
Submits the provided publish information.
Any publish information in client storage is ignored.
Returns the identifier of the record that was published.
Use wait_for_publish to wait for the record to transition to the published state.
sourcepub async fn wait_for_publish(
&self,
package: &PackageName,
record_id: &RecordId,
interval: Duration
) -> ClientResult<()>
pub async fn wait_for_publish( &self, package: &PackageName, record_id: &RecordId, interval: Duration ) -> ClientResult<()>
Waits for a package record to transition to the published state.
The interval is the amount of time to wait between checks.
Returns an error if the package record was rejected.
sourcepub async fn update_all(&mut self) -> ClientResult<()>
pub async fn update_all(&mut self) -> ClientResult<()>
Updates every package log in every client registry storage to the latest registry checkpoint.
sourcepub async fn update(&self) -> ClientResult<()>
pub async fn update(&self) -> ClientResult<()>
Updates every package log in client storage to the latest registry checkpoint.
sourcepub async fn upsert<'a, I>(&self, packages: I) -> Result<(), ClientError>
pub async fn upsert<'a, I>(&self, packages: I) -> Result<(), ClientError>
Inserts or updates the logs of the specified packages in client storage to the latest registry checkpoint.
sourcepub async fn download(
&self,
name: &PackageName,
requirement: &VersionReq
) -> Result<Option<PackageDownload>, ClientError>
pub async fn download( &self, name: &PackageName, requirement: &VersionReq ) -> Result<Option<PackageDownload>, ClientError>
Downloads the latest version of a package into client storage that satisfies the given version requirement.
If the requested package log is not present in client storage, it will be fetched from the registry first.
An error is returned if the package does not exist.
If a version satisfying the requirement does not exist, None is
returned.
Returns the path within client storage of the package contents for the resolved version.
sourcepub async fn download_exact(
&self,
package: &PackageName,
version: &Version
) -> Result<PackageDownload, ClientError>
pub async fn download_exact( &self, package: &PackageName, version: &Version ) -> Result<PackageDownload, ClientError>
Downloads the specified version of a package into client storage.
If the requested package log is not present in client storage, it will be fetched from the registry first.
An error is returned if the package does not exist.
Returns the path within client storage of the package contents for the specified version.
sourcepub async fn download_content(
&self,
digest: &AnyHash
) -> Result<PathBuf, ClientError>
pub async fn download_content( &self, digest: &AnyHash ) -> Result<PathBuf, ClientError>
Downloads the content for the specified digest into client storage.
If the content already exists in client storage, the existing path is returned.
source§impl Client<FileSystemRegistryStorage, FileSystemContentStorage, FileSystemNamespaceMapStorage>
impl Client<FileSystemRegistryStorage, FileSystemContentStorage, FileSystemNamespaceMapStorage>
sourcepub fn try_new_with_config(
url: Option<&str>,
config: &Config,
auth_token: Option<Secret<String>>
) -> Result<StorageLockResult<Self>, ClientError>
pub fn try_new_with_config( url: Option<&str>, config: &Config, auth_token: Option<Secret<String>> ) -> Result<StorageLockResult<Self>, ClientError>
Attempts to create a client for the given registry URL.
If the URL is None, the home registry URL is used; if there is no home registry
URL, an error is returned.
If a lock cannot be acquired for a storage directory, then
NewClientResult::Blocked is returned with the path to the
directory that could not be locked.
sourcepub fn new_with_config(
url: Option<&str>,
config: &Config,
auth_token: Option<Secret<String>>
) -> Result<Self, ClientError>
pub fn new_with_config( url: Option<&str>, config: &Config, auth_token: Option<Secret<String>> ) -> Result<Self, ClientError>
Creates a client for the given registry URL.
If the URL is None, the home registry URL is used; if there is no home registry
URL, an error is returned.
This method blocks if storage locks cannot be acquired.