Skip to content

Commit 7c7a37c

Browse files
author
Ailin Yu
authored
chore(protos): Update for metadata (#230)
1 parent 805a6fb commit 7c7a37c

16 files changed

Lines changed: 722 additions & 95 deletions

File tree

protos/sift/assets/v1/assets.proto

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "google/api/field_behavior.proto";
77
import "google/protobuf/field_mask.proto";
88
import "google/protobuf/timestamp.proto";
99
import "protoc-gen-openapiv2/options/annotations.proto";
10+
import "sift/metadata/v1/metadata.proto";
1011

1112

1213
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
@@ -22,7 +23,7 @@ service AssetService {
2223
}
2324
};
2425

25-
// Deletes an asset.
26+
// Delete will archive an asset.
2627
rpc DeleteAsset(DeleteAssetRequest) returns (DeleteAssetResponse) {
2728
option (google.api.http) = {delete: "/api/v1/assets/{asset_id}"};
2829
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
@@ -70,8 +71,14 @@ message Asset {
7071
google.protobuf.Timestamp modified_date = 7 [(google.api.field_behavior) = REQUIRED];
7172
string modified_by_user_id = 8 [(google.api.field_behavior) = REQUIRED];
7273

73-
// The names of the tags to associate with this asset.
74+
// The names of the tags associated with this asset.
7475
repeated string tags = 9 [(google.api.field_behavior) = REQUIRED];
76+
77+
// The metadata values associated with this asset.
78+
repeated sift.metadata.v1.MetadataValue metadata = 10 [(google.api.field_behavior) = REQUIRED];
79+
80+
// The date the asset was archived.
81+
google.protobuf.Timestamp archived_date = 11 [(google.api.field_behavior) = OPTIONAL];
7582
}
7683

7784
// The request for a call to `AssetService_ListAssets`.
@@ -90,14 +97,14 @@ message ListAssetsRequest {
9097

9198
// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
9299
// Available fields to filter by are `asset_id`, `created_by_user_id`, `modified_by_user_id`,
93-
// `created_date`, `modified_date`, and `name`.
100+
// `created_date`, `modified_date`, `name`, `tag_id`, `tag_name`, and `metadata`. Metadata can be used in filters by using `metadata.{metadata_key_name}` as the field name.
94101
// For further information about how to use CELs, please refer to [this guide](https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions).
95102
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/assets#asset). Optional.
96103
string filter = 3 [(google.api.field_behavior) = OPTIONAL];
97104

98105
// How to order the retrieved assets. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
99-
// Available fields to order_by are `created_date` and `modified_date`.
100-
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
106+
// Available fields to order_by are `name`, `created_date` and `modified_date`.
107+
// If left empty, items are ordered by `created_date` in descending order (newest-first).
101108
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
102109
// Example: "created_date desc,modified_date"
103110
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
@@ -109,10 +116,13 @@ message ListAssetsResponse {
109116
string next_page_token = 5;
110117
}
111118

112-
// The request for a call to `AssetService_DeleteAsset` to delete a single existing annotation by its asset_id.
119+
// The request for a call to `AssetService_DeleteAsset` to archive a single existing asset by its asset_id.
113120
message DeleteAssetRequest {
114-
// The id of the asset to be deleted. Required.
121+
// The id of the asset to be archived. Required.
115122
string asset_id = 1 [(google.api.field_behavior) = REQUIRED];
123+
124+
// If true, will archive all runs associated with the asset.
125+
bool archive_runs = 2 [(google.api.field_behavior) = OPTIONAL];
116126
}
117127

118128
// The response of a call to `AssetService_DeleteAsset`.
@@ -127,14 +137,18 @@ message GetAssetRequest {
127137
message GetAssetResponse {
128138
Asset asset = 1;
129139
}
140+
141+
// The request for a call to `AssetService_UpdateAsset` to update a single existing asset.
130142
message UpdateAssetRequest {
131143
// The asset to update. The asset's `asset_id` field is used to identify asset run to update
132144
// and is required.
133145
Asset asset = 1;
134146

135-
// The list of fields to be updated. Currently, the only field available to be updated is `tags`.
147+
// The list of fields to be updated. The fields available to be updated are `tags`, `metadata`, and `archived_date`.
136148
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
137149
}
150+
151+
// The response of a call to `AssetService_UpdateAsset`.
138152
message UpdateAssetResponse {
139153
Asset asset = 1;
140154
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
syntax = "proto3";
2+
3+
package sift.metadata.v1;
4+
5+
import "google/api/annotations.proto";
6+
import "google/api/field_behavior.proto";
7+
import "protoc-gen-openapiv2/options/annotations.proto";
8+
9+
10+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
11+
info: {title: "Metadata service"}
12+
};
13+
14+
service MetadataService {
15+
// Create a metadata key.
16+
rpc CreateMetadataKey(CreateMetadataKeyRequest) returns (CreateMetadataKeyResponse) {
17+
option (google.api.http) = {
18+
post: "/api/v1/metadata-keys"
19+
body: "*"
20+
};
21+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
22+
summary: "CreateMetadataKey",
23+
description: "Create a metadata key."
24+
};
25+
}
26+
27+
// List metadata keys.
28+
rpc ListMetadataKeys(ListMetadataKeysRequest) returns (ListMetadataKeysResponse) {
29+
option (google.api.http) = {get: "/api/v1/metadata-keys"};
30+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
31+
summary: "ListMetadataKeys"
32+
description: "List metadata keys."
33+
};
34+
}
35+
}
36+
37+
// Metadata key type.
38+
enum MetadataKeyType {
39+
METADATA_KEY_TYPE_UNSPECIFIED = 0;
40+
// string
41+
METADATA_KEY_TYPE_STRING = 1;
42+
// number
43+
METADATA_KEY_TYPE_NUMBER = 2;
44+
// boolean
45+
METADATA_KEY_TYPE_BOOLEAN = 3;
46+
}
47+
48+
message MetadataKey {
49+
string name = 1 [(google.api.field_behavior) = REQUIRED];
50+
MetadataKeyType type = 2 [(google.api.field_behavior) = REQUIRED];
51+
}
52+
53+
message MetadataValue {
54+
MetadataKey key = 1 [(google.api.field_behavior) = REQUIRED];
55+
oneof value {
56+
string string_value = 2;
57+
double number_value = 3;
58+
bool boolean_value = 4;
59+
}
60+
}
61+
62+
// The request of a call to `MetadataService_CreateMetadataKey` to create a metadata key.
63+
message CreateMetadataKeyRequest {
64+
MetadataKey metadata_key = 1 [(google.api.field_behavior) = REQUIRED];
65+
}
66+
67+
// The response of a call to `MetadataService_CreateMetadataKey` to create a metadata key.
68+
message CreateMetadataKeyResponse {
69+
MetadataKey metadata_key = 1 [(google.api.field_behavior) = REQUIRED];
70+
}
71+
72+
// The request for a call to `MetadataService_ListMetadataKeys` to retrieve metadata keys.
73+
message ListMetadataKeysRequest {
74+
// The maximum number of metadata keys to return. The service may return fewer than this value.
75+
// If unspecified, at most 50 metadata keys will be returned. The maximum value is 1000; values above
76+
// 1000 will be coerced to 1000. Optional.
77+
uint32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
78+
79+
// A page token, received from a previous `ListMetadataKeys` call.
80+
// Provide this to retrieve the subsequent page.
81+
// When paginating, all other parameters provided to `ListMetadataKeys` must match
82+
// the call that provided the page token. Optional.
83+
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
84+
85+
// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
86+
// Available fields to filter by are:
87+
// `name`.
88+
// For further information about how to use CELs, please refer to [this guide](https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions).
89+
// For more information about the fields used for filtering, please refer to this definition. Optional.
90+
string filter = 3 [(google.api.field_behavior) = OPTIONAL];
91+
92+
// How to order the retrieved metadata keys. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
93+
// Available fields to order_by are `created_date` and `name`.
94+
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
95+
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
96+
// Example: "created_date desc,modified_date"
97+
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
98+
}
99+
100+
// The response of a call to `MetadataService_ListMetadataKeysResponse`.
101+
message ListMetadataKeysResponse {
102+
repeated MetadataKey metadata_keys = 1;
103+
string next_page_token = 2;
104+
}

protos/sift/runs/v2/runs.proto

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "google/api/field_behavior.proto";
77
import "google/protobuf/field_mask.proto";
88
import "google/protobuf/timestamp.proto";
99
import "protoc-gen-openapiv2/options/annotations.proto";
10+
import "sift/metadata/v1/metadata.proto";
1011

1112

1213
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
@@ -113,12 +114,18 @@ message Run {
113114
repeated string tags = 12 [(google.api.field_behavior) = REQUIRED];
114115
string default_report_id = 13 [(google.api.field_behavior) = OPTIONAL];
115116
optional string client_key = 14 [(google.api.field_behavior) = OPTIONAL];
117+
// The metadata values associated with this run.
118+
repeated sift.metadata.v1.MetadataValue metadata = 15 [(google.api.field_behavior) = REQUIRED];
119+
repeated string asset_ids = 16 [(google.api.field_behavior) = REQUIRED];
120+
optional google.protobuf.Timestamp archived_date = 17 [(google.api.field_behavior) = OPTIONAL];
116121
}
117122

118123
// The request for a call to `RunService_GetRun` to retrieve run.
119124
message GetRunRequest {
120125
// The ID of the run to retrieve.
121-
string run_id = 1 [(google.api.field_behavior) = REQUIRED];
126+
string run_id = 1 [
127+
(google.api.field_behavior) = REQUIRED
128+
];
122129
}
123130

124131
// The response of a call to `RunService_GetRun` containing the requested run.
@@ -142,14 +149,15 @@ message ListRunsRequest {
142149

143150
// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
144151
// Available fields to filter by are `run_id`, `organization_id`, `name`, `description`, `created_by_user_id`, `modified_by_user_id`,
145-
// `created_date`, `modified_date`, `start_time`, `stop_time`, `client_key`, `is_pinned`, `asset_id`, `client_key`, and `asset_name`.
152+
// `created_date`, `modified_date`, `start_time`, `stop_time`, `client_key`, `is_pinned`, `asset_id`, `asset_name`, `archived_date`,
153+
// and `metadata`. Metadata can be used in filters by using `metadata.{metadata_key_name}` as the field name.
146154
// For further information about how to use CELs, please refer to [this guide](https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions).
147155
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/runs#run). Optional.
148156
string filter = 3 [(google.api.field_behavior) = OPTIONAL];
149157

150158
// How to order the retrieved runs. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
151-
// Available fields to order_by are `created_date`, `modified_date`, `start_time`, and `stop_time`.
152-
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
159+
// Available fields to order_by are `name`, `description`, `created_date`, `modified_date`, `start_time`, and `stop_time`.
160+
// If left empty, items are ordered by `created_date` in descending order (newest-first).
153161
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
154162
// Example: "created_date desc,modified_date"
155163
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
@@ -187,7 +195,12 @@ message CreateRunRequest {
187195
string organization_id = 7 [(google.api.field_behavior) = OPTIONAL];
188196

189197
// An arbitrary user-chosen key that uniquely identifies this run. Optional, though it is recommended to provide.
190-
optional string client_key = 8 [(google.api.field_behavior) = OPTIONAL];
198+
optional string client_key = 8 [
199+
(google.api.field_behavior) = OPTIONAL
200+
];
201+
202+
// The metadata values associated with this run.
203+
repeated sift.metadata.v1.MetadataValue metadata = 9 [(google.api.field_behavior) = OPTIONAL];
191204
}
192205

193206
// The response of a call to `RunService_CreateRuns` containing the newly created run.
@@ -202,12 +215,14 @@ message UpdateRunRequest {
202215
Run run = 1 [(google.api.field_behavior) = REQUIRED];
203216

204217
// The list of fields to be updated. The fields available to be updated are `name`, `description`,
205-
// `start_time`, `stop_time`, `is_pinned`, `client_key` and `tags`.
218+
// `start_time`, `stop_time`, `is_pinned`, `client_key`, `tags`, and `metadata`.
206219
// Important Note: When updating the `start_time`, please be aware that if a subsequent data ingestion
207220
// commences for this run, the `start_time` will be automatically overwritten and set to the timestamp
208221
// corresponding to the beginning of the latest run. Additionally, `client_key` can only be set once either in run creation or in update.
209222
// Any subsequent attempt to update `client_key` will result in an error.
210-
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
223+
google.protobuf.FieldMask update_mask = 2 [
224+
(google.api.field_behavior) = REQUIRED
225+
];
211226
}
212227

213228
// The response of a call to `RunService_UpdateRun` containing the updated run.
@@ -217,7 +232,9 @@ message UpdateRunResponse {
217232

218233
message CreateAutomaticRunAssociationForAssetsRequest {
219234
// The ID of the run to associate the asset with.
220-
string run_id = 1 [(google.api.field_behavior) = REQUIRED];
235+
string run_id = 1 [
236+
(google.api.field_behavior) = REQUIRED
237+
];
221238

222239
// A list of asset names to automatically associate with the run.
223240
// Any data that is received for these assets will automatically added to the run.
@@ -233,15 +250,19 @@ message CreateAutomaticRunAssociationForAssetsResponse {}
233250

234251
// The request for a call to `RunService_DeleteRun`.
235252
message DeleteRunRequest {
236-
string run_id = 1 [(google.api.field_behavior) = REQUIRED];
253+
string run_id = 1 [
254+
(google.api.field_behavior) = REQUIRED
255+
];
237256
}
238257

239258
// The response of a call to `RunService_DeleteRun`.
240259
message DeleteRunResponse {}
241260

242261
// The request for a call to `RunService_StopRun` to stop a run.
243262
message StopRunRequest {
244-
string run_id = 1 [(google.api.field_behavior) = REQUIRED];
263+
string run_id = 1 [
264+
(google.api.field_behavior) = REQUIRED
265+
];
245266
}
246267

247268
// The response of a call to `RunService_StopRun` to stop a run.

0 commit comments

Comments
 (0)