github.com/stackdocker/rkt@v0.10.1-0.20151109095037-1aa827478248/api/v1alpha/api.proto (about)

     1  // Copyright 2015 The rkt Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // To compile, run 'protoc -I api/v1alpha api/v1alpha/api.proto --go_out=plugins=grpc:api/v1alpha' in rkt root directory.
    16  // The protoc version must be 3.0.0.
    17  
    18  // *************************************************** //
    19  // ************ WARNING - HERE BE DRAGONS ************ //
    20  //                                                     //
    21  //   The API defined here is proposed, experimental,   //
    22  //   and (for now) subject to change at any time.      //
    23  //                                                     //
    24  //                   Do not use it.                    //
    25  //                                                     //
    26  //  If you think you want to use it, or for any other  //
    27  //     queries, contact <rkt-dev@googlegroups.com>     //
    28  //      or file an issue on github.com/coreos/rkt      //
    29  //                                                     //
    30  // *************************************************** //
    31  // ****************** END WARNING ******************** //
    32  
    33  syntax = "proto3";
    34  
    35  package v1alpha;
    36  
    37  // ImageType defines the supported image type.
    38  enum ImageType {
    39          IMAGE_TYPE_UNDEFINED = 0;
    40          IMAGE_TYPE_APPC      = 1;
    41          IMAGE_TYPE_DOCKER    = 2;
    42          IMAGE_TYPE_OCI       = 3;
    43  }
    44  
    45  // ImageFormat defines the format of the image.
    46  message ImageFormat {
    47          // Type of the image, required.
    48          ImageType type = 1;
    49  
    50          // Version of the image format, required.
    51          string version = 2;
    52  }
    53  
    54  // Image describes the image's information.
    55  message Image {
    56          // Base format of the image, required. This indicates the original format
    57          // for the image as nowadays all the image formats will be transformed to
    58          // ACI.
    59          ImageFormat base_format = 1;
    60  
    61          // ID of the image, a string that can be used to uniquely identify the image,
    62          // e.g. sha512 hash of the ACIs, required.
    63          string id = 2;
    64  
    65          // Name of the image in the image manifest, e.g. 'coreos.com/etcd', optional.
    66          string name = 3;
    67  
    68          // Version of the image, e.g. 'latest', '2.0.10', optional.
    69          string version = 4;
    70  
    71          // Timestamp of when the image is imported, it is the seconds since epoch, optional.
    72          int64 import_timestamp = 5;
    73  
    74          // JSON-encoded byte array that represents the image manifest, optional.
    75          bytes manifest = 6;
    76  }
    77  
    78  // Network describes the network information of a pod.
    79  message Network {
    80          // Name of the network that a pod belongs to, required.
    81          string name = 1;
    82  
    83          // Pod's IPv4 address within the network, optional if IPv6 address is given.
    84          string ipv4 = 2;
    85  
    86          // Pod's IPv6 address within the network, optional if IPv4 address is given.
    87          string ipv6 = 3;
    88  }
    89  
    90  // AppState defines the possible states of the app.
    91  enum AppState {
    92          APP_STATE_UNDEFINED = 0;
    93          APP_STATE_RUNNING   = 1;
    94          APP_STATE_EXITED    = 2;
    95  }
    96  
    97  // App describes the information of an app that's running in a pod.
    98  message App {
    99          // Name of the app, required.
   100          string name = 1;
   101  
   102          // Image used by the app, required. However, this may only contain the image id
   103          // if it is returned by ListPods().
   104          Image image = 2;
   105  
   106          // State of the app. optional, non-empty only if it's returned by InspectPod().
   107          AppState state = 3;
   108  
   109          // Exit code of the app. optional, only valid if it's returned by InspectPod() and
   110          // the app has already exited.
   111          sint32 exit_code = 4;
   112  }
   113  
   114  // PodState defines the possible states of the pod.
   115  // See https://github.com/coreos/rkt/blob/master/Documentation/devel/pod-lifecycle.md for a detailed
   116  // explanation of each state.
   117  enum PodState {
   118          POD_STATE_UNDEFINED = 0;
   119  
   120          // States before the pod is running.
   121          POD_STATE_EMBRYO    = 1; // Pod is created, ready to entering 'preparing' state.
   122          POD_STATE_PREPARING = 2; // Pod is being prepared. On success it will become 'prepared', otherwise it will become 'aborted prepared'.
   123          POD_STATE_PREPARED  = 3; // Pod has been successfully prepared, ready to enter 'running' state. it can also enter 'deleting' if it's garbage collected before running.
   124  
   125          // State that indicates the pod is running.
   126          POD_STATE_RUNNING = 4; // Pod is running, when it exits, it will become 'exited'.
   127  
   128          // States that indicates the pod is exited, and will never run.
   129          POD_STATE_ABORTED_PREPARE = 5; // Pod failed to prepare, it will only be garbage collected and will never run again.
   130          POD_STATE_EXITED          = 6; // Pod has exited, it now can be garbage collected.
   131          POD_STATE_DELETING        = 7; // Pod is being garbage collected, after that it will enter 'garbage' state.
   132          POD_STATE_GARBAGE         = 8; // Pod is marked as garbage collected, it no longer exists on the machine.
   133  }
   134  
   135  // Pod describes a pod's information.
   136  message Pod {
   137          // ID of the pod, in the form of a UUID, required.
   138          string id = 1;
   139  
   140          // PID of the pod, optional, only valid if it's returned by InspectPod(). A negative value means the pod has exited.
   141          sint32 pid = 2;
   142  
   143          // State of the pod, required.
   144          PodState state = 3;
   145  
   146          // List of apps in the pod, required.
   147          repeated App apps = 4;
   148  
   149          // Network information of the pod, optional, non-empty if the pod is running in private net.
   150          // Note that a pod can be in multiple networks.
   151          repeated Network networks = 5;
   152  
   153          // JSON-encoded byte array that represents the pod manifest of the pod, required.
   154          bytes manifest = 6;
   155  }
   156  
   157  message KeyValue {
   158          // Key part of the key-value pair.
   159          string Key = 1;
   160          // Value part of the key-value pair.
   161          string value = 2;
   162  }
   163  
   164  // PodFilter defines the condition that the returned pods need to satisfy in ListPods().
   165  // The conditions are combined by 'AND'.
   166  message PodFilter {
   167          // If not empty, the pods that have any of the ids will be returned.
   168          repeated string ids = 1;
   169  
   170          // If not empty, the pods that have any of the states will be returned.
   171          repeated PodState states = 2;
   172  
   173          // If not empty, the pods that have any of the apps will be returned.
   174          repeated string app_names = 3;
   175  
   176          // If not empty, the pods that have any of the images(in the apps) will be returned
   177          repeated string image_ids = 4;
   178  
   179          // If not empty, the pods that are in any of the networks will be returned.
   180          repeated string network_names = 5;
   181  
   182          // If not empty, the pods that have any of the annotations will be returned.
   183          repeated KeyValue annotations = 6;
   184  }
   185  
   186  // ImageFilter defines the condition that the returned images need to satisfy in ListImages().
   187  // The conditions are combined by 'AND'.
   188  message ImageFilter {
   189          // If not empty, the images that have any of the ids will be returned.
   190          repeated string ids = 1;
   191  
   192          // if not empty, the images that have any of the prefixes in the name will be returned.
   193          repeated string prefixes = 2;
   194  
   195          // If not empty, the images that have any of the base names will be returned.
   196          // For example, both 'coreos.com/etcd' and 'k8s.io/etcd' will be returned if 'etcd' is included,
   197          // however 'k8s.io/etcd-backup' will not be returned.
   198          repeated string base_names = 3;
   199  
   200          // If not empty, the images that have any of the keywords in the name will be returned.
   201          // For example, both 'kubernetes-etcd', 'etcd:latest' will be returned if 'etcd' is included,
   202          repeated string keywords = 4;
   203  
   204          // If not empty, the images that have any of the labels will be returned.
   205          repeated KeyValue labels = 5;
   206  
   207          // If set, the images that are imported after this timestamp will be returned.
   208          int64 imported_after = 6;
   209  
   210          // If set, the images that are imported before this timestamp will be returned.
   211          int64 imported_before = 7;
   212  
   213          // If not empty, the images that have any of the annotations will be returned.
   214          repeated KeyValue annotations = 8;
   215  }
   216  
   217  // Info describes the information of rkt on the machine.
   218  message Info {
   219          // Version of rkt, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
   220          string rkt_version = 1;
   221  
   222          // Version of appc, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
   223          string appc_version = 2;
   224  
   225          // Latest version of the api that's supported by the service, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
   226          string api_version = 3;
   227  }
   228  
   229  // EventType defines the type of the events that will be received via ListenEvents().
   230  enum EventType {
   231          EVENT_TYPE_UNDEFINED = 0;
   232  
   233          // Pod events.
   234          EVENT_TYPE_POD_PREPARED          = 1;
   235          EVENT_TYPE_POD_PREPARE_ABORTED   = 2;
   236          EVENT_TYPE_POD_STARTED           = 3;
   237          EVENT_TYPE_POD_EXITED            = 4;
   238          EVENT_TYPE_POD_GARBAGE_COLLECTED = 5;
   239  
   240          // App events.
   241          EVENT_TYPE_APP_STARTED = 6;
   242          EVENT_TYPE_APP_EXITED  = 7; // (XXX)yifan: Maybe also return exit code in the event object?
   243  
   244          // Image events.
   245          EVENT_TYPE_IMAGE_IMPORTED = 8;
   246          EVENT_TYPE_IMAGE_REMOVED  = 9;
   247  }
   248  
   249  // Event describes the events that will be received via ListenEvents().
   250  message Event {
   251          // Type of the event, required.
   252          EventType type = 1;
   253  
   254          // ID of the subject that causes the event, required.
   255          // If the event is a pod or app event, the id is the pod's uuid.
   256          // If the event is an image event, the id is the image's id.
   257          string id = 2;
   258  
   259          // Name of the subject that causes the event, required.
   260          // If the event is a pod event, the name is the pod's name.
   261          // If the event is an app event, the name is the app's name.
   262          // If the event is an image event, the name is the image's name.
   263          string from = 3;
   264  
   265          // Timestamp of when the event happens, it is the seconds since epoch, required.
   266          int64 time = 4;
   267  
   268          // Data of the event, in the form of key-value pairs, optional.
   269          repeated KeyValue data = 5;
   270  }
   271  
   272  // EventFilter defines the condition that the returned events needs to satisfy in ListImages().
   273  // The condition are combined by 'AND'.
   274  message EventFilter {
   275          // If not empty, then only returns the events that have the listed types.
   276          repeated EventType types = 1;
   277  
   278          // If not empty, then only returns the events whose 'id' is included in the listed ids.
   279          repeated string ids = 2;
   280  
   281          // If not empty, then only returns the events whose 'from' is included in the listed names.
   282          repeated string names = 3;
   283  
   284          // If set, then only returns the events after this timestamp.
   285          // If the server starts after since_time, then only the events happened after the start of the server will be returned.
   286          // If since_time is a future timestamp, then no events will be returned until that time.
   287          int64 since_time = 4;
   288  
   289          // If set, then only returns the events before this timestamp.
   290          // If it is a future timestamp, then the event stream will be closed at that moment.
   291          int64 until_time = 5;
   292  }
   293  
   294  
   295  // Request for GetInfo().
   296  message GetInfoRequest {}
   297  
   298  // Response for GetInfo().
   299  message GetInfoResponse {
   300          Info info = 1; // Required.
   301  }
   302  
   303  // Request for ListPods().
   304  message ListPodsRequest {
   305          PodFilter filter = 1; // Optional.
   306  }
   307  
   308  // Response for ListPods().
   309  message ListPodsResponse {
   310          repeated Pod pods = 1; // Required.
   311  }
   312  
   313  // Request for InspectPod().
   314  message InspectPodRequest {
   315          // ID of the pod which we are querying status for, required.
   316          string id = 1;
   317  }
   318  
   319  // Response for InspectPod().
   320  message InspectPodResponse {
   321          Pod pod = 1; // Required.
   322  }
   323  
   324  // Request for ListImages().
   325  message ListImagesRequest {
   326          ImageFilter filter = 1; // Optional.
   327  }
   328  
   329  // Response for ListImages().
   330  message ListImagesResponse {
   331          repeated Image images = 1; // Required.
   332  }
   333  
   334  // Request for InspectImage().
   335  message InspectImageRequest {
   336          string id = 1; // Required.
   337  }
   338  
   339  // Response for InspectImage().
   340  message InspectImageResponse {
   341          Image image = 1; // Required.
   342  }
   343  
   344  // Request for ListenEvents().
   345  message ListenEventsRequest {
   346          EventFilter filter = 1; // Optional.
   347  }
   348  
   349  // Response for ListenEvents().
   350  message ListenEventsResponse {
   351          // Aggregate multiple events to reduce round trips, optional as the response can contain no events.
   352          repeated Event events = 1;
   353  }
   354  
   355  // Request for GetLogs().
   356  message GetLogsRequest {
   357          // ID of the pod which we will get logs from, required.
   358          string pod_id = 1;
   359  
   360          // Name of the app within the pod which we will get logs
   361          // from, optional. If not set, then the logs of all the
   362          // apps within the pod will be returned.
   363          string app_name = 2;
   364  
   365          // Number of most recent lines to return, optional.
   366          int32 lines = 3;
   367  
   368          // If true, then a response stream will not be closed,
   369          // and new log response will be sent via the stream, default is false.
   370          bool follow = 4;
   371  
   372          // If set, then only the logs after the timestamp will
   373          // be returned, optional.
   374          int64 since_time = 5;
   375  
   376          // If set, then only the logs before the timestamp will
   377          // be returned, optional.
   378          int64 until_time = 6;
   379  }
   380  
   381  // Response for GetLogs().
   382  message GetLogsResponse {
   383          // List of the log lines that returned, optional as the response can contain no logs.
   384          repeated string lines = 1;
   385  }
   386  
   387  // PublicAPI defines the read-only APIs that will be supported.
   388  // These will be handled over TCP sockets.
   389  service PublicAPI {
   390          // GetInfo gets the rkt's information on the machine.
   391          rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) {}
   392  
   393          // ListPods lists rkt pods on the machine.
   394          rpc ListPods (ListPodsRequest) returns (ListPodsResponse) {}
   395  
   396          // InspectPod gets detailed pod information of the specified pod.
   397          rpc InspectPod (InspectPodRequest) returns (InspectPodResponse) {}
   398  
   399          // ListImages lists the images on the machine.
   400          rpc ListImages (ListImagesRequest) returns (ListImagesResponse) {}
   401  
   402          // InspectImage gets the detailed image information of the specified image.
   403          rpc InspectImage (InspectImageRequest) returns (InspectImageResponse) {}
   404  
   405          // ListenEvents listens for the events, it will return a response stream
   406          // that will contain event objects.
   407          rpc ListenEvents (ListenEventsRequest) returns (stream ListenEventsResponse) {}
   408  
   409          // GetLogs gets the logs for a pod, if the app is also specified, then only the logs
   410          // of the app will be returned.
   411          //
   412          // If 'follow' in the 'GetLogsRequest' is set to 'true', then the response stream
   413          // will not be closed after the first response, the future logs will be sent via
   414          // the stream.
   415          rpc GetLogs(GetLogsRequest) returns (stream GetLogsResponse) {}
   416  }