Skip to content

Commit

Permalink
SIFT-000: Updated protos for Sift APIs (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgfreeman7 authored Dec 11, 2024
1 parent 6f3296b commit 5c557dd
Show file tree
Hide file tree
Showing 16 changed files with 419 additions and 28 deletions.
2 changes: 1 addition & 1 deletion protos/sift/annotation_logs/v1/annotation_logs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ message ListAnnotationLogsRequest {
// Available fields to filter by are `annotation_log_id`, `annotation_id`, `created_by_user_id`,
// `created_date`, `modified_date`, and `kind`.
// 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).
// For more information about the fields used for filtering, please refer to [this definition](/api/grpc/protocol_buffers/annotation_logs#annotationlogsearchresult). Optional.
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/annotation_logs#annotationlogsearchresult). Optional.
string filter = 4 [(google.api.field_behavior) = OPTIONAL];
}

Expand Down
6 changes: 3 additions & 3 deletions protos/sift/annotations/v1/annotations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ message ListAnnotationsRequest {
// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
// Available fields to filter by are `annotation_id`, `start_time`, `end_time`,
// `created_date`, `modified_date`, `run_id`, `name`, `description`, `state`, `created_by_user_id`, `created_by_rule_condition_version_id`,
// `annotation_type`, `tag_name`, and `assignee`.
// `annotation_type`, `tag_name`, `report_id`, `asset_id`, `asset_name`, and `assignee`.
// 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).
// For more information about the fields used for filtering, please refer to [this definition](/api/grpc/protocol_buffers/annotations#annotation). Optional.
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/annotations#annotation). Optional.
string filter = 3 [(google.api.field_behavior) = OPTIONAL];

// This field is only required if your user belongs to multiple organizations.
string organization_id = 4 [(google.api.field_behavior) = OPTIONAL];

// How to order the retrieved annotations. Formatted as a comma-separated string i.e. "<field_name>[ desc],...".
// How to order the retrieved annotations. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
// Available fields to order_by are `created_date`, `modified_date`, `start_time`, and `end_time`.
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
Expand Down
4 changes: 2 additions & 2 deletions protos/sift/assets/v1/assets.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ message ListAssetsRequest {
// Available fields to filter by are `asset_id`, `created_by_user_id`, `modified_by_user_id`,
// `created_date`, `modified_date`, and `name`.
// 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).
// For more information about the fields used for filtering, please refer to [this definition](/api/grpc/protocol_buffers/assets#asset). Optional.
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/assets#asset). Optional.
string filter = 3 [(google.api.field_behavior) = OPTIONAL];

// How to order the retrieved assets. Formatted as a comma-separated string i.e. "<field_name>[ desc],...".
// How to order the retrieved assets. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
// Available fields to order_by are `created_date` and `modified_date`.
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
Expand Down
240 changes: 240 additions & 0 deletions protos/sift/calculated_channels/v2/calculated_channels.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
syntax = "proto3";

package sift.calculated_channels.v2;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "sift/calculated_channels/v1/calculated_channels.proto";



service CalculatedChannelService {
// Retrieve the latest version of a calculated channel
rpc GetCalculatedChannel(GetCalculatedChannelRequest) returns (GetCalculatedChannelResponse) {
option (google.api.http) = {
get: "/api/v2/calculated-channels/{calculated_channel_id}"
additional_bindings {get: "/v2/organizations/{organization_id}/calculated-channels/{client_key}"}
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "GetCalculatedChannel",
description: "Retrieve the latest version of a calculated channel."
};
}

// Create a calculated channel.
rpc CreateCalculatedChannel(CreateCalculatedChannelRequest) returns (CreateCalculatedChannelResponse) {
option (google.api.http) = {
post: "/api/v2/calculated-channels"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "CreateCalculatedChannel",
description: "Create a calculated channel."
};
}

// Retrieve the latest versions of calculated channels based on an optional filter.
rpc ListCalculatedChannels(ListCalculatedChannelsRequest) returns (ListCalculatedChannelsResponse) {
option (google.api.http) = {get: "/api/v2/calculated-channels"};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "ListCalculatedChannels",
description: "Retrieve the latest versions of calculated channels based on an optional filter."
};
}

// Update and create a new version of a calculated channel.
rpc UpdateCalculatedChannel(UpdateCalculatedChannelRequest) returns (UpdateCalculatedChannelResponse) {
option (google.api.http) = {
patch: "/api/v2/calculated-channels"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "UpdateCalculatedChannel",
description: "Update and create a new version of a calculated channel."
};
}

// List versions of a particular calculated channel with an optional filter.
rpc ListCalculatedChannelVersions(ListCalculatedChannelVersionsRequest) returns (ListCalculatedChannelVersionsResponse) {
option (google.api.http) = {
get: "/api/v2/calculated-channels/{calculated_channel_id}/versions"
additional_bindings {get: "/v2/organizations/{organization_id}/calculated-channels/{client_key}/versions"}
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "ListCalculatedChannelVersions",
description: "List versions of a particular calculated channel with an optional filter."
};
}
}

message CalculatedChannel {
string calculated_channel_id = 1 [(google.api.field_behavior) = REQUIRED];
string organization_id = 2 [(google.api.field_behavior) = REQUIRED];
optional string client_key = 3 [(google.api.field_behavior) = OPTIONAL];
optional google.protobuf.Timestamp archived_date = 4 [(google.api.field_behavior) = OPTIONAL];

string version_id = 5 [(google.api.field_behavior) = REQUIRED];
uint32 version = 6 [(google.api.field_behavior) = REQUIRED];
string name = 7 [(google.api.field_behavior) = REQUIRED];
string description = 8 [(google.api.field_behavior) = REQUIRED];
string change_message = 9 [(google.api.field_behavior) = REQUIRED];
string user_notes = 10 [(google.api.field_behavior) = REQUIRED];
google.protobuf.Timestamp created_date = 11 [(google.api.field_behavior) = REQUIRED];
google.protobuf.Timestamp modified_date = 12 [(google.api.field_behavior) = REQUIRED];
CalculatedChannelAssetConfiguration asset_configuration = 13 [(google.api.field_behavior) = REQUIRED];
CalculatedChannelQueryConfiguration query_configuration = 14 [(google.api.field_behavior) = REQUIRED];
}

message CalculatedChannelAssetConfiguration {
message AssetSelection {
repeated string asset_ids = 1;
repeated string tag_ids = 2;
}
oneof asset_scope {
bool all_assets = 1;
AssetSelection selection = 2;
}
}

message CalculatedChannelQueryConfiguration {
// Sift Expression Language
message Sel {
string expression = 1;
repeated sift.calculated_channels.v1.ExpressionChannelReference expression_channel_references = 2;
}

oneof query {
Sel sel = 1;
}
}

// The request for a call to `CalculatedChannelService_GetCalculatedChannel` to retrieve the latest version of a calculated channel.
// If `calculated_channel_id` is provided then all other arguments will be ignored. The argument `calculated_channel_id`
// should not be used together with `client_key`. The `organization_id` argument is only required
// if using `client_key` and the user belongs to multiple organizations.
message GetCalculatedChannelRequest {
string calculated_channel_id = 1 [(google.api.field_behavior) = OPTIONAL];
string client_key = 2 [(google.api.field_behavior) = OPTIONAL];
string organization_id = 3 [(google.api.field_behavior) = OPTIONAL];
}

message GetCalculatedChannelResponse {
CalculatedChannel calculated_channel = 1 [(google.api.field_behavior) = REQUIRED];
}

message CreateCalculatedChannelRequest {
string name = 1 [(google.api.field_behavior) = REQUIRED];
string description = 2 [(google.api.field_behavior) = OPTIONAL];
string user_notes = 3 [(google.api.field_behavior) = OPTIONAL];
optional string client_key = 4 [(google.api.field_behavior) = OPTIONAL];
CalculatedChannelAssetConfiguration asset_configuration = 5 [(google.api.field_behavior) = REQUIRED];
CalculatedChannelQueryConfiguration query_configuration = 6 [(google.api.field_behavior) = REQUIRED];
}

message CreateCalculatedChannelResponse {
CalculatedChannel calculated_channel = 1 [(google.api.field_behavior) = REQUIRED];
}

// The request for a call to `CalculatedChannelService_ListCalculatedChannels` to retrieve lateset vesrions of calculated channels.
message ListCalculatedChannelsRequest {
// The maximum number of calculated channels to return. The service may return fewer than this value.
// If unspecified, at most 50 calculated channels will be returned. The maximum value is 1000; values above
// 1000 will be coerced to 1000. Optional.
uint32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];

// A page token, received from a previous `ListCalculatedChannels` call.
// Provide this to retrieve the subsequent page.
// When paginating, all other parameters provided to `ListCalculatedChannels` must match
// the call that provided the page token. Optional.
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];

// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
// Available fields to filter by are `calculated_channel_id`, `client_key`, `name`, and `description`.
// 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).
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/calculated_channels#calculated_channel). Optional.
string filter = 3 [(google.api.field_behavior) = OPTIONAL];

// This field is only required if your user belongs to multiple organizations.
string organization_id = 4 [(google.api.field_behavior) = OPTIONAL];

// If `true` then archived calculated channels will be included in the query. Defaults to `false`.
bool include_archived = 5 [(google.api.field_behavior) = OPTIONAL];

// How to order the retrieved calculated channels. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
// Available fields to order_by are `created_date` and `modified_date`.
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
// Example: "created_date desc,modified_date"
string order_by = 6 [(google.api.field_behavior) = OPTIONAL];
}

