From 8bccd3c19311c01b3c9697771d83878d7e351365 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Wed, 2 Sep 2015 18:48:21 -0700 Subject: [PATCH] api: add v1 API protobuf definition and generated codes. --- api/v1/api.pb.go | 1071 ++++++++++++++++++++++++++++++++++++++++++++++ api/v1/api.proto | 412 ++++++++++++++++++ 2 files changed, 1483 insertions(+) create mode 100644 api/v1/api.pb.go create mode 100644 api/v1/api.proto diff --git a/api/v1/api.pb.go b/api/v1/api.pb.go new file mode 100644 index 0000000000..61be1a40a2 --- /dev/null +++ b/api/v1/api.pb.go @@ -0,0 +1,1071 @@ +// Code generated by protoc-gen-go. +// source: api.proto +// DO NOT EDIT! + +/* +Package v1 is a generated protocol buffer package. + +It is generated from these files: + api.proto + +It has these top-level messages: + ImageFormat + Image + Network + App + Pod + AnnotationSelector + PodFilter + ImageFilter + Info + Event + EventFilter + GetInfoRequest + GetInfoResponse + ListPodsRequest + ListPodsResponse + InspectPodRequest + InspectPodResponse + ListImagesRequest + ListImagesResponse + InspectImageRequest + InspectImageResponse + ListenEventsRequest + ListenEventsResponse + AddEventRequest + AddEventResponse + GetLogsRequest + GetLogsResponse +*/ +package v1 + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// ImageType defines the supported image type. +type ImageType int32 + +const ( + ImageType_IMAGE_TYPE_UNDEFINED ImageType = 0 + ImageType_IMAGE_TYPE_APPC ImageType = 1 + ImageType_IMAGE_TYPE_DOCKER ImageType = 2 + ImageType_IMAGE_TYPE_OCI ImageType = 3 +) + +var ImageType_name = map[int32]string{ + 0: "IMAGE_TYPE_UNDEFINED", + 1: "IMAGE_TYPE_APPC", + 2: "IMAGE_TYPE_DOCKER", + 3: "IMAGE_TYPE_OCI", +} +var ImageType_value = map[string]int32{ + "IMAGE_TYPE_UNDEFINED": 0, + "IMAGE_TYPE_APPC": 1, + "IMAGE_TYPE_DOCKER": 2, + "IMAGE_TYPE_OCI": 3, +} + +func (x ImageType) String() string { + return proto.EnumName(ImageType_name, int32(x)) +} + +// AppState defines the possible states of the app. +type AppState int32 + +const ( + AppState_APP_STATE_UNDEFINED AppState = 0 + AppState_APP_STATE_RUNNING AppState = 1 + AppState_APP_STATE_EXITED AppState = 2 +) + +var AppState_name = map[int32]string{ + 0: "APP_STATE_UNDEFINED", + 1: "APP_STATE_RUNNING", + 2: "APP_STATE_EXITED", +} +var AppState_value = map[string]int32{ + "APP_STATE_UNDEFINED": 0, + "APP_STATE_RUNNING": 1, + "APP_STATE_EXITED": 2, +} + +func (x AppState) String() string { + return proto.EnumName(AppState_name, int32(x)) +} + +// PodState defines the possible states of the pod. +// See https://github.com/coreos/rkt/blob/master/Documentation/devel/pod-lifecycle.md for detailed +// explaination about each state. +type PodState int32 + +const ( + PodState_POD_STATE_UNDEFINED PodState = 0 + // States that before the pod is running. + PodState_POD_STATE_EMBRYO PodState = 1 + PodState_POD_STATE_PREPARING PodState = 2 + PodState_POD_STATE_PREPARED PodState = 3 + // State that indicates the pod is running. + PodState_POD_STATE_RUNNING PodState = 4 + // States that indicates the pod is exited, and will never run. + PodState_POD_STATE_ABORTED_PREPARE PodState = 5 + PodState_POD_STATE_EXITED PodState = 6 + PodState_POD_STATE_DELETING PodState = 7 + PodState_POD_STATE_GARBAGE PodState = 8 +) + +var PodState_name = map[int32]string{ + 0: "POD_STATE_UNDEFINED", + 1: "POD_STATE_EMBRYO", + 2: "POD_STATE_PREPARING", + 3: "POD_STATE_PREPARED", + 4: "POD_STATE_RUNNING", + 5: "POD_STATE_ABORTED_PREPARE", + 6: "POD_STATE_EXITED", + 7: "POD_STATE_DELETING", + 8: "POD_STATE_GARBAGE", +} +var PodState_value = map[string]int32{ + "POD_STATE_UNDEFINED": 0, + "POD_STATE_EMBRYO": 1, + "POD_STATE_PREPARING": 2, + "POD_STATE_PREPARED": 3, + "POD_STATE_RUNNING": 4, + "POD_STATE_ABORTED_PREPARE": 5, + "POD_STATE_EXITED": 6, + "POD_STATE_DELETING": 7, + "POD_STATE_GARBAGE": 8, +} + +func (x PodState) String() string { + return proto.EnumName(PodState_name, int32(x)) +} + +// AnnotationRequirement defines the requirements for filtering annotations. +// The semantics are same to Kubernetes' label selector. More details can be found +// in http://kubernetes.io/v1.0/docs/user-guide/labels.html +type AnnotationRequirement int32 + +const ( + AnnotationRequirement_ANNOTATION_REQUIREMENT_UNDEFINED AnnotationRequirement = 0 + AnnotationRequirement_ANNOTATION_REQUIREMENT_EQUAL AnnotationRequirement = 1 + AnnotationRequirement_ANNOTATION_REQUIREMENT_NOT_EQUAL AnnotationRequirement = 2 + AnnotationRequirement_ANNOTATION_REQUIREMENT_IN AnnotationRequirement = 3 + AnnotationRequirement_ANNOTATION_REQUIREMENT_NOT_IN AnnotationRequirement = 4 + AnnotationRequirement_ANNOTATION_REQUIREMENT_HAS_NAME AnnotationRequirement = 5 +) + +var AnnotationRequirement_name = map[int32]string{ + 0: "ANNOTATION_REQUIREMENT_UNDEFINED", + 1: "ANNOTATION_REQUIREMENT_EQUAL", + 2: "ANNOTATION_REQUIREMENT_NOT_EQUAL", + 3: "ANNOTATION_REQUIREMENT_IN", + 4: "ANNOTATION_REQUIREMENT_NOT_IN", + 5: "ANNOTATION_REQUIREMENT_HAS_NAME", +} +var AnnotationRequirement_value = map[string]int32{ + "ANNOTATION_REQUIREMENT_UNDEFINED": 0, + "ANNOTATION_REQUIREMENT_EQUAL": 1, + "ANNOTATION_REQUIREMENT_NOT_EQUAL": 2, + "ANNOTATION_REQUIREMENT_IN": 3, + "ANNOTATION_REQUIREMENT_NOT_IN": 4, + "ANNOTATION_REQUIREMENT_HAS_NAME": 5, +} + +func (x AnnotationRequirement) String() string { + return proto.EnumName(AnnotationRequirement_name, int32(x)) +} + +// EventType defines the type of the events that will be received via ListenEvents(). +type EventType int32 + +const ( + EventType_EVENT_TYPE_UNDEFINED EventType = 0 + // Pod events. + EventType_EVENT_TYPE_POD_PREPARED EventType = 1 + EventType_EVENT_TYPE_POD_PREPARE_ABORTED EventType = 2 + EventType_EVENT_TYPE_POD_STARTED EventType = 3 + EventType_EVENT_TYPE_POD_EXITED EventType = 4 + EventType_EVENT_TYPE_POD_GARBAGE_COLLECTED EventType = 5 + // App events. + EventType_EVENT_TYPE_APP_STARTED EventType = 6 + EventType_EVENT_TYPE_APP_EXITED EventType = 7 + // Image events. + EventType_EVENT_TYPE_IMAGE_IMPORTED EventType = 8 + EventType_EVENT_TYPE_IMAGE_REMOVED EventType = 9 +) + +var EventType_name = map[int32]string{ + 0: "EVENT_TYPE_UNDEFINED", + 1: "EVENT_TYPE_POD_PREPARED", + 2: "EVENT_TYPE_POD_PREPARE_ABORTED", + 3: "EVENT_TYPE_POD_STARTED", + 4: "EVENT_TYPE_POD_EXITED", + 5: "EVENT_TYPE_POD_GARBAGE_COLLECTED", + 6: "EVENT_TYPE_APP_STARTED", + 7: "EVENT_TYPE_APP_EXITED", + 8: "EVENT_TYPE_IMAGE_IMPORTED", + 9: "EVENT_TYPE_IMAGE_REMOVED", +} +var EventType_value = map[string]int32{ + "EVENT_TYPE_UNDEFINED": 0, + "EVENT_TYPE_POD_PREPARED": 1, + "EVENT_TYPE_POD_PREPARE_ABORTED": 2, + "EVENT_TYPE_POD_STARTED": 3, + "EVENT_TYPE_POD_EXITED": 4, + "EVENT_TYPE_POD_GARBAGE_COLLECTED": 5, + "EVENT_TYPE_APP_STARTED": 6, + "EVENT_TYPE_APP_EXITED": 7, + "EVENT_TYPE_IMAGE_IMPORTED": 8, + "EVENT_TYPE_IMAGE_REMOVED": 9, +} + +func (x EventType) String() string { + return proto.EnumName(EventType_name, int32(x)) +} + +// ImageFormat defines the format of the image. +type ImageFormat struct { + // Type of the image, required. + Type ImageType `protobuf:"varint,1,opt,name=type,enum=v1.ImageType" json:"type,omitempty"` + // Version of the image format, required. + Version string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` +} + +func (m *ImageFormat) Reset() { *m = ImageFormat{} } +func (m *ImageFormat) String() string { return proto.CompactTextString(m) } +func (*ImageFormat) ProtoMessage() {} + +// Image describes the image's information. +type Image struct { + // The format of the image. + Format *ImageFormat `protobuf:"bytes,1,opt,name=format" json:"format,omitempty"` + // ID of the image, a string of the format 'hash-value'. + // Currently the only permitted hash algorithm is sha512. + Id string `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"` + // Name of the image in the image manifest, e.g. 'coreos.com/etcd'. + Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` + // Version of the image, e.g. 'latest', '2.0.10'. + Version string `protobuf:"bytes,4,opt,name=version" json:"version,omitempty"` + // The timestamp of when the image is imported. + ImportTimestamp int64 `protobuf:"varint,5,opt,name=import_timestamp" json:"import_timestamp,omitempty"` + // The JSON-encoded string that represents the manifest. + Manifest string `protobuf:"bytes,6,opt,name=manifest" json:"manifest,omitempty"` +} + +func (m *Image) Reset() { *m = Image{} } +func (m *Image) String() string { return proto.CompactTextString(m) } +func (*Image) ProtoMessage() {} + +func (m *Image) GetFormat() *ImageFormat { + if m != nil { + return m.Format + } + return nil +} + +// Network describes the network information of a pod. +type Network struct { + // The name of the network that a pod belongs to. + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // The pod’s IPv4 address within the network, optional if IPv6 address is given. + Ipv4 string `protobuf:"bytes,2,opt,name=ipv4" json:"ipv4,omitempty"` + // The pod’s IPv6 address within the network, optional if IPv4 address is given. + Ipv6 string `protobuf:"bytes,3,opt,name=ipv6" json:"ipv6,omitempty"` +} + +func (m *Network) Reset() { *m = Network{} } +func (m *Network) String() string { return proto.CompactTextString(m) } +func (*Network) ProtoMessage() {} + +// App describes the information of an app that's running in a pod. +type App struct { + // Name of the app. + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // The image used by the app. Note that it may only contain the image id. + Image *Image `protobuf:"bytes,2,opt,name=image" json:"image,omitempty"` + // The state of the app. Undefined if the app is not returned by InspectPod(). + State AppState `protobuf:"varint,3,opt,name=state,enum=v1.AppState" json:"state,omitempty"` + // The exit code of the app. + // Undefined if the app is not returned by InspectPod(), or the app has not exited. + ExitCode int32 `protobuf:"zigzag32,4,opt,name=exit_code" json:"exit_code,omitempty"` +} + +func (m *App) Reset() { *m = App{} } +func (m *App) String() string { return proto.CompactTextString(m) } +func (*App) ProtoMessage() {} + +func (m *App) GetImage() *Image { + if m != nil { + return m.Image + } + return nil +} + +// Pod describes a pod's information. +type Pod struct { + // The ID of the pod, it's in the form of a UUID. + Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` + // The PID of the pod. Undefined if the Pod is not returned by InspectPod(). + Pid int32 `protobuf:"zigzag32,2,opt,name=pid" json:"pid,omitempty"` + // The state of the pod. + State PodState `protobuf:"varint,3,opt,name=state,enum=v1.PodState" json:"state,omitempty"` + // The list of apps in the pod. + Apps []*App `protobuf:"bytes,4,rep,name=apps" json:"apps,omitempty"` + // The network information of the pod. Note that a pod can be in multiple networks. + Network []*Network `protobuf:"bytes,5,rep,name=network" json:"network,omitempty"` + // The JSON-encoded string that represetns the pod manifest of the pod. + Manifest string `protobuf:"bytes,6,opt,name=manifest" json:"manifest,omitempty"` +} + +func (m *Pod) Reset() { *m = Pod{} } +func (m *Pod) String() string { return proto.CompactTextString(m) } +func (*Pod) ProtoMessage() {} + +func (m *Pod) GetApps() []*App { + if m != nil { + return m.Apps + } + return nil +} + +func (m *Pod) GetNetwork() []*Network { + if m != nil { + return m.Network + } + return nil +} + +// Annotation in the pod, it's a key value pair. +type AnnotationSelector struct { + // The requirements of the filterd annotation. + Requirement AnnotationRequirement `protobuf:"varint,1,opt,name=requirement,enum=v1.AnnotationRequirement" json:"requirement,omitempty"` + // The name of the annotation. + Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` + // The value of the annotation. + Value string `protobuf:"bytes,3,opt,name=value" json:"value,omitempty"` +} + +func (m *AnnotationSelector) Reset() { *m = AnnotationSelector{} } +func (m *AnnotationSelector) String() string { return proto.CompactTextString(m) } +func (*AnnotationSelector) ProtoMessage() {} + +// PodFilter defines the condition that the returned pods need to satisfy in ListPods(). +// The conditions are combined by 'AND'. +type PodFilter struct { + // If not empty, then the returned pods must be in one of these states. + States []PodState `protobuf:"varint,1,rep,name=states,enum=v1.PodState" json:"states,omitempty"` + // If not empty, then the returned pods must have one of these names in the apps. + AppNames []string `protobuf:"bytes,2,rep,name=app_names" json:"app_names,omitempty"` + // If not empty, then the returned pods must contain at least one of these images in the apps. + Images []string `protobuf:"bytes,3,rep,name=images" json:"images,omitempty"` + // If not empty, then the returned pods must be in at least one of these networks. + NetworkNames []string `protobuf:"bytes,4,rep,name=network_names" json:"network_names,omitempty"` + // If not empty, then the returned pods must satisfy the annotation requirements. + AnnotationRequirements []AnnotationRequirement `protobuf:"varint,5,rep,name=annotation_requirements,enum=v1.AnnotationRequirement" json:"annotation_requirements,omitempty"` +} + +func (m *PodFilter) Reset() { *m = PodFilter{} } +func (m *PodFilter) String() string { return proto.CompactTextString(m) } +func (*PodFilter) ProtoMessage() {} + +// ImageFilter defines the condition that the returned images need to satisfy in ListImages(). +// The conditions are combined by 'AND'. +type ImageFilter struct { + // If not empty, then the returned images must have the listed ids. + Ids []string `protobuf:"bytes,1,rep,name=ids" json:"ids,omitempty"` + // if not empty, then the returned images must have one of the listed prefixes. + Prefixes []string `protobuf:"bytes,2,rep,name=prefixes" json:"prefixes,omitempty"` + // If not empty, then the returned images must contain one of the listed names as the base name. + // For example, both 'coreos.com/etcd' and 'k8s.io/etcd' will be returned if 'etcd' is included, + // however 'etcd-backup' will not be returned. + BaseNames []string `protobuf:"bytes,3,rep,name=base_names" json:"base_names,omitempty"` + // If not empty, then the returned images' names must contain one of the listed key words. + // For example, both 'kubernetes-etcd', 'etcd:latest' will be returned if 'etcd' is included, + KeyWords []string `protobuf:"bytes,4,rep,name=key_words" json:"key_words,omitempty"` + // If not empty, then the returned images must have one of the listed tags. + Tags []string `protobuf:"bytes,5,rep,name=tags" json:"tags,omitempty"` + // If set, then the returned images must be imported after this timestamp. + ImportedAfter int64 `protobuf:"varint,6,opt,name=imported_after" json:"imported_after,omitempty"` + // If set, then the returned images must be imported before this timestamp. + ImportedBefore int64 `protobuf:"varint,7,opt,name=imported_before" json:"imported_before,omitempty"` + // If not empty, then the returned images must satisfy the annotation requirements. + AnnotationRequirements []AnnotationRequirement `protobuf:"varint,8,rep,name=annotation_requirements,enum=v1.AnnotationRequirement" json:"annotation_requirements,omitempty"` +} + +func (m *ImageFilter) Reset() { *m = ImageFilter{} } +func (m *ImageFilter) String() string { return proto.CompactTextString(m) } +func (*ImageFilter) ProtoMessage() {} + +// Info describes the information of rkt on the machine. +type Info struct { + // Version of the rkt. In the form of Semantic Versioning (http://semver.org/). + RktVersion string `protobuf:"bytes,1,opt,name=rkt_version" json:"rkt_version,omitempty"` + // Version of the appc. In the form of Semantic Versioning (http://semver.org/). + AppcVersion string `protobuf:"bytes,2,opt,name=appc_version" json:"appc_version,omitempty"` +} + +func (m *Info) Reset() { *m = Info{} } +func (m *Info) String() string { return proto.CompactTextString(m) } +func (*Info) ProtoMessage() {} + +// Event describes the events that will be received via ListenEvents(). +type Event struct { + // Type of the event. + Type EventType `protobuf:"varint,1,opt,name=type,enum=v1.EventType" json:"type,omitempty"` + // ID of the subject that causes the event, it can be the pod id or the image id. + Id string `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"` + // Name of the subject that causes the event. + From string `protobuf:"bytes,3,opt,name=from" json:"from,omitempty"` + // Timestamp of when the event happens. + Time int64 `protobuf:"varint,4,opt,name=time" json:"time,omitempty"` +} + +func (m *Event) Reset() { *m = Event{} } +func (m *Event) String() string { return proto.CompactTextString(m) } +func (*Event) ProtoMessage() {} + +// EventFilter defines the condition that the returned events needs to satisfy in ListImages(). +// The condition are combined by 'AND'. +type EventFilter struct { + // If not empty, then only returns the events that have the listed types. + Types []EventType `protobuf:"varint,1,rep,name=types,enum=v1.EventType" json:"types,omitempty"` + // If not empty, then only returns the events whose subject is included in the listed ids. + Ids []string `protobuf:"bytes,2,rep,name=ids" json:"ids,omitempty"` + // If not empty, then only returns the events whose subject is included in the listed names. + Names []string `protobuf:"bytes,3,rep,name=names" json:"names,omitempty"` + // If set, then only returns the events after this timestamp. + // If the server starts after since_time, then only the events happened after the start of the server will be returned. + // If since_time is a future timestamp, then not events will be returned until that time. + SinceTime int64 `protobuf:"varint,4,opt,name=since_time" json:"since_time,omitempty"` + // If set, then only returns the events before this timestamp. + // If it is a future timestamp, then the event stream will be closed at that moment. + UntilTime int64 `protobuf:"varint,5,opt,name=until_time" json:"until_time,omitempty"` +} + +func (m *EventFilter) Reset() { *m = EventFilter{} } +func (m *EventFilter) String() string { return proto.CompactTextString(m) } +func (*EventFilter) ProtoMessage() {} + +// The request for GetInfo(). +type GetInfoRequest struct { +} + +func (m *GetInfoRequest) Reset() { *m = GetInfoRequest{} } +func (m *GetInfoRequest) String() string { return proto.CompactTextString(m) } +func (*GetInfoRequest) ProtoMessage() {} + +// The response for GetInfo(). +type GetInfoResponse struct { + Info *Info `protobuf:"bytes,1,opt,name=info" json:"info,omitempty"` +} + +func (m *GetInfoResponse) Reset() { *m = GetInfoResponse{} } +func (m *GetInfoResponse) String() string { return proto.CompactTextString(m) } +func (*GetInfoResponse) ProtoMessage() {} + +func (m *GetInfoResponse) GetInfo() *Info { + if m != nil { + return m.Info + } + return nil +} + +// The request for ListPods(). +type ListPodsRequest struct { + Filter *PodFilter `protobuf:"bytes,1,opt,name=filter" json:"filter,omitempty"` +} + +func (m *ListPodsRequest) Reset() { *m = ListPodsRequest{} } +func (m *ListPodsRequest) String() string { return proto.CompactTextString(m) } +func (*ListPodsRequest) ProtoMessage() {} + +func (m *ListPodsRequest) GetFilter() *PodFilter { + if m != nil { + return m.Filter + } + return nil +} + +// The response for ListPods(). +type ListPodsResponse struct { + Pods []*Pod `protobuf:"bytes,1,rep,name=pods" json:"pods,omitempty"` +} + +func (m *ListPodsResponse) Reset() { *m = ListPodsResponse{} } +func (m *ListPodsResponse) String() string { return proto.CompactTextString(m) } +func (*ListPodsResponse) ProtoMessage() {} + +func (m *ListPodsResponse) GetPods() []*Pod { + if m != nil { + return m.Pods + } + return nil +} + +// The request for InspectPod(). +type InspectPodRequest struct { + // ID of the pod that we are querying status for. + Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` +} + +func (m *InspectPodRequest) Reset() { *m = InspectPodRequest{} } +func (m *InspectPodRequest) String() string { return proto.CompactTextString(m) } +func (*InspectPodRequest) ProtoMessage() {} + +// The response for InspectPod(). +type InspectPodResponse struct { + Pod *Pod `protobuf:"bytes,1,opt,name=pod" json:"pod,omitempty"` +} + +func (m *InspectPodResponse) Reset() { *m = InspectPodResponse{} } +func (m *InspectPodResponse) String() string { return proto.CompactTextString(m) } +func (*InspectPodResponse) ProtoMessage() {} + +func (m *InspectPodResponse) GetPod() *Pod { + if m != nil { + return m.Pod + } + return nil +} + +// The request for ListImages(). +type ListImagesRequest struct { + Filter *ImageFilter `protobuf:"bytes,1,opt,name=filter" json:"filter,omitempty"` +} + +func (m *ListImagesRequest) Reset() { *m = ListImagesRequest{} } +func (m *ListImagesRequest) String() string { return proto.CompactTextString(m) } +func (*ListImagesRequest) ProtoMessage() {} + +func (m *ListImagesRequest) GetFilter() *ImageFilter { + if m != nil { + return m.Filter + } + return nil +} + +// The response for ListImages(). +type ListImagesResponse struct { + Images []*Image `protobuf:"bytes,1,rep,name=images" json:"images,omitempty"` +} + +func (m *ListImagesResponse) Reset() { *m = ListImagesResponse{} } +func (m *ListImagesResponse) String() string { return proto.CompactTextString(m) } +func (*ListImagesResponse) ProtoMessage() {} + +func (m *ListImagesResponse) GetImages() []*Image { + if m != nil { + return m.Images + } + return nil +} + +// The request for InspectImage(). +type InspectImageRequest struct { + Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` +} + +func (m *InspectImageRequest) Reset() { *m = InspectImageRequest{} } +func (m *InspectImageRequest) String() string { return proto.CompactTextString(m) } +func (*InspectImageRequest) ProtoMessage() {} + +// The response for InspectImage(). +type InspectImageResponse struct { + Image *Image `protobuf:"bytes,1,opt,name=image" json:"image,omitempty"` +} + +func (m *InspectImageResponse) Reset() { *m = InspectImageResponse{} } +func (m *InspectImageResponse) String() string { return proto.CompactTextString(m) } +func (*InspectImageResponse) ProtoMessage() {} + +func (m *InspectImageResponse) GetImage() *Image { + if m != nil { + return m.Image + } + return nil +} + +// The request for ListenEvents(). +type ListenEventsRequest struct { + Filter *EventFilter `protobuf:"bytes,1,opt,name=filter" json:"filter,omitempty"` +} + +func (m *ListenEventsRequest) Reset() { *m = ListenEventsRequest{} } +func (m *ListenEventsRequest) String() string { return proto.CompactTextString(m) } +func (*ListenEventsRequest) ProtoMessage() {} + +func (m *ListenEventsRequest) GetFilter() *EventFilter { + if m != nil { + return m.Filter + } + return nil +} + +// The response for ListenEvents(). +type ListenEventsResponse struct { + Event *Event `protobuf:"bytes,1,opt,name=event" json:"event,omitempty"` +} + +func (m *ListenEventsResponse) Reset() { *m = ListenEventsResponse{} } +func (m *ListenEventsResponse) String() string { return proto.CompactTextString(m) } +func (*ListenEventsResponse) ProtoMessage() {} + +func (m *ListenEventsResponse) GetEvent() *Event { + if m != nil { + return m.Event + } + return nil +} + +// The request for AddEvent(). +type AddEventRequest struct { + Event *Event `protobuf:"bytes,1,opt,name=event" json:"event,omitempty"` +} + +func (m *AddEventRequest) Reset() { *m = AddEventRequest{} } +func (m *AddEventRequest) String() string { return proto.CompactTextString(m) } +func (*AddEventRequest) ProtoMessage() {} + +func (m *AddEventRequest) GetEvent() *Event { + if m != nil { + return m.Event + } + return nil +} + +// The response for AddEvent(). +type AddEventResponse struct { +} + +func (m *AddEventResponse) Reset() { *m = AddEventResponse{} } +func (m *AddEventResponse) String() string { return proto.CompactTextString(m) } +func (*AddEventResponse) ProtoMessage() {} + +// The request for GetLogs(). +type GetLogsRequest struct { + // The id of the pod to get logs from. + PodId string `protobuf:"bytes,1,opt,name=pod_id" json:"pod_id,omitempty"` + // The name of the app with the pod to get logs from. + // If not set, then the logs of all the apps within + // the pod will be returned. + AppName string `protobuf:"bytes,2,opt,name=app_name" json:"app_name,omitempty"` + // The number of most recent lines to return. + Lines int32 `protobuf:"varint,3,opt,name=lines" json:"lines,omitempty"` + // If true, then a response stream will not be closed, + // and new log response will be sent via the stream. + Follow bool `protobuf:"varint,4,opt,name=follow" json:"follow,omitempty"` + // If set, then only the logs after the timestamp will + // be returned. + SinceTime int64 `protobuf:"varint,5,opt,name=since_time" json:"since_time,omitempty"` + // If set, then only the logs before the timestamp will + // be returned. + UntilTime int64 `protobuf:"varint,6,opt,name=until_time" json:"until_time,omitempty"` +} + +func (m *GetLogsRequest) Reset() { *m = GetLogsRequest{} } +func (m *GetLogsRequest) String() string { return proto.CompactTextString(m) } +func (*GetLogsRequest) ProtoMessage() {} + +// The response for GetLogs(). +type GetLogsResponse struct { + // The list of log lines that returned. + Lines []string `protobuf:"bytes,1,rep,name=lines" json:"lines,omitempty"` +} + +func (m *GetLogsResponse) Reset() { *m = GetLogsResponse{} } +func (m *GetLogsResponse) String() string { return proto.CompactTextString(m) } +func (*GetLogsResponse) ProtoMessage() {} + +func init() { + proto.RegisterEnum("v1.ImageType", ImageType_name, ImageType_value) + proto.RegisterEnum("v1.AppState", AppState_name, AppState_value) + proto.RegisterEnum("v1.PodState", PodState_name, PodState_value) + proto.RegisterEnum("v1.AnnotationRequirement", AnnotationRequirement_name, AnnotationRequirement_value) + proto.RegisterEnum("v1.EventType", EventType_name, EventType_value) +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// Client API for PublicAPI service + +type PublicAPIClient interface { + // GetInfo gets the rkt's information on the machine. + GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) + // ListPods lists rkt pods on the machine. + ListPods(ctx context.Context, in *ListPodsRequest, opts ...grpc.CallOption) (*ListPodsResponse, error) + // InspectPod gets detailed pod information of the specified pod. + InspectPod(ctx context.Context, in *InspectPodRequest, opts ...grpc.CallOption) (*InspectPodResponse, error) + // ListImages lists the images on the machine. + ListImages(ctx context.Context, in *ListImagesRequest, opts ...grpc.CallOption) (*ListImagesResponse, error) + // InspectImage gets the detailed image information of the image. + InspectImage(ctx context.Context, in *InspectImageRequest, opts ...grpc.CallOption) (*InspectImageResponse, error) + // ListenEvents listens for the intereted events, it will return a response stream + // that will contain event objects. + ListenEvents(ctx context.Context, in *ListenEventsRequest, opts ...grpc.CallOption) (PublicAPI_ListenEventsClient, error) + // GetLogs gets the logs for a pod, if the app is also specified, then only the logs + // of the app will be returned. + // + // If 'follow' in the 'GetLogsRequest' is set to 'true', then the response stream + // will not be closed after the first response, the future logs will be sent via + // the stream. + GetLogs(ctx context.Context, in *GetLogsRequest, opts ...grpc.CallOption) (PublicAPI_GetLogsClient, error) +} + +type publicAPIClient struct { + cc *grpc.ClientConn +} + +func NewPublicAPIClient(cc *grpc.ClientConn) PublicAPIClient { + return &publicAPIClient{cc} +} + +func (c *publicAPIClient) GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) { + out := new(GetInfoResponse) + err := grpc.Invoke(ctx, "/v1.PublicAPI/GetInfo", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *publicAPIClient) ListPods(ctx context.Context, in *ListPodsRequest, opts ...grpc.CallOption) (*ListPodsResponse, error) { + out := new(ListPodsResponse) + err := grpc.Invoke(ctx, "/v1.PublicAPI/ListPods", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *publicAPIClient) InspectPod(ctx context.Context, in *InspectPodRequest, opts ...grpc.CallOption) (*InspectPodResponse, error) { + out := new(InspectPodResponse) + err := grpc.Invoke(ctx, "/v1.PublicAPI/InspectPod", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *publicAPIClient) ListImages(ctx context.Context, in *ListImagesRequest, opts ...grpc.CallOption) (*ListImagesResponse, error) { + out := new(ListImagesResponse) + err := grpc.Invoke(ctx, "/v1.PublicAPI/ListImages", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *publicAPIClient) InspectImage(ctx context.Context, in *InspectImageRequest, opts ...grpc.CallOption) (*InspectImageResponse, error) { + out := new(InspectImageResponse) + err := grpc.Invoke(ctx, "/v1.PublicAPI/InspectImage", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *publicAPIClient) ListenEvents(ctx context.Context, in *ListenEventsRequest, opts ...grpc.CallOption) (PublicAPI_ListenEventsClient, error) { + stream, err := grpc.NewClientStream(ctx, &_PublicAPI_serviceDesc.Streams[0], c.cc, "/v1.PublicAPI/ListenEvents", opts...) + if err != nil { + return nil, err + } + x := &publicAPIListenEventsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type PublicAPI_ListenEventsClient interface { + Recv() (*ListenEventsResponse, error) + grpc.ClientStream +} + +type publicAPIListenEventsClient struct { + grpc.ClientStream +} + +func (x *publicAPIListenEventsClient) Recv() (*ListenEventsResponse, error) { + m := new(ListenEventsResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *publicAPIClient) GetLogs(ctx context.Context, in *GetLogsRequest, opts ...grpc.CallOption) (PublicAPI_GetLogsClient, error) { + stream, err := grpc.NewClientStream(ctx, &_PublicAPI_serviceDesc.Streams[1], c.cc, "/v1.PublicAPI/GetLogs", opts...) + if err != nil { + return nil, err + } + x := &publicAPIGetLogsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type PublicAPI_GetLogsClient interface { + Recv() (*GetLogsResponse, error) + grpc.ClientStream +} + +type publicAPIGetLogsClient struct { + grpc.ClientStream +} + +func (x *publicAPIGetLogsClient) Recv() (*GetLogsResponse, error) { + m := new(GetLogsResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Server API for PublicAPI service + +type PublicAPIServer interface { + // GetInfo gets the rkt's information on the machine. + GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) + // ListPods lists rkt pods on the machine. + ListPods(context.Context, *ListPodsRequest) (*ListPodsResponse, error) + // InspectPod gets detailed pod information of the specified pod. + InspectPod(context.Context, *InspectPodRequest) (*InspectPodResponse, error) + // ListImages lists the images on the machine. + ListImages(context.Context, *ListImagesRequest) (*ListImagesResponse, error) + // InspectImage gets the detailed image information of the image. + InspectImage(context.Context, *InspectImageRequest) (*InspectImageResponse, error) + // ListenEvents listens for the intereted events, it will return a response stream + // that will contain event objects. + ListenEvents(*ListenEventsRequest, PublicAPI_ListenEventsServer) error + // GetLogs gets the logs for a pod, if the app is also specified, then only the logs + // of the app will be returned. + // + // If 'follow' in the 'GetLogsRequest' is set to 'true', then the response stream + // will not be closed after the first response, the future logs will be sent via + // the stream. + GetLogs(*GetLogsRequest, PublicAPI_GetLogsServer) error +} + +func RegisterPublicAPIServer(s *grpc.Server, srv PublicAPIServer) { + s.RegisterService(&_PublicAPI_serviceDesc, srv) +} + +func _PublicAPI_GetInfo_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(GetInfoRequest) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(PublicAPIServer).GetInfo(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _PublicAPI_ListPods_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(ListPodsRequest) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(PublicAPIServer).ListPods(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _PublicAPI_InspectPod_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(InspectPodRequest) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(PublicAPIServer).InspectPod(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _PublicAPI_ListImages_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(ListImagesRequest) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(PublicAPIServer).ListImages(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _PublicAPI_InspectImage_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(InspectImageRequest) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(PublicAPIServer).InspectImage(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _PublicAPI_ListenEvents_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ListenEventsRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(PublicAPIServer).ListenEvents(m, &publicAPIListenEventsServer{stream}) +} + +type PublicAPI_ListenEventsServer interface { + Send(*ListenEventsResponse) error + grpc.ServerStream +} + +type publicAPIListenEventsServer struct { + grpc.ServerStream +} + +func (x *publicAPIListenEventsServer) Send(m *ListenEventsResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _PublicAPI_GetLogs_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetLogsRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(PublicAPIServer).GetLogs(m, &publicAPIGetLogsServer{stream}) +} + +type PublicAPI_GetLogsServer interface { + Send(*GetLogsResponse) error + grpc.ServerStream +} + +type publicAPIGetLogsServer struct { + grpc.ServerStream +} + +func (x *publicAPIGetLogsServer) Send(m *GetLogsResponse) error { + return x.ServerStream.SendMsg(m) +} + +var _PublicAPI_serviceDesc = grpc.ServiceDesc{ + ServiceName: "v1.PublicAPI", + HandlerType: (*PublicAPIServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetInfo", + Handler: _PublicAPI_GetInfo_Handler, + }, + { + MethodName: "ListPods", + Handler: _PublicAPI_ListPods_Handler, + }, + { + MethodName: "InspectPod", + Handler: _PublicAPI_InspectPod_Handler, + }, + { + MethodName: "ListImages", + Handler: _PublicAPI_ListImages_Handler, + }, + { + MethodName: "InspectImage", + Handler: _PublicAPI_InspectImage_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "ListenEvents", + Handler: _PublicAPI_ListenEvents_Handler, + ServerStreams: true, + }, + { + StreamName: "GetLogs", + Handler: _PublicAPI_GetLogs_Handler, + ServerStreams: true, + }, + }, +} + +// Client API for InternalAPI service + +type InternalAPIClient interface { + // AddEvent adds one event to the events list so that it can be retrieved by ListenEvents(). + AddEvent(ctx context.Context, in *AddEventRequest, opts ...grpc.CallOption) (*AddEventResponse, error) +} + +type internalAPIClient struct { + cc *grpc.ClientConn +} + +func NewInternalAPIClient(cc *grpc.ClientConn) InternalAPIClient { + return &internalAPIClient{cc} +} + +func (c *internalAPIClient) AddEvent(ctx context.Context, in *AddEventRequest, opts ...grpc.CallOption) (*AddEventResponse, error) { + out := new(AddEventResponse) + err := grpc.Invoke(ctx, "/v1.InternalAPI/AddEvent", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for InternalAPI service + +type InternalAPIServer interface { + // AddEvent adds one event to the events list so that it can be retrieved by ListenEvents(). + AddEvent(context.Context, *AddEventRequest) (*AddEventResponse, error) +} + +func RegisterInternalAPIServer(s *grpc.Server, srv InternalAPIServer) { + s.RegisterService(&_InternalAPI_serviceDesc, srv) +} + +func _InternalAPI_AddEvent_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(AddEventRequest) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(InternalAPIServer).AddEvent(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +var _InternalAPI_serviceDesc = grpc.ServiceDesc{ + ServiceName: "v1.InternalAPI", + HandlerType: (*InternalAPIServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddEvent", + Handler: _InternalAPI_AddEvent_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, +} diff --git a/api/v1/api.proto b/api/v1/api.proto new file mode 100644 index 0000000000..c91989499f --- /dev/null +++ b/api/v1/api.proto @@ -0,0 +1,412 @@ +// Copyright 2015 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// To compile, run 'protoc -I api/v1 api/v1/api.proto --go_out=plugins=grpc:api/v1' in rkt root directory. + +syntax = "proto3"; + +package v1; + +// ImageType defines the supported image type. +enum ImageType { + IMAGE_TYPE_UNDEFINED = 0; + IMAGE_TYPE_APPC = 1; + IMAGE_TYPE_DOCKER = 2; + IMAGE_TYPE_OCI = 3; +} + +// ImageFormat defines the format of the image. +message ImageFormat { + // Type of the image, required. + ImageType type = 1; + + // Version of the image format, required. + string version = 2; +} + +// Image describes the image's information. +message Image { + // The format of the image. + ImageFormat format = 1; + + // ID of the image, a string of the format 'hash-value'. + // Currently the only permitted hash algorithm is sha512. + string id = 2; + + // Name of the image in the image manifest, e.g. 'coreos.com/etcd'. + string name = 3; + + // Version of the image, e.g. 'latest', '2.0.10'. + string version = 4; + + // The timestamp of when the image is imported. + int64 import_timestamp = 5; + + // The JSON-encoded string that represents the manifest. + string manifest = 6; +} + +// Network describes the network information of a pod. +message Network { + // The name of the network that a pod belongs to. + string name = 1; + + // The pod’s IPv4 address within the network, optional if IPv6 address is given. + string ipv4 = 2; + + // The pod’s IPv6 address within the network, optional if IPv4 address is given. + string ipv6 = 3; +} + +// AppState defines the possible states of the app. +enum AppState { + APP_STATE_UNDEFINED = 0; + APP_STATE_RUNNING = 1; + APP_STATE_EXITED = 2; +} + +// App describes the information of an app that's running in a pod. +message App { + // Name of the app. + string name = 1; + + // The image used by the app. Note that it may only contain the image id. + Image image = 2; + + // The state of the app. Undefined if the app is not returned by InspectPod(). + AppState state = 3; + + // The exit code of the app. + // Undefined if the app is not returned by InspectPod(), or the app has not exited. + sint32 exit_code = 4; +} + +// PodState defines the possible states of the pod. +// See https://github.com/coreos/rkt/blob/master/Documentation/devel/pod-lifecycle.md for detailed +// explaination about each state. +enum PodState { + POD_STATE_UNDEFINED = 0; + + // States that before the pod is running. + POD_STATE_EMBRYO = 1; // Pod is created, and hasn't entering preparing state. + POD_STATE_PREPARING = 2; // Pod locked 'pods/prepare/$uuid', it is being prepared. + POD_STATE_PREPARED = 3; // Pod unlocked 'pod/prepare/$uuid', it has been successfully prepared, ready to enter running state. + + // State that indicates the pod is running. + POD_STATE_RUNNING = 4; // Pod locked 'pod/run/$uuid', it is running. + + // States that indicates the pod is exited, and will never run. + POD_STATE_ABORTED_PREPARE = 5; // Pod unlocked 'pod/prepare/$uuid', the preparing step failed, it will never run. + POD_STATE_EXITED = 6; // Pod unlocked 'pod/run/$uuid', the run exited running. + POD_STATE_DELETING = 7; // Pod locked 'pod/garbage/$uuid'(prepare failed) or 'pod/exited-garbage/$uuid'(exited), the pod is being garbage collected. + POD_STATE_GARBAGE = 8; // Pod unlocked 'pod/garbage/$uuid'(prepare failed) or 'pod/exited-garbage/$uuid'(exited), the pod is garbage collected. +} + +// Pod describes a pod's information. +message Pod { + // The ID of the pod, it's in the form of a UUID. + string id = 1; + + // The PID of the pod. Undefined if the Pod is not returned by InspectPod(). + sint32 pid = 2; + + // The state of the pod. + PodState state = 3; + + // The list of apps in the pod. + repeated App apps = 4; + + // The network information of the pod. Note that a pod can be in multiple networks. + repeated Network network = 5; + + // The JSON-encoded string that represetns the pod manifest of the pod. + string manifest = 6; +} + +// AnnotationRequirement defines the requirements for filtering annotations. +// The semantics are same to Kubernetes' label selector. More details can be found +// in http://kubernetes.io/v1.0/docs/user-guide/labels.html +enum AnnotationRequirement { + ANNOTATION_REQUIREMENT_UNDEFINED = 0; + ANNOTATION_REQUIREMENT_EQUAL = 1; + ANNOTATION_REQUIREMENT_NOT_EQUAL = 2; + ANNOTATION_REQUIREMENT_IN = 3; + ANNOTATION_REQUIREMENT_NOT_IN = 4; + ANNOTATION_REQUIREMENT_HAS_NAME = 5; +} + +// Annotation in the pod, it's a key value pair. +message AnnotationSelector { + // The requirements of the filterd annotation. + AnnotationRequirement requirement = 1; + + // The name of the annotation. + string name = 2; + + // The value of the annotation. + string value = 3; +} + +// PodFilter defines the condition that the returned pods need to satisfy in ListPods(). +// The conditions are combined by 'AND'. +message PodFilter { + // If not empty, then the returned pods must be in one of these states. + repeated PodState states = 1; + + // If not empty, then the returned pods must have one of these names in the apps. + repeated string app_names = 2; + + // If not empty, then the returned pods must contain at least one of these images in the apps. + repeated string images = 3; + + // If not empty, then the returned pods must be in at least one of these networks. + repeated string network_names = 4; + + // If not empty, then the returned pods must satisfy the annotation requirements. + repeated AnnotationRequirement annotation_requirements = 5; +} + +// ImageFilter defines the condition that the returned images need to satisfy in ListImages(). +// The conditions are combined by 'AND'. +message ImageFilter { + // If not empty, then the returned images must have the listed ids. + repeated string ids = 1; + + // if not empty, then the returned images must have one of the listed prefixes. + repeated string prefixes = 2; + + // If not empty, then the returned images must contain one of the listed names as the base name. + // For example, both 'coreos.com/etcd' and 'k8s.io/etcd' will be returned if 'etcd' is included, + // however 'etcd-backup' will not be returned. + repeated string base_names = 3; + + // If not empty, then the returned images' names must contain one of the listed key words. + // For example, both 'kubernetes-etcd', 'etcd:latest' will be returned if 'etcd' is included, + repeated string key_words = 4; + + // If not empty, then the returned images must have one of the listed tags. + repeated string tags = 5; + + // If set, then the returned images must be imported after this timestamp. + int64 imported_after = 6; + + // If set, then the returned images must be imported before this timestamp. + int64 imported_before = 7; + + // If not empty, then the returned images must satisfy the annotation requirements. + repeated AnnotationRequirement annotation_requirements = 8; +} + +// Info describes the information of rkt on the machine. +message Info { + // Version of the rkt. In the form of Semantic Versioning (http://semver.org/). + string rkt_version = 1; + + // Version of the appc. In the form of Semantic Versioning (http://semver.org/). + string appc_version = 2; +} + +// EventType defines the type of the events that will be received via ListenEvents(). +enum EventType { + EVENT_TYPE_UNDEFINED = 0; + + // Pod events. + EVENT_TYPE_POD_PREPARED = 1; + EVENT_TYPE_POD_PREPARE_ABORTED = 2; + EVENT_TYPE_POD_STARTED = 3; + EVENT_TYPE_POD_EXITED = 4; + EVENT_TYPE_POD_GARBAGE_COLLECTED = 5; + + // App events. + EVENT_TYPE_APP_STARTED = 6; + EVENT_TYPE_APP_EXITED = 7; // (XXX)yifan: Maybe also return exit code in the event object? + + // Image events. + EVENT_TYPE_IMAGE_IMPORTED = 8; + EVENT_TYPE_IMAGE_REMOVED = 9; +} + +// Event describes the events that will be received via ListenEvents(). +message Event { + // Type of the event. + EventType type = 1; + + // ID of the subject that causes the event, it can be the pod id or the image id. + string id = 2; + + // Name of the subject that causes the event. + string from = 3; + + // Timestamp of when the event happens. + int64 time = 4; +} + +// EventFilter defines the condition that the returned events needs to satisfy in ListImages(). +// The condition are combined by 'AND'. +message EventFilter { + // If not empty, then only returns the events that have the listed types. + repeated EventType types = 1; + + // If not empty, then only returns the events whose subject is included in the listed ids. + repeated string ids = 2; + + // If not empty, then only returns the events whose subject is included in the listed names. + repeated string names = 3; + + // If set, then only returns the events after this timestamp. + // If the server starts after since_time, then only the events happened after the start of the server will be returned. + // If since_time is a future timestamp, then not events will be returned until that time. + int64 since_time = 4; + + // If set, then only returns the events before this timestamp. + // If it is a future timestamp, then the event stream will be closed at that moment. + int64 until_time = 5; +} + +// The request for GetInfo(). +message GetInfoRequest {} + +// The response for GetInfo(). +message GetInfoResponse { + Info info = 1; +} + +// The request for ListPods(). +message ListPodsRequest { + PodFilter filter = 1; +} + +// The response for ListPods(). +message ListPodsResponse { + repeated Pod pods = 1; +} + +// The request for InspectPod(). +message InspectPodRequest { + // ID of the pod that we are querying status for. + string id = 1; +} + +// The response for InspectPod(). +message InspectPodResponse { + Pod pod = 1; +} + +// The request for ListImages(). +message ListImagesRequest { + ImageFilter filter = 1; +} + +// The response for ListImages(). +message ListImagesResponse { + repeated Image images = 1; +} + +// The request for InspectImage(). +message InspectImageRequest { + string id = 1; +} + +// The response for InspectImage(). +message InspectImageResponse { + Image image = 1; +} + +// The request for ListenEvents(). +message ListenEventsRequest { + EventFilter filter = 1; +} + +// The response for ListenEvents(). +message ListenEventsResponse { + Event event = 1; +} + +// The request for AddEvent(). +message AddEventRequest { + Event event = 1; +} + +// The response for AddEvent(). +message AddEventResponse {} + +// The request for GetLogs(). +message GetLogsRequest { + // The id of the pod to get logs from. + string pod_id = 1; + + // The name of the app with the pod to get logs from. + // If not set, then the logs of all the apps within + // the pod will be returned. + string app_name = 2; + + // The number of most recent lines to return. + int32 lines = 3; + + // If true, then a response stream will not be closed, + // and new log response will be sent via the stream. + bool follow = 4; + + // If set, then only the logs after the timestamp will + // be returned. + int64 since_time = 5; + + // If set, then only the logs before the timestamp will + // be returned. + int64 until_time = 6; +} + +// The response for GetLogs(). +message GetLogsResponse { + // The list of log lines that returned. + repeated string lines = 1; +} + +// PublicAPI defines the read-only APIs that will be supported. +// These will be handled over TCP sockets. +service PublicAPI { + // GetInfo gets the rkt's information on the machine. + rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) {} + + // ListPods lists rkt pods on the machine. + rpc ListPods (ListPodsRequest) returns (ListPodsResponse) {} + + // InspectPod gets detailed pod information of the specified pod. + rpc InspectPod (InspectPodRequest) returns (InspectPodResponse) {} + + // ListImages lists the images on the machine. + rpc ListImages (ListImagesRequest) returns (ListImagesResponse) {} + + // InspectImage gets the detailed image information of the image. + rpc InspectImage (InspectImageRequest) returns (InspectImageResponse) {} + + // ListenEvents listens for the intereted events, it will return a response stream + // that will contain event objects. + rpc ListenEvents (ListenEventsRequest) returns (stream ListenEventsResponse) {} + + // GetLogs gets the logs for a pod, if the app is also specified, then only the logs + // of the app will be returned. + // + // If 'follow' in the 'GetLogsRequest' is set to 'true', then the response stream + // will not be closed after the first response, the future logs will be sent via + // the stream. + rpc GetLogs(GetLogsRequest) returns (stream GetLogsResponse) {} +} + +// InternalAPI defines the APIs for the internal pods, e.g. reporting events. +// These will be handled over UNIX sockets. +service InternalAPI { + // AddEvent adds one event to the events list so that it can be retrieved by ListenEvents(). + rpc AddEvent(AddEventRequest) returns (AddEventResponse) {} +}