Skip to main content

CLIENT

Struct CLIENT 

Source
pub struct CLIENT { /* private fields */ }
Available on crate feature k8s only.

Methods from Deref<Target = Client>§

Source

pub fn valid_until(&self) -> &Option<Timestamp>

Get the expiration timestamp of the client, if it has been set.

Source

pub fn default_namespace(&self) -> &str

Get the default namespace for the client

The namespace is either configured on context in the kubeconfig, falls back to default when running locally, or uses the service account’s namespace when deployed in-cluster.

Source

pub async fn send( &self, request: Request<Body>, ) -> Result<Response<Body>, Error>

Perform a raw HTTP request against the API and return the raw response back. This method can be used to get raw access to the API which may be used to, for example, create a proxy server or application-level gateway between localhost and the API server.

Source

pub async fn request<T>(&self, request: Request<Vec<u8>>) -> Result<T, Error>

Perform a raw HTTP request against the API and deserialize the response as JSON to some known type.

Source

pub async fn request_text( &self, request: Request<Vec<u8>>, ) -> Result<String, Error>

Perform a raw HTTP request against the API and get back the response as a string

Source

pub async fn request_stream( &self, request: Request<Vec<u8>>, ) -> Result<impl AsyncBufRead + use<>, Error>

Perform a raw HTTP request against the API and stream the response body.

The response can be processed using AsyncReadExt and AsyncBufReadExt.

Source

pub async fn request_status<T>( &self, request: Request<Vec<u8>>, ) -> Result<Either<T, Status>, Error>

Perform a raw HTTP request against the API and get back either an object deserialized as JSON or a Status Object.

Source

pub async fn request_events<T>( &self, request: Request<Vec<u8>>, ) -> Result<impl TryStream + use<T>, Error>

Perform a raw request and get back a stream of WatchEvent objects

Source

pub async fn apiserver_version(&self) -> Result<Info, Error>

Returns apiserver version.

Source

pub async fn list_api_groups(&self) -> Result<APIGroupList, Error>

Lists api groups that apiserver serves.

Source

pub async fn list_api_group_resources( &self, apiversion: &str, ) -> Result<APIResourceList, Error>

Lists resources served in given API group.

§Example usage:
let apigroups = client.list_api_groups().await?;
for g in apigroups.groups {
    let ver = g
        .preferred_version
        .as_ref()
        .or_else(|| g.versions.first())
        .expect("preferred or versions exists");
    let apis = client.list_api_group_resources(&ver.group_version).await?;
    dbg!(apis);
}
Source

pub async fn list_core_api_versions(&self) -> Result<APIVersions, Error>

Lists versions of core a.k.a. "" legacy API group.

Source

pub async fn list_core_api_resources( &self, version: &str, ) -> Result<APIResourceList, Error>

Lists resources served in particular core group version.

Source

pub async fn list_api_groups_aggregated( &self, ) -> Result<APIGroupDiscoveryList, Error>

Returns aggregated discovery for all API groups served at /apis.

This uses the Aggregated Discovery API to fetch all non-core API groups and their resources in a single request.

Requires Kubernetes 1.26+ (beta) or 1.30+ (stable).

§Example usage:
let discovery = client.list_api_groups_aggregated().await?;
for group in discovery.items {
    let name = group.metadata.as_ref().and_then(|m| m.name.as_ref());
    println!("Group: {:?}", name);
    for version in group.versions {
        println!("  Version: {:?}", version.version);
        for resource in version.resources {
            println!("    Resource: {:?}", resource.resource);
        }
    }
}
Source

pub async fn list_core_api_versions_aggregated( &self, ) -> Result<APIGroupDiscoveryList, Error>

Returns aggregated discovery for core API group served at /api.

This uses the Aggregated Discovery API to fetch the core API group and all its resources in a single request.

Requires Kubernetes 1.26+ (beta) or 1.30+ (stable).

§Example usage:
let discovery = client.list_core_api_versions_aggregated().await?;
for group in discovery.items {
    for version in group.versions {
        println!("Core version: {:?}", version.version);
        for resource in version.resources {
            println!("  Resource: {:?} (scope: {:?})", resource.resource, resource.scope);
        }
    }
}

Trait Implementations§

Source§

impl Deref for CLIENT

Source§

type Target = Client

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Client

Dereferences the value.
Source§

impl LazyStatic for CLIENT

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ServiceExt for T

Source§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Available on crate feature map-response-body only.
Apply a transformation to the response body. Read more
Source§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

Available on crate feature trace only.
High level tracing that classifies responses using HTTP status codes. Read more
Source§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

Available on crate feature trace only.
High level tracing that classifies responses using gRPC headers. Read more
Source§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Available on crate feature follow-redirect only.
Follow redirect resposes using the Standard policy. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more