cri_api/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//!
//! ## Examples
//!
//! Connecting over TCP:
//!
//! ```no_run
//! use cri_api::v1::runtime_service_client::RuntimeServiceClient;
//! use cri_api::v1::ListContainersRequest;
//! use tokio::main;
//!
//! #[tokio::main]
//! async fn main() {
//!     let mut client = RuntimeServiceClient::connect("http://[::1]:50051")
//!         .await
//!         .expect("Could not create client.");
//!
//!     let request = tonic::Request::new(ListContainersRequest { filter: None });
//!     let response = client
//!         .list_containers(request)
//!         .await
//!         .expect("Request failed.");
//!     println!("{:?}", response);
//! }
//! ```
//!
//! Connecting to a Unix domain socket:
//!
//! ```no_run
//! use std::convert::TryFrom;
//! use tokio::main;
//!
//! use cri_api::v1::runtime_service_client::RuntimeServiceClient;
//! use tokio::net::UnixStream;
//! use tonic::transport::{Channel, Endpoint, Uri};
//! use tower::service_fn;
//!
//! #[tokio::main]
//! async fn main() {
//!     let path = "/run/containerd/containerd.sock";
//!     let channel = Endpoint::try_from("http://[::]")
//!         .unwrap()
//!         .connect_with_connector(service_fn(move |_: Uri| UnixStream::connect(path)))
//!         .await
//!         .expect("Could not create client.");
//!
//!     let mut client = RuntimeServiceClient::new(channel);
//! }
//! ```
//!
//! List sandboxes
//!
//! ```no_run
//! use cri_api::v1::{ListPodSandboxRequest};
//! use cri_api::v1::runtime_service_client::RuntimeServiceClient;
//! use tokio::net::UnixStream;
//! use tonic::transport::{Endpoint, Uri};
//! use tower::service_fn;
//! use tokio::main;
//!
//! #[tokio::main]
//! async fn main() {
//!     let path = "/run/containerd/containerd.sock";
//!     let channel = Endpoint::try_from("http://[::]")
//!         .unwrap()
//!         .connect_with_connector(service_fn(move |_: Uri| UnixStream::connect(path)))
//!         .await
//!         .expect("Could not create client.");
//!
//!     let mut client = RuntimeServiceClient::new(channel);
//!
//!     let request = ListPodSandboxRequest {
//!         filter: None
//!     };
//!
//!     let response =  client.list_pod_sandbox(request).await;
//!     println!("{:#?}", response);
//! }
//! ```
//!
//! List containers
//!
//! ```no_run
//! use cri_api::v1::{ListContainersRequest};
//! use cri_api::v1::runtime_service_client::RuntimeServiceClient;
//! use tokio::net::UnixStream;
//! use tonic::transport::{Endpoint, Uri};
//! use tower::service_fn;
//! use tokio::main;
//!
//! #[tokio::main]
//! async fn main() {
//!     let path = "/run/containerd/containerd.sock";
//!     let channel = Endpoint::try_from("http://[::]")
//!         .unwrap()
//!         .connect_with_connector(service_fn(move |_: Uri| UnixStream::connect(path)))
//!         .await
//!         .expect("Could not create client.");
//!
//!     let mut client = RuntimeServiceClient::new(channel);
//!
//!     let request = ListContainersRequest {
//!         filter: None
//!     };
//!
//!     let response =  client.list_containers(request).await;
//!     println!("{:#?}", response);
//! }
//! ```

/**
 * Copyright (2024, ) Institute of Software, Chinese Academy of Sciences
 * since 0.1.1
 **/

pub mod v1 {
    //! API version v1, [original Protocol Buffers file](https://github.com/kubernetes/cri-api/tree/7d8ade91836419c9dd49d059bda1fe4a7dc283f5/pkg/apis/runtime/v1/api.proto).
    tonic::include_proto!("runtime.v1");
}