pub struct WorkloadApiClient { /* private fields */ }Expand description
Client for the SPIFFE Workload API.
Provides one-shot calls and streaming updates for X.509 and JWT SVIDs and bundles.
For an always-up-to-date, shareable source of X.509 material with automatic reconnection,
see crate::X509Source.
Implementations§
Source§impl WorkloadApiClient
impl WorkloadApiClient
Sourcepub fn socket_path(&self) -> &str
pub fn socket_path(&self) -> &str
Returns the configured Workload API socket path.
Sourcepub async fn new_from_path(
path: impl AsRef<str>,
) -> Result<Self, GrpcClientError>
pub async fn new_from_path( path: impl AsRef<str>, ) -> Result<Self, GrpcClientError>
Connects to the Workload API using the given UNIX domain socket path.
The path may optionally be prefixed with unix: (e.g. unix:/tmp/spire-agent/public/api.sock).
Sourcepub async fn reconnect(&mut self) -> Result<(), GrpcClientError>
pub async fn reconnect(&mut self) -> Result<(), GrpcClientError>
Rebuilds the underlying gRPC channel.
This is intended for manual recovery scenarios. Higher-level abstractions such as X509Source
typically create fresh clients and manage reconnection automatically.
Sourcepub async fn default() -> Result<Self, GrpcClientError>
pub async fn default() -> Result<Self, GrpcClientError>
Connects to the Workload API using SPIFFE_ENDPOINT_SOCKET.
Sourcepub fn new(
socket_path: impl AsRef<str>,
conn: Channel,
) -> Result<Self, GrpcClientError>
pub fn new( socket_path: impl AsRef<str>, conn: Channel, ) -> Result<Self, GrpcClientError>
Creates a client from an existing gRPC channel.
This is primarily useful for tests or advanced transport customization.
Sourcepub async fn fetch_x509_svid(&mut self) -> Result<X509Svid, GrpcClientError>
pub async fn fetch_x509_svid(&mut self) -> Result<X509Svid, GrpcClientError>
Fetches the default X.509 SVID for the calling workload.
Sourcepub async fn fetch_all_x509_svids(
&mut self,
) -> Result<Vec<X509Svid>, GrpcClientError>
pub async fn fetch_all_x509_svids( &mut self, ) -> Result<Vec<X509Svid>, GrpcClientError>
Fetches all X.509 SVIDs available to the calling workload.
Sourcepub async fn fetch_x509_bundles(
&mut self,
) -> Result<X509BundleSet, GrpcClientError>
pub async fn fetch_x509_bundles( &mut self, ) -> Result<X509BundleSet, GrpcClientError>
Fetches the current X.509 bundle set.
Sourcepub async fn fetch_jwt_bundles(
&mut self,
) -> Result<JwtBundleSet, GrpcClientError>
pub async fn fetch_jwt_bundles( &mut self, ) -> Result<JwtBundleSet, GrpcClientError>
Fetches the current JWT bundle set.
Sourcepub async fn fetch_x509_context(
&mut self,
) -> Result<X509Context, GrpcClientError>
pub async fn fetch_x509_context( &mut self, ) -> Result<X509Context, GrpcClientError>
Fetches the current X.509 context (SVIDs and bundles).
Sourcepub async fn fetch_jwt_svid<T: AsRef<str> + ToString>(
&mut self,
audience: &[T],
spiffe_id: Option<&SpiffeId>,
) -> Result<JwtSvid, GrpcClientError>
pub async fn fetch_jwt_svid<T: AsRef<str> + ToString>( &mut self, audience: &[T], spiffe_id: Option<&SpiffeId>, ) -> Result<JwtSvid, GrpcClientError>
Fetches a JWT-SVID for the given audience and optional SPIFFE ID.
If spiffe_id is None, the Workload API returns the default identity.
Sourcepub async fn fetch_jwt_token<T: AsRef<str> + ToString>(
&mut self,
audience: &[T],
spiffe_id: Option<&SpiffeId>,
) -> Result<String, GrpcClientError>
pub async fn fetch_jwt_token<T: AsRef<str> + ToString>( &mut self, audience: &[T], spiffe_id: Option<&SpiffeId>, ) -> Result<String, GrpcClientError>
Fetches a JWT-SVID token string for the given audience and optional SPIFFE ID.
If spiffe_id is None, the Workload API returns the default identity.
Sourcepub async fn validate_jwt_token<T: AsRef<str> + ToString>(
&mut self,
audience: T,
jwt_token: &str,
) -> Result<JwtSvid, GrpcClientError>
pub async fn validate_jwt_token<T: AsRef<str> + ToString>( &mut self, audience: T, jwt_token: &str, ) -> Result<JwtSvid, GrpcClientError>
Validates a JWT-SVID token for the given audience and returns the parsed JwtSvid.
Sourcepub async fn stream_x509_contexts(
&mut self,
) -> Result<impl Stream<Item = Result<X509Context, GrpcClientError>> + use<>, GrpcClientError>
pub async fn stream_x509_contexts( &mut self, ) -> Result<impl Stream<Item = Result<X509Context, GrpcClientError>> + use<>, GrpcClientError>
Streams X.509 context updates from the Workload API.
Sourcepub async fn stream_x509_svids(
&mut self,
) -> Result<impl Stream<Item = Result<X509Svid, GrpcClientError>> + use<>, GrpcClientError>
pub async fn stream_x509_svids( &mut self, ) -> Result<impl Stream<Item = Result<X509Svid, GrpcClientError>> + use<>, GrpcClientError>
Streams X.509 SVID updates from the Workload API.
Sourcepub async fn stream_x509_bundles(
&mut self,
) -> Result<impl Stream<Item = Result<X509BundleSet, GrpcClientError>> + use<>, GrpcClientError>
pub async fn stream_x509_bundles( &mut self, ) -> Result<impl Stream<Item = Result<X509BundleSet, GrpcClientError>> + use<>, GrpcClientError>
Streams X.509 bundle set updates from the Workload API.
Sourcepub async fn stream_jwt_bundles(
&mut self,
) -> Result<impl Stream<Item = Result<JwtBundleSet, GrpcClientError>> + use<>, GrpcClientError>
pub async fn stream_jwt_bundles( &mut self, ) -> Result<impl Stream<Item = Result<JwtBundleSet, GrpcClientError>> + use<>, GrpcClientError>
Streams JWT bundle set updates from the Workload API.
Trait Implementations§
Source§impl Clone for WorkloadApiClient
impl Clone for WorkloadApiClient
Source§fn clone(&self) -> WorkloadApiClient
fn clone(&self) -> WorkloadApiClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for WorkloadApiClient
impl !RefUnwindSafe for WorkloadApiClient
impl Send for WorkloadApiClient
impl Sync for WorkloadApiClient
impl Unpin for WorkloadApiClient
impl !UnwindSafe for WorkloadApiClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request