feat: Added Snooze API support

PiperOrigin-RevId: 500543032
pull/765/head
Google APIs 2 years ago committed by Copybara-Service
parent 2c7756f622
commit d4864bf142
  1. 130
      google/monitoring/v3/BUILD.bazel
  2. 25
      google/monitoring/v3/monitoring.yaml
  3. 34
      google/monitoring/v3/monitoring_grpc_service_config.json
  4. 78
      google/monitoring/v3/snooze.proto
  5. 210
      google/monitoring/v3/snooze_service.proto

@ -9,44 +9,14 @@
# * extra_protoc_file_parameters
# The complete list of preserved parameters can be found in the source code.
# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])
##############################################################################
# Common
##############################################################################
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"@com_google_googleapis_imports//:imports.bzl",
"cc_grpc_library",
"cc_proto_library",
"csharp_gapic_assembly_pkg",
"csharp_gapic_library",
"csharp_grpc_library",
"csharp_proto_library",
"go_gapic_assembly_pkg",
"go_gapic_library",
"go_proto_library",
"go_test",
"java_gapic_assembly_gradle_pkg",
"java_gapic_library",
"java_gapic_test",
"java_grpc_library",
"java_proto_library",
"nodejs_gapic_assembly_pkg",
"nodejs_gapic_library",
"php_gapic_assembly_pkg",
"php_gapic_library",
"php_grpc_library",
"php_proto_library",
"proto_library_with_info",
"py_gapic_assembly_pkg",
"py_gapic_library",
"ruby_cloud_gapic_library",
"ruby_gapic_assembly_pkg",
"ruby_grpc_library",
"ruby_proto_library",
)
# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")
proto_library(
name = "monitoring_proto",
@ -65,6 +35,8 @@ proto_library(
"query_service.proto",
"service.proto",
"service_service.proto",
"snooze.proto",
"snooze_service.proto",
"span_context.proto",
"uptime.proto",
"uptime_service.proto",
@ -79,13 +51,11 @@ proto_library(
"//google/api:metric_proto",
"//google/api:monitored_resource_proto",
"//google/api:resource_proto",
"//google/longrunning:operations_proto",
"//google/rpc:status_proto",
"//google/type:calendar_period_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
],
@ -99,6 +69,18 @@ proto_library_with_info(
],
)
##############################################################################
# Java
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"java_gapic_assembly_gradle_pkg",
"java_gapic_library",
"java_gapic_test",
"java_grpc_library",
"java_proto_library",
)
java_proto_library(
name = "monitoring_java_proto",
deps = [":monitoring_proto"],
@ -136,6 +118,7 @@ java_gapic_test(
"com.google.cloud.monitoring.v3.NotificationChannelServiceClientTest",
"com.google.cloud.monitoring.v3.QueryServiceClientTest",
"com.google.cloud.monitoring.v3.ServiceMonitoringServiceClientTest",
"com.google.cloud.monitoring.v3.SnoozeServiceClientTest",
"com.google.cloud.monitoring.v3.UptimeCheckServiceClientTest",
],
runtime_deps = [":monitoring_java_gapic_test"],
@ -154,6 +137,17 @@ java_gapic_assembly_gradle_pkg(
],
)
##############################################################################
# Go
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"go_gapic_assembly_pkg",
"go_gapic_library",
"go_proto_library",
"go_test",
)
go_proto_library(
name = "monitoring_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
@ -166,7 +160,6 @@ go_proto_library(
"//google/api:label_go_proto",
"//google/api:metric_go_proto",
"//google/api:monitoredres_go_proto",
"//google/longrunning:longrunning_go_proto",
"//google/rpc:status_go_proto",
"//google/type:calendar_period_go_proto",
],
@ -189,7 +182,6 @@ go_gapic_library(
"@com_google_cloud_go_longrunning//:go_default_library",
"@com_google_cloud_go_longrunning//autogen:go_default_library",
"@io_bazel_rules_go//proto/wkt:duration_go_proto",
"@io_bazel_rules_go//proto/wkt:struct_go_proto",
],
)
@ -211,6 +203,16 @@ go_gapic_assembly_pkg(
],
)
##############################################################################
# Python
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"py_gapic_assembly_pkg",
"py_gapic_library",
"py_test",
)
py_gapic_library(
name = "monitoring_py_gapic",
srcs = [":monitoring_proto"],
@ -239,6 +241,17 @@ py_gapic_assembly_pkg(
],
)
##############################################################################
# PHP
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"php_gapic_assembly_pkg",
"php_gapic_library",
"php_grpc_library",
"php_proto_library",
)
php_proto_library(
name = "monitoring_php_proto",
deps = [":monitoring_proto"],
@ -273,6 +286,15 @@ php_gapic_assembly_pkg(
],
)
##############################################################################
# Node.js
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"nodejs_gapic_assembly_pkg",
"nodejs_gapic_library",
)
nodejs_gapic_library(
name = "monitoring_nodejs_gapic",
package_name = "@google-cloud/monitoring",
@ -295,6 +317,17 @@ nodejs_gapic_assembly_pkg(
],
)
##############################################################################
# Ruby
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"ruby_cloud_gapic_library",
"ruby_gapic_assembly_pkg",
"ruby_grpc_library",
"ruby_proto_library",
)
ruby_proto_library(
name = "monitoring_ruby_proto",
deps = [":monitoring_proto"],
@ -336,6 +369,17 @@ ruby_gapic_assembly_pkg(
],
)
##############################################################################
# C#
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"csharp_gapic_assembly_pkg",
"csharp_gapic_library",
"csharp_grpc_library",
"csharp_proto_library",
)
csharp_proto_library(
name = "monitoring_csharp_proto",
deps = [":monitoring_proto"],
@ -370,6 +414,15 @@ csharp_gapic_assembly_pkg(
],
)
##############################################################################
# C++
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"cc_grpc_library",
"cc_proto_library",
)
cc_proto_library(
name = "monitoring_cc_proto",
deps = [":monitoring_proto"],
@ -378,7 +431,6 @@ cc_proto_library(
cc_grpc_library(
name = "monitoring_cc_grpc",
srcs = [":monitoring_proto"],
generate_mocks = True,
grpc_only = True,
deps = [":monitoring_cc_proto"],
)

@ -10,6 +10,7 @@ apis:
- name: google.monitoring.v3.NotificationChannelService
- name: google.monitoring.v3.QueryService
- name: google.monitoring.v3.ServiceMonitoringService
- name: google.monitoring.v3.SnoozeService
- name: google.monitoring.v3.UptimeCheckService
types:
@ -39,6 +40,8 @@ backend:
deadline: 30.0
- selector: google.monitoring.v3.QueryService.QueryTimeSeries
deadline: 90.0
- selector: 'google.monitoring.v3.SnoozeService.*'
deadline: 30.0
authentication:
rules:
@ -186,6 +189,28 @@ authentication:
https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/monitoring,
https://www.googleapis.com/auth/monitoring.read
- selector: google.monitoring.v3.SnoozeService.CreateSnooze
oauth:
canonical_scopes: |-
https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/monitoring
- selector: google.monitoring.v3.SnoozeService.GetSnooze
oauth:
canonical_scopes: |-
https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/monitoring,
https://www.googleapis.com/auth/monitoring.read
- selector: google.monitoring.v3.SnoozeService.ListSnoozes
oauth:
canonical_scopes: |-
https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/monitoring,
https://www.googleapis.com/auth/monitoring.read
- selector: google.monitoring.v3.SnoozeService.UpdateSnooze
oauth:
canonical_scopes: |-
https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/monitoring
- selector: 'google.monitoring.v3.UptimeCheckService.*'
oauth:
canonical_scopes: |-

@ -321,6 +321,40 @@
}
],
"timeout": "30s"
},
{
"name": [
{
"service": "google.monitoring.v3.SnoozeService",
"method": "GetSnooze"
},
{
"service": "google.monitoring.v3.SnoozeService",
"method": "ListSnoozes"
}
],
"timeout": "30s",
"retryPolicy": {
"maxAttempts": 5,
"initialBackoff": "0.100s",
"maxBackoff": "30s",
"backoffMultiplier": 1.3,
"retryableStatusCodes": [
"UNAVAILABLE"
]
}
},
{
"name": [
{
"service": "google.monitoring.v3.SnoozeService",
"method": "CreateSnooze"
},
{
"service": "google.monitoring.v3.SnoozeService",
"method": "UpdateSnooze"
}
], "timeout": "30s"
}
]
}

