xref: /aosp_15_r20/external/googleapis/google/cloud/advisorynotifications/v1/service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 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.advisorynotifications.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/protobuf/timestamp.proto";
24
25option csharp_namespace = "Google.Cloud.AdvisoryNotifications.V1";
26option go_package = "cloud.google.com/go/advisorynotifications/apiv1/advisorynotificationspb;advisorynotificationspb";
27option java_multiple_files = true;
28option java_outer_classname = "ServiceProto";
29option java_package = "com.google.cloud.advisorynotifications.v1";
30option php_namespace = "Google\\Cloud\\AdvisoryNotifications\\V1";
31option ruby_package = "Google::Cloud::AdvisoryNotifications::V1";
32option (google.api.resource_definition) = {
33  type: "advisorynotifications.googleapis.com/Location"
34  pattern: "organizations/{organization}/locations/{location}"
35  pattern: "projects/{project}/locations/{location}"
36};
37
38// Service to manage Security and Privacy Notifications.
39service AdvisoryNotificationsService {
40  option (google.api.default_host) = "advisorynotifications.googleapis.com";
41  option (google.api.oauth_scopes) =
42      "https://www.googleapis.com/auth/cloud-platform";
43
44  // Lists notifications under a given parent.
45  rpc ListNotifications(ListNotificationsRequest)
46      returns (ListNotificationsResponse) {
47    option (google.api.http) = {
48      get: "/v1/{parent=organizations/*/locations/*}/notifications"
49      additional_bindings {
50        get: "/v1/{parent=projects/*/locations/*}/notifications"
51      }
52    };
53    option (google.api.method_signature) = "parent";
54  }
55
56  // Gets a notification.
57  rpc GetNotification(GetNotificationRequest) returns (Notification) {
58    option (google.api.http) = {
59      get: "/v1/{name=organizations/*/locations/*/notifications/*}"
60      additional_bindings {
61        get: "/v1/{name=projects/*/locations/*/notifications/*}"
62      }
63    };
64    option (google.api.method_signature) = "name";
65  }
66
67  // Get notification settings.
68  rpc GetSettings(GetSettingsRequest) returns (Settings) {
69    option (google.api.http) = {
70      get: "/v1/{name=organizations/*/locations/*/settings}"
71      additional_bindings { get: "/v1/{name=projects/*/locations/*/settings}" }
72    };
73    option (google.api.method_signature) = "name";
74  }
75
76  // Update notification settings.
77  rpc UpdateSettings(UpdateSettingsRequest) returns (Settings) {
78    option (google.api.http) = {
79      patch: "/v1/{settings.name=organizations/*/locations/*/settings}"
80      body: "settings"
81      additional_bindings {
82        patch: "/v1/{settings.name=projects/*/locations/*/settings}"
83        body: "settings"
84      }
85    };
86    option (google.api.method_signature) = "settings";
87  }
88}
89
90// Notification view.
91enum NotificationView {
92  // Not specified, equivalent to BASIC.
93  NOTIFICATION_VIEW_UNSPECIFIED = 0;
94
95  // Server responses only include title, creation time and Notification ID.
96  // Note: for internal use responses also include the last update time,
97  // the latest message text and whether notification has attachments.
98  BASIC = 1;
99
100  // Include everything.
101  FULL = 2;
102}
103
104// Status of localized text.
105enum LocalizationState {
106  // Not used.
107  LOCALIZATION_STATE_UNSPECIFIED = 0;
108
109  // Localization is not applicable for requested language. This can happen
110  // when:
111  // - The requested language was not supported by Advisory Notifications at the
112  // time of localization (including notifications created before the
113  // localization feature was launched).
114  // - The requested language is English, so only the English text is returned.
115  LOCALIZATION_STATE_NOT_APPLICABLE = 1;
116
117  // Localization for requested language is in progress, and not ready yet.
118  LOCALIZATION_STATE_PENDING = 2;
119
120  // Localization for requested language is completed.
121  LOCALIZATION_STATE_COMPLETED = 3;
122}
123
124// Type of notification
125enum NotificationType {
126  // Default type
127  NOTIFICATION_TYPE_UNSPECIFIED = 0;
128
129  // Security and privacy advisory notifications
130  NOTIFICATION_TYPE_SECURITY_PRIVACY_ADVISORY = 1;
131
132  // Sensitive action notifications
133  NOTIFICATION_TYPE_SENSITIVE_ACTIONS = 2;
134
135  // General security MSA
136  NOTIFICATION_TYPE_SECURITY_MSA = 3;
137
138  // Threat horizons MSA
139  NOTIFICATION_TYPE_THREAT_HORIZONS = 4;
140}
141
142// A notification object for notifying customers about security and privacy
143// issues.
144message Notification {
145  option (google.api.resource) = {
146    type: "advisorynotifications.googleapis.com/Notification"
147    pattern: "organizations/{organization}/locations/{location}/notifications/{notification}"
148    pattern: "projects/{project}/locations/{location}/notifications/{notification}"
149    plural: "notifications"
150    singular: "notification"
151  };
152
153  // The resource name of the notification.
154  // Format:
155  // organizations/{organization}/locations/{location}/notifications/{notification}
156  // or projects/{project}/locations/{location}/notifications/{notification}.
157  string name = 1;
158
159  // The subject line of the notification.
160  Subject subject = 2;
161
162  // A list of messages in the notification.
163  repeated Message messages = 3;
164
165  // Output only. Time the notification was created.
166  google.protobuf.Timestamp create_time = 4
167      [(google.api.field_behavior) = OUTPUT_ONLY];
168
169  // Type of notification
170  NotificationType notification_type = 12;
171}
172
173// A text object containing the English text and its localized copies.
174message Text {
175  // The English copy.
176  string en_text = 1;
177
178  // The requested localized copy (if applicable).
179  string localized_text = 2;
180
181  // Status of the localization.
182  LocalizationState localization_state = 3;
183}
184
185// A subject line of a notification.
186message Subject {
187  // The text content.
188  Text text = 1;
189}
190
191// A message which contains notification details.
192message Message {
193  // A message body containing text.
194  message Body {
195    // The text content of the message body.
196    Text text = 1;
197  }
198
199  // The message content.
200  Body body = 1;
201
202  // The attachments to download.
203  repeated Attachment attachments = 2;
204
205  // The Message creation timestamp.
206  google.protobuf.Timestamp create_time = 3;
207
208  // Time when Message was localized
209  google.protobuf.Timestamp localization_time = 4;
210}
211
212// Attachment with specific information about the issue.
213message Attachment {
214  // Data type of the attachment.
215  oneof data {
216    // A CSV file attachment. Max size is 10 MB.
217    Csv csv = 2;
218  }
219
220  // The title of the attachment.
221  string display_name = 1;
222}
223
224// A representation of a CSV file attachment, as a list of column headers and
225// a list of data rows.
226message Csv {
227  // A representation of a single data row in a CSV file.
228  message CsvRow {
229    // The data entries in a CSV file row, as a string array rather than a
230    // single comma-separated string.
231    repeated string entries = 1;
232  }
233
234  // The list of headers for data columns in a CSV file.
235  repeated string headers = 1;
236
237  // The list of data rows in a CSV file, as string arrays rather than as a
238  // single comma-separated string.
239  repeated CsvRow data_rows = 2;
240}
241
242// Request for fetching all notifications for a given parent.
243message ListNotificationsRequest {
244  // Required. The parent, which owns this collection of notifications.
245  // Must be of the form "organizations/{organization}/locations/{location}"
246  // or "projects/{project}/locations/{location}".
247  string parent = 1 [
248    (google.api.field_behavior) = REQUIRED,
249    (google.api.resource_reference) = {
250      child_type: "advisorynotifications.googleapis.com/Notification"
251    }
252  ];
253
254  // The maximum number of notifications to return. The service may return
255  // fewer than this value. If unspecified or equal to 0, at most 50
256  // notifications will be returned. The maximum value is 50; values above 50
257  // will be coerced to 50.
258  int32 page_size = 2;
259
260  // A page token returned from a previous request.
261  // When paginating, all other parameters provided in the request
262  // must match the call that returned the page token.
263  string page_token = 3;
264
265  // Specifies which parts of the notification resource should be returned
266  // in the response.
267  NotificationView view = 4;
268
269  // ISO code for requested localization language.  If unset, will be
270  // interpereted as "en". If the requested language is valid, but not supported
271  // for this notification, English will be returned with an "Not applicable"
272  // LocalizationState. If the ISO code is invalid (i.e. not a real language),
273  // this RPC will throw an error.
274  string language_code = 5;
275}
276
277// Response of ListNotifications endpoint.
278message ListNotificationsResponse {
279  // List of notifications under a given parent.
280  repeated Notification notifications = 1;
281
282  // A token, which can be sent as `page_token` to retrieve the next page.
283  // If this field is omitted, there are no subsequent pages.
284  string next_page_token = 2;
285
286  // Estimation of a total number of notifications.
287  int32 total_size = 3;
288}
289
290// Request for fetching a notification.
291message GetNotificationRequest {
292  // Required. A name of the notification to retrieve.
293  // Format:
294  // organizations/{organization}/locations/{location}/notifications/{notification}
295  // or projects/{projects}/locations/{location}/notifications/{notification}.
296  string name = 1 [
297    (google.api.field_behavior) = REQUIRED,
298    (google.api.resource_reference) = {
299      type: "advisorynotifications.googleapis.com/Notification"
300    }
301  ];
302
303  // ISO code for requested localization language. If unset, will be
304  // interpereted as "en". If the requested language is valid, but not supported
305  // for this notification, English will be returned with an "Not applicable"
306  // LocalizationState. If the ISO code is invalid (i.e. not a real language),
307  // this RPC will throw an error.
308  string language_code = 5;
309}
310
311// Settings for Advisory Notifications.
312message Settings {
313  option (google.api.resource) = {
314    type: "advisorynotifications.googleapis.com/Settings"
315    pattern: "organizations/{organization}/locations/{location}/settings"
316    pattern: "projects/{project}/locations/{location}/settings"
317    plural: "settings"
318    singular: "settings"
319  };
320
321  // Identifier. The resource name of the settings to retrieve.
322  // Format:
323  // organizations/{organization}/locations/{location}/settings or
324  // projects/{projects}/locations/{location}/settings.
325  string name = 1 [(google.api.field_behavior) = IDENTIFIER];
326
327  // Required. Map of each notification type and its settings to get/set all
328  // settings at once. The server will validate the value for each notification
329  // type.
330  map<string, NotificationSettings> notification_settings = 2
331      [(google.api.field_behavior) = REQUIRED];
332
333  // Required. Fingerprint for optimistic concurrency returned in Get requests.
334  // Must be provided for Update requests. If the value provided does not match
335  // the value known to the server, ABORTED will be thrown, and the client
336  // should retry the read-modify-write cycle.
337  string etag = 3 [(google.api.field_behavior) = REQUIRED];
338}
339
340// Settings for each NotificationType.
341message NotificationSettings {
342  // Whether the associated NotificationType is enabled.
343  bool enabled = 1;
344}
345
346// Request of GetSettings endpoint.
347message GetSettingsRequest {
348  // Required. The resource name of the settings to retrieve.
349  // Format:
350  // organizations/{organization}/locations/{location}/settings or
351  // projects/{projects}/locations/{location}/settings.
352  string name = 1 [
353    (google.api.field_behavior) = REQUIRED,
354    (google.api.resource_reference) = {
355      type: "advisorynotifications.googleapis.com/Settings"
356    }
357  ];
358}
359
360// Request of UpdateSettings endpoint.
361message UpdateSettingsRequest {
362  // Required. New settings.
363  Settings settings = 1 [(google.api.field_behavior) = REQUIRED];
364}
365