Strictly necessary cookies keep this site working. Videos, maps and fonts from other services load only with your permission, and we never sell or share your personal information.
syntax = "proto3";
package obsp.v1;
option go_package = "obsp/v1;obspv1";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "obsp/v1/common.proto";
// Exchange service of the gRPC binding: draft OIP-0024 (bindings/grpc in the proposal), not an accepted protocol
// contract. The Document message and the Exchange service with its request and response messages are taken from the
// draft's services.proto with their field numbers unchanged; the fields and messages marked "added" are not in the
// draft and are proposed by this reference implementation.
//
// JSON Schema stays authoritative for every protocol document: a document travels as a Document, its canonical JSON
// form with its digest, never re-modelled field by field. Every request opens with the RequestContext (specification
// section 4.3). Errors are gRPC statuses whose details carry an ErrorProblem (the draft mapping.yaml has the code
// table).
// A protocol document in its canonical JSON form (RFC 8785, UTF-8) and the OBSP digest of those bytes.
message Document {
string schema = 1; // protocol schema name, for example "observation-record"
string schema_version = 2; // the schemaVersion the document states
bytes json = 3;
Digest digest = 4;
}
// Exchange: consumers read observation records and products with their state.
service Exchange {
// The latest version of one record (or the version named by "uni@version"). A withdrawn or recalled record is
// returned only when include_history is set; then the earlier versions come in ObservationItem.history.
rpc GetObservation(GetObservationRequest) returns (ObservationItem);
// Records by system, observed property and phenomenon time. Without include_history: the latest version of each
// record, withdrawn and recalled records left out. With include_history: every version, each with its own state
// and, when superseded, its successor.
rpc ListObservations(ListObservationsRequest) returns (stream ObservationItem);
rpc GetProduct(GetProductRequest) returns (ProductItem);
rpc ListCorrectionNotices(ListCorrectionNoticesRequest) returns (stream Document);
// Added: the exchange's event log as CloudEvents, replayed after a cursor and then followed live, so a correction
// reaches a subscriber at least once even across a reconnect.
rpc SubscribeEvents(SubscribeEventsRequest) returns (stream CloudEvent);
}
message GetObservationRequest {
RequestContext context = 1;
string observation_uni = 2; // a record UNI, or "uni@version" for one version
bool include_history = 3;
}
message ListObservationsRequest {
RequestContext context = 1;
string system_uni = 2;
string observed_property = 3;
string phenomenon_from = 4; // RFC 3339; records whose phenomenon time ends before it are left out
string phenomenon_to = 5; // RFC 3339; records whose phenomenon time starts after it are left out
bool include_history = 6;
uint32 page_size = 7; // 0: the server default (100); at most 1000
string page_token = 8; // opaque; from next_page_token
}
message ObservationItem {
Document record = 1;
StateVector state = 2; // correction_state: the version's correction state as served
EvidenceRef provenance = 3;
string next_page_token = 4; // set on the last item of a page when more items follow
// Added: the version that supersedes this one, as "uni@version"; empty unless the version is superseded.
string superseded_by = 5;
// Added: the version this one supersedes, as "uni@version"; empty for a first version.
string supersedes = 6;
// Added: this record version ("1" unless the publisher states another).
string record_version = 7;
// Added: whether this is the latest version of its record.
bool latest = 8;
// Added: the correction notices that changed this version's state, oldest first (their noticeUni).
repeated string correction_notices = 9;
// Added: GetObservation with include_history only: the earlier versions of the record, oldest first.
repeated ObservationItem history = 10;
}
message GetProductRequest {
RequestContext context = 1;
string product_uni = 2; // the productId, or "uni:product:<productId>"
string version = 3; // empty: the served version
bool include_history = 4;
}
message ProductItem {
Document manifest = 1;
StateVector state = 2;
EvidenceRef provenance = 3;
}
message ListCorrectionNoticesRequest {
RequestContext context = 1;
string record_uni = 2; // empty: every notice
string issued_after = 3; // RFC 3339; empty: from the first notice
}
// Added.
message SubscribeEventsRequest {
RequestContext context = 1;
uint64 cursor = 2; // the last sequence the subscriber has; 0 replays the whole log
repeated string products = 3; // product ids; empty: all
repeated string types = 4; // CloudEvents types; empty: all
}
// Added. A CloudEvent in the CloudEvents 1.0.2 Protobuf Event Format, carried in package obsp.v1 rather than
// io.cloudevents.v1 so that the binding stays one package; field names and numbers are those of the format.
// Extension attributes (obspsequence, obspcorrectionstate, obspsupersededby, ...) travel in attributes; the JSON
// data of an OBSP event travels as text_data (datacontenttype application/json).
message CloudEvent {
string id = 1;
string source = 2; // URI-reference
string spec_version = 3;
string type = 4;
map<string, CloudEventAttributeValue> attributes = 5;
oneof data {
bytes binary_data = 6;
string text_data = 7;
google.protobuf.Any proto_data = 8;
}
}
message CloudEventAttributeValue {
oneof attr {
bool ce_boolean = 1;
int32 ce_integer = 2;
string ce_string = 3;
bytes ce_bytes = 4;
string ce_uri = 5;
string ce_uri_ref = 6;
google.protobuf.Timestamp ce_timestamp = 7;
}
}