@ -0,0 +1,78 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.monitoring.v3;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/monitoring/v3/common.proto";
option csharp_namespace = "Google.Cloud.Monitoring.V3";
option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
option java_multiple_files = true;
option java_outer_classname = "SnoozeProto";
option java_package = "com.google.monitoring.v3";
option php_namespace = "Google\\Cloud\\Monitoring\\V3";
option ruby_package = "Google::Cloud::Monitoring::V3";
// A `Snooze` will prevent any alerts from being opened, and close any that
// are already open. The `Snooze` will work on alerts that match the
// criteria defined in the `Snooze`. The `Snooze` will be active from
// `interval.start_time` through `interval.end_time`.
message Snooze {
option (google.api.resource) = {
type: "monitoring.googleapis.com/Snooze"
pattern: "projects/{project}/snoozes/{snooze}"
};
// Criteria specific to the `AlertPolicy`s that this `Snooze` applies to. The
// `Snooze` will suppress alerts that come from one of the `AlertPolicy`s
// whose names are supplied.
message Criteria {
// The specific `AlertPolicy` names for the alert that should be snoozed.
// The format is:
//
// projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[POLICY_ID]
//
// There is a limit of 10 policies per snooze. This limit is checked during
// snooze creation.
repeated string policies = 1 [(google.api.resource_reference) = {
type: "monitoring.googleapis.com/AlertPolicy"
}];
}
// Required. The name of the `Snooze`. The format is:
//
// projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
//
// The ID of the `Snooze` will be generated by the system.
string name = 1 [(google.api.field_behavior) = REQUIRED];
// Required. This defines the criteria for applying the `Snooze`. See
// `Criteria` for more information.
Criteria criteria = 3 [(google.api.field_behavior) = REQUIRED];
// Required. The `Snooze` will be active from `interval.start_time` through
// `interval.end_time`.
// `interval.start_time` cannot be in the past. There is a 15 second clock
// skew to account for the time it takes for a request to reach the API from
// the UI.
TimeInterval interval = 4 [(google.api.field_behavior) = REQUIRED];
// Required. A display name for the `Snooze`. This can be, at most, 512
// unicode characters.
string display_name = 5 [(google.api.field_behavior) = REQUIRED];
}

