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.monitoring.v3;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/monitoring/v3/alert.proto";
24import "google/protobuf/empty.proto";
25import "google/protobuf/field_mask.proto";
26
27option csharp_namespace = "Google.Cloud.Monitoring.V3";
28option go_package = "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb;monitoringpb";
29option java_multiple_files = true;
30option java_outer_classname = "AlertServiceProto";
31option java_package = "com.google.monitoring.v3";
32option php_namespace = "Google\\Cloud\\Monitoring\\V3";
33option ruby_package = "Google::Cloud::Monitoring::V3";
34
35// The AlertPolicyService API is used to manage (list, create, delete,
36// edit) alert policies in Cloud Monitoring. An alerting policy is
37// a description of the conditions under which some aspect of your
38// system is considered to be "unhealthy" and the ways to notify
39// people or services about this state. In addition to using this API, alert
40// policies can also be managed through
41// [Cloud Monitoring](https://cloud.google.com/monitoring/docs/),
42// which can be reached by clicking the "Monitoring" tab in
43// [Cloud console](https://console.cloud.google.com/).
44service AlertPolicyService {
45  option (google.api.default_host) = "monitoring.googleapis.com";
46  option (google.api.oauth_scopes) =
47      "https://www.googleapis.com/auth/cloud-platform,"
48      "https://www.googleapis.com/auth/monitoring,"
49      "https://www.googleapis.com/auth/monitoring.read";
50
51  // Lists the existing alerting policies for the workspace.
52  rpc ListAlertPolicies(ListAlertPoliciesRequest) returns (ListAlertPoliciesResponse) {
53    option (google.api.http) = {
54      get: "/v3/{name=projects/*}/alertPolicies"
55    };
56    option (google.api.method_signature) = "name";
57  }
58
59  // Gets a single alerting policy.
60  rpc GetAlertPolicy(GetAlertPolicyRequest) returns (AlertPolicy) {
61    option (google.api.http) = {
62      get: "/v3/{name=projects/*/alertPolicies/*}"
63    };
64    option (google.api.method_signature) = "name";
65  }
66
67  // Creates a new alerting policy.
68  rpc CreateAlertPolicy(CreateAlertPolicyRequest) returns (AlertPolicy) {
69    option (google.api.http) = {
70      post: "/v3/{name=projects/*}/alertPolicies"
71      body: "alert_policy"
72    };
73    option (google.api.method_signature) = "name,alert_policy";
74  }
75
76  // Deletes an alerting policy.
77  rpc DeleteAlertPolicy(DeleteAlertPolicyRequest) returns (google.protobuf.Empty) {
78    option (google.api.http) = {
79      delete: "/v3/{name=projects/*/alertPolicies/*}"
80    };
81    option (google.api.method_signature) = "name";
82  }
83
84  // Updates an alerting policy. You can either replace the entire policy with
85  // a new one or replace only certain fields in the current alerting policy by
86  // specifying the fields to be updated via `updateMask`. Returns the
87  // updated alerting policy.
88  rpc UpdateAlertPolicy(UpdateAlertPolicyRequest) returns (AlertPolicy) {
89    option (google.api.http) = {
90      patch: "/v3/{alert_policy.name=projects/*/alertPolicies/*}"
91      body: "alert_policy"
92    };
93    option (google.api.method_signature) = "update_mask,alert_policy";
94  }
95}
96
97// The protocol for the `CreateAlertPolicy` request.
98message CreateAlertPolicyRequest {
99  // Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in
100  // which to create the alerting policy. The format is:
101  //
102  //     projects/[PROJECT_ID_OR_NUMBER]
103  //
104  // Note that this field names the parent container in which the alerting
105  // policy will be written, not the name of the created policy. |name| must be
106  // a host project of a Metrics Scope, otherwise INVALID_ARGUMENT error will
107  // return. The alerting policy that is returned will have a name that contains
108  // a normalized representation of this name as a prefix but adds a suffix of
109  // the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the
110  // container.
111  string name = 3 [
112    (google.api.field_behavior) = REQUIRED,
113    (google.api.resource_reference) = {
114      child_type: "monitoring.googleapis.com/AlertPolicy"
115    }
116  ];
117
118  // Required. The requested alerting policy. You should omit the `name` field in this
119  // policy. The name will be returned in the new policy, including
120  // a new `[ALERT_POLICY_ID]` value.
121  AlertPolicy alert_policy = 2 [(google.api.field_behavior) = REQUIRED];
122}
123
124// The protocol for the `GetAlertPolicy` request.
125message GetAlertPolicyRequest {
126  // Required. The alerting policy to retrieve. The format is:
127  //
128  //     projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
129  string name = 3 [
130    (google.api.field_behavior) = REQUIRED,
131    (google.api.resource_reference) = {
132      type: "monitoring.googleapis.com/AlertPolicy"
133    }
134  ];
135}
136
137// The protocol for the `ListAlertPolicies` request.
138message ListAlertPoliciesRequest {
139  // Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name)
140  // whose alert policies are to be listed. The format is:
141  //
142  //     projects/[PROJECT_ID_OR_NUMBER]
143  //
144  // Note that this field names the parent container in which the alerting
145  // policies to be listed are stored. To retrieve a single alerting policy
146  // by name, use the
147  // [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy]
148  // operation, instead.
149  string name = 4 [
150    (google.api.field_behavior) = REQUIRED,
151    (google.api.resource_reference) = {
152      child_type: "monitoring.googleapis.com/AlertPolicy"
153    }
154  ];
155
156  // If provided, this field specifies the criteria that must be met by
157  // alert policies to be included in the response.
158  //
159  // For more details, see [sorting and
160  // filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
161  string filter = 5;
162
163  // A comma-separated list of fields by which to sort the result. Supports
164  // the same set of field references as the `filter` field. Entries can be
165  // prefixed with a minus sign to sort by the field in descending order.
166  //
167  // For more details, see [sorting and
168  // filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
169  string order_by = 6;
170
171  // The maximum number of results to return in a single response.
172  int32 page_size = 2;
173
174  // If this field is not empty then it must contain the `nextPageToken` value
175  // returned by a previous call to this method.  Using this field causes the
176  // method to return more results from the previous method call.
177  string page_token = 3;
178}
179
180// The protocol for the `ListAlertPolicies` response.
181message ListAlertPoliciesResponse {
182  // The returned alert policies.
183  repeated AlertPolicy alert_policies = 3;
184
185  // If there might be more results than were returned, then this field is set
186  // to a non-empty value. To see the additional results,
187  // use that value as `page_token` in the next call to this method.
188  string next_page_token = 2;
189
190  // The total number of alert policies in all pages. This number is only an
191  // estimate, and may change in subsequent pages. https://aip.dev/158
192  int32 total_size = 4;
193}
194
195// The protocol for the `UpdateAlertPolicy` request.
196message UpdateAlertPolicyRequest {
197  // Optional. A list of alerting policy field names. If this field is not
198  // empty, each listed field in the existing alerting policy is set to the
199  // value of the corresponding field in the supplied policy (`alert_policy`),
200  // or to the field's default value if the field is not in the supplied
201  // alerting policy.  Fields not listed retain their previous value.
202  //
203  // Examples of valid field masks include `display_name`, `documentation`,
204  // `documentation.content`, `documentation.mime_type`, `user_labels`,
205  // `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc.
206  //
207  // If this field is empty, then the supplied alerting policy replaces the
208  // existing policy. It is the same as deleting the existing policy and
209  // adding the supplied policy, except for the following:
210  //
211  // +   The new policy will have the same `[ALERT_POLICY_ID]` as the former
212  //     policy. This gives you continuity with the former policy in your
213  //     notifications and incidents.
214  // +   Conditions in the new policy will keep their former `[CONDITION_ID]` if
215  //     the supplied condition includes the `name` field with that
216  //     `[CONDITION_ID]`. If the supplied condition omits the `name` field,
217  //     then a new `[CONDITION_ID]` is created.
218  google.protobuf.FieldMask update_mask = 2;
219
220  // Required. The updated alerting policy or the updated values for the
221  // fields listed in `update_mask`.
222  // If `update_mask` is not empty, any fields in this policy that are
223  // not in `update_mask` are ignored.
224  AlertPolicy alert_policy = 3 [(google.api.field_behavior) = REQUIRED];
225}
226
227// The protocol for the `DeleteAlertPolicy` request.
228message DeleteAlertPolicyRequest {
229  // Required. The alerting policy to delete. The format is:
230  //
231  //     projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
232  //
233  // For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy].
234  string name = 3 [
235    (google.api.field_behavior) = REQUIRED,
236    (google.api.resource_reference) = {
237      type: "monitoring.googleapis.com/AlertPolicy"
238    }
239  ];
240}
241