// The response of a call to `CalculatedChannelService_ListCalculatedChannelsResponse`.
message ListCalculatedChannelsResponse {
repeated CalculatedChannel calculated_channels = 1;
string next_page_token = 2;
}

// The request for a call to `CalculatedChannelService_UpdateCalculatedChannel` to update a calculated channel. Updating a calculated
// channel creates a new version of the calculated channel, leaving the previous untouched. If no update is deemed necessary, then the
// the current version is returned. To archive calculated channel, specify `archived_date` in the `update mask` as well as a non-null
// value for `archived_date` in the `calculated_channel` object. To unarchive a calculated channel, specify `archived_date` in the
// `update mask` and a `null` value for `archived_date` in the `calculated_channel` object.
message UpdateCalculatedChannelRequest {
// The calculated channel to update.
CalculatedChannel calculated_channel = 1 [(google.api.field_behavior) = REQUIRED];

// The list of fields to be updated. The fields available to be updated are `name`, `description`,
// `query_configuration`, `archived_date`, and `asset_configuration`.
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];

// Optional user notes to describe changes.
optional string user_notes = 3 [(google.api.field_behavior) = OPTIONAL];
}

// The response of a call to `CalculatedChannelService_UpdateCalculatedChannel`.
message UpdateCalculatedChannelResponse {
CalculatedChannel calculated_channel = 1 [(google.api.field_behavior) = REQUIRED];
}

