[−][src]Struct kube::DynamicResource
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]
pub fn default() -> DynamicResource
[src]
impl TryFrom<DynamicResource> for Resource
[src]
Auto Trait Implementations
impl RefUnwindSafe for DynamicResource
[src]
impl Send for DynamicResource
[src]
impl Sync for DynamicResource
[src]
impl Unpin for DynamicResource
[src]
impl UnwindSafe for DynamicResource
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,