xref: /aosp_15_r20/external/googleapis/google/cloud/eventarc/v1/trigger.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2022 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.eventarc.v1;
18
19import "google/api/field_behavior.proto";
20import "google/api/resource.proto";
21import "google/protobuf/timestamp.proto";
22import "google/rpc/code.proto";
23
24option go_package = "cloud.google.com/go/eventarc/apiv1/eventarcpb;eventarcpb";
25option java_multiple_files = true;
26option java_outer_classname = "TriggerProto";
27option java_package = "com.google.cloud.eventarc.v1";
28option (google.api.resource_definition) = {
29  type: "cloudfunctions.googleapis.com/CloudFunction"
30  pattern: "projects/{project}/locations/{location}/functions/{function}"
31};
32option (google.api.resource_definition) = {
33  type: "iam.googleapis.com/ServiceAccount"
34  pattern: "projects/{project}/serviceAccounts/{service_account}"
35};
36option (google.api.resource_definition) = {
37  type: "run.googleapis.com/Service"
38  pattern: "*"
39};
40option (google.api.resource_definition) = {
41  type: "workflows.googleapis.com/Workflow"
42  pattern: "projects/{project}/locations/{location}/workflows/{workflow}"
43};
44
45
46// A representation of the trigger resource.
47message Trigger {
48  option (google.api.resource) = {
49    type: "eventarc.googleapis.com/Trigger"
50    pattern: "projects/{project}/locations/{location}/triggers/{trigger}"
51    plural: "triggers"
52    singular: "trigger"
53  };
54
55  // Required. The resource name of the trigger. Must be unique within the location of the
56  // project and must be in
57  // `projects/{project}/locations/{location}/triggers/{trigger}` format.
58  string name = 1 [(google.api.field_behavior) = REQUIRED];
59
60  // Output only. Server-assigned unique identifier for the trigger. The value is a UUID4
61  // string and guaranteed to remain unchanged until the resource is deleted.
62  string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
63
64  // Output only. The creation time.
65  google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
66
67  // Output only. The last-modified time.
68  google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
69
70  // Required. Unordered list. The list of filters that applies to event attributes. Only events that
71  // match all the provided filters are sent to the destination.
72  repeated EventFilter event_filters = 8 [
73    (google.api.field_behavior) = UNORDERED_LIST,
74    (google.api.field_behavior) = REQUIRED
75  ];
76
77  // Optional. The IAM service account email associated with the trigger. The
78  // service account represents the identity of the trigger.
79  //
80  // The principal who calls this API must have the `iam.serviceAccounts.actAs`
81  // permission in the service account. See
82  // https://cloud.google.com/iam/docs/understanding-service-accounts?hl=en#sa_common
83  // for more information.
84  //
85  // For Cloud Run destinations, this service account is used to generate
86  // identity tokens when invoking the service. See
87  // https://cloud.google.com/run/docs/triggering/pubsub-push#create-service-account
88  // for information on how to invoke authenticated Cloud Run services.
89  // To create Audit Log triggers, the service account should also
90  // have the `roles/eventarc.eventReceiver` IAM role.
91  string service_account = 9 [
92    (google.api.field_behavior) = OPTIONAL,
93    (google.api.resource_reference) = {
94      type: "iam.googleapis.com/ServiceAccount"
95    }
96  ];
97
98  // Required. Destination specifies where the events should be sent to.
99  Destination destination = 10 [(google.api.field_behavior) = REQUIRED];
100
101  // Optional. To deliver messages, Eventarc might use other GCP
102  // products as a transport intermediary. This field contains a reference to
103  // that transport intermediary. This information can be used for debugging
104  // purposes.
105  Transport transport = 11 [(google.api.field_behavior) = OPTIONAL];
106
107  // Optional. User labels attached to the triggers that can be used to group resources.
108  map<string, string> labels = 12 [(google.api.field_behavior) = OPTIONAL];
109
110  // Optional. The name of the channel associated with the trigger in
111  // `projects/{project}/locations/{location}/channels/{channel}` format.
112  // You must provide a channel to receive events from Eventarc SaaS partners.
113  string channel = 13 [(google.api.field_behavior) = OPTIONAL];
114
115  // Output only. The reason(s) why a trigger is in FAILED state.
116  map<string, StateCondition> conditions = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
117
118  // Output only. This checksum is computed by the server based on the value of other
119  // fields, and might be sent only on create requests to ensure that the
120  // client has an up-to-date value before proceeding.
121  string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY];
122}
123
124// Filters events based on exact matches on the CloudEvents attributes.
125message EventFilter {
126  // Required. The name of a CloudEvents attribute. Currently, only a subset of attributes
127  // are supported for filtering.
128  //
129  // All triggers MUST provide a filter for the 'type' attribute.
130  string attribute = 1 [(google.api.field_behavior) = REQUIRED];
131
132  // Required. The value for the attribute.
133  string value = 2 [(google.api.field_behavior) = REQUIRED];
134
135  // Optional. The operator used for matching the events with the value of the
136  // filter. If not specified, only events that have an exact key-value pair
137  // specified in the filter are matched. The only allowed value is
138  // `match-path-pattern`.
139  string operator = 3 [(google.api.field_behavior) = OPTIONAL];
140}
141
142// A condition that is part of the trigger state computation.
143message StateCondition {
144  // The canonical code of the condition.
145  google.rpc.Code code = 1;
146
147  // Human-readable message.
148  string message = 2;
149}
150
151// Represents a target of an invocation over HTTP.
152message Destination {
153  oneof descriptor {
154    // Cloud Run fully-managed resource that receives the events. The resource
155    // should be in the same project as the trigger.
156    CloudRun cloud_run = 1;
157
158    // The Cloud Function resource name. Only Cloud Functions V2 is supported.
159    // Format: `projects/{project}/locations/{location}/functions/{function}`
160    string cloud_function = 2 [(google.api.resource_reference) = {
161                                 type: "cloudfunctions.googleapis.com/CloudFunction"
162                               }];
163
164    // A GKE service capable of receiving events. The service should be running
165    // in the same project as the trigger.
166    GKE gke = 3;
167
168    // The resource name of the Workflow whose Executions are triggered by
169    // the events. The Workflow resource should be deployed in the same project
170    // as the trigger.
171    // Format: `projects/{project}/locations/{location}/workflows/{workflow}`
172    string workflow = 4 [(google.api.resource_reference) = {
173                           type: "workflows.googleapis.com/Workflow"
174                         }];
175  }
176}
177
178// Represents the transport intermediaries created for the trigger to
179// deliver events.
180message Transport {
181  oneof intermediary {
182    // The Pub/Sub topic and subscription used by Eventarc as a transport
183    // intermediary.
184    Pubsub pubsub = 1;
185  }
186}
187
188// Represents a Cloud Run destination.
189message CloudRun {
190  // Required. The name of the Cloud Run service being addressed. See
191  // https://cloud.google.com/run/docs/reference/rest/v1/namespaces.services.
192  //
193  // Only services located in the same project as the trigger object
194  // can be addressed.
195  string service = 1 [
196    (google.api.field_behavior) = REQUIRED,
197    (google.api.resource_reference) = {
198      type: "run.googleapis.com/Service"
199    }
200  ];
201
202  // Optional. The relative path on the Cloud Run service the events should be sent to.
203  //
204  // The value must conform to the definition of a URI path segment (section 3.3
205  // of RFC2396). Examples: "/route", "route", "route/subroute".
206  string path = 2 [(google.api.field_behavior) = OPTIONAL];
207
208  // Required. The region the Cloud Run service is deployed in.
209  string region = 3 [(google.api.field_behavior) = REQUIRED];
210}
211
212// Represents a GKE destination.
213message GKE {
214  // Required. The name of the cluster the GKE service is running in. The cluster must be
215  // running in the same project as the trigger being created.
216  string cluster = 1 [(google.api.field_behavior) = REQUIRED];
217
218  // Required. The name of the Google Compute Engine in which the cluster resides, which
219  // can either be compute zone (for example, us-central1-a) for the zonal
220  // clusters or region (for example, us-central1) for regional clusters.
221  string location = 2 [(google.api.field_behavior) = REQUIRED];
222
223  // Required. The namespace the GKE service is running in.
224  string namespace = 3 [(google.api.field_behavior) = REQUIRED];
225
226  // Required. Name of the GKE service.
227  string service = 4 [(google.api.field_behavior) = REQUIRED];
228
229  // Optional. The relative path on the GKE service the events should be sent to.
230  //
231  // The value must conform to the definition of a URI path segment (section 3.3
232  // of RFC2396). Examples: "/route", "route", "route/subroute".
233  string path = 5 [(google.api.field_behavior) = OPTIONAL];
234}
235
236// Represents a Pub/Sub transport.
237message Pubsub {
238  // Optional. The name of the Pub/Sub topic created and managed by Eventarc as
239  // a transport for the event delivery. Format:
240  // `projects/{PROJECT_ID}/topics/{TOPIC_NAME}`.
241  //
242  // You can set an existing topic for triggers of the type
243  // `google.cloud.pubsub.topic.v1.messagePublished`. The topic you provide
244  // here is not deleted by Eventarc at trigger deletion.
245  string topic = 1 [(google.api.field_behavior) = OPTIONAL];
246
247  // Output only. The name of the Pub/Sub subscription created and managed by Eventarc
248  // as a transport for the event delivery. Format:
249  // `projects/{PROJECT_ID}/subscriptions/{SUBSCRIPTION_NAME}`.
250  string subscription = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
251}
252