Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial protos #1

Merged
merged 6 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

if [[ ! -f $(which buf) ]]; then
echo "Could not find 'buf' executable. Ensure that it is installed in your path."
exit 2
fi

changed_files=($(git diff --cached --name-only --diff-filter=ACM | grep '^protos/' | grep '**.proto$'))

if [[ -n "$changed_files" ]]; then
echo "running buf lint protos"
buf lint protos || {
echo -e "ERROR! protos linting failed. Please fix the errors and recommit.\n"
exit 1
}
echo "running buf format protos"
buf format protos -w --exit-code || {
echo -e "ERROR! protos file were reformatted. Please stage the changes and recommit.\n"
exit 1
}
fi

exit 0
11 changes: 11 additions & 0 deletions .github/workflows/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: protos
on: pull_request
jobs:
lint-protos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bufbuild/buf-setup-action@v1
- uses: bufbuild/buf-lint-action@v1
with:
input: protos
25 changes: 25 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: v1
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/go:v1.28.1
out: gen/go
opt: paths=source_relative
- plugin: go-vtproto
out: gen/go
opt: paths=source_relative
- plugin: buf.build/grpc-ecosystem/gateway:v2.16.2
out: gen/go
opt: paths=source_relative
- plugin: buf.build/grpc/java:v1.54.1
out: gen/java
- plugin: buf.build/protocolbuffers/java:v21.7
out: gen/java
- plugin: buf.build/grpc/python:v1.57.0
out: gen/python
- plugin: buf.build/protocolbuffers/python:v26.1
out: gen/python
- plugin: buf.build/community/neoeinstein-prost:v0.3.1
out: gen/rust
- plugin: buf.build/community/neoeinstein-tonic:v0.4.0
out: gen/rust
13 changes: 13 additions & 0 deletions protos/buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 7a6bc1e3207144b38e9066861e1de0ff
digest: shake256:d646836485c34192401253703c4e7ce899c826fceec060bf4b2a62c4749bd9976dc960833e134a1f814725e1ffd60b1bb3cf0335a7e99ef0e8cec34b070ffb66
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: 3f42134f4c564983838425bc43c7a65f
digest: shake256:3d11d4c0fe5e05fda0131afefbce233940e27f0c31c5d4e385686aea58ccd30f72053f61af432fa83f1fc11cda57f5f18ca3da26a29064f73c5a0d076bba8d92
10 changes: 10 additions & 0 deletions protos/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
147 changes: 147 additions & 0 deletions protos/sift/annotation_logs/v1/annotation_logs.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
syntax = "proto3";

package sift.annotation_logs.v1;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/sift-stack/protobufs/gen/protos/go/sift/annotation_logs/v1;annotation_logsv1pb";

service AnnotationLogService {
rpc CreateAnnotationLog(CreateAnnotationLogRequest) returns (CreateAnnotationLogResponse) {
option (google.api.http) = {
post: "/api/v1/annotations/{annotation_id}/logs"
body: "*"
};
}
rpc ListAnnotationLogs(ListAnnotationLogsRequest) returns (ListAnnotationLogsResponse) {
option (google.api.http) = {get: "/api/v1/annotations/{annotation_id}/logs"};
}
rpc DeleteAnnotationLog(DeleteAnnotationLogRequest) returns (DeleteAnnotationLogResponse) {
option (google.api.http) = {delete: "/api/v1/annotations/{annotation_id}/logs/{annotation_log_id}"};
}
}

// The request for a call to `AnnotationLogService_CreateAnnotationLog` to create an annotation log.
message CreateAnnotationLogRequest {
// The ID of the parent annotation associated to associate with the new annotation log.
string annotation_id = 1 [(google.api.field_behavior) = REQUIRED];

// The kind of annotation log to create.
AnnotationLogKind kind = 2 [(google.api.field_behavior) = REQUIRED];

// The properties associated with the specific kind of annotation log.
oneof properties {
AnnotationLogAssignedProperties assigned = 3;
AnnotationLogStateUpdateProperties state_update = 4;
AnnotationLogCommentProperties comment = 5;
}
}

// The response of a call to `AnnotationLogService_CreateAnnotationLog`.
message CreateAnnotationLogResponse {
AnnotationLogSearchResult annotation_log = 1;
}

