Skip to content

Commit

Permalink
feat: Add proto annotations for extension attributes.
Browse files Browse the repository at this point in the history
The `cloud_event_extension_attribute` annotation describes the attribute within events.proto, including the name, description and optional camel-cased name to aid tooling.

The `cloud_event_extension_name` annotation indicates that Eventarc will (sometimes conditionally) include the specified extension attribute for the given event.

Purpose of this change:

- Collect as much information about an event in these protos, as a single source of truth
- Enable tooling to make these extension attributes easier for customers to find. See googleapis/google-cloudevents-dotnet#62 as an example

PiperOrigin-RevId: 379672582
  • Loading branch information
yoshi-code-bot authored and jskeet committed Jun 16, 2021
1 parent b62ba36 commit 6b0eb9f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
21 changes: 21 additions & 0 deletions proto/google/events/cloud/audit/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,31 @@ import "google/events/cloudevent.proto";
option csharp_namespace = "Google.Events.Protobuf.Cloud.Audit.V1";
option (google.events.cloud_event_product) = "Cloud Audit Logs";

option (google.events.cloud_event_extension_attribute) = {
name: "servicename"
description: "The name of the service which triggered the Cloud Audit log entry."
camel_case_name: "serviceName"
};

option (google.events.cloud_event_extension_attribute) = {
name: "methodname"
description: "The name of the method (RPC) triggering the Cloud Audit log entry."
camel_case_name: "methodName"
};

option (google.events.cloud_event_extension_attribute) = {
name: "resourcename"
description: "The name of the resource that is the subject of the Cloud Audit log entry."
camel_case_name: "resourceName"
};
// The CloudEvent raised when an audit log entry is written.
message AuditLogWrittenEvent {
option (google.events.cloud_event_type) = "google.cloud.audit.log.v1.written";

option (google.events.cloud_event_extension_name) = "servicename";
option (google.events.cloud_event_extension_name) = "methodname";
option (google.events.cloud_event_extension_name) = "resourcename";

// The data associated with the event.
LogEntryData data = 1;
}
6 changes: 6 additions & 0 deletions proto/google/events/cloud/pubsub/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ import "google/events/cloudevent.proto";
option csharp_namespace = "Google.Events.Protobuf.Cloud.PubSub.V1";
option (google.events.cloud_event_product) = "Cloud Pub/Sub";

option (google.events.cloud_event_extension_attribute) = {
name: "topic"
description: "The Pub/Sub topic for which the message was published.",
};

// The CloudEvent raised when a PubSub message is published for a topic.
message MessagePublishedEvent {
option (google.events.cloud_event_type) =
"google.cloud.pubsub.topic.v1.messagePublished";
option (google.events.cloud_event_extension_name) = "topic";

// The data associated with the event.
MessagePublishedData data = 1;
Expand Down
25 changes: 25 additions & 0 deletions proto/google/events/cloudevent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,28 @@ extend google.protobuf.FileOptions {
// in this file.
string cloud_event_product = 11716487;
}

extend google.protobuf.FileOptions {
// An extension attribute used within the CloudEvents described in this file.
repeated ExtensionAttribute cloud_event_extension_attribute = 11716488;
}

extend google.protobuf.MessageOptions {
// The name of an extension attribute populated for this event. The extension
// attribute should be more fully described within the file options.
repeated string cloud_event_extension_name = 11716489;
}

// Description of an extension attribute.
message ExtensionAttribute {
// Name of the CloudEvents attribute, e.g. "topic".
// This must be all lower-case, to satisfy CloudEvent requirements.
string name = 1;

// Description of the attribute.
string description = 2;

// The name of the CloudEvents attribute in lower Camel case, e.g. "firebaseDatabaseHost".
// This only needs to be populated if the name would otherwise be mis-represented.
string camel_case_name = 3;
}

0 comments on commit 6b0eb9f

Please sign in to comment.