1+ syntax = "proto3" ;
2+
3+ package feos.container.v1 ;
4+
5+ import "google/protobuf/any.proto" ;
6+
7+ // ContainerService manages the lifecycle of containers. It provides an
8+ // external-facing API for clients to create, run, and manage containers,
9+ // abstracting the underlying details of shims and runtimes like youki.
10+ service ContainerService {
11+ // Creates a new container from an OCI image but does not start it.
12+ // This call is asynchronous. It will first trigger an image pull if the
13+ // image is not available locally. The service returns a container_id immediately.
14+ // Clients can then use StreamContainerEvents to track the progress from
15+ // "PULLING_IMAGE" to "CREATED".
16+ rpc CreateContainer (CreateContainerRequest ) returns (CreateContainerResponse );
17+
18+ // Starts a previously created container.
19+ rpc StartContainer (StartContainerRequest ) returns (StartContainerResponse );
20+
21+ // Stops a running container by sending it a configurable signal.
22+ rpc StopContainer (StopContainerRequest ) returns (StopContainerResponse );
23+
24+ // Retrieves detailed information about a specific container.
25+ rpc GetContainer (GetContainerRequest ) returns (ContainerInfo );
26+
27+ // Lists all containers currently managed by the service.
28+ rpc ListContainers (ListContainersRequest ) returns (ListContainersResponse );
29+
30+ // Deletes a container, cleaning up all associated resources including its
31+ // root filesystem. The container must be in a stopped state.
32+ rpc DeleteContainer (DeleteContainerRequest ) returns (DeleteContainerResponse );
33+
34+ // Streams logs (stdout and stderr) from a running or stopped container.
35+ rpc StreamContainerLogs (StreamContainerLogsRequest ) returns (stream LogEntry );
36+
37+ // Streams lifecycle events for one or all containers. This is useful for
38+ // tracking the status of asynchronous operations like CreateContainer.
39+ rpc StreamContainerEvents (StreamContainerEventsRequest ) returns (stream ContainerEvent );
40+ }
41+
42+ // Configuration for creating a new container.
43+ message ContainerConfig {
44+ // Reference to the OCI image to use for the container's root filesystem
45+ // (e.g., "docker.io/library/alpine:latest").
46+ string image_ref = 1 ;
47+ // Optional command to execute inside the container. If not provided, the
48+ // image's default command (from its config) is used.
49+ repeated string command = 2 ;
50+ // Optional environment variables to set inside the container.
51+ map <string , string > env = 3 ;
52+ }
53+
54+ message CreateContainerRequest {
55+ // The configuration for the container.
56+ ContainerConfig config = 1 ;
57+ // An optional client-provided ID for the container. If not provided, a
58+ // UUID will be generated.
59+ optional string container_id = 2 ;
60+ }
61+
62+ message CreateContainerResponse {
63+ // The unique ID of the newly created container.
64+ string container_id = 1 ;
65+ }
66+
67+ message StartContainerRequest {
68+ string container_id = 1 ;
69+ }
70+
71+ message StartContainerResponse {}
72+
73+ message StopContainerRequest {
74+ string container_id = 1 ;
75+ // Optional signal to send for stopping the container. Defaults to SIGTERM.
76+ optional uint32 signal = 2 ;
77+ // Optional timeout in seconds to wait before sending SIGKILL if the container
78+ // has not stopped.
79+ optional uint32 timeout_seconds = 3 ;
80+ }
81+
82+ message StopContainerResponse {}
83+
84+ message GetContainerRequest {
85+ string container_id = 1 ;
86+ }
87+
88+ message ListContainersRequest {}
89+
90+ message ListContainersResponse {
91+ repeated ContainerInfo containers = 1 ;
92+ }
93+
94+ message DeleteContainerRequest {
95+ string container_id = 1 ;
96+ }
97+
98+ message DeleteContainerResponse {}
99+
100+ message StreamContainerLogsRequest {
101+ string container_id = 1 ;
102+ // If true, the stream will not close when the end of the log is reached,
103+ // but will wait for new log entries.
104+ bool follow = 2 ;
105+ // If true, sends all previous logs before streaming new ones.
106+ bool tail = 3 ;
107+ }
108+
109+ message LogEntry {
110+ // The raw log line from either stdout or stderr.
111+ bytes line = 1 ;
112+ // Specifies the source stream of the log line.
113+ enum Source {
114+ SOURCE_UNSPECIFIED = 0 ;
115+ STDOUT = 1 ;
116+ STDERR = 2 ;
117+ }
118+ Source source = 2 ;
119+ }
120+
121+ enum ContainerState {
122+ CONTAINER_STATE_UNSPECIFIED = 0 ;
123+ // The service is pulling the OCI image for the container.
124+ PULLING_IMAGE = 1 ;
125+ // The container's resources have been prepared, and it is ready to be started.
126+ CREATED = 2 ;
127+ // The container is currently running.
128+ RUNNING = 3 ;
129+ // The container process has exited.
130+ STOPPED = 4 ;
131+ }
132+
133+ // Represents information about a single container.
134+ message ContainerInfo {
135+ string container_id = 1 ;
136+ ContainerState state = 2 ;
137+ ContainerConfig config = 3 ;
138+ // The process ID of the container, if it is running.
139+ optional int64 pid = 4 ;
140+ // The exit code of the container process, if it has stopped.
141+ optional int32 exit_code = 5 ;
142+ }
143+
144+ // --- Event Streaming Messages ---
145+
146+ message StreamContainerEventsRequest {
147+ // The ID of the container for which to retrieve events.
148+ // If not provided, the stream will send events for all containers.
149+ optional string container_id = 1 ;
150+ }
151+
152+ message ContainerEvent {
153+ string container_id = 1 ;
154+ // A unique identifier for the event.
155+ string id = 2 ;
156+ // The specific event payload.
157+ google.protobuf.Any data = 3 ;
158+ }
159+
160+ message ContainerStateChangedEvent {
161+ ContainerState new_state = 1 ;
162+ // A human-readable reason for the state change.
163+ string reason = 2 ;
164+ }
0 commit comments