Struct podman_api::Podman
source · [−]pub struct Podman { /* private fields */ }
Expand description
Entrypoint interface for communicating with podman daemon
Implementations
sourceimpl Podman
impl Podman
sourcepub fn new<U>(uri: U) -> Result<Podman> where
U: AsRef<str>,
pub fn new<U>(uri: U) -> Result<Podman> where
U: AsRef<str>,
Creates a new Podman instance by automatically choosing appropriate connection type based
on provided uri
.
Supported schemes are:
unix://
only works when build target isunix
, otherwise returns an Errortcp://
http://
To create a Podman instance utilizing TLS use explicit Podman::tls
constructor (this requires tls
feature enabled).
Uses LATEST_API_VERSION
, to use a specific version see
Podman::new_versioned
.
sourcepub fn new_versioned<U>(
uri: U,
version: impl Into<ApiVersion>
) -> Result<Podman> where
U: AsRef<str>,
pub fn new_versioned<U>(
uri: U,
version: impl Into<ApiVersion>
) -> Result<Podman> where
U: AsRef<str>,
Same as Podman::new
but the API version can be explicitly specified.
sourcepub fn unix<P>(socket_path: P) -> Podman where
P: AsRef<Path>,
This is supported on Unix only.
pub fn unix<P>(socket_path: P) -> Podman where
P: AsRef<Path>,
Creates a new podman instance for a podman host listening on a given Unix socket.
socket_path
is the part of URI that comes after the unix://
. For example a URI unix:///run/podman.sock
has a
socket_path
== “/run/podman.sock”.
Uses LATEST_API_VERSION
, to use a specific version see
Podman::unix_versioned
.
sourcepub fn unix_versioned<P>(
socket_path: P,
version: impl Into<ApiVersion>
) -> Podman where
P: AsRef<Path>,
This is supported on Unix only.
pub fn unix_versioned<P>(
socket_path: P,
version: impl Into<ApiVersion>
) -> Podman where
P: AsRef<Path>,
Same as Podman::unix
but the API version can be explicitly specified.
sourcepub fn tls<H, P>(host: H, cert_path: P, verify: bool) -> Result<Podman> where
H: AsRef<str>,
P: AsRef<Path>,
This is supported on crate feature tls
only.
pub fn tls<H, P>(host: H, cert_path: P, verify: bool) -> Result<Podman> where
H: AsRef<str>,
P: AsRef<Path>,
tls
only.Creates a new podman instance for a podman host listening on a given TCP socket host
.
host
is the part of URI that comes after tcp://
or http://
or https://
schemes,
also known as authority part.
cert_path
specifies the base path in the filesystem containing a certificate (cert.pem
)
and a key (key.pem
) that will be used by the client. If verify is true
a CA file will be
added (ca.pem
) to the connector.
Returns an error if the provided host will fail to parse as URL or reading the certificate files will fail.
Uses LATEST_API_VERSION
, to use a specific version see
Podman::tls_versioned
.
sourcepub fn tls_versioned<H, P>(
host: H,
version: impl Into<ApiVersion>,
cert_path: P,
verify: bool
) -> Result<Podman> where
H: AsRef<str>,
P: AsRef<Path>,
This is supported on crate feature tls
only.
pub fn tls_versioned<H, P>(
host: H,
version: impl Into<ApiVersion>,
cert_path: P,
verify: bool
) -> Result<Podman> where
H: AsRef<str>,
P: AsRef<Path>,
tls
only.Same as Podman::tls
but the API version can be explicitly specified.
sourcepub fn tcp<H>(host: H) -> Result<Podman> where
H: AsRef<str>,
pub fn tcp<H>(host: H) -> Result<Podman> where
H: AsRef<str>,
Creates a new podman instance for a podman host listening on a given TCP socket host
.
host
is the part of URI that comes after tcp://
or http://
schemes, also known as
authority part.
TLS is supported with feature tls
enabled through Podman::tls constructor.
Returns an error if the provided host will fail to parse as URL.
Uses LATEST_API_VERSION
, to use a specific version see
Podman::tcp_versioned
.
sourcepub fn tcp_versioned<H>(
host: H,
version: impl Into<ApiVersion>
) -> Result<Podman> where
H: AsRef<str>,
pub fn tcp_versioned<H>(
host: H,
version: impl Into<ApiVersion>
) -> Result<Podman> where
H: AsRef<str>,
Same as Podman::tcp
but the API version can be explicitly specified.
sourcepub async fn adjust_api_version(&mut self) -> Result<()>
pub async fn adjust_api_version(&mut self) -> Result<()>
Verifies the API version returned by the server and adjusts the version used by this client in future requests.
sourcepub fn containers(&self) -> Containers<'_>
pub fn containers(&self) -> Containers<'_>
Returns a handle to podman containers that can be used to operate on them.
sourcepub fn execs(&self) -> Execs<'_>
pub fn execs(&self) -> Execs<'_>
Returns a handle to podman execs that can be used to operate on them.
sourcepub fn images(&self) -> Images<'_>
pub fn images(&self) -> Images<'_>
Returns a handle to podman images that can be used to operate on them.
sourcepub fn manifests(&self) -> Manifests<'_>
pub fn manifests(&self) -> Manifests<'_>
Returns a handle to podman manifests that can be used to operate on them.
sourcepub fn networks(&self) -> Networks<'_>
pub fn networks(&self) -> Networks<'_>
Returns a handle to podman networks that can be used to operate on them.
sourcepub fn pods(&self) -> Pods<'_>
pub fn pods(&self) -> Pods<'_>
Returns a handle to podman pods that can be used to operate on them.
sourcepub fn volumes(&self) -> Volumes<'_>
pub fn volumes(&self) -> Volumes<'_>
Returns a handle to podman volumes that can be used to operate on them.
sourcepub fn secrets(&self) -> Secrets<'_>
pub fn secrets(&self) -> Secrets<'_>
Returns a handle to podman secrets that can be used to operate on them.
sourcepub async fn info(&self) -> Result<Info>
pub async fn info(&self) -> Result<Info>
Returns information on the system and libpod configuration
Example:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.info().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn ping(&self) -> Result<LibpodPingInfo>
pub async fn ping(&self) -> Result<LibpodPingInfo>
Return protocol information from libpod.
Example:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.ping().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn version(&self) -> Result<LibpodVersionResponse>
pub async fn version(&self) -> Result<LibpodVersionResponse>
Returns component version information.
Example:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.version().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn data_usage(&self) -> Result<LibpodDataUsageResponse>
pub async fn data_usage(&self) -> Result<LibpodDataUsageResponse>
Return information about disk usage for containers, images, and volumes.
Example:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.data_usage().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn prune(&self) -> Result<LibpodSystemPruneResponse>
pub async fn prune(&self) -> Result<LibpodSystemPruneResponse>
Prune unused data.
Example:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.prune().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub fn events<'libpod>(
&'libpod self,
opts: &EventsOpts
) -> impl Stream<Item = Result<Event>> + Unpin + 'libpod
pub fn events<'libpod>(
&'libpod self,
opts: &EventsOpts
) -> impl Stream<Item = Result<Event>> + Unpin + 'libpod
Returns system events
Example:
async {
use podman_api::Podman;
use futures_util::StreamExt;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
let mut events = podman.events(&Default::default());
while let Some(event) = events.next().await {
match event {
Ok(event) => println!("{:?}", event),
Err(e) => eprintln!("{}", e),
}
}
};
sourcepub async fn play_kubernetes_yaml(
&self,
opts: &PlayKubernetesYamlOpts,
yaml: impl Into<String>
) -> Result<PlayKubeReport>
pub async fn play_kubernetes_yaml(
&self,
opts: &PlayKubernetesYamlOpts,
yaml: impl Into<String>
) -> Result<PlayKubeReport>
Create and run pods based on a Kubernetes YAML file (pod or service kind).
Example:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
let yaml = r#"
apiVersion: v1
kind: Pod
metadata:
name: youthfulwescoff
spec:
containers:
- image: docker.io/library/alpine:latest
name: youthfulwescoff
securityContext:
capabilities:
drop:
- CAP_MKNOD
- CAP_NET_RAW
- CAP_AUDIT_WRITE
stdin: true
tty: true
"#;
match podman.play_kubernetes_yaml(&Default::default(), yaml).await {
Ok(report) => println!("{:?}", report),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn remove_kubernetes_pods(&self) -> Result<PlayKubeReport>
pub async fn remove_kubernetes_pods(&self) -> Result<PlayKubeReport>
Tears down pods defined in a YAML file.
Example:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.remove_kubernetes_pods().await {
Ok(report) => println!("{:?}", report),
Err(e) => eprintln!("{}", e),
}
};
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Podman
impl Send for Podman
impl Sync for Podman
impl Unpin for Podman
impl !UnwindSafe for Podman
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more