@ -0,0 +1,210 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.monitoring.v3;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/monitoring/v3/snooze.proto";
import "google/protobuf/field_mask.proto";
option csharp_namespace = "Google.Cloud.Monitoring.V3";
option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
option java_multiple_files = true;
option java_outer_classname = "SnoozeServiceProto";
option java_package = "com.google.monitoring.v3";
option php_namespace = "Google\\Cloud\\Monitoring\\V3";
option ruby_package = "Google::Cloud::Monitoring::V3";
// The SnoozeService API is used to temporarily prevent an alert policy from
// generating alerts. A Snooze is a description of the criteria under which one
// or more alert policies should not fire alerts for the specified duration.
service SnoozeService {
option (google.api.default_host) = "monitoring.googleapis.com";
option (google.api.oauth_scopes) =
"https://www.googleapis.com/auth/cloud-platform,"
"https://www.googleapis.com/auth/monitoring,"
"https://www.googleapis.com/auth/monitoring.read";
// Creates a `Snooze` that will prevent alerts, which match the provided
// criteria, from being opened. The `Snooze` applies for a specific time
// interval.
rpc CreateSnooze(CreateSnoozeRequest) returns (Snooze) {
option (google.api.http) = {
post: "/v3/{parent=projects/*}/snoozes"
body: "snooze"
};
option (google.api.method_signature) = "parent,snooze";
}
// Lists the `Snooze`s associated with a project. Can optionally pass in
// `filter`, which specifies predicates to match `Snooze`s.
rpc ListSnoozes(ListSnoozesRequest) returns (ListSnoozesResponse) {
option (google.api.http) = {
get: "/v3/{parent=projects/*}/snoozes"
};
option (google.api.method_signature) = "parent";
}
// Retrieves a `Snooze` by `name`.
rpc GetSnooze(GetSnoozeRequest) returns (Snooze) {
option (google.api.http) = {
get: "/v3/{name=projects/*/snoozes/*}"
};
option (google.api.method_signature) = "name";
}
// Updates a `Snooze`, identified by its `name`, with the parameters in the
// given `Snooze` object.
rpc UpdateSnooze(UpdateSnoozeRequest) returns (Snooze) {
option (google.api.http) = {
patch: "/v3/{snooze.name=projects/*/snoozes/*}"
body: "snooze"
};
option (google.api.method_signature) = "snooze,update_mask";
}
}
// The message definition for creating a `Snooze`. Users must provide the body
// of the `Snooze` to be created but must omit the `Snooze` field, `name`.
message CreateSnoozeRequest {
// Required. The
// [project](https://cloud.google.com/monitoring/api/v3#project_name) in which
// a `Snooze` should be created. The format is:
//
// projects/[PROJECT_ID_OR_NUMBER]
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
child_type: "monitoring.googleapis.com/Snooze"
}
];
// Required. The `Snooze` to create. Omit the `name` field, as it will be
// filled in by the API.
Snooze snooze = 2 [(google.api.field_behavior) = REQUIRED];
}
// The message definition for listing `Snooze`s associated with the given
// `parent`, satisfying the optional `filter`.
message ListSnoozesRequest {
// Required. The
// [project](https://cloud.google.com/monitoring/api/v3#project_name) whose
// `Snooze`s should be listed. The format is:
//
// projects/[PROJECT_ID_OR_NUMBER]
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
child_type: "monitoring.googleapis.com/Snooze"
}
];
// Optional. Optional filter to restrict results to the given criteria. The
// following fields are supported.
//
// * `interval.start_time`
// * `interval.end_time`
//
// For example:
//
// ```
// interval.start_time > "2022-03-11T00:00:00-08:00" AND
// interval.end_time < "2022-03-12T00:00:00-08:00"
// ```
string filter = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. The maximum number of results to return for a single query. The
// server may further constrain the maximum number of results returned in a
// single page. The value should be in the range [1, 1000]. If the value given
// is outside this range, the server will decide the number of results to be
// returned.
int32 page_size = 4 [(google.api.field_behavior) = OPTIONAL];
// Optional. The `next_page_token` from a previous call to
// `ListSnoozesRequest` to get the next page of results.
string page_token = 5 [(google.api.field_behavior) = OPTIONAL];
}
// The results of a successful `ListSnoozes` call, containing the matching
// `Snooze`s.
message ListSnoozesResponse {
// `Snooze`s matching this list call.
repeated Snooze snoozes = 1;
// Page token for repeated calls to `ListSnoozes`, to fetch additional pages
// of results. If this is empty or missing, there are no more pages.
string next_page_token = 2;
}
// The message definition for retrieving a `Snooze`. Users must specify the
// field, `name`, which identifies the `Snooze`.
message GetSnoozeRequest {
// Required. The ID of the `Snooze` to retrieve. The format is:
//
// projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "monitoring.googleapis.com/Snooze"
}
];
}
// The message definition for updating a `Snooze`. The field, `snooze.name`
// identifies the `Snooze` to be updated. The remainder of `snooze` gives the
// content the `Snooze` in question will be assigned.
//
// What fields can be updated depends on the start time and end time of the
// `Snooze`.
//
// * end time is in the past: These `Snooze`s are considered
// read-only and cannot be updated.
// * start time is in the past and end time is in the future: `display_name`
// and `interval.end_time` can be updated.
// * start time is in the future: `display_name`, `interval.start_time` and
// `interval.end_time` can be updated.
message UpdateSnoozeRequest {
// Required. The `Snooze` to update. Must have the name field present.
Snooze snooze = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The fields to update.
//
// For each field listed in `update_mask`:
//
// * If the `Snooze` object supplied in the `UpdateSnoozeRequest` has a
// value for that field, the value of the field in the existing `Snooze`
// will be set to the value of the field in the supplied `Snooze`.
// * If the field does not have a value in the supplied `Snooze`, the field
// in the existing `Snooze` is set to its default value.
//
// Fields not listed retain their existing value.
//
// The following are the field names that are accepted in `update_mask`:
//
// * `display_name`
// * `interval.start_time`
// * `interval.end_time`
//
// That said, the start time and end time of the `Snooze` determines which
// fields can legally be updated. Before attempting an update, users should
// consult the documentation for `UpdateSnoozeRequest`, which talks about
// which fields can be updated.
google.protobuf.FieldMask update_mask = 2
[(google.api.field_behavior) = REQUIRED];
}
Loading…
Cancel
Save