// The request for a call to `CalculatedChannelService_ListCalculatedChannelVersions` to retrieve versions
// of a particular calculated channel. If `calculated_channel_id` is provided then `client_key` is ignored.
message ListCalculatedChannelVersionsRequest {
string calculated_channel_id = 1 [(google.api.field_behavior) = OPTIONAL];
string client_key = 2 [(google.api.field_behavior) = OPTIONAL];

// The maximum number of calculated channel versions to return. The service may return fewer than this value.
// If unspecified, at most 50 calculated channels will be returned. The maximum value is 1000; values above
// 1000 will be coerced to 1000. Optional.
uint32 page_size = 3 [(google.api.field_behavior) = OPTIONAL];

// A page token, received from a previous `ListCalculatedChannelVersions` call.
// Provide this to retrieve the subsequent page.
// When paginating, all other parameters provided to `ListCalculatedChannelVersions` must match
// the call that provided the page token. Optional.
string page_token = 4 [(google.api.field_behavior) = OPTIONAL];

// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
// Available fields to filter by are `calculated_channel_id`, `name`, and `description`.
// 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).
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/calculated_channels#calculated_channel). Optional.
string filter = 5 [(google.api.field_behavior) = OPTIONAL];

// This field is only required if your user belongs to multiple organizations.
string organization_id = 6 [(google.api.field_behavior) = OPTIONAL];

// How to order the retrieved calculated channel versions. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
// Available fields to order_by are `created_date` and `modified_date`.
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
// Example: "created_date desc,modified_date"
string order_by = 7 [(google.api.field_behavior) = OPTIONAL];
}