// The request for a call to `AnnotationLogService_ListAnnotationLogs` to retrieve annotation logs.
message ListAnnotationLogsRequest {
// The ID of the parent annotation associated with the annotation logs.
string annotation_id = 1 [(google.api.field_behavior) = REQUIRED];

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

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

// A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string.
// 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](/ingestion/api#sift_annotation_logs_v1_annotation_logs-proto). Optional.
string filter = 4 [(google.api.field_behavior) = OPTIONAL];
}

// The response of a call to `AnnotationLogService_ListAnnotationLogs`.
message ListAnnotationLogsResponse {
repeated AnnotationLogSearchResult annotation_logs = 1;
string next_page_token = 2;
}

// The request for a call to `AnnotationLogService_DeleteAnnotationLog` to delete an annotation log.
message DeleteAnnotationLogRequest {
// The ID of the parent annotation associated with the annotation log to be deleted.
string annotation_id = 1 [(google.api.field_behavior) = REQUIRED];
// ID of the annotation log to be deleted.
string annotation_log_id = 2 [(google.api.field_behavior) = REQUIRED];
}

// The Response of a call to `AnnotationLogService_DeleteAnnotationLog`.
message DeleteAnnotationLogResponse {}

message AnnotationLogSearchResult {
string annotation_log_id = 1 [(google.api.field_behavior) = REQUIRED];
google.protobuf.Timestamp created_date = 2 [(google.api.field_behavior) = REQUIRED];
google.protobuf.Timestamp modified_date = 3 [(google.api.field_behavior) = REQUIRED];
string annotation_id = 4 [(google.api.field_behavior) = REQUIRED];
AnnotationLogKind kind = 5 [(google.api.field_behavior) = REQUIRED];
string created_by_user_id = 6 [(google.api.field_behavior) = REQUIRED];
string created_by_user_name = 7 [(google.api.field_behavior) = REQUIRED];
oneof properties {
AnnotationLogAssignedProperties assigned = 8;
AnnotationLogStateUpdateProperties state_update = 9;
AnnotationLogCommentProperties comment = 10;
}
}

enum AnnotationLogKind {
ANNOTATION_LOG_KIND_UNSPECIFIED = 0;
ANNOTATION_LOG_KIND_COMMENT = 1;
ANNOTATION_LOG_KIND_STATE_UPDATE = 2;
ANNOTATION_LOG_KIND_ASSIGNED = 3;
}

message AnnotationLogAssignedProperties {
string assigned_to_user_id = 1 [(google.api.field_behavior) = REQUIRED];
string assigned_to_user_email = 2 [(google.api.field_behavior) = REQUIRED];
}

message AnnotationLogStateUpdateProperties {
AnnotationLogState state = 1 [(google.api.field_behavior) = REQUIRED];
}

enum AnnotationLogState {
ANNOTATION_LOG_STATE_UNSPECIFIED = 0;
ANNOTATION_LOG_STATE_CREATED = 1;
ANNOTATION_LOG_STATE_OPEN = 2;
ANNOTATION_LOG_STATE_FLAGGED = 3;
ANNOTATION_LOG_STATE_RESOLVED = 4;
}

message AnnotationLogCommentProperties {
repeated AnnotationCommentBodyElement body = 1;
}

message AnnotationCommentBodyElement {
AnnotationCommentBodyElementType type = 1 [(google.api.field_behavior) = REQUIRED];
string text = 2 [(google.api.field_behavior) = OPTIONAL];
AnnotationCommentUserMention user_mention = 3 [(google.api.field_behavior) = OPTIONAL];
}

message AnnotationCommentUserMention {
string user_id = 1 [(google.api.field_behavior) = REQUIRED];
string user_email = 2 [(google.api.field_behavior) = REQUIRED];
}

enum AnnotationCommentBodyElementType {
ANNOTATION_COMMENT_BODY_ELEMENT_TYPE_UNSPECIFIED = 0;
ANNOTATION_COMMENT_BODY_ELEMENT_TYPE_TEXT = 1;
ANNOTATION_COMMENT_BODY_ELEMENT_TYPE_USER_MENTION = 2;
}
Loading
Loading