mortar/proto/mortar.proto -rw-r--r-- 3.4 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
syntax = "proto3";
option go_package = "mortarpb";
package mortar;

service Mortar {
    rpc GetAPIKey(GetAPIKeyRequest) returns (APIKeyResponse);
    // identify which sites meet the requirements of the queries
    rpc Qualify(QualifyRequest) returns (QualifyResponse);
    // pull data from Mortar
    rpc Fetch(FetchRequest) returns (stream FetchResponse);
}

message GetAPIKeyRequest {
    string username = 1;
    string password = 2;
    string refreshtoken = 3;
}

message APIKeyResponse {
    string token = 1;
    string refreshtoken = 2;
}

message QualifyRequest {
    // all of these queries must return a response for the site to be considered
    // qualified
    repeated string required = 1;

    // only one of these needs to return a response for the site to be
    // considered qualified
    repeated string optional = 2;
}

message QualifyResponse {
    string error = 1;
    // list of sitenames
    repeated string sites = 2;
}

message FetchRequest {
    // the list of sites to execute against
    repeated string sites = 1;
    // list of streams to download
    repeated Stream streams = 2;
    // temporal parameters for all streams
    // (range of data to download, resolution)
    TimeParams time = 3;

    repeated View views = 4;
    repeated DataFrame dataFrames = 5;
}

message Stream {
    // name of the stream
    string name = 1;

    // Brick query (alternative)
    string definition = 2;
    repeated string dataVars = 6;
    // list of stream UUIDs
    repeated string uuids = 3;

    // aggregation function for this stream
    AggFunc aggregation = 4;
    // engineering units to convert the stream to
    string units = 5;
}

message FetchResponse {
    // error from backend
    string error = 1;
    // stream definition fields:
    // - site name
    // - view name
    // - data frame name
    // - variable name (from View definition)
    string site = 2;
    string view = 9;
    string dataFrame = 10;
    string variable = 3;
    // uuid
    string identifier = 4;

    // timestamps and value should have same length
    repeated int64 times = 5;
    repeated double values = 6;
    // brick query contents related to this variable
    repeated string variables = 7;
    repeated Row rows = 8;
}

message Row {
    repeated URI values = 1;
}

//message Triple {
//    URI subject = 1;
//    URI predicate = 2;
//    URI object = 3;
//}

message URI {
    // full URI
    string namespace = 1;
    string value = 2;
}

message TimeParams {
    string start = 1;
    string end = 2;
    string window = 3;
    bool aligned = 4;
}

enum AggFunc {
    AGG_FUNC_INVALID = 0;
    AGG_FUNC_RAW = 1;
    AGG_FUNC_MEAN = 2;
    AGG_FUNC_MIN = 3;
    AGG_FUNC_MAX = 4;
    AGG_FUNC_COUNT = 5;
    AGG_FUNC_SUM = 6;
}


message View {
    // name of the View
    string name = 1;
    // sites included in this View
    repeated string sites = 2;
    // brick query definition
    string definition = 3;
}

message DataFrame {
    // name of the streams
    string name = 1;

    // aggregation function
    AggFunc aggregation = 2;
    // window argument for aggregation
    string window = 3;
    // engineering units
    string unit = 4;

    // refer to variables in Views
    repeated Timeseries timeseries = 5;
    // instead of vars in views, list the UUIDs explicitly.
    repeated string uuids = 6;
}

message Timeseries {
    // name of the View
    string view = 1;
    // list of variables from the view that
    // we want to get data for
    repeated string dataVars = 2;
}