@@ -107,3 +107,123 @@ macro_rules! with_namespace {
107
107
req
108
108
} } ;
109
109
}
110
+
111
+ use services:: v1:: {
112
+ containers_client:: ContainersClient ,
113
+ content_client:: ContentClient ,
114
+ diff_client:: DiffClient ,
115
+ events_client:: EventsClient ,
116
+ images_client:: ImagesClient ,
117
+ introspection_client:: IntrospectionClient ,
118
+ leases_client:: LeasesClient ,
119
+ namespaces_client:: NamespacesClient ,
120
+ sandbox:: { controller_client:: ControllerClient , store_client:: StoreClient } ,
121
+ snapshots:: snapshots_client:: SnapshotsClient ,
122
+ tasks_client:: TasksClient ,
123
+ version_client:: VersionClient ,
124
+ } ;
125
+ use tonic:: transport:: { Channel , Error } ;
126
+
127
+ /// Client to containerd's APIs.
128
+ pub struct Client {
129
+ channel : Channel ,
130
+ }
131
+
132
+ impl From < Channel > for Client {
133
+ fn from ( value : Channel ) -> Self {
134
+ Self { channel : value }
135
+ }
136
+ }
137
+
138
+ impl Client {
139
+ /// Create a new client from UDS socket.
140
+ #[ cfg( feature = "connect" ) ]
141
+ pub async fn from_path ( path : impl AsRef < std:: path:: Path > ) -> Result < Self , Error > {
142
+ let channel = connect ( path) . await ?;
143
+ Ok ( Self { channel } )
144
+ }
145
+
146
+ /// Access to the underlying Tonic channel.
147
+ #[ inline]
148
+ pub fn channel ( & self ) -> Channel {
149
+ self . channel . clone ( )
150
+ }
151
+
152
+ /// Version service.
153
+ #[ inline]
154
+ pub fn version ( & self ) -> VersionClient < Channel > {
155
+ VersionClient :: new ( self . channel ( ) )
156
+ }
157
+
158
+ /// Task service client.
159
+ #[ inline]
160
+ pub fn tasks ( & self ) -> TasksClient < Channel > {
161
+ TasksClient :: new ( self . channel ( ) )
162
+ }
163
+
164
+ /// Sandbox store client.
165
+ #[ inline]
166
+ pub fn sandbox_store ( & self ) -> StoreClient < Channel > {
167
+ StoreClient :: new ( self . channel ( ) )
168
+ }
169
+
170
+ /// Sandbox controller client.
171
+ #[ inline]
172
+ pub fn sandbox_controller ( & self ) -> ControllerClient < Channel > {
173
+ ControllerClient :: new ( self . channel ( ) )
174
+ }
175
+
176
+ /// Snapshots service.
177
+ #[ inline]
178
+ pub fn snapshots ( & self ) -> SnapshotsClient < Channel > {
179
+ SnapshotsClient :: new ( self . channel ( ) )
180
+ }
181
+
182
+ /// Namespaces service.
183
+ #[ inline]
184
+ pub fn namespaces ( & self ) -> NamespacesClient < Channel > {
185
+ NamespacesClient :: new ( self . channel ( ) )
186
+ }
187
+
188
+ /// Leases service.
189
+ #[ inline]
190
+ pub fn leases ( & self ) -> LeasesClient < Channel > {
191
+ LeasesClient :: new ( self . channel ( ) )
192
+ }
193
+
194
+ /// Intropection service.
195
+ #[ inline]
196
+ pub fn introspection ( & self ) -> IntrospectionClient < Channel > {
197
+ IntrospectionClient :: new ( self . channel ( ) )
198
+ }
199
+
200
+ /// Image service.
201
+ #[ inline]
202
+ pub fn images ( & self ) -> ImagesClient < Channel > {
203
+ ImagesClient :: new ( self . channel ( ) )
204
+ }
205
+
206
+ /// Event service.
207
+ #[ inline]
208
+ pub fn events ( & self ) -> EventsClient < Channel > {
209
+ EventsClient :: new ( self . channel ( ) )
210
+ }
211
+
212
+ /// Diff service.
213
+ #[ inline]
214
+ pub fn diff ( & self ) -> DiffClient < Channel > {
215
+ DiffClient :: new ( self . channel ( ) )
216
+ }
217
+
218
+ /// Content service.
219
+ #[ inline]
220
+ pub fn content ( & self ) -> ContentClient < Channel > {
221
+ ContentClient :: new ( self . channel ( ) )
222
+ }
223
+
224
+ /// Container service.
225
+ #[ inline]
226
+ pub fn containers ( & self ) -> ContainersClient < Channel > {
227
+ ContainersClient :: new ( self . channel ( ) )
228
+ }
229
+ }
0 commit comments