pub struct Podman { /* private fields */ }
Expand description
Entrypoint interface for communicating with podman daemon
Implementations§
Source§impl Podman
impl Podman
Sourcepub fn new<U>(uri: U) -> Result<Podman>
pub fn new<U>(uri: U) -> Result<Podman>
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>
pub fn new_versioned<U>( uri: U, version: impl Into<ApiVersion>, ) -> Result<Podman>
Same as Podman::new
but the API version can be explicitly specified.
Sourcepub fn unix<P>(socket_path: P) -> Podman
Available on Unix only.
pub fn unix<P>(socket_path: P) -> Podman
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
Available on Unix only.
pub fn unix_versioned<P>( socket_path: P, version: impl Into<ApiVersion>, ) -> Podman
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>
Available on crate feature tls
only.
pub fn tls<H, P>(host: H, cert_path: P, verify: bool) -> Result<Podman>
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>
Available on crate feature tls
only.
pub fn tls_versioned<H, P>( host: H, version: impl Into<ApiVersion>, cert_path: P, verify: bool, ) -> Result<Podman>
tls
only.Same as Podman::tls
but the API version can be explicitly specified.
Sourcepub fn tcp<H>(host: H) -> Result<Podman>
pub fn tcp<H>(host: H) -> Result<Podman>
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>
pub fn tcp_versioned<H>( host: H, version: impl Into<ApiVersion>, ) -> Result<Podman>
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<VersionResponse>
pub async fn version(&self) -> Result<VersionResponse>
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<SystemDfReport>
pub async fn data_usage(&self) -> Result<SystemDfReport>
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<SystemPruneReport>
pub async fn prune(&self) -> Result<SystemPruneReport>
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),
}
};