Struct kube::DynamicResource[][src]

pub struct DynamicResource { /* fields omitted */ }

A dynamic builder for Resource

Can be used to interact with a dynamic api resources. Can be constructed either from DynamicResource::from_api_resource, or directly.

Direct usage

use kube::api::Resource;
let foos = Resource::dynamic("Foo") // <.spec.kind>
   .group("clux.dev") // <.spec.group>
   .version("v1")
   .into_resource();

It is recommended to use kube::CustomResource (from kube’s derive feature) for CRD cases where you own a struct rather than this.

Note: You will need to implement k8s_openapi traits yourself to use the typed Api with a Resource built from a DynamicResource (and this is not always feasible).

Implementations

impl DynamicResource[src]

pub fn from_api_resource(ar: &APIResource, group_version: &str) -> Self[src]

Creates DynamicResource from an APIResource.

APIResource objects can be extracted from Client::list_api_group_resources. If it does not specify version and/or group, they will be taken from group_version.

Example usage:

use kube::api::DynamicResource;
let apps = client.list_api_group_resources("apps/v1").await?;
for ar in &apps.resources {
    let dr = DynamicResource::from_api_resource(ar, &apps.group_version);
    let r = dr.within("kube-system").into_resource();
    dbg!(r);
}

pub fn new(kind: &str) -> Self[src]

Create a DynamicResource specifying the kind.

The kind must not be plural and it must be in PascalCase Note: You must call group and version to successfully convert this object into something useful.

pub fn group(self, group: &str) -> Self[src]

Set the api group of a custom resource

pub fn version(self, version: &str) -> Self[src]

Set the api version of a custom resource

pub fn within(self, ns: &str) -> Self[src]

Set the namespace of a custom resource

pub fn into_resource(self) -> Resource[src]

Consume the DynamicResource and build a Resource.

Note this crashes on invalid group/version/kinds. Use try_into_resource to handle the errors.

pub fn into_api<K>(self, client: Client) -> Api<K>[src]

Consume the DynamicResource and convert to an Api object.

Note this crashes on invalid group/version/kinds. Use try_into_api to handle the errors.

pub fn try_into_resource(self) -> Result<Resource>[src]

Consume the DynamicResource and attempt to build a Resource.

Equivalent to importing TryFrom trait into scope.

pub fn try_into_api<K>(self, client: Client) -> Result<Api<K>>[src]

Consume the DynamicResource and and attempt to convert to an Api object.

Trait Implementations

impl Default for DynamicResource[src]

impl TryFrom<DynamicResource> for Resource[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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