// The response of a call to `CalculatedChannelService_ListCalculatedChannelVersionsResponse`.
message ListCalculatedChannelVersionsResponse {
repeated CalculatedChannel calculated_channel_versions = 1;
string next_page_token = 2;
}
7 changes: 4 additions & 3 deletions protos/sift/channels/v2/channels.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ message ListChannelsRequest {
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];

// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
// Available fields to filter by are `channel_id`, `asset_id`, `name`, `component`, `description`, `active`, `created_date`, and `modified_date`.
// Available fields to filter by are `channel_id`, `asset_id`, `name`, `component`, `description`, `active`,
// `run_id`, `run_name`, `run_client_key`, `created_date`, and `modified_date`.
// 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).
// For more information about the fields used for filtering, please refer to [this definition](/api/grpc/protocol_buffers/channels#channel). Optional.
// For more information about the fields used for filtering, please refer to [this definition](/docs/api/grpc/protocol-buffers/channels#channel). Optional.
string filter = 3 [(google.api.field_behavior) = OPTIONAL];

// This field is only required if your user belongs to multiple organizations.
string organization_id = 4 [(google.api.field_behavior) = OPTIONAL];

// How to order the retrieved channels. Formatted as a comma-separated string i.e. "<field_name>[ desc],...".
// How to order the retrieved channels. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
// Available fields to order_by are `created_date` and `modified_date`.
// If left empty, items are ordered by `created_date` in ascending order (oldest-first).
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
Expand Down
42 changes: 42 additions & 0 deletions protos/sift/common/type/v1/resource_ref.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
syntax = "proto3";

package sift.common.type.v1;

import "google/api/field_behavior.proto";



// ResourceRef is meant to be embedded as a field in other resources. It's used by one resource to point to another resource.
// In a request, use the `find_by` field to select a resource to point to.
// In a response, the fields marked `google.api.field_behavior = OUTPUT_ONLY` will be populated by the backend.
message ResourceRef {
// The global unique id of the resource, e.g. the asset_id, run_id, or report_id.
string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

// If a resource has a client_key associated with it, it will be included.
optional string client_key = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

// The name of the resource.
string name = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

// Use this field to 'construct' a ResourceRef.
// You can give just the name, id, or client_key and the backend will find the resource you're referring to.
FindResourceBy find_by = 4 [(google.api.field_behavior) = INPUT_ONLY];
}

message FindResourceBy {
oneof identifier {
// Find by the resource's global id, e.g. asset_id, run_id, report_id.
string id = 1;

// Find by the resource's client_key, if available.
string client_key = 2;

// Find by the resource's name. If multiple resources are found with the same name, an error will be returned.
string name = 3;
}

// When finding by `client_key` or `name`, the `organization_id` should also be specified.
// Only required if the user belongs to more than one organization.
string organization_id = 4 [(google.api.field_behavior) = OPTIONAL];
}
Loading

0 comments on commit 5c557dd

Please sign in to comment.