pub struct Client { /* private fields */ }Expand description
Client is the cleanlib-client HTTP transport handle. Cheap to clone;
share across verbs in the same process.
Implementations§
Source§impl Client
impl Client
Sourcepub fn from_config(config: &Config) -> Result<Self, CleanLibraryError>
pub fn from_config(config: &Config) -> Result<Self, CleanLibraryError>
Construct from a loaded Config. TLS required for non-localhost
endpoints. Returns TlsRequired for http:// on remote hosts.
Sourcepub fn new(
endpoint: &str,
api_key: Option<String>,
) -> Result<Self, CleanLibraryError>
pub fn new( endpoint: &str, api_key: Option<String>, ) -> Result<Self, CleanLibraryError>
Construct with explicit endpoint + api_key. Intended for integration
tests + ad-hoc invocations (e.g., CLI --endpoint= flag future).
Sourcepub async fn fetch_verdict(
&self,
ecosystem: &str,
package: &str,
version: &str,
) -> Result<Verdict, CleanLibraryError>
pub async fn fetch_verdict( &self, ecosystem: &str, package: &str, version: &str, ) -> Result<Verdict, CleanLibraryError>
Fetch a single verdict per App Rev 4 §9.3 +
GET /v1/customer/verdicts/{ecosystem}/{package}/{version}.
Sourcepub async fn policy_preview(
&self,
req: &PolicyPreviewRequest,
) -> Result<PolicyPreviewResponse, CleanLibraryError>
pub async fn policy_preview( &self, req: &PolicyPreviewRequest, ) -> Result<PolicyPreviewResponse, CleanLibraryError>
Submit a packages + optional-policy request to
POST /v1/customer/policy/preview. Used by cleanlib scan (no
policy override; preview against active customer policy) and
cleanlib policy preview (with explicit policy override).
Sourcepub async fn fetch_artifact(
&self,
ecosystem: &str,
package: &str,
version: &str,
) -> Result<Vec<u8>, CleanLibraryError>
pub async fn fetch_artifact( &self, ecosystem: &str, package: &str, version: &str, ) -> Result<Vec<u8>, CleanLibraryError>
Fetch the raw artifact bytes for (ecosystem, package, version) via
App’s per-ecosystem registry proxy (App Rev 4 §5.4 + cycle-3 §C.8).
Returns owned Vec<u8> — caller decides write target. Emits decision
- reason headers to stderr for visibility (binary stdout stays clean).
Sourcepub async fn fetch_artifact_stream<W>(
&self,
ecosystem: &str,
package: &str,
version: &str,
writer: &mut W,
) -> Result<u64, CleanLibraryError>where
W: AsyncWrite + Unpin,
pub async fn fetch_artifact_stream<W>(
&self,
ecosystem: &str,
package: &str,
version: &str,
writer: &mut W,
) -> Result<u64, CleanLibraryError>where
W: AsyncWrite + Unpin,
Streaming variant of Self::fetch_artifact — writes chunks to
writer without buffering the full body in memory. Per Client Rev 2
amendment §9.4 cycle-4 §D.5 streaming substrate. Returns total bytes
written. Decision + reason headers surface to stderr before stream.
Sourcepub async fn audit(
&self,
since: Option<&str>,
decision: Option<&str>,
ecosystem: Option<&str>,
) -> Result<AuditResponse, CleanLibraryError>
pub async fn audit( &self, since: Option<&str>, decision: Option<&str>, ecosystem: Option<&str>, ) -> Result<AuditResponse, CleanLibraryError>
Query customer audit log via GET /v1/customer/audit with optional
filters. Caller passes already-validated filter values.