Skip to content

Commit f0378b9

Browse files
authored
protos: updated protos for metadata management (#309)
Metadata has been added to all resources. Updated all endpoints with metadata changes
1 parent 4dbb425 commit f0378b9

12 files changed

Lines changed: 481 additions & 64 deletions

File tree

protos/sift/annotations/v1/annotations.proto

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ 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/common/type/v1/user.proto";
11+
import "sift/metadata/v1/metadata.proto";
1012

1113

1214
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
@@ -34,7 +36,9 @@ service AnnotationService {
3436
};
3537
}
3638

37-
// Deletes an annotation.
39+
// Delete Annotation is deprecated. Calling this will archive the annotation, which should be done using the
40+
// UpdateAnnotation method with the delete date set to a non-null value. Restoring an annotation can be done
41+
// by calling UpdateAnnotation with the delete date set to a null value.
3842
rpc DeleteAnnotation(DeleteAnnotationRequest) returns (DeleteAnnotationResponse) {
3943
option (google.api.http) = {delete: "/api/v1/annotations/{annotation_id}"};
4044
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
@@ -43,7 +47,8 @@ service AnnotationService {
4347
};
4448
}
4549

46-
// Batch deletes annotations.
50+
// BatchDeleteAnnotations will archive the annotations specified in the request. These can be restored
51+
// by calling UpdateAnnotation with the delete date set to a null value.
4752
rpc BatchDeleteAnnotations(BatchDeleteAnnotationsRequest) returns (BatchDeleteAnnotationsResponse) {
4853
option (google.api.http) = {
4954
post: "/api/v1/annotations:batchDelete",
@@ -110,6 +115,12 @@ message Annotation {
110115
// An annotation is pending if it is part of an ongoing violation of a rule condition.
111116
// The `end_time` of a pending annotation might be set, but is not yet finalized.
112117
bool pending = 20 [(google.api.field_behavior) = OUTPUT_ONLY];
118+
sift.common.type.v1.User assigned_to_user = 21 [(google.api.field_behavior) = OUTPUT_ONLY];
119+
google.protobuf.Timestamp deleted_date = 22 [(google.api.field_behavior) = OPTIONAL];
120+
121+
repeated AnnotationLinkedChannel linked_channels = 23 [(google.api.field_behavior) = OPTIONAL];
122+
repeated string asset_ids = 24 [(google.api.field_behavior) = OPTIONAL];
123+
repeated sift.metadata.v1.MetadataValue metadata = 25 [(google.api.field_behavior) = OPTIONAL];
113124
}
114125

115126
enum AnnotationState {
@@ -175,6 +186,8 @@ message CreateAnnotationRequest {
175186
optional string legend_config = 13 [(google.api.field_behavior) = OPTIONAL];
176187
// The ID of the rule condition version that created this annotation.
177188
optional string created_by_rule_condition_version_id = 15 [(google.api.field_behavior) = OPTIONAL];
189+
// The metadata associated with this annotation.
190+
repeated sift.metadata.v1.MetadataValue metadata = 16 [(google.api.field_behavior) = OPTIONAL];
178191
}
179192

180193
// The result of a call to `AnnotationService_CreateAnnotation`.
@@ -223,7 +236,7 @@ message ListAnnotationsRequest {
223236
// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
224237
// Available fields to filter by are `annotation_id`, `start_time`, `end_time`,
225238
// `created_date`, `modified_date`, `run_id`, `name`, `description`, `state`, `created_by_user_id`, `created_by_rule_condition_version_id`,
226-
// `annotation_type`, `tag_name`, `report_id`, `asset_id`, `asset_name`, `pending`, and `assignee`.
239+
// `annotation_type`, `tag_name`, `report_id`, `asset_id`, `asset_name`, `pending`, `assignee`, `campaign_reports`, and `metadata`.
227240
// 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).
228241
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/annotations#annotation). Optional.
229242
string filter = 3 [(google.api.field_behavior) = OPTIONAL];
@@ -232,8 +245,8 @@ message ListAnnotationsRequest {
232245
string organization_id = 4 [(google.api.field_behavior) = OPTIONAL];
233246

234247
// How to order the retrieved annotations. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
235-
// Available fields to order_by are `created_date`, `modified_date`, `start_time`, and `end_time`.
236-
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
248+
// Available fields to order_by are `created_date`, `modified_date`, `start_time`, `end_time`, `name`, and `description`.
249+
// If left empty, items are ordered by `created_date` in descending order (newest-first).
237250
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
238251
// Example: "created_date desc,modified_date"
239252
string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
@@ -252,7 +265,7 @@ message UpdateAnnotationRequest {
252265
Annotation annotation = 1 [(google.api.field_behavior) = REQUIRED];
253266

254267
// The list of fields to be updated. The fields available to be updated are `name`, `description`, `start_time`,
255-
// `end_time`, `assigned_to_user_id`, `state`, and `tags`.
268+
// `end_time`, `assigned_to_user_id`, `state`, `tags`, `legend_config`, `linked_channels`, and `metadata`.
256269
// Important Note: if `tags` is specified in the update mask and `annotation.tags` is an empty list then all associated tags on the annotation
257270
// will be removed.
258271
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];

protos/sift/calculated_channels/v2/calculated_channels.proto

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import "protoc-gen-openapiv2/options/annotations.proto";
1010
import "sift/calculated_channels/v1/calculated_channels.proto";
1111
import "sift/common/type/v1/channel_data_type.proto";
1212
import "sift/common/type/v1/resource_identifier.proto";
13+
import "sift/common/type/v1/user_defined_functions.proto";
14+
import "sift/metadata/v1/metadata.proto";
1315

1416

1517

@@ -94,6 +96,15 @@ service CalculatedChannelService {
9496
description: "Resolve a batch of calculated channels into expressions with references"
9597
};
9698
}
99+
100+
// Retrieve the latest versions of calculated channels based on an optional filter.
101+
rpc ListResolvedCalculatedChannels(ListResolvedCalculatedChannelsRequest) returns (ListResolvedCalculatedChannelsResponse) {
102+
option (google.api.http) = {get: "/api/v2/calculated-channels/resolved"};
103+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
104+
summary: "ListResolvedCalculatedChannels",
105+
description: "Retrieve the latest versions of calculated channels based on an optional filter."
106+
};
107+
}
97108
}
98109

99110
message CalculatedChannel {
@@ -114,6 +125,8 @@ message CalculatedChannel {
114125
CalculatedChannelConfiguration calculated_channel_configuration = 15 [(google.api.field_behavior) = REQUIRED];
115126
string created_by_user_id = 16 [(google.api.field_behavior) = REQUIRED];
116127
string modified_by_user_id = 17 [(google.api.field_behavior) = REQUIRED];
128+
repeated sift.common.type.v1.FunctionDependency function_dependencies = 19 [(google.api.field_behavior) = REQUIRED];
129+
repeated sift.metadata.v1.MetadataValue metadata = 20 [(google.api.field_behavior) = REQUIRED];
117130
}
118131

119132
message CalculatedChannelConfiguration {
@@ -180,6 +193,7 @@ message CreateCalculatedChannelRequest {
180193
optional string units = 7 [(google.api.field_behavior) = OPTIONAL];
181194
optional string client_key = 4 [(google.api.field_behavior) = OPTIONAL];
182195
CalculatedChannelConfiguration calculated_channel_configuration = 5 [(google.api.field_behavior) = REQUIRED];
196+
repeated sift.metadata.v1.MetadataValue metadata = 8 [(google.api.field_behavior) = REQUIRED];
183197
}
184198

185199
message CreateCalculatedChannelResponse {
@@ -211,7 +225,7 @@ message ListCalculatedChannelsRequest {
211225

212226
// How to order the retrieved calculated channels. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
213227
// Available fields to order_by are `created_date` and `modified_date`.
214-
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
228+
// If left empty, items are ordered by `created_date` in descending order (newest-first).
215229
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
216230
// Example: "created_date desc,modified_date"
217231
string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
@@ -232,7 +246,7 @@ message UpdateCalculatedChannelRequest {
232246
// The calculated channel to update.
233247
CalculatedChannel calculated_channel = 1 [(google.api.field_behavior) = REQUIRED];
234248

235-
// The list of fields to be updated. The fields available to be updated are `name`, `description`, `units`,
249+
// The list of fields to be updated. The fields available to be updated are `name`, `description`, `units`, `metadata`,
236250
// `query_configuration`, `archived_date`, and `asset_configuration`.
237251
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
238252

@@ -264,7 +278,7 @@ message ListCalculatedChannelVersionsRequest {
264278
string page_token = 4 [(google.api.field_behavior) = OPTIONAL];
265279

266280
// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
267-
// Available fields to filter by are `calculated_channel_id`, `client_key`, `name`, `asset_id`, `asset_name`, `tag_id`, `tag_name`, `version`, and `archived_date.
281+
// Available fields to filter by are `calculated_channel_id`, `client_key`, `name`, `asset_id`, `asset_name`, `tag_id`, `tag_name`, `version`, `archived_date`, and `metadata`.
268282
// 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).
269283
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/calculated_channels#calculated_channel). Optional.
270284
string filter = 5 [(google.api.field_behavior) = OPTIONAL];
@@ -308,24 +322,25 @@ message ResolveCalculatedChannelRequest {
308322
optional sift.common.type.v1.ResourceIdentifier run = 5 [(google.api.field_behavior) = OPTIONAL];
309323
}
310324

311-
// The response of a call to `CalculatedChannelService_ResolveCalculatedChannel`.
312-
message ResolveCalculatedChannelResponse {
313-
// A specific calculated channel including the asset and exact channels to query.
314-
message ResolvedCalculatedChannel {
315-
// The name of the specific asset that was resolved.
316-
string asset_name = 1 [(google.api.field_behavior) = REQUIRED];
317-
// The expression resolved including channel references.
318-
sift.calculated_channels.v1.ExpressionRequest expression_request = 2 [(google.api.field_behavior) = REQUIRED];
319-
sift.common.type.v1.ChannelDataType output_data_type = 3 [(google.api.field_behavior) = REQUIRED];
320-
}
325+
// A specific calculated channel including the asset and exact channels to query.
326+
message ResolvedCalculatedChannel {
327+
// The name of the specific asset that was resolved.
328+
string asset_name = 1 [(google.api.field_behavior) = REQUIRED];
329+
// The expression resolved including channel references.
330+
sift.calculated_channels.v1.ExpressionRequest expression_request = 2 [(google.api.field_behavior) = REQUIRED];
331+
sift.common.type.v1.ChannelDataType output_data_type = 3 [(google.api.field_behavior) = REQUIRED];
332+
string asset_id = 4 [(google.api.field_behavior) = REQUIRED];
333+
}
321334

322-
// Any failure in resolution.
323-
message UnresolvedCalculatedChannel {
324-
// The name of the specific asset that was not resolved.
325-
string asset_name = 1 [(google.api.field_behavior) = REQUIRED];
326-
string error_message = 2 [(google.api.field_behavior) = REQUIRED];
327-
}
335+
// Any failure in resolution.
336+
message UnresolvedCalculatedChannel {
337+
// The name of the specific asset that was not resolved.
338+
string asset_name = 1 [(google.api.field_behavior) = REQUIRED];
339+
string error_message = 2 [(google.api.field_behavior) = REQUIRED];
340+
}
328341

342+
// The response of a call to `CalculatedChannelService_ResolveCalculatedChannel`.
343+
message ResolveCalculatedChannelResponse {
329344
// If provided in the request, the calculated channel resolved.
330345
optional string calculated_channel_id = 1 [(google.api.field_behavior) = OPTIONAL];
331346
// All resolved calculated channels.
@@ -345,3 +360,47 @@ message BatchResolveCalculatedChannelsResponse {
345360
// All calculated channels that attempted resolution.
346361
repeated ResolveCalculatedChannelResponse responses = 1 [(google.api.field_behavior) = REQUIRED];
347362
}
363+
364+
message ListResolvedCalculatedChannelsRequest {
365+
// Assets or runs to get the resolved calculated channels for. At least one asset or run must be provided.
366+
string asset_id = 1 [(google.api.field_behavior) = OPTIONAL];
367+
string run_id = 2 [(google.api.field_behavior) = OPTIONAL];
368+
369+
// The maximum number of calculated channels to return. The service may return fewer than this value.
370+
// If unspecified, at most 50 calculated channels will be returned. The maximum value is 1000; values above
371+
// 1000 will be coerced to 1000. Optional.
372+
uint32 page_size = 3 [(google.api.field_behavior) = OPTIONAL];
373+
374+
// A page token, received from a previous `ListCalculatedChannels` call.
375+
// Provide this to retrieve the subsequent page.
376+
// When paginating, all other parameters provided to `ListCalculatedChannels` must match
377+
// the call that provided the page token. Optional.
378+
string page_token = 4 [(google.api.field_behavior) = OPTIONAL];
379+
380+
// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
381+
// Available fields to filter by are `calculated_channel_id`, `client_key`, `name`, `asset_id`, `asset_name`, `tag_id`, `tag_name`, `version`, and `archived_date.
382+
// 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).
383+
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/calculated_channels#calculated_channel). Optional.
384+
string filter = 5 [(google.api.field_behavior) = OPTIONAL];
385+
386+
// How to order the retrieved calculated channels. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
387+
// Available fields to order_by are `created_date` and `modified_date`.
388+
// If left empty, items are ordered by `created_date` in descending order (newest-first).
389+
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
390+
// Example: "created_date desc,modified_date"
391+
string order_by = 6 [(google.api.field_behavior) = OPTIONAL];
392+
}
393+
394+
message CalculatedChannelResolution {
395+
// The calculated channel resolved.
396+
optional CalculatedChannel calculated_channel = 1 [(google.api.field_behavior) = OPTIONAL];
397+
// All resolved calculated channels.
398+
repeated ResolvedCalculatedChannel resolved = 2 [(google.api.field_behavior) = REQUIRED];
399+
// All assets with any issues in resolution.
400+
repeated UnresolvedCalculatedChannel unresolved = 3 [(google.api.field_behavior) = REQUIRED];
401+
}
402+
403+
message ListResolvedCalculatedChannelsResponse {
404+
repeated CalculatedChannelResolution calculated_channel_resolutions = 1 [(google.api.field_behavior) = REQUIRED];
405+
string next_page_token = 3 [(google.api.field_behavior) = OPTIONAL];
406+
}

0 commit comments

Comments
 (0)