From 04f00e96fc4fd4de6bb2c0e300260c55fcfdc020 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 11 Feb 2020 10:51:23 -0800 Subject: [PATCH 1/8] add protos to monitoring/v3, include all protos in unit test --- .../protos/google/monitoring/v3/alert.proto | 360 +++++++++++++ .../google/monitoring/v3/alert_service.proto | 231 +++++++++ .../protos/google/monitoring/v3/common.proto | 475 ++++++++++++++++++ .../google/monitoring/v3/dropped_labels.proto | 45 ++ .../protos/google/monitoring/v3/group.proto | 86 ++++ .../google/monitoring/v3/group_service.proto | 273 ++++++++++ .../protos/google/monitoring/v3/metric.proto | 96 ++++ .../google/monitoring/v3/metric_service.proto | 407 +++++++++++++++ .../monitoring/v3/mutation_record.proto | 36 ++ .../google/monitoring/v3/notification.proto | 183 +++++++ .../monitoring/v3/notification_service.proto | 401 +++++++++++++++ .../testdata/monitoring/proto.list.baseline | 11 +- .../monitoring/v3/service.proto.baseline | 397 +++++++++++++++ .../monitoring/v3/span_context.proto.baseline | 43 ++ .../monitoring/v3/uptime.proto.baseline | 350 +++++++++++++ ...onitoring_service_proto_list.json.baseline | 1 + ...ime_check_service_proto_list.json.baseline | 1 + typescript/test/unit/monitor.ts | 2 +- 18 files changed, 3392 insertions(+), 6 deletions(-) create mode 100644 typescript/test/protos/google/monitoring/v3/alert.proto create mode 100644 typescript/test/protos/google/monitoring/v3/alert_service.proto create mode 100644 typescript/test/protos/google/monitoring/v3/common.proto create mode 100644 typescript/test/protos/google/monitoring/v3/dropped_labels.proto create mode 100644 typescript/test/protos/google/monitoring/v3/group.proto create mode 100644 typescript/test/protos/google/monitoring/v3/group_service.proto create mode 100644 typescript/test/protos/google/monitoring/v3/metric.proto create mode 100644 typescript/test/protos/google/monitoring/v3/metric_service.proto create mode 100644 typescript/test/protos/google/monitoring/v3/mutation_record.proto create mode 100644 typescript/test/protos/google/monitoring/v3/notification.proto create mode 100644 typescript/test/protos/google/monitoring/v3/notification_service.proto create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/service.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/span_context.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/uptime.proto.baseline diff --git a/typescript/test/protos/google/monitoring/v3/alert.proto b/typescript/test/protos/google/monitoring/v3/alert.proto new file mode 100644 index 000000000..d65e00dba --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/alert.proto @@ -0,0 +1,360 @@ +// Copyright 2019 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/resource.proto"; +import "google/monitoring/v3/common.proto"; +import "google/monitoring/v3/mutation_record.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/wrappers.proto"; +import "google/rpc/status.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 = "AlertProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A description of the conditions under which some aspect of your system is +// considered to be "unhealthy" and the ways to notify people or services about +// this state. For an overview of alert policies, see +// [Introduction to Alerting](/monitoring/alerts/). +message AlertPolicy { + option (google.api.resource) = { + type: "monitoring.googleapis.com/AlertPolicy" + pattern: "projects/{project}/alertPolicies/{alert_policy}" + pattern: "organizations/{organization}/alertPolicies/{alert_policy}" + pattern: "folders/{folder}/alertPolicies/{alert_policy}" + pattern: "*" + }; + + // A content string and a MIME type that describes the content string's + // format. + message Documentation { + // The text of the documentation, interpreted according to `mime_type`. + // The content may not exceed 8,192 Unicode characters and may not exceed + // more than 10,240 bytes when encoded in UTF-8 format, whichever is + // smaller. + string content = 1; + + // The format of the `content` field. Presently, only the value + // `"text/markdown"` is supported. See + // [Markdown](https://en.wikipedia.org/wiki/Markdown) for more information. + string mime_type = 2; + } + + // A condition is a true/false test that determines when an alerting policy + // should open an incident. If a condition evaluates to true, it signifies + // that something is wrong. + message Condition { + option (google.api.resource) = { + type: "monitoring.googleapis.com/AlertPolicyCondition" + pattern: "projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}" + pattern: "organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}" + pattern: "folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}" + pattern: "*" + }; + + // Specifies how many time series must fail a predicate to trigger a + // condition. If not specified, then a `{count: 1}` trigger is used. + message Trigger { + // A type of trigger. + oneof type { + // The absolute number of time series that must fail + // the predicate for the condition to be triggered. + int32 count = 1; + + // The percentage of time series that must fail the + // predicate for the condition to be triggered. + double percent = 2; + } + } + + // A condition type that compares a collection of time series + // against a threshold. + message MetricThreshold { + // A [filter](/monitoring/api/v3/filters) that + // identifies which time series should be compared with the threshold. + // + // The filter is similar to the one that is specified in the + // [`ListTimeSeries` + // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that + // call is useful to verify the time series that will be retrieved / + // processed) and must specify the metric type and optionally may contain + // restrictions on resource type, resource labels, and metric labels. + // This field may not exceed 2048 Unicode characters in length. + string filter = 2; + + // Specifies the alignment of data points in individual time series as + // well as how to combine the retrieved time series together (such as + // when aggregating multiple streams on each resource to a single + // stream for each resource or when aggregating streams across all + // members of a group of resrouces). Multiple aggregations + // are applied in the order specified. + // + // This field is similar to the one in the [`ListTimeSeries` + // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It + // is advisable to use the `ListTimeSeries` method when debugging this + // field. + repeated Aggregation aggregations = 8; + + // A [filter](/monitoring/api/v3/filters) that identifies a time + // series that should be used as the denominator of a ratio that will be + // compared with the threshold. If a `denominator_filter` is specified, + // the time series specified by the `filter` field will be used as the + // numerator. + // + // The filter must specify the metric type and optionally may contain + // restrictions on resource type, resource labels, and metric labels. + // This field may not exceed 2048 Unicode characters in length. + string denominator_filter = 9; + + // Specifies the alignment of data points in individual time series + // selected by `denominatorFilter` as + // well as how to combine the retrieved time series together (such as + // when aggregating multiple streams on each resource to a single + // stream for each resource or when aggregating streams across all + // members of a group of resources). + // + // When computing ratios, the `aggregations` and + // `denominator_aggregations` fields must use the same alignment period + // and produce time series that have the same periodicity and labels. + repeated Aggregation denominator_aggregations = 10; + + // The comparison to apply between the time series (indicated by `filter` + // and `aggregation`) and the threshold (indicated by `threshold_value`). + // The comparison is applied on each time series, with the time series + // on the left-hand side and the threshold on the right-hand side. + // + // Only `COMPARISON_LT` and `COMPARISON_GT` are supported currently. + ComparisonType comparison = 4; + + // A value against which to compare the time series. + double threshold_value = 5; + + // The amount of time that a time series must violate the + // threshold to be considered failing. Currently, only values + // that are a multiple of a minute--e.g., 0, 60, 120, or 300 + // seconds--are supported. If an invalid value is given, an + // error will be returned. When choosing a duration, it is useful to + // keep in mind the frequency of the underlying time series data + // (which may also be affected by any alignments specified in the + // `aggregations` field); a good duration is long enough so that a single + // outlier does not generate spurious alerts, but short enough that + // unhealthy states are detected and alerted on quickly. + google.protobuf.Duration duration = 6; + + // The number/percent of time series for which the comparison must hold + // in order for the condition to trigger. If unspecified, then the + // condition will trigger if the comparison is true for any of the + // time series that have been identified by `filter` and `aggregations`, + // or by the ratio, if `denominator_filter` and `denominator_aggregations` + // are specified. + Trigger trigger = 7; + } + + // A condition type that checks that monitored resources + // are reporting data. The configuration defines a metric and + // a set of monitored resources. The predicate is considered in violation + // when a time series for the specified metric of a monitored + // resource does not include any data in the specified `duration`. + message MetricAbsence { + // A [filter](/monitoring/api/v3/filters) that + // identifies which time series should be compared with the threshold. + // + // The filter is similar to the one that is specified in the + // [`ListTimeSeries` + // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that + // call is useful to verify the time series that will be retrieved / + // processed) and must specify the metric type and optionally may contain + // restrictions on resource type, resource labels, and metric labels. + // This field may not exceed 2048 Unicode characters in length. + string filter = 1; + + // Specifies the alignment of data points in individual time series as + // well as how to combine the retrieved time series together (such as + // when aggregating multiple streams on each resource to a single + // stream for each resource or when aggregating streams across all + // members of a group of resrouces). Multiple aggregations + // are applied in the order specified. + // + // This field is similar to the one in the [`ListTimeSeries` + // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It + // is advisable to use the `ListTimeSeries` method when debugging this + // field. + repeated Aggregation aggregations = 5; + + // The amount of time that a time series must fail to report new + // data to be considered failing. Currently, only values that + // are a multiple of a minute--e.g. 60, 120, or 300 + // seconds--are supported. If an invalid value is given, an + // error will be returned. The `Duration.nanos` field is + // ignored. + google.protobuf.Duration duration = 2; + + // The number/percent of time series for which the comparison must hold + // in order for the condition to trigger. If unspecified, then the + // condition will trigger if the comparison is true for any of the + // time series that have been identified by `filter` and `aggregations`. + Trigger trigger = 3; + } + + // Required if the condition exists. The unique resource name for this + // condition. Its syntax is: + // + // projects/[PROJECT_ID]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID] + // + // `[CONDITION_ID]` is assigned by Stackdriver Monitoring when the + // condition is created as part of a new or updated alerting policy. + // + // When calling the + // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy] + // method, do not include the `name` field in the conditions of the + // requested alerting policy. Stackdriver Monitoring creates the + // condition identifiers and includes them in the new policy. + // + // When calling the + // [alertPolicies.update][google.monitoring.v3.AlertPolicyService.UpdateAlertPolicy] + // method to update a policy, including a condition `name` causes the + // existing condition to be updated. Conditions without names are added to + // the updated policy. Existing conditions are deleted if they are not + // updated. + // + // Best practice is to preserve `[CONDITION_ID]` if you make only small + // changes, such as those to condition thresholds, durations, or trigger + // values. Otherwise, treat the change as a new condition and let the + // existing condition be deleted. + string name = 12; + + // A short name or phrase used to identify the condition in dashboards, + // notifications, and incidents. To avoid confusion, don't use the same + // display name for multiple conditions in the same policy. + string display_name = 6; + + // Only one of the following condition types will be specified. + oneof condition { + // A condition that compares a time series against a threshold. + MetricThreshold condition_threshold = 1; + + // A condition that checks that a time series continues to + // receive new data points. + MetricAbsence condition_absent = 2; + } + } + + // Operators for combining conditions. + enum ConditionCombinerType { + // An unspecified combiner. + COMBINE_UNSPECIFIED = 0; + + // Combine conditions using the logical `AND` operator. An + // incident is created only if all conditions are met + // simultaneously. This combiner is satisfied if all conditions are + // met, even if they are met on completely different resources. + AND = 1; + + // Combine conditions using the logical `OR` operator. An incident + // is created if any of the listed conditions is met. + OR = 2; + + // Combine conditions using logical `AND` operator, but unlike the regular + // `AND` option, an incident is created only if all conditions are met + // simultaneously on at least one resource. + AND_WITH_MATCHING_RESOURCE = 3; + } + + // Required if the policy exists. The resource name for this policy. The + // syntax is: + // + // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + // + // `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy + // is created. When calling the + // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy] + // method, do not include the `name` field in the alerting policy passed as + // part of the request. + string name = 1; + + // A short name or phrase used to identify the policy in dashboards, + // notifications, and incidents. To avoid confusion, don't use the same + // display name for multiple policies in the same project. The name is + // limited to 512 Unicode characters. + string display_name = 2; + + // Documentation that is included with notifications and incidents related to + // this policy. Best practice is for the documentation to include information + // to help responders understand, mitigate, escalate, and correct the + // underlying problems detected by the alerting policy. Notification channels + // that have limited capacity might not show this documentation. + Documentation documentation = 13; + + // User-supplied key/value data to be used for organizing and + // identifying the `AlertPolicy` objects. + // + // The field can contain up to 64 entries. Each key and value is limited to + // 63 Unicode characters or 128 bytes, whichever is smaller. Labels and + // values can contain only lowercase letters, numerals, underscores, and + // dashes. Keys must begin with a letter. + map user_labels = 16; + + // A list of conditions for the policy. The conditions are combined by AND or + // OR according to the `combiner` field. If the combined conditions evaluate + // to true, then an incident is created. A policy can have from one to six + // conditions. + // If |condition_time_series_uery_language| is present, it must be the only + // |condition|. + repeated Condition conditions = 12; + + // How to combine the results of multiple conditions to determine if an + // incident should be opened. + // If condition_time_series_query_language is present, this must be + // COMBINE_UNSPECIFIED. + ConditionCombinerType combiner = 6; + + // Whether or not the policy is enabled. On write, the default interpretation + // if unset is that the policy is enabled. On read, clients should not make + // any assumption about the state if it has not been populated. The + // field should always be populated on List and Get operations, unless + // a field projection has been specified that strips it out. + google.protobuf.BoolValue enabled = 17; + + // Read-only description of how the alert policy is invalid. OK if the alert + // policy is valid. If not OK, the alert policy will not generate incidents. + google.rpc.Status validity = 18; + + // Identifies the notification channels to which notifications should be sent + // when incidents are opened or closed or when new violations occur on + // an already opened incident. Each element of this array corresponds to + // the `name` field in each of the + // [`NotificationChannel`][google.monitoring.v3.NotificationChannel] + // objects that are returned from the [`ListNotificationChannels`] + // [google.monitoring.v3.NotificationChannelService.ListNotificationChannels] + // method. The syntax of the entries in this field is: + // + // projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID] + repeated string notification_channels = 14; + + // A read-only record of the creation of the alerting policy. If provided + // in a call to create or update, this field will be ignored. + MutationRecord creation_record = 10; + + // A read-only record of the most recent change to the alerting policy. If + // provided in a call to create or update, this field will be ignored. + MutationRecord mutation_record = 11; +} diff --git a/typescript/test/protos/google/monitoring/v3/alert_service.proto b/typescript/test/protos/google/monitoring/v3/alert_service.proto new file mode 100644 index 000000000..a88c376f5 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/alert_service.proto @@ -0,0 +1,231 @@ +// Copyright 2019 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/alert.proto"; +import "google/protobuf/empty.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 = "AlertServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The AlertPolicyService API is used to manage (list, create, delete, +// edit) alert policies in Stackdriver Monitoring. An alerting policy is +// a description of the conditions under which some aspect of your +// system is considered to be "unhealthy" and the ways to notify +// people or services about this state. In addition to using this API, alert +// policies can also be managed through +// [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), +// which can be reached by clicking the "Monitoring" tab in +// [Cloud Console](https://console.cloud.google.com/). +service AlertPolicyService { + 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"; + + // Lists the existing alerting policies for the project. + rpc ListAlertPolicies(ListAlertPoliciesRequest) returns (ListAlertPoliciesResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/alertPolicies" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single alerting policy. + rpc GetAlertPolicy(GetAlertPolicyRequest) returns (AlertPolicy) { + option (google.api.http) = { + get: "/v3/{name=projects/*/alertPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new alerting policy. + rpc CreateAlertPolicy(CreateAlertPolicyRequest) returns (AlertPolicy) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/alertPolicies" + body: "alert_policy" + }; + option (google.api.method_signature) = "name,alert_policy"; + } + + // Deletes an alerting policy. + rpc DeleteAlertPolicy(DeleteAlertPolicyRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/alertPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates an alerting policy. You can either replace the entire policy with + // a new one or replace only certain fields in the current alerting policy by + // specifying the fields to be updated via `updateMask`. Returns the + // updated alerting policy. + rpc UpdateAlertPolicy(UpdateAlertPolicyRequest) returns (AlertPolicy) { + option (google.api.http) = { + patch: "/v3/{alert_policy.name=projects/*/alertPolicies/*}" + body: "alert_policy" + }; + option (google.api.method_signature) = "update_mask,alert_policy"; + } +} + +// The protocol for the `CreateAlertPolicy` request. +message CreateAlertPolicyRequest { + // Required. The project in which to create the alerting policy. The format is + // `projects/[PROJECT_ID]`. + // + // Note that this field names the parent container in which the alerting + // policy will be written, not the name of the created policy. The alerting + // policy that is returned will have a name that contains a normalized + // representation of this name as a prefix but adds a suffix of the form + // `/alertPolicies/[POLICY_ID]`, identifying the policy in the container. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/AlertPolicy" + } + ]; + + // Required. The requested alerting policy. You should omit the `name` field in this + // policy. The name will be returned in the new policy, including + // a new [ALERT_POLICY_ID] value. + AlertPolicy alert_policy = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The protocol for the `GetAlertPolicy` request. +message GetAlertPolicyRequest { + // Required. The alerting policy to retrieve. The format is + // + // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/AlertPolicy" + } + ]; +} + +// The protocol for the `ListAlertPolicies` request. +message ListAlertPoliciesRequest { + // Required. The project whose alert policies are to be listed. The format is + // + // projects/[PROJECT_ID] + // + // Note that this field names the parent container in which the alerting + // policies to be listed are stored. To retrieve a single alerting policy + // by name, use the + // [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy] + // operation, instead. + string name = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/AlertPolicy" + } + ]; + + // If provided, this field specifies the criteria that must be met by + // alert policies to be included in the response. + // + // For more details, see [sorting and + // filtering](/monitoring/api/v3/sorting-and-filtering). + string filter = 5; + + // A comma-separated list of fields by which to sort the result. Supports + // the same set of field references as the `filter` field. Entries can be + // prefixed with a minus sign to sort by the field in descending order. + // + // For more details, see [sorting and + // filtering](/monitoring/api/v3/sorting-and-filtering). + string order_by = 6; + + // The maximum number of results to return in a single response. + int32 page_size = 2; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return more results from the previous method call. + string page_token = 3; +} + +// The protocol for the `ListAlertPolicies` response. +message ListAlertPoliciesResponse { + // The returned alert policies. + repeated AlertPolicy alert_policies = 3; + + // If there might be more results than were returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The protocol for the `UpdateAlertPolicy` request. +message UpdateAlertPolicyRequest { + // Optional. A list of alerting policy field names. If this field is not + // empty, each listed field in the existing alerting policy is set to the + // value of the corresponding field in the supplied policy (`alert_policy`), + // or to the field's default value if the field is not in the supplied + // alerting policy. Fields not listed retain their previous value. + // + // Examples of valid field masks include `display_name`, `documentation`, + // `documentation.content`, `documentation.mime_type`, `user_labels`, + // `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc. + // + // If this field is empty, then the supplied alerting policy replaces the + // existing policy. It is the same as deleting the existing policy and + // adding the supplied policy, except for the following: + // + // + The new policy will have the same `[ALERT_POLICY_ID]` as the former + // policy. This gives you continuity with the former policy in your + // notifications and incidents. + // + Conditions in the new policy will keep their former `[CONDITION_ID]` if + // the supplied condition includes the `name` field with that + // `[CONDITION_ID]`. If the supplied condition omits the `name` field, + // then a new `[CONDITION_ID]` is created. + google.protobuf.FieldMask update_mask = 2; + + // Required. The updated alerting policy or the updated values for the + // fields listed in `update_mask`. + // If `update_mask` is not empty, any fields in this policy that are + // not in `update_mask` are ignored. + AlertPolicy alert_policy = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The protocol for the `DeleteAlertPolicy` request. +message DeleteAlertPolicyRequest { + // Required. The alerting policy to delete. The format is: + // + // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + // + // For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/AlertPolicy" + } + ]; +} diff --git a/typescript/test/protos/google/monitoring/v3/common.proto b/typescript/test/protos/google/monitoring/v3/common.proto new file mode 100644 index 000000000..a4093b1c3 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/common.proto @@ -0,0 +1,475 @@ +// Copyright 2019 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/distribution.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.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 = "CommonProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A single strongly-typed value. +message TypedValue { + // The typed value field. + oneof value { + // A Boolean value: `true` or `false`. + bool bool_value = 1; + + // A 64-bit integer. Its range is approximately ±9.2x1018. + int64 int64_value = 2; + + // A 64-bit double-precision floating-point number. Its magnitude + // is approximately ±10±300 and it has 16 + // significant digits of precision. + double double_value = 3; + + // A variable-length string value. + string string_value = 4; + + // A distribution value. + google.api.Distribution distribution_value = 5; + } +} + +// A closed time interval. It extends from the start time to the end time, and includes both: `[startTime, endTime]`. Valid time intervals depend on the [`MetricKind`](/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricKind) of the metric value. In no case can the end time be earlier than the start time. +// +// * For a `GAUGE` metric, the `startTime` value is technically optional; if +// no value is specified, the start time defaults to the value of the +// end time, and the interval represents a single point in time. If both +// start and end times are specified, they must be identical. Such an +// interval is valid only for `GAUGE` metrics, which are point-in-time +// measurements. +// +// * For `DELTA` and `CUMULATIVE` metrics, the start time must be earlier +// than the end time. +// +// * In all cases, the start time of the next interval must be +// at least a microsecond after the end time of the previous interval. +// Because the interval is closed, if the start time of a new interval +// is the same as the end time of the previous interval, data written +// at the new start time could overwrite data written at the previous +// end time. +message TimeInterval { + // Required. The end of the time interval. + google.protobuf.Timestamp end_time = 2; + + // Optional. The beginning of the time interval. The default value + // for the start time is the end time. The start time must not be + // later than the end time. + google.protobuf.Timestamp start_time = 1; +} + +// Describes how to combine multiple time series to provide a different view of +// the data. Aggregation of time series is done in two steps. First, each time +// series in the set is _aligned_ to the same time interval boundaries, then the +// set of time series is optionally _reduced_ in number. +// +// Alignment consists of applying the `per_series_aligner` operation +// to each time series after its data has been divided into regular +// `alignment_period` time intervals. This process takes _all_ of the data +// points in an alignment period, applies a mathematical transformation such as +// averaging, minimum, maximum, delta, etc., and converts them into a single +// data point per period. +// +// Reduction is when the aligned and transformed time series can optionally be +// combined, reducing the number of time series through similar mathematical +// transformations. Reduction involves applying a `cross_series_reducer` to +// all the time series, optionally sorting the time series into subsets with +// `group_by_fields`, and applying the reducer to each subset. +// +// The raw time series data can contain a huge amount of information from +// multiple sources. Alignment and reduction transforms this mass of data into +// a more manageable and representative collection of data, for example "the +// 95% latency across the average of all tasks in a cluster". This +// representative data can be more easily graphed and comprehended, and the +// individual time series data is still available for later drilldown. For more +// details, see [Aggregating Time +// Series](/monitoring/api/v3/metrics#aggregating_time_series). +message Aggregation { + // The `Aligner` specifies the operation that will be applied to the data + // points in each alignment period in a time series. Except for + // `ALIGN_NONE`, which specifies that no operation be applied, each alignment + // operation replaces the set of data values in each alignment period with + // a single value: the result of applying the operation to the data values. + // An aligned time series has a single data value at the end of each + // `alignment_period`. + // + // An alignment operation can change the data type of the values, too. For + // example, if you apply a counting operation to boolean values, the data + // `value_type` in the original time series is `BOOLEAN`, but the `value_type` + // in the aligned result is `INT64`. + enum Aligner { + // No alignment. Raw data is returned. Not valid if cross-series reduction + // is requested. The `value_type` of the result is the same as the + // `value_type` of the input. + ALIGN_NONE = 0; + + // Align and convert to + // [DELTA][google.api.MetricDescriptor.MetricKind.DELTA]. + // The output is `delta = y1 - y0`. + // + // This alignment is valid for + // [CUMULATIVE][google.api.MetricDescriptor.MetricKind.CUMULATIVE] and + // `DELTA` metrics. If the selected alignment period results in periods + // with no data, then the aligned value for such a period is created by + // interpolation. The `value_type` of the aligned result is the same as + // the `value_type` of the input. + ALIGN_DELTA = 1; + + // Align and convert to a rate. The result is computed as + // `rate = (y1 - y0)/(t1 - t0)`, or "delta over time". + // Think of this aligner as providing the slope of the line that passes + // through the value at the start and at the end of the `alignment_period`. + // + // This aligner is valid for `CUMULATIVE` + // and `DELTA` metrics with numeric values. If the selected alignment + // period results in periods with no data, then the aligned value for + // such a period is created by interpolation. The output is a `GAUGE` + // metric with `value_type` `DOUBLE`. + // + // If, by "rate", you mean "percentage change", see the + // `ALIGN_PERCENT_CHANGE` aligner instead. + ALIGN_RATE = 2; + + // Align by interpolating between adjacent points around the alignment + // period boundary. This aligner is valid for `GAUGE` metrics with + // numeric values. The `value_type` of the aligned result is the same as the + // `value_type` of the input. + ALIGN_INTERPOLATE = 3; + + // Align by moving the most recent data point before the end of the + // alignment period to the boundary at the end of the alignment + // period. This aligner is valid for `GAUGE` metrics. The `value_type` of + // the aligned result is the same as the `value_type` of the input. + ALIGN_NEXT_OLDER = 4; + + // Align the time series by returning the minimum value in each alignment + // period. This aligner is valid for `GAUGE` and `DELTA` metrics with + // numeric values. The `value_type` of the aligned result is the same as + // the `value_type` of the input. + ALIGN_MIN = 10; + + // Align the time series by returning the maximum value in each alignment + // period. This aligner is valid for `GAUGE` and `DELTA` metrics with + // numeric values. The `value_type` of the aligned result is the same as + // the `value_type` of the input. + ALIGN_MAX = 11; + + // Align the time series by returning the mean value in each alignment + // period. This aligner is valid for `GAUGE` and `DELTA` metrics with + // numeric values. The `value_type` of the aligned result is `DOUBLE`. + ALIGN_MEAN = 12; + + // Align the time series by returning the number of values in each alignment + // period. This aligner is valid for `GAUGE` and `DELTA` metrics with + // numeric or Boolean values. The `value_type` of the aligned result is + // `INT64`. + ALIGN_COUNT = 13; + + // Align the time series by returning the sum of the values in each + // alignment period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with numeric and distribution values. The `value_type` of the + // aligned result is the same as the `value_type` of the input. + ALIGN_SUM = 14; + + // Align the time series by returning the standard deviation of the values + // in each alignment period. This aligner is valid for `GAUGE` and + // `DELTA` metrics with numeric values. The `value_type` of the output is + // `DOUBLE`. + ALIGN_STDDEV = 15; + + // Align the time series by returning the number of `True` values in + // each alignment period. This aligner is valid for `GAUGE` metrics with + // Boolean values. The `value_type` of the output is `INT64`. + ALIGN_COUNT_TRUE = 16; + + // Align the time series by returning the number of `False` values in + // each alignment period. This aligner is valid for `GAUGE` metrics with + // Boolean values. The `value_type` of the output is `INT64`. + ALIGN_COUNT_FALSE = 24; + + // Align the time series by returning the ratio of the number of `True` + // values to the total number of values in each alignment period. This + // aligner is valid for `GAUGE` metrics with Boolean values. The output + // value is in the range [0.0, 1.0] and has `value_type` `DOUBLE`. + ALIGN_FRACTION_TRUE = 17; + + // Align the time series by using [percentile + // aggregation](https://en.wikipedia.org/wiki/Percentile). The resulting + // data point in each alignment period is the 99th percentile of all data + // points in the period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with distribution values. The output is a `GAUGE` metric with + // `value_type` `DOUBLE`. + ALIGN_PERCENTILE_99 = 18; + + // Align the time series by using [percentile + // aggregation](https://en.wikipedia.org/wiki/Percentile). The resulting + // data point in each alignment period is the 95th percentile of all data + // points in the period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with distribution values. The output is a `GAUGE` metric with + // `value_type` `DOUBLE`. + ALIGN_PERCENTILE_95 = 19; + + // Align the time series by using [percentile + // aggregation](https://en.wikipedia.org/wiki/Percentile). The resulting + // data point in each alignment period is the 50th percentile of all data + // points in the period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with distribution values. The output is a `GAUGE` metric with + // `value_type` `DOUBLE`. + ALIGN_PERCENTILE_50 = 20; + + // Align the time series by using [percentile + // aggregation](https://en.wikipedia.org/wiki/Percentile). The resulting + // data point in each alignment period is the 5th percentile of all data + // points in the period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with distribution values. The output is a `GAUGE` metric with + // `value_type` `DOUBLE`. + ALIGN_PERCENTILE_05 = 21; + + // Align and convert to a percentage change. This aligner is valid for + // `GAUGE` and `DELTA` metrics with numeric values. This alignment returns + // `((current - previous)/previous) * 100`, where the value of `previous` is + // determined based on the `alignment_period`. + // + // If the values of `current` and `previous` are both 0, then the returned + // value is 0. If only `previous` is 0, the returned value is infinity. + // + // A 10-minute moving mean is computed at each point of the alignment period + // prior to the above calculation to smooth the metric and prevent false + // positives from very short-lived spikes. The moving mean is only + // applicable for data whose values are `>= 0`. Any values `< 0` are + // treated as a missing datapoint, and are ignored. While `DELTA` + // metrics are accepted by this alignment, special care should be taken that + // the values for the metric will always be positive. The output is a + // `GAUGE` metric with `value_type` `DOUBLE`. + ALIGN_PERCENT_CHANGE = 23; + } + + // A Reducer operation describes how to aggregate data points from multiple + // time series into a single time series, where the value of each data point + // in the resulting series is a function of all the already aligned values in + // the input time series. + enum Reducer { + // No cross-time series reduction. The output of the `Aligner` is + // returned. + REDUCE_NONE = 0; + + // Reduce by computing the mean value across time series for each + // alignment period. This reducer is valid for + // [DELTA][google.api.MetricDescriptor.MetricKind.DELTA] and + // [GAUGE][google.api.MetricDescriptor.MetricKind.GAUGE] metrics with + // numeric or distribution values. The `value_type` of the output is + // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE]. + REDUCE_MEAN = 1; + + // Reduce by computing the minimum value across time series for each + // alignment period. This reducer is valid for `DELTA` and `GAUGE` metrics + // with numeric values. The `value_type` of the output is the same as the + // `value_type` of the input. + REDUCE_MIN = 2; + + // Reduce by computing the maximum value across time series for each + // alignment period. This reducer is valid for `DELTA` and `GAUGE` metrics + // with numeric values. The `value_type` of the output is the same as the + // `value_type` of the input. + REDUCE_MAX = 3; + + // Reduce by computing the sum across time series for each + // alignment period. This reducer is valid for `DELTA` and `GAUGE` metrics + // with numeric and distribution values. The `value_type` of the output is + // the same as the `value_type` of the input. + REDUCE_SUM = 4; + + // Reduce by computing the standard deviation across time series + // for each alignment period. This reducer is valid for `DELTA` and + // `GAUGE` metrics with numeric or distribution values. The `value_type` + // of the output is `DOUBLE`. + REDUCE_STDDEV = 5; + + // Reduce by computing the number of data points across time series + // for each alignment period. This reducer is valid for `DELTA` and + // `GAUGE` metrics of numeric, Boolean, distribution, and string + // `value_type`. The `value_type` of the output is `INT64`. + REDUCE_COUNT = 6; + + // Reduce by computing the number of `True`-valued data points across time + // series for each alignment period. This reducer is valid for `DELTA` and + // `GAUGE` metrics of Boolean `value_type`. The `value_type` of the output + // is `INT64`. + REDUCE_COUNT_TRUE = 7; + + // Reduce by computing the number of `False`-valued data points across time + // series for each alignment period. This reducer is valid for `DELTA` and + // `GAUGE` metrics of Boolean `value_type`. The `value_type` of the output + // is `INT64`. + REDUCE_COUNT_FALSE = 15; + + // Reduce by computing the ratio of the number of `True`-valued data points + // to the total number of data points for each alignment period. This + // reducer is valid for `DELTA` and `GAUGE` metrics of Boolean `value_type`. + // The output value is in the range [0.0, 1.0] and has `value_type` + // `DOUBLE`. + REDUCE_FRACTION_TRUE = 8; + + // Reduce by computing the [99th + // percentile](https://en.wikipedia.org/wiki/Percentile) of data points + // across time series for each alignment period. This reducer is valid for + // `GAUGE` and `DELTA` metrics of numeric and distribution type. The value + // of the output is `DOUBLE`. + REDUCE_PERCENTILE_99 = 9; + + // Reduce by computing the [95th + // percentile](https://en.wikipedia.org/wiki/Percentile) of data points + // across time series for each alignment period. This reducer is valid for + // `GAUGE` and `DELTA` metrics of numeric and distribution type. The value + // of the output is `DOUBLE`. + REDUCE_PERCENTILE_95 = 10; + + // Reduce by computing the [50th + // percentile](https://en.wikipedia.org/wiki/Percentile) of data points + // across time series for each alignment period. This reducer is valid for + // `GAUGE` and `DELTA` metrics of numeric and distribution type. The value + // of the output is `DOUBLE`. + REDUCE_PERCENTILE_50 = 11; + + // Reduce by computing the [5th + // percentile](https://en.wikipedia.org/wiki/Percentile) of data points + // across time series for each alignment period. This reducer is valid for + // `GAUGE` and `DELTA` metrics of numeric and distribution type. The value + // of the output is `DOUBLE`. + REDUCE_PERCENTILE_05 = 12; + } + + // The `alignment_period` specifies a time interval, in seconds, that is used + // to divide the data in all the + // [time series][google.monitoring.v3.TimeSeries] into consistent blocks of + // time. This will be done before the per-series aligner can be applied to + // the data. + // + // The value must be at least 60 seconds. If a per-series aligner other than + // `ALIGN_NONE` is specified, this field is required or an error is returned. + // If no per-series aligner is specified, or the aligner `ALIGN_NONE` is + // specified, then this field is ignored. + google.protobuf.Duration alignment_period = 1; + + // An `Aligner` describes how to bring the data points in a single + // time series into temporal alignment. Except for `ALIGN_NONE`, all + // alignments cause all the data points in an `alignment_period` to be + // mathematically grouped together, resulting in a single data point for + // each `alignment_period` with end timestamp at the end of the period. + // + // Not all alignment operations may be applied to all time series. The valid + // choices depend on the `metric_kind` and `value_type` of the original time + // series. Alignment can change the `metric_kind` or the `value_type` of + // the time series. + // + // Time series data must be aligned in order to perform cross-time + // series reduction. If `cross_series_reducer` is specified, then + // `per_series_aligner` must be specified and not equal to `ALIGN_NONE` + // and `alignment_period` must be specified; otherwise, an error is + // returned. + Aligner per_series_aligner = 2; + + // The reduction operation to be used to combine time series into a single + // time series, where the value of each data point in the resulting series is + // a function of all the already aligned values in the input time series. + // + // Not all reducer operations can be applied to all time series. The valid + // choices depend on the `metric_kind` and the `value_type` of the original + // time series. Reduction can yield a time series with a different + // `metric_kind` or `value_type` than the input time series. + // + // Time series data must first be aligned (see `per_series_aligner`) in order + // to perform cross-time series reduction. If `cross_series_reducer` is + // specified, then `per_series_aligner` must be specified, and must not be + // `ALIGN_NONE`. An `alignment_period` must also be specified; otherwise, an + // error is returned. + Reducer cross_series_reducer = 4; + + // The set of fields to preserve when `cross_series_reducer` is + // specified. The `group_by_fields` determine how the time series are + // partitioned into subsets prior to applying the aggregation + // operation. Each subset contains time series that have the same + // value for each of the grouping fields. Each individual time + // series is a member of exactly one subset. The + // `cross_series_reducer` is applied to each subset of time series. + // It is not possible to reduce across different resource types, so + // this field implicitly contains `resource.type`. Fields not + // specified in `group_by_fields` are aggregated away. If + // `group_by_fields` is not specified and all the time series have + // the same resource type, then the time series are aggregated into + // a single output time series. If `cross_series_reducer` is not + // defined, this field is ignored. + repeated string group_by_fields = 5; +} + +// Specifies an ordering relationship on two arguments, called `left` and +// `right`. +enum ComparisonType { + // No ordering relationship is specified. + COMPARISON_UNSPECIFIED = 0; + + // True if the left argument is greater than the right argument. + COMPARISON_GT = 1; + + // True if the left argument is greater than or equal to the right argument. + COMPARISON_GE = 2; + + // True if the left argument is less than the right argument. + COMPARISON_LT = 3; + + // True if the left argument is less than or equal to the right argument. + COMPARISON_LE = 4; + + // True if the left argument is equal to the right argument. + COMPARISON_EQ = 5; + + // True if the left argument is not equal to the right argument. + COMPARISON_NE = 6; +} + +// The tier of service for a Workspace. Please see the +// [service tiers +// documentation](https://cloud.google.com/monitoring/workspaces/tiers) for more +// details. +enum ServiceTier { + option deprecated = true; + + // An invalid sentinel value, used to indicate that a tier has not + // been provided explicitly. + SERVICE_TIER_UNSPECIFIED = 0; + + // The Stackdriver Basic tier, a free tier of service that provides basic + // features, a moderate allotment of logs, and access to built-in metrics. + // A number of features are not available in this tier. For more details, + // see [the service tiers + // documentation](https://cloud.google.com/monitoring/workspaces/tiers). + SERVICE_TIER_BASIC = 1; + + // The Stackdriver Premium tier, a higher, more expensive tier of service + // that provides access to all Stackdriver features, lets you use Stackdriver + // with AWS accounts, and has a larger allotments for logs and metrics. For + // more details, see [the service tiers + // documentation](https://cloud.google.com/monitoring/workspaces/tiers). + SERVICE_TIER_PREMIUM = 2; +} diff --git a/typescript/test/protos/google/monitoring/v3/dropped_labels.proto b/typescript/test/protos/google/monitoring/v3/dropped_labels.proto new file mode 100644 index 000000000..9b943ccd0 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/dropped_labels.proto @@ -0,0 +1,45 @@ +// Copyright 2019 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; + +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 = "DroppedLabelsProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A set of (label, value) pairs which were dropped during aggregation, attached +// to google.api.Distribution.Exemplars in google.api.Distribution values during +// aggregation. +// +// These values are used in combination with the label values that remain on the +// aggregated Distribution timeseries to construct the full label set for the +// exemplar values. The resulting full label set may be used to identify the +// specific task/job/instance (for example) which may be contributing to a +// long-tail, while allowing the storage savings of only storing aggregated +// distribution values for a large group. +// +// Note that there are no guarantees on ordering of the labels from +// exemplar-to-exemplar and from distribution-to-distribution in the same +// stream, and there may be duplicates. It is up to clients to resolve any +// ambiguities. +message DroppedLabels { + // Map from label to its value, for all labels dropped in any aggregation. + map label = 1; +} diff --git a/typescript/test/protos/google/monitoring/v3/group.proto b/typescript/test/protos/google/monitoring/v3/group.proto new file mode 100644 index 000000000..c6428071f --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/group.proto @@ -0,0 +1,86 @@ +// Copyright 2019 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/resource.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 = "GroupProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The description of a dynamic collection of monitored resources. Each group +// has a filter that is matched against monitored resources and their associated +// metadata. If a group's filter matches an available monitored resource, then +// that resource is a member of that group. Groups can contain any number of +// monitored resources, and each monitored resource can be a member of any +// number of groups. +// +// Groups can be nested in parent-child hierarchies. The `parentName` field +// identifies an optional parent for each group. If a group has a parent, then +// the only monitored resources available to be matched by the group's filter +// are the resources contained in the parent group. In other words, a group +// contains the monitored resources that match its filter and the filters of all +// the group's ancestors. A group without a parent can contain any monitored +// resource. +// +// For example, consider an infrastructure running a set of instances with two +// user-defined tags: `"environment"` and `"role"`. A parent group has a filter, +// `environment="production"`. A child of that parent group has a filter, +// `role="transcoder"`. The parent group contains all instances in the +// production environment, regardless of their roles. The child group contains +// instances that have the transcoder role *and* are in the production +// environment. +// +// The monitored resources contained in a group can change at any moment, +// depending on what resources exist and what filters are associated with the +// group and its ancestors. +message Group { + option (google.api.resource) = { + type: "monitoring.googleapis.com/Group" + pattern: "projects/{project}/groups/{group}" + pattern: "organizations/{organization}/groups/{group}" + pattern: "folders/{folder}/groups/{group}" + pattern: "*" + }; + + // Output only. The name of this group. The format is + // `"projects/{project_id_or_number}/groups/{group_id}"`. + // When creating a group, this field is ignored and a new name is created + // consisting of the project specified in the call to `CreateGroup` + // and a unique `{group_id}` that is generated automatically. + string name = 1; + + // A user-assigned name for this group, used only for display purposes. + string display_name = 2; + + // The name of the group's parent, if it has one. + // The format is `"projects/{project_id_or_number}/groups/{group_id}"`. + // For groups with no parent, `parentName` is the empty string, `""`. + string parent_name = 3; + + // The filter used to determine which monitored resources belong to this + // group. + string filter = 5; + + // If true, the members of this group are considered to be a cluster. + // The system can perform additional analysis on groups that are clusters. + bool is_cluster = 6; +} diff --git a/typescript/test/protos/google/monitoring/v3/group_service.proto b/typescript/test/protos/google/monitoring/v3/group_service.proto new file mode 100644 index 000000000..5647dcfbf --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/group_service.proto @@ -0,0 +1,273 @@ +// Copyright 2019 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/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/monitoring/v3/common.proto"; +import "google/monitoring/v3/group.proto"; +import "google/protobuf/empty.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 = "GroupServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The Group API lets you inspect and manage your +// [groups](#google.monitoring.v3.Group). +// +// A group is a named filter that is used to identify +// a collection of monitored resources. Groups are typically used to +// mirror the physical and/or logical topology of the environment. +// Because group membership is computed dynamically, monitored +// resources that are started in the future are automatically placed +// in matching groups. By using a group to name monitored resources in, +// for example, an alert policy, the target of that alert policy is +// updated automatically as monitored resources are added and removed +// from the infrastructure. +service GroupService { + 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"; + + // Lists the existing groups. + rpc ListGroups(ListGroupsRequest) returns (ListGroupsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/groups" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single group. + rpc GetGroup(GetGroupRequest) returns (Group) { + option (google.api.http) = { + get: "/v3/{name=projects/*/groups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new group. + rpc CreateGroup(CreateGroupRequest) returns (Group) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/groups" + body: "group" + }; + option (google.api.method_signature) = "name,group"; + } + + // Updates an existing group. + // You can change any group attributes except `name`. + rpc UpdateGroup(UpdateGroupRequest) returns (Group) { + option (google.api.http) = { + put: "/v3/{group.name=projects/*/groups/*}" + body: "group" + }; + option (google.api.method_signature) = "group"; + } + + // Deletes an existing group. + rpc DeleteGroup(DeleteGroupRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/groups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the monitored resources that are members of a group. + rpc ListGroupMembers(ListGroupMembersRequest) returns (ListGroupMembersResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*/groups/*}/members" + }; + option (google.api.method_signature) = "name"; + } +} + +// The `ListGroup` request. +message ListGroupsRequest { + // Required. The project whose groups are to be listed. The format is + // `"projects/{project_id_or_number}"`. + string name = 7 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/Group" + } + ]; + + // An optional filter consisting of a single group name. The filters limit + // the groups returned based on their parent-child relationship with the + // specified group. If no filter is specified, all groups are returned. + oneof filter { + // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + // Returns groups whose `parentName` field contains the group + // name. If no groups have this parent, the results are empty. + string children_of_group = 2 [(google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + }]; + + // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + // Returns groups that are ancestors of the specified group. + // The groups are returned in order, starting with the immediate parent and + // ending with the most distant ancestor. If the specified group has no + // immediate parent, the results are empty. + string ancestors_of_group = 3 [(google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + }]; + + // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + // Returns the descendants of the specified group. This is a superset of + // the results returned by the `childrenOfGroup` filter, and includes + // children-of-children, and so forth. + string descendants_of_group = 4 [(google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + }]; + } + + // A positive number that is the maximum number of results to return. + int32 page_size = 5; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 6; +} + +// The `ListGroups` response. +message ListGroupsResponse { + // The groups that match the specified filters. + repeated Group group = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The `GetGroup` request. +message GetGroupRequest { + // Required. The group to retrieve. The format is + // `"projects/{project_id_or_number}/groups/{group_id}"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + } + ]; +} + +// The `CreateGroup` request. +message CreateGroupRequest { + // Required. The project in which to create the group. The format is + // `"projects/{project_id_or_number}"`. + string name = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/Group" + } + ]; + + // Required. A group definition. It is an error to define the `name` field because + // the system assigns the name. + Group group = 2 [(google.api.field_behavior) = REQUIRED]; + + // If true, validate this request but do not create the group. + bool validate_only = 3; +} + +// The `UpdateGroup` request. +message UpdateGroupRequest { + // Required. The new definition of the group. All fields of the existing group, + // excepting `name`, are replaced with the corresponding fields of this group. + Group group = 2 [(google.api.field_behavior) = REQUIRED]; + + // If true, validate this request but do not update the existing group. + bool validate_only = 3; +} + +// The `DeleteGroup` request. The default behavior is to be able to delete a +// single group without any descendants. +message DeleteGroupRequest { + // Required. The group to delete. The format is + // `"projects/{project_id_or_number}/groups/{group_id}"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + } + ]; + + // If this field is true, then the request means to delete a group with all + // its descendants. Otherwise, the request means to delete a group only when + // it has no descendants. The default value is false. + bool recursive = 4; +} + +// The `ListGroupMembers` request. +message ListGroupMembersRequest { + // Required. The group whose members are listed. The format is + // `"projects/{project_id_or_number}/groups/{group_id}"`. + string name = 7 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + } + ]; + + // A positive number that is the maximum number of results to return. + int32 page_size = 3; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 4; + + // An optional [list filter](/monitoring/api/learn_more#filtering) describing + // the members to be returned. The filter may reference the type, labels, and + // metadata of monitored resources that comprise the group. + // For example, to return only resources representing Compute Engine VM + // instances, use this filter: + // + // resource.type = "gce_instance" + string filter = 5; + + // An optional time interval for which results should be returned. Only + // members that were part of the group during the specified interval are + // included in the response. If no interval is provided then the group + // membership over the last minute is returned. + TimeInterval interval = 6; +} + +// The `ListGroupMembers` response. +message ListGroupMembersResponse { + // A set of monitored resources in the group. + repeated google.api.MonitoredResource members = 1; + + // If there are more results than have been returned, then this field is + // set to a non-empty value. To see the additional results, use that value as + // `pageToken` in the next call to this method. + string next_page_token = 2; + + // The total number of elements matching this request. + int32 total_size = 3; +} diff --git a/typescript/test/protos/google/monitoring/v3/metric.proto b/typescript/test/protos/google/monitoring/v3/metric.proto new file mode 100644 index 000000000..3c202ed41 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/metric.proto @@ -0,0 +1,96 @@ +// Copyright 2019 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/distribution.proto"; +import "google/api/label.proto"; +import "google/api/metric.proto"; +import "google/api/monitored_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 = "MetricProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A single data point in a time series. +message Point { + // The time interval to which the data point applies. For `GAUGE` metrics, + // the start time is optional, but if it is supplied, it must equal the + // end time. For `DELTA` metrics, the start + // and end time should specify a non-zero interval, with subsequent points + // specifying contiguous and non-overlapping intervals. For `CUMULATIVE` + // metrics, the start and end time should specify a non-zero interval, with + // subsequent points specifying the same start time and increasing end times, + // until an event resets the cumulative value to zero and sets a new start + // time for the following points. + TimeInterval interval = 1; + + // The value of the data point. + TypedValue value = 2; +} + +// A collection of data points that describes the time-varying values +// of a metric. A time series is identified by a combination of a +// fully-specified monitored resource and a fully-specified metric. +// This type is used for both listing and creating time series. +message TimeSeries { + // The associated metric. A fully-specified metric used to identify the time + // series. + google.api.Metric metric = 1; + + // The associated monitored resource. Custom metrics can use only certain + // monitored resource types in their time series data. + google.api.MonitoredResource resource = 2; + + // Output only. The associated monitored resource metadata. When reading a + // a timeseries, this field will include metadata labels that are explicitly + // named in the reduction. When creating a timeseries, this field is ignored. + google.api.MonitoredResourceMetadata metadata = 7; + + // The metric kind of the time series. When listing time series, this metric + // kind might be different from the metric kind of the associated metric if + // this time series is an alignment or reduction of other time series. + // + // When creating a time series, this field is optional. If present, it must be + // the same as the metric kind of the associated metric. If the associated + // metric's descriptor must be auto-created, then this field specifies the + // metric kind of the new descriptor and must be either `GAUGE` (the default) + // or `CUMULATIVE`. + google.api.MetricDescriptor.MetricKind metric_kind = 3; + + // The value type of the time series. When listing time series, this value + // type might be different from the value type of the associated metric if + // this time series is an alignment or reduction of other time series. + // + // When creating a time series, this field is optional. If present, it must be + // the same as the type of the data in the `points` field. + google.api.MetricDescriptor.ValueType value_type = 4; + + // The data points of this time series. When listing time series, points are + // returned in reverse time order. + // + // When creating a time series, this field must contain exactly one point and + // the point's type must be the same as the value type of the associated + // metric. If the associated metric's descriptor must be auto-created, then + // the value type of the descriptor is determined by the point's type, which + // must be `BOOL`, `INT64`, `DOUBLE`, or `DISTRIBUTION`. + repeated Point points = 5; +} diff --git a/typescript/test/protos/google/monitoring/v3/metric_service.proto b/typescript/test/protos/google/monitoring/v3/metric_service.proto new file mode 100644 index 000000000..d5d2c3343 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/metric_service.proto @@ -0,0 +1,407 @@ +// Copyright 2019 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/metric.proto"; +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/monitoring/v3/alert.proto"; +import "google/monitoring/v3/common.proto"; +import "google/monitoring/v3/metric.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/rpc/status.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 = "MetricServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; +option (google.api.resource_definition) = { + type: "monitoring.googleapis.com/MetricDescriptor" + pattern: "projects/{project}/metricDescriptors/{metric_descriptor=**}" + pattern: "organizations/{organization}/metricDescriptors/{metric_descriptor=**}" + pattern: "folders/{folder}/metricDescriptors/{metric_descriptor=**}" + pattern: "*" + history: ORIGINALLY_SINGLE_PATTERN +}; +option (google.api.resource_definition) = { + type: "monitoring.googleapis.com/MonitoredResourceDescriptor" + pattern: "projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}" + pattern: "organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor}" + pattern: "folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}" + pattern: "*" + history: ORIGINALLY_SINGLE_PATTERN +}; + +// Manages metric descriptors, monitored resource descriptors, and +// time series data. +service MetricService { + 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," + "https://www.googleapis.com/auth/monitoring.write"; + + // Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. + rpc ListMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest) returns (ListMonitoredResourceDescriptorsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/monitoredResourceDescriptors" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single monitored resource descriptor. This method does not require a Stackdriver account. + rpc GetMonitoredResourceDescriptor(GetMonitoredResourceDescriptorRequest) returns (google.api.MonitoredResourceDescriptor) { + option (google.api.http) = { + get: "/v3/{name=projects/*/monitoredResourceDescriptors/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists metric descriptors that match a filter. This method does not require a Stackdriver account. + rpc ListMetricDescriptors(ListMetricDescriptorsRequest) returns (ListMetricDescriptorsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/metricDescriptors" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single metric descriptor. This method does not require a Stackdriver account. + rpc GetMetricDescriptor(GetMetricDescriptorRequest) returns (google.api.MetricDescriptor) { + option (google.api.http) = { + get: "/v3/{name=projects/*/metricDescriptors/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new metric descriptor. + // User-created metric descriptors define + // [custom metrics](/monitoring/custom-metrics). + rpc CreateMetricDescriptor(CreateMetricDescriptorRequest) returns (google.api.MetricDescriptor) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/metricDescriptors" + body: "metric_descriptor" + }; + option (google.api.method_signature) = "name,metric_descriptor"; + } + + // Deletes a metric descriptor. Only user-created + // [custom metrics](/monitoring/custom-metrics) can be deleted. + rpc DeleteMetricDescriptor(DeleteMetricDescriptorRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/metricDescriptors/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists time series that match a filter. This method does not require a Stackdriver account. + rpc ListTimeSeries(ListTimeSeriesRequest) returns (ListTimeSeriesResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/timeSeries" + }; + option (google.api.method_signature) = "name,filter,interval,view"; + } + + // Creates or adds data to one or more time series. + // The response is empty if all time series in the request were written. + // If any time series could not be written, a corresponding failure message is + // included in the error response. + rpc CreateTimeSeries(CreateTimeSeriesRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/timeSeries" + body: "*" + }; + option (google.api.method_signature) = "name,time_series"; + } +} + +// The `ListMonitoredResourceDescriptors` request. +message ListMonitoredResourceDescriptorsRequest { + // Required. The project on which to execute the request. The format is + // `"projects/{project_id_or_number}"`. + string name = 5 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/MonitoredResourceDescriptor" + } + ]; + + // An optional [filter](/monitoring/api/v3/filters) describing + // the descriptors to be returned. The filter can reference + // the descriptor's type and labels. For example, the + // following filter returns only Google Compute Engine descriptors + // that have an `id` label: + // + // resource.type = starts_with("gce_") AND resource.label:id + string filter = 2; + + // A positive number that is the maximum number of results to return. + int32 page_size = 3; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 4; +} + +// The `ListMonitoredResourceDescriptors` response. +message ListMonitoredResourceDescriptorsResponse { + // The monitored resource descriptors that are available to this project + // and that match `filter`, if present. + repeated google.api.MonitoredResourceDescriptor resource_descriptors = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The `GetMonitoredResourceDescriptor` request. +message GetMonitoredResourceDescriptorRequest { + // Required. The monitored resource descriptor to get. The format is + // `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`. + // The `{resource_type}` is a predefined type, such as + // `cloudsql_database`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/MonitoredResourceDescriptor" + } + ]; +} + +// The `ListMetricDescriptors` request. +message ListMetricDescriptorsRequest { + // Required. The project on which to execute the request. The format is + // `"projects/{project_id_or_number}"`. + string name = 5 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/MetricDescriptor" + } + ]; + + // If this field is empty, all custom and + // system-defined metric descriptors are returned. + // Otherwise, the [filter](/monitoring/api/v3/filters) + // specifies which metric descriptors are to be + // returned. For example, the following filter matches all + // [custom metrics](/monitoring/custom-metrics): + // + // metric.type = starts_with("custom.googleapis.com/") + string filter = 2; + + // A positive number that is the maximum number of results to return. + int32 page_size = 3; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 4; +} + +// The `ListMetricDescriptors` response. +message ListMetricDescriptorsResponse { + // The metric descriptors that are available to the project + // and that match the value of `filter`, if present. + repeated google.api.MetricDescriptor metric_descriptors = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The `GetMetricDescriptor` request. +message GetMetricDescriptorRequest { + // Required. The metric descriptor on which to execute the request. The format is + // `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + // An example value of `{metric_id}` is + // `"compute.googleapis.com/instance/disk/read_bytes_count"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/MetricDescriptor" + } + ]; +} + +// The `CreateMetricDescriptor` request. +message CreateMetricDescriptorRequest { + // Required. The project on which to execute the request. The format is + // `"projects/{project_id_or_number}"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/MetricDescriptor" + } + ]; + + // Required. The new [custom metric](/monitoring/custom-metrics) + // descriptor. + google.api.MetricDescriptor metric_descriptor = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The `DeleteMetricDescriptor` request. +message DeleteMetricDescriptorRequest { + // Required. The metric descriptor on which to execute the request. The format is + // `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + // An example of `{metric_id}` is: + // `"custom.googleapis.com/my_test_metric"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/MetricDescriptor" + } + ]; +} + +// The `ListTimeSeries` request. +message ListTimeSeriesRequest { + // Controls which fields are returned by `ListTimeSeries`. + enum TimeSeriesView { + // Returns the identity of the metric(s), the time series, + // and the time series data. + FULL = 0; + + // Returns the identity of the metric and the time series resource, + // but not the time series data. + HEADERS = 1; + } + + // Required. The project on which to execute the request. The format is + // "projects/{project_id_or_number}". + string name = 10 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/TimeSeries" + } + ]; + + // Required. A [monitoring filter](/monitoring/api/v3/filters) that specifies which time + // series should be returned. The filter must specify a single metric type, + // and can additionally specify metric labels and other information. For + // example: + // + // metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + // metric.labels.instance_name = "my-instance-name" + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The time interval for which results should be returned. Only time series + // that contain data points in the specified interval are included + // in the response. + TimeInterval interval = 4 [(google.api.field_behavior) = REQUIRED]; + + // Specifies the alignment of data points in individual time series as + // well as how to combine the retrieved time series across specified labels. + // + // By default (if no `aggregation` is explicitly specified), the raw time + // series data is returned. + Aggregation aggregation = 5; + + // Unsupported: must be left blank. The points in each time series are + // currently returned in reverse time order (most recent to oldest). + string order_by = 6; + + // Required. Specifies which information is returned about the time series. + TimeSeriesView view = 7 [(google.api.field_behavior) = REQUIRED]; + + // A positive number that is the maximum number of results to return. If + // `page_size` is empty or more than 100,000 results, the effective + // `page_size` is 100,000 results. If `view` is set to `FULL`, this is the + // maximum number of `Points` returned. If `view` is set to `HEADERS`, this is + // the maximum number of `TimeSeries` returned. + int32 page_size = 8; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 9; +} + +// The `ListTimeSeries` response. +message ListTimeSeriesResponse { + // One or more time series that match the filter included in the request. + repeated TimeSeries time_series = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; + + // Query execution errors that may have caused the time series data returned + // to be incomplete. + repeated google.rpc.Status execution_errors = 3; +} + +// The `CreateTimeSeries` request. +message CreateTimeSeriesRequest { + // Required. The project on which to execute the request. The format is + // `"projects/{project_id_or_number}"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/TimeSeries" + } + ]; + + // Required. The new data to be added to a list of time series. + // Adds at most one data point to each of several time series. The new data + // point must be more recent than any other point in its time series. Each + // `TimeSeries` value must fully specify a unique time series by supplying + // all label values for the metric and the monitored resource. + // + // The maximum number of `TimeSeries` objects per `Create` request is 200. + repeated TimeSeries time_series = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// DEPRECATED. Used to hold per-time-series error status. +message CreateTimeSeriesError { + // DEPRECATED. Time series ID that resulted in the `status` error. + TimeSeries time_series = 1 [deprecated = true]; + + // DEPRECATED. The status of the requested write operation for `time_series`. + google.rpc.Status status = 2 [deprecated = true]; +} + +// Summary of the result of a failed request to write data to a time series. +message CreateTimeSeriesSummary { + // Detailed information about an error category. + message Error { + // The status of the requested write operation. + google.rpc.Status status = 1; + + // The number of points that couldn't be written because of `status`. + int32 point_count = 2; + } + + // The number of points in the request. + int32 total_point_count = 1; + + // The number of points that were successfully written. + int32 success_point_count = 2; + + // The number of points that failed to be written. Order is not guaranteed. + repeated Error errors = 3; +} diff --git a/typescript/test/protos/google/monitoring/v3/mutation_record.proto b/typescript/test/protos/google/monitoring/v3/mutation_record.proto new file mode 100644 index 000000000..eab1f37d2 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/mutation_record.proto @@ -0,0 +1,36 @@ +// Copyright 2019 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/protobuf/timestamp.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 = "MutationRecordProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// Describes a change made to a configuration. +message MutationRecord { + // When the change occurred. + google.protobuf.Timestamp mutate_time = 1; + + // The email address of the user making the change. + string mutated_by = 2; +} diff --git a/typescript/test/protos/google/monitoring/v3/notification.proto b/typescript/test/protos/google/monitoring/v3/notification.proto new file mode 100644 index 000000000..fb3ef4625 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/notification.proto @@ -0,0 +1,183 @@ +// Copyright 2019 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/label.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/monitoring/v3/common.proto"; +import "google/protobuf/wrappers.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 = "NotificationProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A description of a notification channel. The descriptor includes +// the properties of the channel and the set of labels or fields that +// must be specified to configure channels of a given type. +message NotificationChannelDescriptor { + option (google.api.resource) = { + type: "monitoring.googleapis.com/NotificationChannelDescriptor" + pattern: "projects/{project}/notificationChannelDescriptors/{channel_descriptor}" + pattern: "organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}" + pattern: "folders/{folder}/notificationChannelDescriptors/{channel_descriptor}" + pattern: "*" + }; + + // The full REST resource name for this descriptor. The syntax is: + // + // projects/[PROJECT_ID]/notificationChannelDescriptors/[TYPE] + // + // In the above, `[TYPE]` is the value of the `type` field. + string name = 6; + + // The type of notification channel, such as "email", "sms", etc. + // Notification channel types are globally unique. + string type = 1; + + // A human-readable name for the notification channel type. This + // form of the name is suitable for a user interface. + string display_name = 2; + + // A human-readable description of the notification channel + // type. The description may include a description of the properties + // of the channel and pointers to external documentation. + string description = 3; + + // The set of labels that must be defined to identify a particular + // channel of the corresponding type. Each label includes a + // description for how that field should be populated. + repeated google.api.LabelDescriptor labels = 4; + + // The tiers that support this notification channel; the project service tier + // must be one of the supported_tiers. + repeated ServiceTier supported_tiers = 5 [deprecated = true]; + + // The product launch stage for channels of this type. + google.api.LaunchStage launch_stage = 7; +} + +// A `NotificationChannel` is a medium through which an alert is +// delivered when a policy violation is detected. Examples of channels +// include email, SMS, and third-party messaging applications. Fields +// containing sensitive information like authentication tokens or +// contact info are only partially populated on retrieval. +message NotificationChannel { + option (google.api.resource) = { + type: "monitoring.googleapis.com/NotificationChannel" + pattern: "projects/{project}/notificationChannels/{notification_channel}" + pattern: "organizations/{organization}/notificationChannels/{notification_channel}" + pattern: "folders/{folder}/notificationChannels/{notification_channel}" + pattern: "*" + }; + + // Indicates whether the channel has been verified or not. It is illegal + // to specify this field in a + // [`CreateNotificationChannel`][google.monitoring.v3.NotificationChannelService.CreateNotificationChannel] + // or an + // [`UpdateNotificationChannel`][google.monitoring.v3.NotificationChannelService.UpdateNotificationChannel] + // operation. + enum VerificationStatus { + // Sentinel value used to indicate that the state is unknown, omitted, or + // is not applicable (as in the case of channels that neither support + // nor require verification in order to function). + VERIFICATION_STATUS_UNSPECIFIED = 0; + + // The channel has yet to be verified and requires verification to function. + // Note that this state also applies to the case where the verification + // process has been initiated by sending a verification code but where + // the verification code has not been submitted to complete the process. + UNVERIFIED = 1; + + // It has been proven that notifications can be received on this + // notification channel and that someone on the project has access + // to messages that are delivered to that channel. + VERIFIED = 2; + } + + // The type of the notification channel. This field matches the + // value of the [NotificationChannelDescriptor.type][google.monitoring.v3.NotificationChannelDescriptor.type] field. + string type = 1; + + // The full REST resource name for this channel. The syntax is: + // + // projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID] + // + // The `[CHANNEL_ID]` is automatically assigned by the server on creation. + string name = 6; + + // An optional human-readable name for this notification channel. It is + // recommended that you specify a non-empty and unique name in order to + // make it easier to identify the channels in your project, though this is + // not enforced. The display name is limited to 512 Unicode characters. + string display_name = 3; + + // An optional human-readable description of this notification channel. This + // description may provide additional details, beyond the display + // name, for the channel. This may not exceed 1024 Unicode characters. + string description = 4; + + // Configuration fields that define the channel and its behavior. The + // permissible and required labels are specified in the + // [NotificationChannelDescriptor.labels][google.monitoring.v3.NotificationChannelDescriptor.labels] of the + // `NotificationChannelDescriptor` corresponding to the `type` field. + map labels = 5; + + // User-supplied key/value data that does not need to conform to + // the corresponding `NotificationChannelDescriptor`'s schema, unlike + // the `labels` field. This field is intended to be used for organizing + // and identifying the `NotificationChannel` objects. + // + // The field can contain up to 64 entries. Each key and value is limited to + // 63 Unicode characters or 128 bytes, whichever is smaller. Labels and + // values can contain only lowercase letters, numerals, underscores, and + // dashes. Keys must begin with a letter. + map user_labels = 8; + + // Indicates whether this channel has been verified or not. On a + // [`ListNotificationChannels`][google.monitoring.v3.NotificationChannelService.ListNotificationChannels] + // or + // [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] + // operation, this field is expected to be populated. + // + // If the value is `UNVERIFIED`, then it indicates that the channel is + // non-functioning (it both requires verification and lacks verification); + // otherwise, it is assumed that the channel works. + // + // If the channel is neither `VERIFIED` nor `UNVERIFIED`, it implies that + // the channel is of a type that does not require verification or that + // this specific channel has been exempted from verification because it was + // created prior to verification being required for channels of this type. + // + // This field cannot be modified using a standard + // [`UpdateNotificationChannel`][google.monitoring.v3.NotificationChannelService.UpdateNotificationChannel] + // operation. To change the value of this field, you must call + // [`VerifyNotificationChannel`][google.monitoring.v3.NotificationChannelService.VerifyNotificationChannel]. + VerificationStatus verification_status = 9; + + // Whether notifications are forwarded to the described channel. This makes + // it possible to disable delivery of notifications to a particular channel + // without removing the channel from all alerting policies that reference + // the channel. This is a more convenient approach when the change is + // temporary and you want to receive notifications from the same set + // of alerting policies on the channel at some point in the future. + google.protobuf.BoolValue enabled = 11; +} diff --git a/typescript/test/protos/google/monitoring/v3/notification_service.proto b/typescript/test/protos/google/monitoring/v3/notification_service.proto new file mode 100644 index 000000000..959cc0496 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/notification_service.proto @@ -0,0 +1,401 @@ +// Copyright 2019 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/notification.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.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 = "NotificationServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The Notification Channel API provides access to configuration that +// controls how messages related to incidents are sent. +service NotificationChannelService { + 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"; + + // Lists the descriptors for supported channel types. The use of descriptors + // makes it possible for new channel types to be dynamically added. + rpc ListNotificationChannelDescriptors(ListNotificationChannelDescriptorsRequest) returns (ListNotificationChannelDescriptorsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/notificationChannelDescriptors" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single channel descriptor. The descriptor indicates which fields + // are expected / permitted for a notification channel of the given type. + rpc GetNotificationChannelDescriptor(GetNotificationChannelDescriptorRequest) returns (NotificationChannelDescriptor) { + option (google.api.http) = { + get: "/v3/{name=projects/*/notificationChannelDescriptors/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the notification channels that have been created for the project. + rpc ListNotificationChannels(ListNotificationChannelsRequest) returns (ListNotificationChannelsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/notificationChannels" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single notification channel. The channel includes the relevant + // configuration details with which the channel was created. However, the + // response may truncate or omit passwords, API keys, or other private key + // matter and thus the response may not be 100% identical to the information + // that was supplied in the call to the create method. + rpc GetNotificationChannel(GetNotificationChannelRequest) returns (NotificationChannel) { + option (google.api.http) = { + get: "/v3/{name=projects/*/notificationChannels/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new notification channel, representing a single notification + // endpoint such as an email address, SMS number, or PagerDuty service. + rpc CreateNotificationChannel(CreateNotificationChannelRequest) returns (NotificationChannel) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/notificationChannels" + body: "notification_channel" + }; + option (google.api.method_signature) = "name,notification_channel"; + } + + // Updates a notification channel. Fields not specified in the field mask + // remain unchanged. + rpc UpdateNotificationChannel(UpdateNotificationChannelRequest) returns (NotificationChannel) { + option (google.api.http) = { + patch: "/v3/{notification_channel.name=projects/*/notificationChannels/*}" + body: "notification_channel" + }; + option (google.api.method_signature) = "update_mask,notification_channel"; + } + + // Deletes a notification channel. + rpc DeleteNotificationChannel(DeleteNotificationChannelRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/notificationChannels/*}" + }; + option (google.api.method_signature) = "name,force"; + } + + // Causes a verification code to be delivered to the channel. The code + // can then be supplied in `VerifyNotificationChannel` to verify the channel. + rpc SendNotificationChannelVerificationCode(SendNotificationChannelVerificationCodeRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v3/{name=projects/*/notificationChannels/*}:sendVerificationCode" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Requests a verification code for an already verified channel that can then + // be used in a call to VerifyNotificationChannel() on a different channel + // with an equivalent identity in the same or in a different project. This + // makes it possible to copy a channel between projects without requiring + // manual reverification of the channel. If the channel is not in the + // verified state, this method will fail (in other words, this may only be + // used if the SendNotificationChannelVerificationCode and + // VerifyNotificationChannel paths have already been used to put the given + // channel into the verified state). + // + // There is no guarantee that the verification codes returned by this method + // will be of a similar structure or form as the ones that are delivered + // to the channel via SendNotificationChannelVerificationCode; while + // VerifyNotificationChannel() will recognize both the codes delivered via + // SendNotificationChannelVerificationCode() and returned from + // GetNotificationChannelVerificationCode(), it is typically the case that + // the verification codes delivered via + // SendNotificationChannelVerificationCode() will be shorter and also + // have a shorter expiration (e.g. codes such as "G-123456") whereas + // GetVerificationCode() will typically return a much longer, websafe base + // 64 encoded string that has a longer expiration time. + rpc GetNotificationChannelVerificationCode(GetNotificationChannelVerificationCodeRequest) returns (GetNotificationChannelVerificationCodeResponse) { + option (google.api.http) = { + post: "/v3/{name=projects/*/notificationChannels/*}:getVerificationCode" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Verifies a `NotificationChannel` by proving receipt of the code + // delivered to the channel as a result of calling + // `SendNotificationChannelVerificationCode`. + rpc VerifyNotificationChannel(VerifyNotificationChannelRequest) returns (NotificationChannel) { + option (google.api.http) = { + post: "/v3/{name=projects/*/notificationChannels/*}:verify" + body: "*" + }; + option (google.api.method_signature) = "name,code"; + } +} + +// The `ListNotificationChannelDescriptors` request. +message ListNotificationChannelDescriptorsRequest { + // Required. The REST resource name of the parent from which to retrieve + // the notification channel descriptors. The expected syntax is: + // + // projects/[PROJECT_ID] + // + // Note that this names the parent container in which to look for the + // descriptors; to retrieve a single descriptor by name, use the + // [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] + // operation, instead. + string name = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/NotificationChannelDescriptor" + } + ]; + + // The maximum number of results to return in a single response. If + // not set to a positive number, a reasonable value will be chosen by the + // service. + int32 page_size = 2; + + // If non-empty, `page_token` must contain a value returned as the + // `next_page_token` in a previous response to request the next set + // of results. + string page_token = 3; +} + +// The `ListNotificationChannelDescriptors` response. +message ListNotificationChannelDescriptorsResponse { + // The monitored resource descriptors supported for the specified + // project, optionally filtered. + repeated NotificationChannelDescriptor channel_descriptors = 1; + + // If not empty, indicates that there may be more results that match + // the request. Use the value in the `page_token` field in a + // subsequent request to fetch the next set of results. If empty, + // all results have been returned. + string next_page_token = 2; +} + +// The `GetNotificationChannelDescriptor` response. +message GetNotificationChannelDescriptorRequest { + // Required. The channel type for which to execute the request. The format is + // `projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannelDescriptor" + } + ]; +} + +// The `CreateNotificationChannel` request. +message CreateNotificationChannelRequest { + // Required. The project on which to execute the request. The format is: + // + // projects/[PROJECT_ID] + // + // Note that this names the container into which the channel will be + // written. This does not name the newly created channel. The resulting + // channel's name will have a normalized version of this field as a prefix, + // but will add `/notificationChannels/[CHANNEL_ID]` to identify the channel. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // Required. The definition of the `NotificationChannel` to create. + NotificationChannel notification_channel = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The `ListNotificationChannels` request. +message ListNotificationChannelsRequest { + // Required. The project on which to execute the request. The format is + // `projects/[PROJECT_ID]`. That is, this names the container + // in which to look for the notification channels; it does not name a + // specific channel. To query a specific channel by REST resource name, use + // the + // [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] + // operation. + string name = 5 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // If provided, this field specifies the criteria that must be met by + // notification channels to be included in the response. + // + // For more details, see [sorting and + // filtering](/monitoring/api/v3/sorting-and-filtering). + string filter = 6; + + // A comma-separated list of fields by which to sort the result. Supports + // the same set of fields as in `filter`. Entries can be prefixed with + // a minus sign to sort in descending rather than ascending order. + // + // For more details, see [sorting and + // filtering](/monitoring/api/v3/sorting-and-filtering). + string order_by = 7; + + // The maximum number of results to return in a single response. If + // not set to a positive number, a reasonable value will be chosen by the + // service. + int32 page_size = 3; + + // If non-empty, `page_token` must contain a value returned as the + // `next_page_token` in a previous response to request the next set + // of results. + string page_token = 4; +} + +// The `ListNotificationChannels` response. +message ListNotificationChannelsResponse { + // The notification channels defined for the specified project. + repeated NotificationChannel notification_channels = 3; + + // If not empty, indicates that there may be more results that match + // the request. Use the value in the `page_token` field in a + // subsequent request to fetch the next set of results. If empty, + // all results have been returned. + string next_page_token = 2; +} + +// The `GetNotificationChannel` request. +message GetNotificationChannelRequest { + // Required. The channel for which to execute the request. The format is + // `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; +} + +// The `UpdateNotificationChannel` request. +message UpdateNotificationChannelRequest { + // The fields to update. + google.protobuf.FieldMask update_mask = 2; + + // Required. A description of the changes to be applied to the specified + // notification channel. The description must provide a definition for + // fields to be updated; the names of these fields should also be + // included in the `update_mask`. + NotificationChannel notification_channel = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The `DeleteNotificationChannel` request. +message DeleteNotificationChannelRequest { + // Required. The channel for which to execute the request. The format is + // `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // If true, the notification channel will be deleted regardless of its + // use in alert policies (the policies will be updated to remove the + // channel). If false, channels that are still referenced by an existing + // alerting policy will fail to be deleted in a delete operation. + bool force = 5; +} + +// The `SendNotificationChannelVerificationCode` request. +message SendNotificationChannelVerificationCodeRequest { + // Required. The notification channel to which to send a verification code. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; +} + +// The `GetNotificationChannelVerificationCode` request. +message GetNotificationChannelVerificationCodeRequest { + // Required. The notification channel for which a verification code is to be generated + // and retrieved. This must name a channel that is already verified; if + // the specified channel is not verified, the request will fail. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // The desired expiration time. If specified, the API will guarantee that + // the returned code will not be valid after the specified timestamp; + // however, the API cannot guarantee that the returned code will be + // valid for at least as long as the requested time (the API puts an upper + // bound on the amount of time for which a code may be valid). If omitted, + // a default expiration will be used, which may be less than the max + // permissible expiration (so specifying an expiration may extend the + // code's lifetime over omitting an expiration, even though the API does + // impose an upper limit on the maximum expiration that is permitted). + google.protobuf.Timestamp expire_time = 2; +} + +// The `GetNotificationChannelVerificationCode` request. +message GetNotificationChannelVerificationCodeResponse { + // The verification code, which may be used to verify other channels + // that have an equivalent identity (i.e. other channels of the same + // type with the same fingerprint such as other email channels with + // the same email address or other sms channels with the same number). + string code = 1; + + // The expiration time associated with the code that was returned. If + // an expiration was provided in the request, this is the minimum of the + // requested expiration in the request and the max permitted expiration. + google.protobuf.Timestamp expire_time = 2; +} + +// The `VerifyNotificationChannel` request. +message VerifyNotificationChannelRequest { + // Required. The notification channel to verify. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // Required. The verification code that was delivered to the channel as + // a result of invoking the `SendNotificationChannelVerificationCode` API + // method or that was retrieved from a verified channel via + // `GetNotificationChannelVerificationCode`. For example, one might have + // "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only + // guaranteed that the code is valid UTF-8; one should not + // make any assumptions regarding the structure or format of the code). + string code = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/typescript/test/testdata/monitoring/proto.list.baseline b/typescript/test/testdata/monitoring/proto.list.baseline index f9cc3f4c9..99e4eee86 100644 --- a/typescript/test/testdata/monitoring/proto.list.baseline +++ b/typescript/test/testdata/monitoring/proto.list.baseline @@ -1,19 +1,20 @@ -google/api/http.proto -google/protobuf/descriptor.proto -google/api/annotations.proto -google/api/client.proto -google/api/field_behavior.proto google/api/label.proto google/api/launch_stage.proto google/protobuf/struct.proto google/api/monitored_resource.proto +google/protobuf/descriptor.proto google/api/resource.proto google/protobuf/duration.proto google/protobuf/timestamp.proto google/type/calendar_period.proto google/monitoring/v3/service.proto +google/api/http.proto +google/api/annotations.proto +google/api/client.proto +google/api/field_behavior.proto google/protobuf/empty.proto google/protobuf/field_mask.proto google/monitoring/v3/service_service.proto +google/monitoring/v3/span_context.proto google/monitoring/v3/uptime.proto google/monitoring/v3/uptime_service.proto diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/service.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/service.proto.baseline new file mode 100644 index 000000000..82a953bde --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/service.proto.baseline @@ -0,0 +1,397 @@ +// Copyright 2019 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/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/calendar_period.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 = "ServiceMonitoringProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A `Service` is a discrete, autonomous, and network-accessible unit, designed +// to solve an individual concern +// ([Wikipedia](https://en.wikipedia.org/wiki/Service-orientation)). In +// Stackdriver Monitoring, a `Service` acts as the root resource under which +// operational aspects of the service are accessible. +message Service { + option (google.api.resource) = { + type: "monitoring.googleapis.com/Service" + pattern: "projects/{project}/services/{service}" + pattern: "organizations/{organization}/services/{service}" + pattern: "folders/{folder}/services/{service}" + pattern: "*" + }; + + // Custom view of service telemetry. Currently a place-holder pending final + // design. + message Custom { + + } + + // App Engine service. Learn more at https://cloud.google.com/appengine. + message AppEngine { + // The ID of the App Engine module underlying this service. Corresponds to + // the `module_id` resource label in the `gae_app` monitored resource: + // https://cloud.google.com/monitoring/api/resources#tag_gae_app + string module_id = 1; + } + + // Cloud Endpoints service. Learn more at https://cloud.google.com/endpoints. + message CloudEndpoints { + // The name of the Cloud Endpoints service underlying this service. + // Corresponds to the `service` resource label in the `api` monitored + // resource: https://cloud.google.com/monitoring/api/resources#tag_api + string service = 1; + } + + // Istio service. Learn more at http://istio.io. + message ClusterIstio { + // The location of the Kubernetes cluster in which this Istio service is + // defined. Corresponds to the `location` resource label in `k8s_cluster` + // resources. + string location = 1; + + // The name of the Kubernetes cluster in which this Istio service is + // defined. Corresponds to the `cluster_name` resource label in + // `k8s_cluster` resources. + string cluster_name = 2; + + // The namespace of the Istio service underlying this service. Corresponds + // to the `destination_service_namespace` metric label in Istio metrics. + string service_namespace = 3; + + // The name of the Istio service underlying this service. Corresponds to the + // `destination_service_name` metric label in Istio metrics. + string service_name = 4; + } + + // Configuration for how to query telemetry on a Service. + message Telemetry { + // The full name of the resource that defines this service. Formatted as + // described in https://cloud.google.com/apis/design/resource_names. + string resource_name = 1; + } + + // Resource name for this Service. Of the form + // `projects/{project_id}/services/{service_id}`. + string name = 1; + + // Name used for UI elements listing this Service. + string display_name = 2; + + // REQUIRED. Service-identifying atoms specifying the underlying service. + oneof identifier { + // Custom service type. + Custom custom = 6; + + // Type used for App Engine services. + AppEngine app_engine = 7; + + // Type used for Cloud Endpoints services. + CloudEndpoints cloud_endpoints = 8; + + // Type used for Istio services that live in a Kubernetes cluster. + ClusterIstio cluster_istio = 9; + } + + // Configuration for how to query telemetry on a Service. + Telemetry telemetry = 13; +} + +// A Service-Level Objective (SLO) describes a level of desired good service. It +// consists of a service-level indicator (SLI), a performance goal, and a period +// over which the objective is to be evaluated against that goal. The SLO can +// use SLIs defined in a number of different manners. Typical SLOs might include +// "99% of requests in each rolling week have latency below 200 milliseconds" or +// "99.5% of requests in each calendar month return successfully." +message ServiceLevelObjective { + option (google.api.resource) = { + type: "monitoring.googleapis.com/ServiceLevelObjective" + pattern: "projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}" + pattern: "organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}" + pattern: "folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}" + pattern: "*" + history: ORIGINALLY_SINGLE_PATTERN + }; + + // `ServiceLevelObjective.View` determines what form of + // `ServiceLevelObjective` is returned from `GetServiceLevelObjective`, + // `ListServiceLevelObjectives`, and `ListServiceLevelObjectiveVersions` RPCs. + enum View { + // Same as FULL. + VIEW_UNSPECIFIED = 0; + + // Return the embedded `ServiceLevelIndicator` in the form in which it was + // defined. If it was defined using a `BasicSli`, return that `BasicSli`. + FULL = 2; + + // For `ServiceLevelIndicator`s using `BasicSli` articulation, instead + // return the `ServiceLevelIndicator` with its mode of computation fully + // spelled out as a `RequestBasedSli`. For `ServiceLevelIndicator`s using + // `RequestBasedSli` or `WindowsBasedSli`, return the + // `ServiceLevelIndicator` as it was provided. + EXPLICIT = 1; + } + + // Resource name for this `ServiceLevelObjective`. + // Of the form + // `projects/{project_id}/services/{service_id}/serviceLevelObjectives/{slo_name}`. + string name = 1; + + // Name used for UI elements listing this SLO. + string display_name = 11; + + // The definition of good service, used to measure and calculate the quality + // of the `Service`'s performance with respect to a single aspect of service + // quality. + ServiceLevelIndicator service_level_indicator = 3; + + // The fraction of service that must be good in order for this objective to be + // met. `0 < goal <= 0.999`. + double goal = 4; + + // The time period over which the objective will be evaluated. + oneof period { + // A rolling time period, semantically "in the past ``". + // Must be an integer multiple of 1 day no larger than 30 days. + google.protobuf.Duration rolling_period = 5; + + // A calendar period, semantically "since the start of the current + // ``". At this time, only `DAY`, `WEEK`, `FORTNIGHT`, and + // `MONTH` are supported. + google.type.CalendarPeriod calendar_period = 6; + } +} + +// A Service-Level Indicator (SLI) describes the "performance" of a service. For +// some services, the SLI is well-defined. In such cases, the SLI can be +// described easily by referencing the well-known SLI and providing the needed +// parameters. Alternatively, a "custom" SLI can be defined with a query to the +// underlying metric store. An SLI is defined to be `good_service / +// total_service` over any queried time interval. The value of performance +// always falls into the range `0 <= performance <= 1`. A custom SLI describes +// how to compute this ratio, whether this is by dividing values from a pair of +// time series, cutting a `Distribution` into good and bad counts, or counting +// time windows in which the service complies with a criterion. For separation +// of concerns, a single Service-Level Indicator measures performance for only +// one aspect of service quality, such as fraction of successful queries or +// fast-enough queries. +message ServiceLevelIndicator { + // Service level indicators can be grouped by whether the "unit" of service + // being measured is based on counts of good requests or on counts of good + // time windows + oneof type { + // Basic SLI on a well-known service type. + BasicSli basic_sli = 4; + + // Request-based SLIs + RequestBasedSli request_based = 1; + + // Windows-based SLIs + WindowsBasedSli windows_based = 2; + } +} + +// An SLI measuring performance on a well-known service type. Performance will +// be computed on the basis of pre-defined metrics. The type of the +// `service_resource` determines the metrics to use and the +// `service_resource.labels` and `metric_labels` are used to construct a +// monitoring filter to filter that metric down to just the data relevant to +// this service. +message BasicSli { + // Future parameters for the availability SLI. + message AvailabilityCriteria { + + } + + // Parameters for a latency threshold SLI. + message LatencyCriteria { + // Good service is defined to be the count of requests made to this service + // that return in no more than `threshold`. + google.protobuf.Duration threshold = 3; + } + + // OPTIONAL: The set of RPCs to which this SLI is relevant. Telemetry from + // other methods will not be used to calculate performance for this SLI. If + // omitted, this SLI applies to all the Service's methods. For service types + // that don't support breaking down by method, setting this field will result + // in an error. + repeated string method = 7; + + // OPTIONAL: The set of locations to which this SLI is relevant. Telemetry + // from other locations will not be used to calculate performance for this + // SLI. If omitted, this SLI applies to all locations in which the Service has + // activity. For service types that don't support breaking down by location, + // setting this field will result in an error. + repeated string location = 8; + + // OPTIONAL: The set of API versions to which this SLI is relevant. Telemetry + // from other API versions will not be used to calculate performance for this + // SLI. If omitted, this SLI applies to all API versions. For service types + // that don't support breaking down by version, setting this field will result + // in an error. + repeated string version = 9; + + // This SLI can be evaluated on the basis of availability or latency. + oneof sli_criteria { + // Good service is defined to be the count of requests made to this service + // that return successfully. + AvailabilityCriteria availability = 2; + + // Good service is defined to be the count of requests made to this service + // that are fast enough with respect to `latency.threshold`. + LatencyCriteria latency = 3; + } +} + +// Range of numerical values, inclusive of `min` and exclusive of `max`. If the +// open range "< range.max" is desired, set `range.min = -infinity`. If the open +// range ">= range.min" is desired, set `range.max = infinity`. +message Range { + // Range minimum. + double min = 1; + + // Range maximum. + double max = 2; +} + +// Service Level Indicators for which atomic units of service are counted +// directly. +message RequestBasedSli { + // The means to compute a ratio of `good_service` to `total_service`. + oneof method { + // `good_total_ratio` is used when the ratio of `good_service` to + // `total_service` is computed from two `TimeSeries`. + TimeSeriesRatio good_total_ratio = 1; + + // `distribution_cut` is used when `good_service` is a count of values + // aggregated in a `Distribution` that fall into a good range. The + // `total_service` is the total count of all values aggregated in the + // `Distribution`. + DistributionCut distribution_cut = 3; + } +} + +// A `TimeSeriesRatio` specifies two `TimeSeries` to use for computing the +// `good_service / total_service` ratio. The specified `TimeSeries` must have +// `ValueType = DOUBLE` or `ValueType = INT64` and must have `MetricKind = +// DELTA` or `MetricKind = CUMULATIVE`. The `TimeSeriesRatio` must specify +// exactly two of good, bad, and total, and the relationship `good_service + +// bad_service = total_service` will be assumed. +message TimeSeriesRatio { + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` quantifying good service provided. Must have + // `ValueType = DOUBLE` or `ValueType = INT64` and must have `MetricKind = + // DELTA` or `MetricKind = CUMULATIVE`. + string good_service_filter = 4; + + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` quantifying bad service, either demanded service + // that was not provided or demanded service that was of inadequate quality. + // Must have `ValueType = DOUBLE` or `ValueType = INT64` and must have + // `MetricKind = DELTA` or `MetricKind = CUMULATIVE`. + string bad_service_filter = 5; + + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` quantifying total demanded service. Must have + // `ValueType = DOUBLE` or `ValueType = INT64` and must have `MetricKind = + // DELTA` or `MetricKind = CUMULATIVE`. + string total_service_filter = 6; +} + +// A `DistributionCut` defines a `TimeSeries` and thresholds used for measuring +// good service and total service. The `TimeSeries` must have `ValueType = +// DISTRIBUTION` and `MetricKind = DELTA` or `MetricKind = CUMULATIVE`. The +// computed `good_service` will be the count of values x in the `Distribution` +// such that `range.min <= x < range.max`. +message DistributionCut { + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` aggregating values. Must have `ValueType = + // DISTRIBUTION` and `MetricKind = DELTA` or `MetricKind = CUMULATIVE`. + string distribution_filter = 4; + + // Range of values considered "good." For a one-sided range, set one bound to + // an infinite value. + Range range = 5; +} + +// A `WindowsBasedSli` defines `good_service` as the count of time windows for +// which the provided service was of good quality. Criteria for determining +// if service was good are embedded in the `window_criterion`. +message WindowsBasedSli { + // A `PerformanceThreshold` is used when each window is good when that window + // has a sufficiently high `performance`. + message PerformanceThreshold { + // The means, either a request-based SLI or a basic SLI, by which to compute + // performance over a window. + oneof type { + // `RequestBasedSli` to evaluate to judge window quality. + RequestBasedSli performance = 1; + + // `BasicSli` to evaluate to judge window quality. + BasicSli basic_sli_performance = 3; + } + + // If window `performance >= threshold`, the window is counted as good. + double threshold = 2; + } + + // A `MetricRange` is used when each window is good when the value x of a + // single `TimeSeries` satisfies `range.min <= x < range.max`. The provided + // `TimeSeries` must have `ValueType = INT64` or `ValueType = DOUBLE` and + // `MetricKind = GAUGE`. + message MetricRange { + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying the `TimeSeries` to use for evaluating window quality. + string time_series = 1; + + // Range of values considered "good." For a one-sided range, set one bound + // to an infinite value. + Range range = 4; + } + + // The criterion to use for evaluating window goodness. + oneof window_criterion { + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` with `ValueType = BOOL`. The window is good if + // any `true` values appear in the window. + string good_bad_metric_filter = 5; + + // A window is good if its `performance` is high enough. + PerformanceThreshold good_total_ratio_threshold = 2; + + // A window is good if the metric's value is in a good range, averaged + // across returned streams. + MetricRange metric_mean_in_range = 6; + + // A window is good if the metric's value is in a good range, summed across + // returned streams. + MetricRange metric_sum_in_range = 7; + } + + // Duration over which window quality is evaluated. Must be an integer + // fraction of a day and at least `60s`. + google.protobuf.Duration window_period = 4; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/span_context.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/span_context.proto.baseline new file mode 100644 index 000000000..cbcb8f72e --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/span_context.proto.baseline @@ -0,0 +1,43 @@ +// Copyright 2019 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; + +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 = "SpanContextProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The context of a span, attached to google.api.Distribution.Exemplars +// in google.api.Distribution values during aggregation. +// +// It contains the name of a span with format: +// projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID] +message SpanContext { + // The resource name of the span in the following format: + // + // projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID] + // + // [TRACE_ID] is a unique identifier for a trace within a project; + // it is a 32-character hexadecimal encoding of a 16-byte array. + // + // [SPAN_ID] is a unique identifier for a span within a trace; it + // is a 16-character hexadecimal encoding of an 8-byte array. + string span_name = 1; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/uptime.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/uptime.proto.baseline new file mode 100644 index 000000000..7cb4947d5 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/uptime.proto.baseline @@ -0,0 +1,350 @@ +// Copyright 2019 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/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.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 = "UptimeProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The regions from which an Uptime check can be run. +enum UptimeCheckRegion { + // Default value if no region is specified. Will result in Uptime checks + // running from all regions. + REGION_UNSPECIFIED = 0; + + // Allows checks to run from locations within the United States of America. + USA = 1; + + // Allows checks to run from locations within the continent of Europe. + EUROPE = 2; + + // Allows checks to run from locations within the continent of South + // America. + SOUTH_AMERICA = 3; + + // Allows checks to run from locations within the Asia Pacific area (ex: + // Singapore). + ASIA_PACIFIC = 4; +} + +// An internal checker allows Uptime checks to run on private/internal GCP +// resources. +message InternalChecker { + option deprecated = true; + + // Operational states for an internal checker. + enum State { + // An internal checker should never be in the unspecified state. + UNSPECIFIED = 0; + + // The checker is being created, provisioned, and configured. A checker in + // this state can be returned by `ListInternalCheckers` or + // `GetInternalChecker`, as well as by examining the [long running + // Operation](https://cloud.google.com/apis/design/design_patterns#long_running_operations) + // that created it. + CREATING = 1; + + // The checker is running and available for use. A checker in this state + // can be returned by `ListInternalCheckers` or `GetInternalChecker` as + // well as by examining the [long running + // Operation](https://cloud.google.com/apis/design/design_patterns#long_running_operations) + // that created it. + // If a checker is being torn down, it is neither visible nor usable, so + // there is no "deleting" or "down" state. + RUNNING = 2; + } + + // A unique resource name for this InternalChecker. The format is: + // + // `projects/[PROJECT_ID]/internalCheckers/[INTERNAL_CHECKER_ID]`. + // + // `[PROJECT_ID]` is the Stackdriver Workspace project for the + // Uptime check config associated with the internal checker. + string name = 1; + + // The checker's human-readable name. The display name + // should be unique within a Stackdriver Workspace in order to make it easier + // to identify; however, uniqueness is not enforced. + string display_name = 2; + + // The [GCP VPC network](https://cloud.google.com/vpc/docs/vpc) where the + // internal resource lives (ex: "default"). + string network = 3; + + // The GCP zone the Uptime check should egress from. Only respected for + // internal Uptime checks, where internal_network is specified. + string gcp_zone = 4; + + // The GCP project ID where the internal checker lives. Not necessary + // the same as the Workspace project. + string peer_project_id = 6; + + // The current operational state of the internal checker. + State state = 7; +} + +// This message configures which resources and services to monitor for +// availability. +message UptimeCheckConfig { + option (google.api.resource) = { + type: "monitoring.googleapis.com/UptimeCheckConfig" + pattern: "projects/{project}/uptimeCheckConfigs/{uptime_check_config}" + pattern: "organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}" + pattern: "folders/{folder}/uptimeCheckConfigs/{uptime_check_config}" + pattern: "*" + }; + + // The resource submessage for group checks. It can be used instead of a + // monitored resource, when multiple resources are being monitored. + message ResourceGroup { + // The group of resources being monitored. Should be only the `[GROUP_ID]`, + // and not the full-path `projects/[PROJECT_ID]/groups/[GROUP_ID]`. + string group_id = 1; + + // The resource type of the group members. + GroupResourceType resource_type = 2; + } + + // Information involved in an HTTP/HTTPS Uptime check request. + message HttpCheck { + // The authentication parameters to provide to the specified resource or + // URL that requires a username and password. Currently, only + // [Basic HTTP authentication](https://tools.ietf.org/html/rfc7617) is + // supported in Uptime checks. + message BasicAuthentication { + // The username to use when authenticating with the HTTP server. + string username = 1; + + // The password to use when authenticating with the HTTP server. + string password = 2; + } + + // If `true`, use HTTPS instead of HTTP to run the check. + bool use_ssl = 1; + + // Optional (defaults to "/"). The path to the page against which to run + // the check. Will be combined with the `host` (specified within the + // `monitored_resource`) and `port` to construct the full URL. If the + // provided path does not begin with "/", a "/" will be prepended + // automatically. + string path = 2; + + // Optional (defaults to 80 when `use_ssl` is `false`, and 443 when + // `use_ssl` is `true`). The TCP port on the HTTP server against which to + // run the check. Will be combined with host (specified within the + // `monitored_resource`) and `path` to construct the full URL. + int32 port = 3; + + // The authentication information. Optional when creating an HTTP check; + // defaults to empty. + BasicAuthentication auth_info = 4; + + // Boolean specifiying whether to encrypt the header information. + // Encryption should be specified for any headers related to authentication + // that you do not wish to be seen when retrieving the configuration. The + // server will be responsible for encrypting the headers. + // On Get/List calls, if `mask_headers` is set to `true` then the headers + // will be obscured with `******.` + bool mask_headers = 5; + + // The list of headers to send as part of the Uptime check request. + // If two headers have the same key and different values, they should + // be entered as a single header, with the value being a comma-separated + // list of all the desired values as described at + // https://www.w3.org/Protocols/rfc2616/rfc2616.txt (page 31). + // Entering two separate headers with the same key in a Create call will + // cause the first to be overwritten by the second. + // The maximum number of headers allowed is 100. + map headers = 6; + + // Boolean specifying whether to include SSL certificate validation as a + // part of the Uptime check. Only applies to checks where + // `monitored_resource` is set to `uptime_url`. If `use_ssl` is `false`, + // setting `validate_ssl` to `true` has no effect. + bool validate_ssl = 7; + } + + // Information required for a TCP Uptime check request. + message TcpCheck { + // The TCP port on the server against which to run the check. Will be + // combined with host (specified within the `monitored_resource`) to + // construct the full URL. Required. + int32 port = 1; + } + + // Optional. Used to perform content matching. This allows matching based on + // substrings and regular expressions, together with their negations. Only the + // first 4 MB of an HTTP or HTTPS check's response (and the first + // 1 MB of a TCP check's response) are examined for purposes of content + // matching. + message ContentMatcher { + // Options to perform content matching. + enum ContentMatcherOption { + // No content matcher type specified (maintained for backward + // compatibility, but deprecated for future use). + // Treated as `CONTAINS_STRING`. + CONTENT_MATCHER_OPTION_UNSPECIFIED = 0; + + // Selects substring matching. The match succeeds if the output contains + // the `content` string. This is the default value for checks without + // a `matcher` option, or where the value of `matcher` is + // `CONTENT_MATCHER_OPTION_UNSPECIFIED`. + CONTAINS_STRING = 1; + + // Selects negation of substring matching. The match succeeds if the + // output does _NOT_ contain the `content` string. + NOT_CONTAINS_STRING = 2; + + // Selects regular-expression matching. The match succeeds of the output + // matches the regular expression specified in the `content` string. + MATCHES_REGEX = 3; + + // Selects negation of regular-expression matching. The match succeeds if + // the output does _NOT_ match the regular expression specified in the + // `content` string. + NOT_MATCHES_REGEX = 4; + } + + // String or regex content to match. Maximum 1024 bytes. An empty `content` + // string indicates no content matching is to be performed. + string content = 1; + + // The type of content matcher that will be applied to the server output, + // compared to the `content` string when the check is run. + ContentMatcherOption matcher = 2; + } + + // A unique resource name for this Uptime check configuration. The format is: + // + // `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. + // + // This field should be omitted when creating the Uptime check configuration; + // on create, the resource name is assigned by the server and included in the + // response. + string name = 1; + + // A human-friendly name for the Uptime check configuration. The display name + // should be unique within a Stackdriver Workspace in order to make it easier + // to identify; however, uniqueness is not enforced. Required. + string display_name = 2; + + // The resource the check is checking. Required. + oneof resource { + // The [monitored + // resource](https://cloud.google.com/monitoring/api/resources) associated + // with the configuration. + // The following monitored resource types are supported for Uptime checks: + // `uptime_url`, + // `gce_instance`, + // `gae_app`, + // `aws_ec2_instance`, + // `aws_elb_load_balancer` + google.api.MonitoredResource monitored_resource = 3; + + // The group resource associated with the configuration. + ResourceGroup resource_group = 4; + } + + // The type of Uptime check request. + oneof check_request_type { + // Contains information needed to make an HTTP or HTTPS check. + HttpCheck http_check = 5; + + // Contains information needed to make a TCP check. + TcpCheck tcp_check = 6; + } + + // How often, in seconds, the Uptime check is performed. + // Currently, the only supported values are `60s` (1 minute), `300s` + // (5 minutes), `600s` (10 minutes), and `900s` (15 minutes). Optional, + // defaults to `60s`. + google.protobuf.Duration period = 7; + + // The maximum amount of time to wait for the request to complete (must be + // between 1 and 60 seconds). Required. + google.protobuf.Duration timeout = 8; + + // The content that is expected to appear in the data returned by the target + // server against which the check is run. Currently, only the first entry + // in the `content_matchers` list is supported, and additional entries will + // be ignored. This field is optional and should only be specified if a + // content match is required as part of the/ Uptime check. + repeated ContentMatcher content_matchers = 9; + + // The list of regions from which the check will be run. + // Some regions contain one location, and others contain more than one. + // If this field is specified, enough regions must be provided to include a + // minimum of 3 locations. Not specifying this field will result in Uptime + // checks running from all available regions. + repeated UptimeCheckRegion selected_regions = 10; + + // If this is `true`, then checks are made only from the 'internal_checkers'. + // If it is `false`, then checks are made only from the 'selected_regions'. + // It is an error to provide 'selected_regions' when is_internal is `true`, + // or to provide 'internal_checkers' when is_internal is `false`. + bool is_internal = 15 [deprecated = true]; + + // The internal checkers that this check will egress from. If `is_internal` is + // `true` and this list is empty, the check will egress from all the + // InternalCheckers configured for the project that owns this + // `UptimeCheckConfig`. + repeated InternalChecker internal_checkers = 14 [deprecated = true]; +} + +// The supported resource types that can be used as values of +// `group_resource.resource_type`. +// `INSTANCE` includes `gce_instance` and `aws_ec2_instance` resource types. +// The resource types `gae_app` and `uptime_url` are not valid here because +// group checks on App Engine modules and URLs are not allowed. +enum GroupResourceType { + // Default value (not valid). + RESOURCE_TYPE_UNSPECIFIED = 0; + + // A group of instances from Google Cloud Platform (GCP) or + // Amazon Web Services (AWS). + INSTANCE = 1; + + // A group of Amazon ELB load balancers. + AWS_ELB_LOAD_BALANCER = 2; +} + +// Contains the region, location, and list of IP +// addresses where checkers in the location run from. +message UptimeCheckIp { + // A broad region category in which the IP address is located. + UptimeCheckRegion region = 1; + + // A more specific location within the region that typically encodes + // a particular city/town/metro (and its containing state/province or country) + // within the broader umbrella region category. + string location = 2; + + // The IP address from which the Uptime check originates. This is a fully + // specified IP address (not an IP address range). Most IP addresses, as of + // this publication, are in IPv4 format; however, one should not rely on the + // IP addresses being in IPv4 format indefinitely, and should support + // interpreting this field in either IPv4 or IPv6 format. + string ip_address = 3; +} diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline index 6fec2dd59..dae706a8f 100644 --- a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline @@ -1,6 +1,7 @@ [ "../../protos/google/monitoring/v3/service.proto", "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/span_context.proto", "../../protos/google/monitoring/v3/uptime.proto", "../../protos/google/monitoring/v3/uptime_service.proto" ] diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline index 6fec2dd59..dae706a8f 100644 --- a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline @@ -1,6 +1,7 @@ [ "../../protos/google/monitoring/v3/service.proto", "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/span_context.proto", "../../protos/google/monitoring/v3/uptime.proto", "../../protos/google/monitoring/v3/uptime_service.proto" ] diff --git a/typescript/test/unit/monitor.ts b/typescript/test/unit/monitor.ts index 36c8a125c..2bca28c8e 100644 --- a/typescript/test/unit/monitor.ts +++ b/typescript/test/unit/monitor.ts @@ -24,7 +24,7 @@ const MONITOR_PROTO_FILES = path.join( 'google', 'monitoring', 'v3', - '*_service.proto' + '*.proto' ); const BASELINE_DIR = path.join( From 03228c95e660a4b96f656ed4ff368cc15f858724 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 11 Feb 2020 10:53:13 -0800 Subject: [PATCH 2/8] update baseline --- .../testdata/monitoring/proto.list.baseline | 30 +- .../google/monitoring/v3/alert.proto.baseline | 360 +++ .../v3/alert_service.proto.baseline | 231 ++ .../monitoring/v3/common.proto.baseline | 475 ++++ .../v3/dropped_labels.proto.baseline | 45 + .../google/monitoring/v3/group.proto.baseline | 86 + .../v3/group_service.proto.baseline | 273 +++ .../monitoring/v3/metric.proto.baseline | 96 + .../v3/metric_service.proto.baseline | 407 +++ .../v3/mutation_record.proto.baseline | 36 + .../monitoring/v3/notification.proto.baseline | 183 ++ .../v3/notification_service.proto.baseline | 401 +++ .../testdata/monitoring/src/index.ts.baseline | 8 +- .../alert_policy_service_client.ts.baseline | 1588 ++++++++++++ ...policy_service_client_config.json.baseline | 46 + ...rt_policy_service_proto_list.json.baseline | 18 + .../src/v3/group_service_client.ts.baseline | 1711 +++++++++++++ .../group_service_client_config.json.baseline | 50 + .../v3/group_service_proto_list.json.baseline | 18 + .../monitoring/src/v3/index.ts.baseline | 2 +- .../src/v3/metric_service_client.ts.baseline | 2172 +++++++++++++++++ ...metric_service_client_config.json.baseline | 58 + .../metric_service_proto_list.json.baseline | 18 + ...ication_channel_service_client.ts.baseline | 1996 +++++++++++++++ ...hannel_service_client_config.json.baseline | 66 + ...n_channel_service_proto_list.json.baseline | 18 + ...vice_monitoring_service_client.ts.baseline | 468 ++++ ...onitoring_service_proto_list.json.baseline | 11 + .../uptime_check_service_client.ts.baseline | 468 ++++ ...ime_check_service_proto_list.json.baseline | 11 + .../fixtures/sample/src/index.js.baseline | 4 + .../fixtures/sample/src/index.ts.baseline | 6 +- .../gapic-alert_policy_service-v3.ts.baseline | 323 +++ .../test/gapic-group_service-v3.ts.baseline | 371 +++ .../test/gapic-metric_service-v3.ts.baseline | 465 ++++ ...otification_channel_service-v3.ts.baseline | 563 +++++ 36 files changed, 13071 insertions(+), 11 deletions(-) create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/alert.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/alert_service.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/common.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/dropped_labels.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/group.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/group_service.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/metric.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/metric_service.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/mutation_record.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/notification.proto.baseline create mode 100644 typescript/test/testdata/monitoring/protos/google/monitoring/v3/notification_service.proto.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline diff --git a/typescript/test/testdata/monitoring/proto.list.baseline b/typescript/test/testdata/monitoring/proto.list.baseline index 99e4eee86..b2914448e 100644 --- a/typescript/test/testdata/monitoring/proto.list.baseline +++ b/typescript/test/testdata/monitoring/proto.list.baseline @@ -1,19 +1,35 @@ -google/api/label.proto -google/api/launch_stage.proto -google/protobuf/struct.proto -google/api/monitored_resource.proto google/protobuf/descriptor.proto google/api/resource.proto -google/protobuf/duration.proto +google/protobuf/any.proto google/protobuf/timestamp.proto -google/type/calendar_period.proto -google/monitoring/v3/service.proto +google/api/distribution.proto +google/protobuf/duration.proto +google/monitoring/v3/common.proto +google/monitoring/v3/mutation_record.proto +google/protobuf/wrappers.proto +google/rpc/status.proto +google/monitoring/v3/alert.proto google/api/http.proto google/api/annotations.proto google/api/client.proto google/api/field_behavior.proto google/protobuf/empty.proto google/protobuf/field_mask.proto +google/monitoring/v3/alert_service.proto +google/monitoring/v3/dropped_labels.proto +google/monitoring/v3/group.proto +google/api/label.proto +google/api/launch_stage.proto +google/protobuf/struct.proto +google/api/monitored_resource.proto +google/monitoring/v3/group_service.proto +google/api/metric.proto +google/monitoring/v3/metric.proto +google/monitoring/v3/metric_service.proto +google/monitoring/v3/notification.proto +google/monitoring/v3/notification_service.proto +google/type/calendar_period.proto +google/monitoring/v3/service.proto google/monitoring/v3/service_service.proto google/monitoring/v3/span_context.proto google/monitoring/v3/uptime.proto diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/alert.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/alert.proto.baseline new file mode 100644 index 000000000..d65e00dba --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/alert.proto.baseline @@ -0,0 +1,360 @@ +// Copyright 2019 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/resource.proto"; +import "google/monitoring/v3/common.proto"; +import "google/monitoring/v3/mutation_record.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/wrappers.proto"; +import "google/rpc/status.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 = "AlertProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A description of the conditions under which some aspect of your system is +// considered to be "unhealthy" and the ways to notify people or services about +// this state. For an overview of alert policies, see +// [Introduction to Alerting](/monitoring/alerts/). +message AlertPolicy { + option (google.api.resource) = { + type: "monitoring.googleapis.com/AlertPolicy" + pattern: "projects/{project}/alertPolicies/{alert_policy}" + pattern: "organizations/{organization}/alertPolicies/{alert_policy}" + pattern: "folders/{folder}/alertPolicies/{alert_policy}" + pattern: "*" + }; + + // A content string and a MIME type that describes the content string's + // format. + message Documentation { + // The text of the documentation, interpreted according to `mime_type`. + // The content may not exceed 8,192 Unicode characters and may not exceed + // more than 10,240 bytes when encoded in UTF-8 format, whichever is + // smaller. + string content = 1; + + // The format of the `content` field. Presently, only the value + // `"text/markdown"` is supported. See + // [Markdown](https://en.wikipedia.org/wiki/Markdown) for more information. + string mime_type = 2; + } + + // A condition is a true/false test that determines when an alerting policy + // should open an incident. If a condition evaluates to true, it signifies + // that something is wrong. + message Condition { + option (google.api.resource) = { + type: "monitoring.googleapis.com/AlertPolicyCondition" + pattern: "projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}" + pattern: "organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}" + pattern: "folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}" + pattern: "*" + }; + + // Specifies how many time series must fail a predicate to trigger a + // condition. If not specified, then a `{count: 1}` trigger is used. + message Trigger { + // A type of trigger. + oneof type { + // The absolute number of time series that must fail + // the predicate for the condition to be triggered. + int32 count = 1; + + // The percentage of time series that must fail the + // predicate for the condition to be triggered. + double percent = 2; + } + } + + // A condition type that compares a collection of time series + // against a threshold. + message MetricThreshold { + // A [filter](/monitoring/api/v3/filters) that + // identifies which time series should be compared with the threshold. + // + // The filter is similar to the one that is specified in the + // [`ListTimeSeries` + // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that + // call is useful to verify the time series that will be retrieved / + // processed) and must specify the metric type and optionally may contain + // restrictions on resource type, resource labels, and metric labels. + // This field may not exceed 2048 Unicode characters in length. + string filter = 2; + + // Specifies the alignment of data points in individual time series as + // well as how to combine the retrieved time series together (such as + // when aggregating multiple streams on each resource to a single + // stream for each resource or when aggregating streams across all + // members of a group of resrouces). Multiple aggregations + // are applied in the order specified. + // + // This field is similar to the one in the [`ListTimeSeries` + // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It + // is advisable to use the `ListTimeSeries` method when debugging this + // field. + repeated Aggregation aggregations = 8; + + // A [filter](/monitoring/api/v3/filters) that identifies a time + // series that should be used as the denominator of a ratio that will be + // compared with the threshold. If a `denominator_filter` is specified, + // the time series specified by the `filter` field will be used as the + // numerator. + // + // The filter must specify the metric type and optionally may contain + // restrictions on resource type, resource labels, and metric labels. + // This field may not exceed 2048 Unicode characters in length. + string denominator_filter = 9; + + // Specifies the alignment of data points in individual time series + // selected by `denominatorFilter` as + // well as how to combine the retrieved time series together (such as + // when aggregating multiple streams on each resource to a single + // stream for each resource or when aggregating streams across all + // members of a group of resources). + // + // When computing ratios, the `aggregations` and + // `denominator_aggregations` fields must use the same alignment period + // and produce time series that have the same periodicity and labels. + repeated Aggregation denominator_aggregations = 10; + + // The comparison to apply between the time series (indicated by `filter` + // and `aggregation`) and the threshold (indicated by `threshold_value`). + // The comparison is applied on each time series, with the time series + // on the left-hand side and the threshold on the right-hand side. + // + // Only `COMPARISON_LT` and `COMPARISON_GT` are supported currently. + ComparisonType comparison = 4; + + // A value against which to compare the time series. + double threshold_value = 5; + + // The amount of time that a time series must violate the + // threshold to be considered failing. Currently, only values + // that are a multiple of a minute--e.g., 0, 60, 120, or 300 + // seconds--are supported. If an invalid value is given, an + // error will be returned. When choosing a duration, it is useful to + // keep in mind the frequency of the underlying time series data + // (which may also be affected by any alignments specified in the + // `aggregations` field); a good duration is long enough so that a single + // outlier does not generate spurious alerts, but short enough that + // unhealthy states are detected and alerted on quickly. + google.protobuf.Duration duration = 6; + + // The number/percent of time series for which the comparison must hold + // in order for the condition to trigger. If unspecified, then the + // condition will trigger if the comparison is true for any of the + // time series that have been identified by `filter` and `aggregations`, + // or by the ratio, if `denominator_filter` and `denominator_aggregations` + // are specified. + Trigger trigger = 7; + } + + // A condition type that checks that monitored resources + // are reporting data. The configuration defines a metric and + // a set of monitored resources. The predicate is considered in violation + // when a time series for the specified metric of a monitored + // resource does not include any data in the specified `duration`. + message MetricAbsence { + // A [filter](/monitoring/api/v3/filters) that + // identifies which time series should be compared with the threshold. + // + // The filter is similar to the one that is specified in the + // [`ListTimeSeries` + // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that + // call is useful to verify the time series that will be retrieved / + // processed) and must specify the metric type and optionally may contain + // restrictions on resource type, resource labels, and metric labels. + // This field may not exceed 2048 Unicode characters in length. + string filter = 1; + + // Specifies the alignment of data points in individual time series as + // well as how to combine the retrieved time series together (such as + // when aggregating multiple streams on each resource to a single + // stream for each resource or when aggregating streams across all + // members of a group of resrouces). Multiple aggregations + // are applied in the order specified. + // + // This field is similar to the one in the [`ListTimeSeries` + // request](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It + // is advisable to use the `ListTimeSeries` method when debugging this + // field. + repeated Aggregation aggregations = 5; + + // The amount of time that a time series must fail to report new + // data to be considered failing. Currently, only values that + // are a multiple of a minute--e.g. 60, 120, or 300 + // seconds--are supported. If an invalid value is given, an + // error will be returned. The `Duration.nanos` field is + // ignored. + google.protobuf.Duration duration = 2; + + // The number/percent of time series for which the comparison must hold + // in order for the condition to trigger. If unspecified, then the + // condition will trigger if the comparison is true for any of the + // time series that have been identified by `filter` and `aggregations`. + Trigger trigger = 3; + } + + // Required if the condition exists. The unique resource name for this + // condition. Its syntax is: + // + // projects/[PROJECT_ID]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID] + // + // `[CONDITION_ID]` is assigned by Stackdriver Monitoring when the + // condition is created as part of a new or updated alerting policy. + // + // When calling the + // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy] + // method, do not include the `name` field in the conditions of the + // requested alerting policy. Stackdriver Monitoring creates the + // condition identifiers and includes them in the new policy. + // + // When calling the + // [alertPolicies.update][google.monitoring.v3.AlertPolicyService.UpdateAlertPolicy] + // method to update a policy, including a condition `name` causes the + // existing condition to be updated. Conditions without names are added to + // the updated policy. Existing conditions are deleted if they are not + // updated. + // + // Best practice is to preserve `[CONDITION_ID]` if you make only small + // changes, such as those to condition thresholds, durations, or trigger + // values. Otherwise, treat the change as a new condition and let the + // existing condition be deleted. + string name = 12; + + // A short name or phrase used to identify the condition in dashboards, + // notifications, and incidents. To avoid confusion, don't use the same + // display name for multiple conditions in the same policy. + string display_name = 6; + + // Only one of the following condition types will be specified. + oneof condition { + // A condition that compares a time series against a threshold. + MetricThreshold condition_threshold = 1; + + // A condition that checks that a time series continues to + // receive new data points. + MetricAbsence condition_absent = 2; + } + } + + // Operators for combining conditions. + enum ConditionCombinerType { + // An unspecified combiner. + COMBINE_UNSPECIFIED = 0; + + // Combine conditions using the logical `AND` operator. An + // incident is created only if all conditions are met + // simultaneously. This combiner is satisfied if all conditions are + // met, even if they are met on completely different resources. + AND = 1; + + // Combine conditions using the logical `OR` operator. An incident + // is created if any of the listed conditions is met. + OR = 2; + + // Combine conditions using logical `AND` operator, but unlike the regular + // `AND` option, an incident is created only if all conditions are met + // simultaneously on at least one resource. + AND_WITH_MATCHING_RESOURCE = 3; + } + + // Required if the policy exists. The resource name for this policy. The + // syntax is: + // + // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + // + // `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy + // is created. When calling the + // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy] + // method, do not include the `name` field in the alerting policy passed as + // part of the request. + string name = 1; + + // A short name or phrase used to identify the policy in dashboards, + // notifications, and incidents. To avoid confusion, don't use the same + // display name for multiple policies in the same project. The name is + // limited to 512 Unicode characters. + string display_name = 2; + + // Documentation that is included with notifications and incidents related to + // this policy. Best practice is for the documentation to include information + // to help responders understand, mitigate, escalate, and correct the + // underlying problems detected by the alerting policy. Notification channels + // that have limited capacity might not show this documentation. + Documentation documentation = 13; + + // User-supplied key/value data to be used for organizing and + // identifying the `AlertPolicy` objects. + // + // The field can contain up to 64 entries. Each key and value is limited to + // 63 Unicode characters or 128 bytes, whichever is smaller. Labels and + // values can contain only lowercase letters, numerals, underscores, and + // dashes. Keys must begin with a letter. + map user_labels = 16; + + // A list of conditions for the policy. The conditions are combined by AND or + // OR according to the `combiner` field. If the combined conditions evaluate + // to true, then an incident is created. A policy can have from one to six + // conditions. + // If |condition_time_series_uery_language| is present, it must be the only + // |condition|. + repeated Condition conditions = 12; + + // How to combine the results of multiple conditions to determine if an + // incident should be opened. + // If condition_time_series_query_language is present, this must be + // COMBINE_UNSPECIFIED. + ConditionCombinerType combiner = 6; + + // Whether or not the policy is enabled. On write, the default interpretation + // if unset is that the policy is enabled. On read, clients should not make + // any assumption about the state if it has not been populated. The + // field should always be populated on List and Get operations, unless + // a field projection has been specified that strips it out. + google.protobuf.BoolValue enabled = 17; + + // Read-only description of how the alert policy is invalid. OK if the alert + // policy is valid. If not OK, the alert policy will not generate incidents. + google.rpc.Status validity = 18; + + // Identifies the notification channels to which notifications should be sent + // when incidents are opened or closed or when new violations occur on + // an already opened incident. Each element of this array corresponds to + // the `name` field in each of the + // [`NotificationChannel`][google.monitoring.v3.NotificationChannel] + // objects that are returned from the [`ListNotificationChannels`] + // [google.monitoring.v3.NotificationChannelService.ListNotificationChannels] + // method. The syntax of the entries in this field is: + // + // projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID] + repeated string notification_channels = 14; + + // A read-only record of the creation of the alerting policy. If provided + // in a call to create or update, this field will be ignored. + MutationRecord creation_record = 10; + + // A read-only record of the most recent change to the alerting policy. If + // provided in a call to create or update, this field will be ignored. + MutationRecord mutation_record = 11; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/alert_service.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/alert_service.proto.baseline new file mode 100644 index 000000000..a88c376f5 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/alert_service.proto.baseline @@ -0,0 +1,231 @@ +// Copyright 2019 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/alert.proto"; +import "google/protobuf/empty.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 = "AlertServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The AlertPolicyService API is used to manage (list, create, delete, +// edit) alert policies in Stackdriver Monitoring. An alerting policy is +// a description of the conditions under which some aspect of your +// system is considered to be "unhealthy" and the ways to notify +// people or services about this state. In addition to using this API, alert +// policies can also be managed through +// [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), +// which can be reached by clicking the "Monitoring" tab in +// [Cloud Console](https://console.cloud.google.com/). +service AlertPolicyService { + 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"; + + // Lists the existing alerting policies for the project. + rpc ListAlertPolicies(ListAlertPoliciesRequest) returns (ListAlertPoliciesResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/alertPolicies" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single alerting policy. + rpc GetAlertPolicy(GetAlertPolicyRequest) returns (AlertPolicy) { + option (google.api.http) = { + get: "/v3/{name=projects/*/alertPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new alerting policy. + rpc CreateAlertPolicy(CreateAlertPolicyRequest) returns (AlertPolicy) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/alertPolicies" + body: "alert_policy" + }; + option (google.api.method_signature) = "name,alert_policy"; + } + + // Deletes an alerting policy. + rpc DeleteAlertPolicy(DeleteAlertPolicyRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/alertPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates an alerting policy. You can either replace the entire policy with + // a new one or replace only certain fields in the current alerting policy by + // specifying the fields to be updated via `updateMask`. Returns the + // updated alerting policy. + rpc UpdateAlertPolicy(UpdateAlertPolicyRequest) returns (AlertPolicy) { + option (google.api.http) = { + patch: "/v3/{alert_policy.name=projects/*/alertPolicies/*}" + body: "alert_policy" + }; + option (google.api.method_signature) = "update_mask,alert_policy"; + } +} + +// The protocol for the `CreateAlertPolicy` request. +message CreateAlertPolicyRequest { + // Required. The project in which to create the alerting policy. The format is + // `projects/[PROJECT_ID]`. + // + // Note that this field names the parent container in which the alerting + // policy will be written, not the name of the created policy. The alerting + // policy that is returned will have a name that contains a normalized + // representation of this name as a prefix but adds a suffix of the form + // `/alertPolicies/[POLICY_ID]`, identifying the policy in the container. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/AlertPolicy" + } + ]; + + // Required. The requested alerting policy. You should omit the `name` field in this + // policy. The name will be returned in the new policy, including + // a new [ALERT_POLICY_ID] value. + AlertPolicy alert_policy = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The protocol for the `GetAlertPolicy` request. +message GetAlertPolicyRequest { + // Required. The alerting policy to retrieve. The format is + // + // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/AlertPolicy" + } + ]; +} + +// The protocol for the `ListAlertPolicies` request. +message ListAlertPoliciesRequest { + // Required. The project whose alert policies are to be listed. The format is + // + // projects/[PROJECT_ID] + // + // Note that this field names the parent container in which the alerting + // policies to be listed are stored. To retrieve a single alerting policy + // by name, use the + // [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy] + // operation, instead. + string name = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/AlertPolicy" + } + ]; + + // If provided, this field specifies the criteria that must be met by + // alert policies to be included in the response. + // + // For more details, see [sorting and + // filtering](/monitoring/api/v3/sorting-and-filtering). + string filter = 5; + + // A comma-separated list of fields by which to sort the result. Supports + // the same set of field references as the `filter` field. Entries can be + // prefixed with a minus sign to sort by the field in descending order. + // + // For more details, see [sorting and + // filtering](/monitoring/api/v3/sorting-and-filtering). + string order_by = 6; + + // The maximum number of results to return in a single response. + int32 page_size = 2; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return more results from the previous method call. + string page_token = 3; +} + +// The protocol for the `ListAlertPolicies` response. +message ListAlertPoliciesResponse { + // The returned alert policies. + repeated AlertPolicy alert_policies = 3; + + // If there might be more results than were returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The protocol for the `UpdateAlertPolicy` request. +message UpdateAlertPolicyRequest { + // Optional. A list of alerting policy field names. If this field is not + // empty, each listed field in the existing alerting policy is set to the + // value of the corresponding field in the supplied policy (`alert_policy`), + // or to the field's default value if the field is not in the supplied + // alerting policy. Fields not listed retain their previous value. + // + // Examples of valid field masks include `display_name`, `documentation`, + // `documentation.content`, `documentation.mime_type`, `user_labels`, + // `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc. + // + // If this field is empty, then the supplied alerting policy replaces the + // existing policy. It is the same as deleting the existing policy and + // adding the supplied policy, except for the following: + // + // + The new policy will have the same `[ALERT_POLICY_ID]` as the former + // policy. This gives you continuity with the former policy in your + // notifications and incidents. + // + Conditions in the new policy will keep their former `[CONDITION_ID]` if + // the supplied condition includes the `name` field with that + // `[CONDITION_ID]`. If the supplied condition omits the `name` field, + // then a new `[CONDITION_ID]` is created. + google.protobuf.FieldMask update_mask = 2; + + // Required. The updated alerting policy or the updated values for the + // fields listed in `update_mask`. + // If `update_mask` is not empty, any fields in this policy that are + // not in `update_mask` are ignored. + AlertPolicy alert_policy = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The protocol for the `DeleteAlertPolicy` request. +message DeleteAlertPolicyRequest { + // Required. The alerting policy to delete. The format is: + // + // projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + // + // For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/AlertPolicy" + } + ]; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/common.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/common.proto.baseline new file mode 100644 index 000000000..a4093b1c3 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/common.proto.baseline @@ -0,0 +1,475 @@ +// Copyright 2019 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/distribution.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.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 = "CommonProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A single strongly-typed value. +message TypedValue { + // The typed value field. + oneof value { + // A Boolean value: `true` or `false`. + bool bool_value = 1; + + // A 64-bit integer. Its range is approximately ±9.2x1018. + int64 int64_value = 2; + + // A 64-bit double-precision floating-point number. Its magnitude + // is approximately ±10±300 and it has 16 + // significant digits of precision. + double double_value = 3; + + // A variable-length string value. + string string_value = 4; + + // A distribution value. + google.api.Distribution distribution_value = 5; + } +} + +// A closed time interval. It extends from the start time to the end time, and includes both: `[startTime, endTime]`. Valid time intervals depend on the [`MetricKind`](/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricKind) of the metric value. In no case can the end time be earlier than the start time. +// +// * For a `GAUGE` metric, the `startTime` value is technically optional; if +// no value is specified, the start time defaults to the value of the +// end time, and the interval represents a single point in time. If both +// start and end times are specified, they must be identical. Such an +// interval is valid only for `GAUGE` metrics, which are point-in-time +// measurements. +// +// * For `DELTA` and `CUMULATIVE` metrics, the start time must be earlier +// than the end time. +// +// * In all cases, the start time of the next interval must be +// at least a microsecond after the end time of the previous interval. +// Because the interval is closed, if the start time of a new interval +// is the same as the end time of the previous interval, data written +// at the new start time could overwrite data written at the previous +// end time. +message TimeInterval { + // Required. The end of the time interval. + google.protobuf.Timestamp end_time = 2; + + // Optional. The beginning of the time interval. The default value + // for the start time is the end time. The start time must not be + // later than the end time. + google.protobuf.Timestamp start_time = 1; +} + +// Describes how to combine multiple time series to provide a different view of +// the data. Aggregation of time series is done in two steps. First, each time +// series in the set is _aligned_ to the same time interval boundaries, then the +// set of time series is optionally _reduced_ in number. +// +// Alignment consists of applying the `per_series_aligner` operation +// to each time series after its data has been divided into regular +// `alignment_period` time intervals. This process takes _all_ of the data +// points in an alignment period, applies a mathematical transformation such as +// averaging, minimum, maximum, delta, etc., and converts them into a single +// data point per period. +// +// Reduction is when the aligned and transformed time series can optionally be +// combined, reducing the number of time series through similar mathematical +// transformations. Reduction involves applying a `cross_series_reducer` to +// all the time series, optionally sorting the time series into subsets with +// `group_by_fields`, and applying the reducer to each subset. +// +// The raw time series data can contain a huge amount of information from +// multiple sources. Alignment and reduction transforms this mass of data into +// a more manageable and representative collection of data, for example "the +// 95% latency across the average of all tasks in a cluster". This +// representative data can be more easily graphed and comprehended, and the +// individual time series data is still available for later drilldown. For more +// details, see [Aggregating Time +// Series](/monitoring/api/v3/metrics#aggregating_time_series). +message Aggregation { + // The `Aligner` specifies the operation that will be applied to the data + // points in each alignment period in a time series. Except for + // `ALIGN_NONE`, which specifies that no operation be applied, each alignment + // operation replaces the set of data values in each alignment period with + // a single value: the result of applying the operation to the data values. + // An aligned time series has a single data value at the end of each + // `alignment_period`. + // + // An alignment operation can change the data type of the values, too. For + // example, if you apply a counting operation to boolean values, the data + // `value_type` in the original time series is `BOOLEAN`, but the `value_type` + // in the aligned result is `INT64`. + enum Aligner { + // No alignment. Raw data is returned. Not valid if cross-series reduction + // is requested. The `value_type` of the result is the same as the + // `value_type` of the input. + ALIGN_NONE = 0; + + // Align and convert to + // [DELTA][google.api.MetricDescriptor.MetricKind.DELTA]. + // The output is `delta = y1 - y0`. + // + // This alignment is valid for + // [CUMULATIVE][google.api.MetricDescriptor.MetricKind.CUMULATIVE] and + // `DELTA` metrics. If the selected alignment period results in periods + // with no data, then the aligned value for such a period is created by + // interpolation. The `value_type` of the aligned result is the same as + // the `value_type` of the input. + ALIGN_DELTA = 1; + + // Align and convert to a rate. The result is computed as + // `rate = (y1 - y0)/(t1 - t0)`, or "delta over time". + // Think of this aligner as providing the slope of the line that passes + // through the value at the start and at the end of the `alignment_period`. + // + // This aligner is valid for `CUMULATIVE` + // and `DELTA` metrics with numeric values. If the selected alignment + // period results in periods with no data, then the aligned value for + // such a period is created by interpolation. The output is a `GAUGE` + // metric with `value_type` `DOUBLE`. + // + // If, by "rate", you mean "percentage change", see the + // `ALIGN_PERCENT_CHANGE` aligner instead. + ALIGN_RATE = 2; + + // Align by interpolating between adjacent points around the alignment + // period boundary. This aligner is valid for `GAUGE` metrics with + // numeric values. The `value_type` of the aligned result is the same as the + // `value_type` of the input. + ALIGN_INTERPOLATE = 3; + + // Align by moving the most recent data point before the end of the + // alignment period to the boundary at the end of the alignment + // period. This aligner is valid for `GAUGE` metrics. The `value_type` of + // the aligned result is the same as the `value_type` of the input. + ALIGN_NEXT_OLDER = 4; + + // Align the time series by returning the minimum value in each alignment + // period. This aligner is valid for `GAUGE` and `DELTA` metrics with + // numeric values. The `value_type` of the aligned result is the same as + // the `value_type` of the input. + ALIGN_MIN = 10; + + // Align the time series by returning the maximum value in each alignment + // period. This aligner is valid for `GAUGE` and `DELTA` metrics with + // numeric values. The `value_type` of the aligned result is the same as + // the `value_type` of the input. + ALIGN_MAX = 11; + + // Align the time series by returning the mean value in each alignment + // period. This aligner is valid for `GAUGE` and `DELTA` metrics with + // numeric values. The `value_type` of the aligned result is `DOUBLE`. + ALIGN_MEAN = 12; + + // Align the time series by returning the number of values in each alignment + // period. This aligner is valid for `GAUGE` and `DELTA` metrics with + // numeric or Boolean values. The `value_type` of the aligned result is + // `INT64`. + ALIGN_COUNT = 13; + + // Align the time series by returning the sum of the values in each + // alignment period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with numeric and distribution values. The `value_type` of the + // aligned result is the same as the `value_type` of the input. + ALIGN_SUM = 14; + + // Align the time series by returning the standard deviation of the values + // in each alignment period. This aligner is valid for `GAUGE` and + // `DELTA` metrics with numeric values. The `value_type` of the output is + // `DOUBLE`. + ALIGN_STDDEV = 15; + + // Align the time series by returning the number of `True` values in + // each alignment period. This aligner is valid for `GAUGE` metrics with + // Boolean values. The `value_type` of the output is `INT64`. + ALIGN_COUNT_TRUE = 16; + + // Align the time series by returning the number of `False` values in + // each alignment period. This aligner is valid for `GAUGE` metrics with + // Boolean values. The `value_type` of the output is `INT64`. + ALIGN_COUNT_FALSE = 24; + + // Align the time series by returning the ratio of the number of `True` + // values to the total number of values in each alignment period. This + // aligner is valid for `GAUGE` metrics with Boolean values. The output + // value is in the range [0.0, 1.0] and has `value_type` `DOUBLE`. + ALIGN_FRACTION_TRUE = 17; + + // Align the time series by using [percentile + // aggregation](https://en.wikipedia.org/wiki/Percentile). The resulting + // data point in each alignment period is the 99th percentile of all data + // points in the period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with distribution values. The output is a `GAUGE` metric with + // `value_type` `DOUBLE`. + ALIGN_PERCENTILE_99 = 18; + + // Align the time series by using [percentile + // aggregation](https://en.wikipedia.org/wiki/Percentile). The resulting + // data point in each alignment period is the 95th percentile of all data + // points in the period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with distribution values. The output is a `GAUGE` metric with + // `value_type` `DOUBLE`. + ALIGN_PERCENTILE_95 = 19; + + // Align the time series by using [percentile + // aggregation](https://en.wikipedia.org/wiki/Percentile). The resulting + // data point in each alignment period is the 50th percentile of all data + // points in the period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with distribution values. The output is a `GAUGE` metric with + // `value_type` `DOUBLE`. + ALIGN_PERCENTILE_50 = 20; + + // Align the time series by using [percentile + // aggregation](https://en.wikipedia.org/wiki/Percentile). The resulting + // data point in each alignment period is the 5th percentile of all data + // points in the period. This aligner is valid for `GAUGE` and `DELTA` + // metrics with distribution values. The output is a `GAUGE` metric with + // `value_type` `DOUBLE`. + ALIGN_PERCENTILE_05 = 21; + + // Align and convert to a percentage change. This aligner is valid for + // `GAUGE` and `DELTA` metrics with numeric values. This alignment returns + // `((current - previous)/previous) * 100`, where the value of `previous` is + // determined based on the `alignment_period`. + // + // If the values of `current` and `previous` are both 0, then the returned + // value is 0. If only `previous` is 0, the returned value is infinity. + // + // A 10-minute moving mean is computed at each point of the alignment period + // prior to the above calculation to smooth the metric and prevent false + // positives from very short-lived spikes. The moving mean is only + // applicable for data whose values are `>= 0`. Any values `< 0` are + // treated as a missing datapoint, and are ignored. While `DELTA` + // metrics are accepted by this alignment, special care should be taken that + // the values for the metric will always be positive. The output is a + // `GAUGE` metric with `value_type` `DOUBLE`. + ALIGN_PERCENT_CHANGE = 23; + } + + // A Reducer operation describes how to aggregate data points from multiple + // time series into a single time series, where the value of each data point + // in the resulting series is a function of all the already aligned values in + // the input time series. + enum Reducer { + // No cross-time series reduction. The output of the `Aligner` is + // returned. + REDUCE_NONE = 0; + + // Reduce by computing the mean value across time series for each + // alignment period. This reducer is valid for + // [DELTA][google.api.MetricDescriptor.MetricKind.DELTA] and + // [GAUGE][google.api.MetricDescriptor.MetricKind.GAUGE] metrics with + // numeric or distribution values. The `value_type` of the output is + // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE]. + REDUCE_MEAN = 1; + + // Reduce by computing the minimum value across time series for each + // alignment period. This reducer is valid for `DELTA` and `GAUGE` metrics + // with numeric values. The `value_type` of the output is the same as the + // `value_type` of the input. + REDUCE_MIN = 2; + + // Reduce by computing the maximum value across time series for each + // alignment period. This reducer is valid for `DELTA` and `GAUGE` metrics + // with numeric values. The `value_type` of the output is the same as the + // `value_type` of the input. + REDUCE_MAX = 3; + + // Reduce by computing the sum across time series for each + // alignment period. This reducer is valid for `DELTA` and `GAUGE` metrics + // with numeric and distribution values. The `value_type` of the output is + // the same as the `value_type` of the input. + REDUCE_SUM = 4; + + // Reduce by computing the standard deviation across time series + // for each alignment period. This reducer is valid for `DELTA` and + // `GAUGE` metrics with numeric or distribution values. The `value_type` + // of the output is `DOUBLE`. + REDUCE_STDDEV = 5; + + // Reduce by computing the number of data points across time series + // for each alignment period. This reducer is valid for `DELTA` and + // `GAUGE` metrics of numeric, Boolean, distribution, and string + // `value_type`. The `value_type` of the output is `INT64`. + REDUCE_COUNT = 6; + + // Reduce by computing the number of `True`-valued data points across time + // series for each alignment period. This reducer is valid for `DELTA` and + // `GAUGE` metrics of Boolean `value_type`. The `value_type` of the output + // is `INT64`. + REDUCE_COUNT_TRUE = 7; + + // Reduce by computing the number of `False`-valued data points across time + // series for each alignment period. This reducer is valid for `DELTA` and + // `GAUGE` metrics of Boolean `value_type`. The `value_type` of the output + // is `INT64`. + REDUCE_COUNT_FALSE = 15; + + // Reduce by computing the ratio of the number of `True`-valued data points + // to the total number of data points for each alignment period. This + // reducer is valid for `DELTA` and `GAUGE` metrics of Boolean `value_type`. + // The output value is in the range [0.0, 1.0] and has `value_type` + // `DOUBLE`. + REDUCE_FRACTION_TRUE = 8; + + // Reduce by computing the [99th + // percentile](https://en.wikipedia.org/wiki/Percentile) of data points + // across time series for each alignment period. This reducer is valid for + // `GAUGE` and `DELTA` metrics of numeric and distribution type. The value + // of the output is `DOUBLE`. + REDUCE_PERCENTILE_99 = 9; + + // Reduce by computing the [95th + // percentile](https://en.wikipedia.org/wiki/Percentile) of data points + // across time series for each alignment period. This reducer is valid for + // `GAUGE` and `DELTA` metrics of numeric and distribution type. The value + // of the output is `DOUBLE`. + REDUCE_PERCENTILE_95 = 10; + + // Reduce by computing the [50th + // percentile](https://en.wikipedia.org/wiki/Percentile) of data points + // across time series for each alignment period. This reducer is valid for + // `GAUGE` and `DELTA` metrics of numeric and distribution type. The value + // of the output is `DOUBLE`. + REDUCE_PERCENTILE_50 = 11; + + // Reduce by computing the [5th + // percentile](https://en.wikipedia.org/wiki/Percentile) of data points + // across time series for each alignment period. This reducer is valid for + // `GAUGE` and `DELTA` metrics of numeric and distribution type. The value + // of the output is `DOUBLE`. + REDUCE_PERCENTILE_05 = 12; + } + + // The `alignment_period` specifies a time interval, in seconds, that is used + // to divide the data in all the + // [time series][google.monitoring.v3.TimeSeries] into consistent blocks of + // time. This will be done before the per-series aligner can be applied to + // the data. + // + // The value must be at least 60 seconds. If a per-series aligner other than + // `ALIGN_NONE` is specified, this field is required or an error is returned. + // If no per-series aligner is specified, or the aligner `ALIGN_NONE` is + // specified, then this field is ignored. + google.protobuf.Duration alignment_period = 1; + + // An `Aligner` describes how to bring the data points in a single + // time series into temporal alignment. Except for `ALIGN_NONE`, all + // alignments cause all the data points in an `alignment_period` to be + // mathematically grouped together, resulting in a single data point for + // each `alignment_period` with end timestamp at the end of the period. + // + // Not all alignment operations may be applied to all time series. The valid + // choices depend on the `metric_kind` and `value_type` of the original time + // series. Alignment can change the `metric_kind` or the `value_type` of + // the time series. + // + // Time series data must be aligned in order to perform cross-time + // series reduction. If `cross_series_reducer` is specified, then + // `per_series_aligner` must be specified and not equal to `ALIGN_NONE` + // and `alignment_period` must be specified; otherwise, an error is + // returned. + Aligner per_series_aligner = 2; + + // The reduction operation to be used to combine time series into a single + // time series, where the value of each data point in the resulting series is + // a function of all the already aligned values in the input time series. + // + // Not all reducer operations can be applied to all time series. The valid + // choices depend on the `metric_kind` and the `value_type` of the original + // time series. Reduction can yield a time series with a different + // `metric_kind` or `value_type` than the input time series. + // + // Time series data must first be aligned (see `per_series_aligner`) in order + // to perform cross-time series reduction. If `cross_series_reducer` is + // specified, then `per_series_aligner` must be specified, and must not be + // `ALIGN_NONE`. An `alignment_period` must also be specified; otherwise, an + // error is returned. + Reducer cross_series_reducer = 4; + + // The set of fields to preserve when `cross_series_reducer` is + // specified. The `group_by_fields` determine how the time series are + // partitioned into subsets prior to applying the aggregation + // operation. Each subset contains time series that have the same + // value for each of the grouping fields. Each individual time + // series is a member of exactly one subset. The + // `cross_series_reducer` is applied to each subset of time series. + // It is not possible to reduce across different resource types, so + // this field implicitly contains `resource.type`. Fields not + // specified in `group_by_fields` are aggregated away. If + // `group_by_fields` is not specified and all the time series have + // the same resource type, then the time series are aggregated into + // a single output time series. If `cross_series_reducer` is not + // defined, this field is ignored. + repeated string group_by_fields = 5; +} + +// Specifies an ordering relationship on two arguments, called `left` and +// `right`. +enum ComparisonType { + // No ordering relationship is specified. + COMPARISON_UNSPECIFIED = 0; + + // True if the left argument is greater than the right argument. + COMPARISON_GT = 1; + + // True if the left argument is greater than or equal to the right argument. + COMPARISON_GE = 2; + + // True if the left argument is less than the right argument. + COMPARISON_LT = 3; + + // True if the left argument is less than or equal to the right argument. + COMPARISON_LE = 4; + + // True if the left argument is equal to the right argument. + COMPARISON_EQ = 5; + + // True if the left argument is not equal to the right argument. + COMPARISON_NE = 6; +} + +// The tier of service for a Workspace. Please see the +// [service tiers +// documentation](https://cloud.google.com/monitoring/workspaces/tiers) for more +// details. +enum ServiceTier { + option deprecated = true; + + // An invalid sentinel value, used to indicate that a tier has not + // been provided explicitly. + SERVICE_TIER_UNSPECIFIED = 0; + + // The Stackdriver Basic tier, a free tier of service that provides basic + // features, a moderate allotment of logs, and access to built-in metrics. + // A number of features are not available in this tier. For more details, + // see [the service tiers + // documentation](https://cloud.google.com/monitoring/workspaces/tiers). + SERVICE_TIER_BASIC = 1; + + // The Stackdriver Premium tier, a higher, more expensive tier of service + // that provides access to all Stackdriver features, lets you use Stackdriver + // with AWS accounts, and has a larger allotments for logs and metrics. For + // more details, see [the service tiers + // documentation](https://cloud.google.com/monitoring/workspaces/tiers). + SERVICE_TIER_PREMIUM = 2; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/dropped_labels.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/dropped_labels.proto.baseline new file mode 100644 index 000000000..9b943ccd0 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/dropped_labels.proto.baseline @@ -0,0 +1,45 @@ +// Copyright 2019 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; + +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 = "DroppedLabelsProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A set of (label, value) pairs which were dropped during aggregation, attached +// to google.api.Distribution.Exemplars in google.api.Distribution values during +// aggregation. +// +// These values are used in combination with the label values that remain on the +// aggregated Distribution timeseries to construct the full label set for the +// exemplar values. The resulting full label set may be used to identify the +// specific task/job/instance (for example) which may be contributing to a +// long-tail, while allowing the storage savings of only storing aggregated +// distribution values for a large group. +// +// Note that there are no guarantees on ordering of the labels from +// exemplar-to-exemplar and from distribution-to-distribution in the same +// stream, and there may be duplicates. It is up to clients to resolve any +// ambiguities. +message DroppedLabels { + // Map from label to its value, for all labels dropped in any aggregation. + map label = 1; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/group.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/group.proto.baseline new file mode 100644 index 000000000..c6428071f --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/group.proto.baseline @@ -0,0 +1,86 @@ +// Copyright 2019 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/resource.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 = "GroupProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The description of a dynamic collection of monitored resources. Each group +// has a filter that is matched against monitored resources and their associated +// metadata. If a group's filter matches an available monitored resource, then +// that resource is a member of that group. Groups can contain any number of +// monitored resources, and each monitored resource can be a member of any +// number of groups. +// +// Groups can be nested in parent-child hierarchies. The `parentName` field +// identifies an optional parent for each group. If a group has a parent, then +// the only monitored resources available to be matched by the group's filter +// are the resources contained in the parent group. In other words, a group +// contains the monitored resources that match its filter and the filters of all +// the group's ancestors. A group without a parent can contain any monitored +// resource. +// +// For example, consider an infrastructure running a set of instances with two +// user-defined tags: `"environment"` and `"role"`. A parent group has a filter, +// `environment="production"`. A child of that parent group has a filter, +// `role="transcoder"`. The parent group contains all instances in the +// production environment, regardless of their roles. The child group contains +// instances that have the transcoder role *and* are in the production +// environment. +// +// The monitored resources contained in a group can change at any moment, +// depending on what resources exist and what filters are associated with the +// group and its ancestors. +message Group { + option (google.api.resource) = { + type: "monitoring.googleapis.com/Group" + pattern: "projects/{project}/groups/{group}" + pattern: "organizations/{organization}/groups/{group}" + pattern: "folders/{folder}/groups/{group}" + pattern: "*" + }; + + // Output only. The name of this group. The format is + // `"projects/{project_id_or_number}/groups/{group_id}"`. + // When creating a group, this field is ignored and a new name is created + // consisting of the project specified in the call to `CreateGroup` + // and a unique `{group_id}` that is generated automatically. + string name = 1; + + // A user-assigned name for this group, used only for display purposes. + string display_name = 2; + + // The name of the group's parent, if it has one. + // The format is `"projects/{project_id_or_number}/groups/{group_id}"`. + // For groups with no parent, `parentName` is the empty string, `""`. + string parent_name = 3; + + // The filter used to determine which monitored resources belong to this + // group. + string filter = 5; + + // If true, the members of this group are considered to be a cluster. + // The system can perform additional analysis on groups that are clusters. + bool is_cluster = 6; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/group_service.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/group_service.proto.baseline new file mode 100644 index 000000000..5647dcfbf --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/group_service.proto.baseline @@ -0,0 +1,273 @@ +// Copyright 2019 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/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/monitoring/v3/common.proto"; +import "google/monitoring/v3/group.proto"; +import "google/protobuf/empty.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 = "GroupServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The Group API lets you inspect and manage your +// [groups](#google.monitoring.v3.Group). +// +// A group is a named filter that is used to identify +// a collection of monitored resources. Groups are typically used to +// mirror the physical and/or logical topology of the environment. +// Because group membership is computed dynamically, monitored +// resources that are started in the future are automatically placed +// in matching groups. By using a group to name monitored resources in, +// for example, an alert policy, the target of that alert policy is +// updated automatically as monitored resources are added and removed +// from the infrastructure. +service GroupService { + 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"; + + // Lists the existing groups. + rpc ListGroups(ListGroupsRequest) returns (ListGroupsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/groups" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single group. + rpc GetGroup(GetGroupRequest) returns (Group) { + option (google.api.http) = { + get: "/v3/{name=projects/*/groups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new group. + rpc CreateGroup(CreateGroupRequest) returns (Group) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/groups" + body: "group" + }; + option (google.api.method_signature) = "name,group"; + } + + // Updates an existing group. + // You can change any group attributes except `name`. + rpc UpdateGroup(UpdateGroupRequest) returns (Group) { + option (google.api.http) = { + put: "/v3/{group.name=projects/*/groups/*}" + body: "group" + }; + option (google.api.method_signature) = "group"; + } + + // Deletes an existing group. + rpc DeleteGroup(DeleteGroupRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/groups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the monitored resources that are members of a group. + rpc ListGroupMembers(ListGroupMembersRequest) returns (ListGroupMembersResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*/groups/*}/members" + }; + option (google.api.method_signature) = "name"; + } +} + +// The `ListGroup` request. +message ListGroupsRequest { + // Required. The project whose groups are to be listed. The format is + // `"projects/{project_id_or_number}"`. + string name = 7 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/Group" + } + ]; + + // An optional filter consisting of a single group name. The filters limit + // the groups returned based on their parent-child relationship with the + // specified group. If no filter is specified, all groups are returned. + oneof filter { + // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + // Returns groups whose `parentName` field contains the group + // name. If no groups have this parent, the results are empty. + string children_of_group = 2 [(google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + }]; + + // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + // Returns groups that are ancestors of the specified group. + // The groups are returned in order, starting with the immediate parent and + // ending with the most distant ancestor. If the specified group has no + // immediate parent, the results are empty. + string ancestors_of_group = 3 [(google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + }]; + + // A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + // Returns the descendants of the specified group. This is a superset of + // the results returned by the `childrenOfGroup` filter, and includes + // children-of-children, and so forth. + string descendants_of_group = 4 [(google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + }]; + } + + // A positive number that is the maximum number of results to return. + int32 page_size = 5; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 6; +} + +// The `ListGroups` response. +message ListGroupsResponse { + // The groups that match the specified filters. + repeated Group group = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The `GetGroup` request. +message GetGroupRequest { + // Required. The group to retrieve. The format is + // `"projects/{project_id_or_number}/groups/{group_id}"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + } + ]; +} + +// The `CreateGroup` request. +message CreateGroupRequest { + // Required. The project in which to create the group. The format is + // `"projects/{project_id_or_number}"`. + string name = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/Group" + } + ]; + + // Required. A group definition. It is an error to define the `name` field because + // the system assigns the name. + Group group = 2 [(google.api.field_behavior) = REQUIRED]; + + // If true, validate this request but do not create the group. + bool validate_only = 3; +} + +// The `UpdateGroup` request. +message UpdateGroupRequest { + // Required. The new definition of the group. All fields of the existing group, + // excepting `name`, are replaced with the corresponding fields of this group. + Group group = 2 [(google.api.field_behavior) = REQUIRED]; + + // If true, validate this request but do not update the existing group. + bool validate_only = 3; +} + +// The `DeleteGroup` request. The default behavior is to be able to delete a +// single group without any descendants. +message DeleteGroupRequest { + // Required. The group to delete. The format is + // `"projects/{project_id_or_number}/groups/{group_id}"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + } + ]; + + // If this field is true, then the request means to delete a group with all + // its descendants. Otherwise, the request means to delete a group only when + // it has no descendants. The default value is false. + bool recursive = 4; +} + +// The `ListGroupMembers` request. +message ListGroupMembersRequest { + // Required. The group whose members are listed. The format is + // `"projects/{project_id_or_number}/groups/{group_id}"`. + string name = 7 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Group" + } + ]; + + // A positive number that is the maximum number of results to return. + int32 page_size = 3; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 4; + + // An optional [list filter](/monitoring/api/learn_more#filtering) describing + // the members to be returned. The filter may reference the type, labels, and + // metadata of monitored resources that comprise the group. + // For example, to return only resources representing Compute Engine VM + // instances, use this filter: + // + // resource.type = "gce_instance" + string filter = 5; + + // An optional time interval for which results should be returned. Only + // members that were part of the group during the specified interval are + // included in the response. If no interval is provided then the group + // membership over the last minute is returned. + TimeInterval interval = 6; +} + +// The `ListGroupMembers` response. +message ListGroupMembersResponse { + // A set of monitored resources in the group. + repeated google.api.MonitoredResource members = 1; + + // If there are more results than have been returned, then this field is + // set to a non-empty value. To see the additional results, use that value as + // `pageToken` in the next call to this method. + string next_page_token = 2; + + // The total number of elements matching this request. + int32 total_size = 3; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/metric.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/metric.proto.baseline new file mode 100644 index 000000000..3c202ed41 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/metric.proto.baseline @@ -0,0 +1,96 @@ +// Copyright 2019 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/distribution.proto"; +import "google/api/label.proto"; +import "google/api/metric.proto"; +import "google/api/monitored_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 = "MetricProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A single data point in a time series. +message Point { + // The time interval to which the data point applies. For `GAUGE` metrics, + // the start time is optional, but if it is supplied, it must equal the + // end time. For `DELTA` metrics, the start + // and end time should specify a non-zero interval, with subsequent points + // specifying contiguous and non-overlapping intervals. For `CUMULATIVE` + // metrics, the start and end time should specify a non-zero interval, with + // subsequent points specifying the same start time and increasing end times, + // until an event resets the cumulative value to zero and sets a new start + // time for the following points. + TimeInterval interval = 1; + + // The value of the data point. + TypedValue value = 2; +} + +// A collection of data points that describes the time-varying values +// of a metric. A time series is identified by a combination of a +// fully-specified monitored resource and a fully-specified metric. +// This type is used for both listing and creating time series. +message TimeSeries { + // The associated metric. A fully-specified metric used to identify the time + // series. + google.api.Metric metric = 1; + + // The associated monitored resource. Custom metrics can use only certain + // monitored resource types in their time series data. + google.api.MonitoredResource resource = 2; + + // Output only. The associated monitored resource metadata. When reading a + // a timeseries, this field will include metadata labels that are explicitly + // named in the reduction. When creating a timeseries, this field is ignored. + google.api.MonitoredResourceMetadata metadata = 7; + + // The metric kind of the time series. When listing time series, this metric + // kind might be different from the metric kind of the associated metric if + // this time series is an alignment or reduction of other time series. + // + // When creating a time series, this field is optional. If present, it must be + // the same as the metric kind of the associated metric. If the associated + // metric's descriptor must be auto-created, then this field specifies the + // metric kind of the new descriptor and must be either `GAUGE` (the default) + // or `CUMULATIVE`. + google.api.MetricDescriptor.MetricKind metric_kind = 3; + + // The value type of the time series. When listing time series, this value + // type might be different from the value type of the associated metric if + // this time series is an alignment or reduction of other time series. + // + // When creating a time series, this field is optional. If present, it must be + // the same as the type of the data in the `points` field. + google.api.MetricDescriptor.ValueType value_type = 4; + + // The data points of this time series. When listing time series, points are + // returned in reverse time order. + // + // When creating a time series, this field must contain exactly one point and + // the point's type must be the same as the value type of the associated + // metric. If the associated metric's descriptor must be auto-created, then + // the value type of the descriptor is determined by the point's type, which + // must be `BOOL`, `INT64`, `DOUBLE`, or `DISTRIBUTION`. + repeated Point points = 5; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/metric_service.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/metric_service.proto.baseline new file mode 100644 index 000000000..d5d2c3343 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/metric_service.proto.baseline @@ -0,0 +1,407 @@ +// Copyright 2019 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/metric.proto"; +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/monitoring/v3/alert.proto"; +import "google/monitoring/v3/common.proto"; +import "google/monitoring/v3/metric.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/rpc/status.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 = "MetricServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; +option (google.api.resource_definition) = { + type: "monitoring.googleapis.com/MetricDescriptor" + pattern: "projects/{project}/metricDescriptors/{metric_descriptor=**}" + pattern: "organizations/{organization}/metricDescriptors/{metric_descriptor=**}" + pattern: "folders/{folder}/metricDescriptors/{metric_descriptor=**}" + pattern: "*" + history: ORIGINALLY_SINGLE_PATTERN +}; +option (google.api.resource_definition) = { + type: "monitoring.googleapis.com/MonitoredResourceDescriptor" + pattern: "projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}" + pattern: "organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor}" + pattern: "folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}" + pattern: "*" + history: ORIGINALLY_SINGLE_PATTERN +}; + +// Manages metric descriptors, monitored resource descriptors, and +// time series data. +service MetricService { + 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," + "https://www.googleapis.com/auth/monitoring.write"; + + // Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. + rpc ListMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest) returns (ListMonitoredResourceDescriptorsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/monitoredResourceDescriptors" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single monitored resource descriptor. This method does not require a Stackdriver account. + rpc GetMonitoredResourceDescriptor(GetMonitoredResourceDescriptorRequest) returns (google.api.MonitoredResourceDescriptor) { + option (google.api.http) = { + get: "/v3/{name=projects/*/monitoredResourceDescriptors/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists metric descriptors that match a filter. This method does not require a Stackdriver account. + rpc ListMetricDescriptors(ListMetricDescriptorsRequest) returns (ListMetricDescriptorsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/metricDescriptors" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single metric descriptor. This method does not require a Stackdriver account. + rpc GetMetricDescriptor(GetMetricDescriptorRequest) returns (google.api.MetricDescriptor) { + option (google.api.http) = { + get: "/v3/{name=projects/*/metricDescriptors/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new metric descriptor. + // User-created metric descriptors define + // [custom metrics](/monitoring/custom-metrics). + rpc CreateMetricDescriptor(CreateMetricDescriptorRequest) returns (google.api.MetricDescriptor) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/metricDescriptors" + body: "metric_descriptor" + }; + option (google.api.method_signature) = "name,metric_descriptor"; + } + + // Deletes a metric descriptor. Only user-created + // [custom metrics](/monitoring/custom-metrics) can be deleted. + rpc DeleteMetricDescriptor(DeleteMetricDescriptorRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/metricDescriptors/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists time series that match a filter. This method does not require a Stackdriver account. + rpc ListTimeSeries(ListTimeSeriesRequest) returns (ListTimeSeriesResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/timeSeries" + }; + option (google.api.method_signature) = "name,filter,interval,view"; + } + + // Creates or adds data to one or more time series. + // The response is empty if all time series in the request were written. + // If any time series could not be written, a corresponding failure message is + // included in the error response. + rpc CreateTimeSeries(CreateTimeSeriesRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/timeSeries" + body: "*" + }; + option (google.api.method_signature) = "name,time_series"; + } +} + +// The `ListMonitoredResourceDescriptors` request. +message ListMonitoredResourceDescriptorsRequest { + // Required. The project on which to execute the request. The format is + // `"projects/{project_id_or_number}"`. + string name = 5 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/MonitoredResourceDescriptor" + } + ]; + + // An optional [filter](/monitoring/api/v3/filters) describing + // the descriptors to be returned. The filter can reference + // the descriptor's type and labels. For example, the + // following filter returns only Google Compute Engine descriptors + // that have an `id` label: + // + // resource.type = starts_with("gce_") AND resource.label:id + string filter = 2; + + // A positive number that is the maximum number of results to return. + int32 page_size = 3; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 4; +} + +// The `ListMonitoredResourceDescriptors` response. +message ListMonitoredResourceDescriptorsResponse { + // The monitored resource descriptors that are available to this project + // and that match `filter`, if present. + repeated google.api.MonitoredResourceDescriptor resource_descriptors = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The `GetMonitoredResourceDescriptor` request. +message GetMonitoredResourceDescriptorRequest { + // Required. The monitored resource descriptor to get. The format is + // `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`. + // The `{resource_type}` is a predefined type, such as + // `cloudsql_database`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/MonitoredResourceDescriptor" + } + ]; +} + +// The `ListMetricDescriptors` request. +message ListMetricDescriptorsRequest { + // Required. The project on which to execute the request. The format is + // `"projects/{project_id_or_number}"`. + string name = 5 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/MetricDescriptor" + } + ]; + + // If this field is empty, all custom and + // system-defined metric descriptors are returned. + // Otherwise, the [filter](/monitoring/api/v3/filters) + // specifies which metric descriptors are to be + // returned. For example, the following filter matches all + // [custom metrics](/monitoring/custom-metrics): + // + // metric.type = starts_with("custom.googleapis.com/") + string filter = 2; + + // A positive number that is the maximum number of results to return. + int32 page_size = 3; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 4; +} + +// The `ListMetricDescriptors` response. +message ListMetricDescriptorsResponse { + // The metric descriptors that are available to the project + // and that match the value of `filter`, if present. + repeated google.api.MetricDescriptor metric_descriptors = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The `GetMetricDescriptor` request. +message GetMetricDescriptorRequest { + // Required. The metric descriptor on which to execute the request. The format is + // `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + // An example value of `{metric_id}` is + // `"compute.googleapis.com/instance/disk/read_bytes_count"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/MetricDescriptor" + } + ]; +} + +// The `CreateMetricDescriptor` request. +message CreateMetricDescriptorRequest { + // Required. The project on which to execute the request. The format is + // `"projects/{project_id_or_number}"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/MetricDescriptor" + } + ]; + + // Required. The new [custom metric](/monitoring/custom-metrics) + // descriptor. + google.api.MetricDescriptor metric_descriptor = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The `DeleteMetricDescriptor` request. +message DeleteMetricDescriptorRequest { + // Required. The metric descriptor on which to execute the request. The format is + // `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + // An example of `{metric_id}` is: + // `"custom.googleapis.com/my_test_metric"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/MetricDescriptor" + } + ]; +} + +// The `ListTimeSeries` request. +message ListTimeSeriesRequest { + // Controls which fields are returned by `ListTimeSeries`. + enum TimeSeriesView { + // Returns the identity of the metric(s), the time series, + // and the time series data. + FULL = 0; + + // Returns the identity of the metric and the time series resource, + // but not the time series data. + HEADERS = 1; + } + + // Required. The project on which to execute the request. The format is + // "projects/{project_id_or_number}". + string name = 10 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/TimeSeries" + } + ]; + + // Required. A [monitoring filter](/monitoring/api/v3/filters) that specifies which time + // series should be returned. The filter must specify a single metric type, + // and can additionally specify metric labels and other information. For + // example: + // + // metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + // metric.labels.instance_name = "my-instance-name" + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The time interval for which results should be returned. Only time series + // that contain data points in the specified interval are included + // in the response. + TimeInterval interval = 4 [(google.api.field_behavior) = REQUIRED]; + + // Specifies the alignment of data points in individual time series as + // well as how to combine the retrieved time series across specified labels. + // + // By default (if no `aggregation` is explicitly specified), the raw time + // series data is returned. + Aggregation aggregation = 5; + + // Unsupported: must be left blank. The points in each time series are + // currently returned in reverse time order (most recent to oldest). + string order_by = 6; + + // Required. Specifies which information is returned about the time series. + TimeSeriesView view = 7 [(google.api.field_behavior) = REQUIRED]; + + // A positive number that is the maximum number of results to return. If + // `page_size` is empty or more than 100,000 results, the effective + // `page_size` is 100,000 results. If `view` is set to `FULL`, this is the + // maximum number of `Points` returned. If `view` is set to `HEADERS`, this is + // the maximum number of `TimeSeries` returned. + int32 page_size = 8; + + // If this field is not empty then it must contain the `nextPageToken` value + // returned by a previous call to this method. Using this field causes the + // method to return additional results from the previous method call. + string page_token = 9; +} + +// The `ListTimeSeries` response. +message ListTimeSeriesResponse { + // One or more time series that match the filter included in the request. + repeated TimeSeries time_series = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; + + // Query execution errors that may have caused the time series data returned + // to be incomplete. + repeated google.rpc.Status execution_errors = 3; +} + +// The `CreateTimeSeries` request. +message CreateTimeSeriesRequest { + // Required. The project on which to execute the request. The format is + // `"projects/{project_id_or_number}"`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/TimeSeries" + } + ]; + + // Required. The new data to be added to a list of time series. + // Adds at most one data point to each of several time series. The new data + // point must be more recent than any other point in its time series. Each + // `TimeSeries` value must fully specify a unique time series by supplying + // all label values for the metric and the monitored resource. + // + // The maximum number of `TimeSeries` objects per `Create` request is 200. + repeated TimeSeries time_series = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// DEPRECATED. Used to hold per-time-series error status. +message CreateTimeSeriesError { + // DEPRECATED. Time series ID that resulted in the `status` error. + TimeSeries time_series = 1 [deprecated = true]; + + // DEPRECATED. The status of the requested write operation for `time_series`. + google.rpc.Status status = 2 [deprecated = true]; +} + +// Summary of the result of a failed request to write data to a time series. +message CreateTimeSeriesSummary { + // Detailed information about an error category. + message Error { + // The status of the requested write operation. + google.rpc.Status status = 1; + + // The number of points that couldn't be written because of `status`. + int32 point_count = 2; + } + + // The number of points in the request. + int32 total_point_count = 1; + + // The number of points that were successfully written. + int32 success_point_count = 2; + + // The number of points that failed to be written. Order is not guaranteed. + repeated Error errors = 3; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/mutation_record.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/mutation_record.proto.baseline new file mode 100644 index 000000000..eab1f37d2 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/mutation_record.proto.baseline @@ -0,0 +1,36 @@ +// Copyright 2019 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/protobuf/timestamp.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 = "MutationRecordProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// Describes a change made to a configuration. +message MutationRecord { + // When the change occurred. + google.protobuf.Timestamp mutate_time = 1; + + // The email address of the user making the change. + string mutated_by = 2; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/notification.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/notification.proto.baseline new file mode 100644 index 000000000..fb3ef4625 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/notification.proto.baseline @@ -0,0 +1,183 @@ +// Copyright 2019 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/label.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/monitoring/v3/common.proto"; +import "google/protobuf/wrappers.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 = "NotificationProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A description of a notification channel. The descriptor includes +// the properties of the channel and the set of labels or fields that +// must be specified to configure channels of a given type. +message NotificationChannelDescriptor { + option (google.api.resource) = { + type: "monitoring.googleapis.com/NotificationChannelDescriptor" + pattern: "projects/{project}/notificationChannelDescriptors/{channel_descriptor}" + pattern: "organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}" + pattern: "folders/{folder}/notificationChannelDescriptors/{channel_descriptor}" + pattern: "*" + }; + + // The full REST resource name for this descriptor. The syntax is: + // + // projects/[PROJECT_ID]/notificationChannelDescriptors/[TYPE] + // + // In the above, `[TYPE]` is the value of the `type` field. + string name = 6; + + // The type of notification channel, such as "email", "sms", etc. + // Notification channel types are globally unique. + string type = 1; + + // A human-readable name for the notification channel type. This + // form of the name is suitable for a user interface. + string display_name = 2; + + // A human-readable description of the notification channel + // type. The description may include a description of the properties + // of the channel and pointers to external documentation. + string description = 3; + + // The set of labels that must be defined to identify a particular + // channel of the corresponding type. Each label includes a + // description for how that field should be populated. + repeated google.api.LabelDescriptor labels = 4; + + // The tiers that support this notification channel; the project service tier + // must be one of the supported_tiers. + repeated ServiceTier supported_tiers = 5 [deprecated = true]; + + // The product launch stage for channels of this type. + google.api.LaunchStage launch_stage = 7; +} + +// A `NotificationChannel` is a medium through which an alert is +// delivered when a policy violation is detected. Examples of channels +// include email, SMS, and third-party messaging applications. Fields +// containing sensitive information like authentication tokens or +// contact info are only partially populated on retrieval. +message NotificationChannel { + option (google.api.resource) = { + type: "monitoring.googleapis.com/NotificationChannel" + pattern: "projects/{project}/notificationChannels/{notification_channel}" + pattern: "organizations/{organization}/notificationChannels/{notification_channel}" + pattern: "folders/{folder}/notificationChannels/{notification_channel}" + pattern: "*" + }; + + // Indicates whether the channel has been verified or not. It is illegal + // to specify this field in a + // [`CreateNotificationChannel`][google.monitoring.v3.NotificationChannelService.CreateNotificationChannel] + // or an + // [`UpdateNotificationChannel`][google.monitoring.v3.NotificationChannelService.UpdateNotificationChannel] + // operation. + enum VerificationStatus { + // Sentinel value used to indicate that the state is unknown, omitted, or + // is not applicable (as in the case of channels that neither support + // nor require verification in order to function). + VERIFICATION_STATUS_UNSPECIFIED = 0; + + // The channel has yet to be verified and requires verification to function. + // Note that this state also applies to the case where the verification + // process has been initiated by sending a verification code but where + // the verification code has not been submitted to complete the process. + UNVERIFIED = 1; + + // It has been proven that notifications can be received on this + // notification channel and that someone on the project has access + // to messages that are delivered to that channel. + VERIFIED = 2; + } + + // The type of the notification channel. This field matches the + // value of the [NotificationChannelDescriptor.type][google.monitoring.v3.NotificationChannelDescriptor.type] field. + string type = 1; + + // The full REST resource name for this channel. The syntax is: + // + // projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID] + // + // The `[CHANNEL_ID]` is automatically assigned by the server on creation. + string name = 6; + + // An optional human-readable name for this notification channel. It is + // recommended that you specify a non-empty and unique name in order to + // make it easier to identify the channels in your project, though this is + // not enforced. The display name is limited to 512 Unicode characters. + string display_name = 3; + + // An optional human-readable description of this notification channel. This + // description may provide additional details, beyond the display + // name, for the channel. This may not exceed 1024 Unicode characters. + string description = 4; + + // Configuration fields that define the channel and its behavior. The + // permissible and required labels are specified in the + // [NotificationChannelDescriptor.labels][google.monitoring.v3.NotificationChannelDescriptor.labels] of the + // `NotificationChannelDescriptor` corresponding to the `type` field. + map labels = 5; + + // User-supplied key/value data that does not need to conform to + // the corresponding `NotificationChannelDescriptor`'s schema, unlike + // the `labels` field. This field is intended to be used for organizing + // and identifying the `NotificationChannel` objects. + // + // The field can contain up to 64 entries. Each key and value is limited to + // 63 Unicode characters or 128 bytes, whichever is smaller. Labels and + // values can contain only lowercase letters, numerals, underscores, and + // dashes. Keys must begin with a letter. + map user_labels = 8; + + // Indicates whether this channel has been verified or not. On a + // [`ListNotificationChannels`][google.monitoring.v3.NotificationChannelService.ListNotificationChannels] + // or + // [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] + // operation, this field is expected to be populated. + // + // If the value is `UNVERIFIED`, then it indicates that the channel is + // non-functioning (it both requires verification and lacks verification); + // otherwise, it is assumed that the channel works. + // + // If the channel is neither `VERIFIED` nor `UNVERIFIED`, it implies that + // the channel is of a type that does not require verification or that + // this specific channel has been exempted from verification because it was + // created prior to verification being required for channels of this type. + // + // This field cannot be modified using a standard + // [`UpdateNotificationChannel`][google.monitoring.v3.NotificationChannelService.UpdateNotificationChannel] + // operation. To change the value of this field, you must call + // [`VerifyNotificationChannel`][google.monitoring.v3.NotificationChannelService.VerifyNotificationChannel]. + VerificationStatus verification_status = 9; + + // Whether notifications are forwarded to the described channel. This makes + // it possible to disable delivery of notifications to a particular channel + // without removing the channel from all alerting policies that reference + // the channel. This is a more convenient approach when the change is + // temporary and you want to receive notifications from the same set + // of alerting policies on the channel at some point in the future. + google.protobuf.BoolValue enabled = 11; +} diff --git a/typescript/test/testdata/monitoring/protos/google/monitoring/v3/notification_service.proto.baseline b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/notification_service.proto.baseline new file mode 100644 index 000000000..959cc0496 --- /dev/null +++ b/typescript/test/testdata/monitoring/protos/google/monitoring/v3/notification_service.proto.baseline @@ -0,0 +1,401 @@ +// Copyright 2019 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/notification.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.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 = "NotificationServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The Notification Channel API provides access to configuration that +// controls how messages related to incidents are sent. +service NotificationChannelService { + 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"; + + // Lists the descriptors for supported channel types. The use of descriptors + // makes it possible for new channel types to be dynamically added. + rpc ListNotificationChannelDescriptors(ListNotificationChannelDescriptorsRequest) returns (ListNotificationChannelDescriptorsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/notificationChannelDescriptors" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single channel descriptor. The descriptor indicates which fields + // are expected / permitted for a notification channel of the given type. + rpc GetNotificationChannelDescriptor(GetNotificationChannelDescriptorRequest) returns (NotificationChannelDescriptor) { + option (google.api.http) = { + get: "/v3/{name=projects/*/notificationChannelDescriptors/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the notification channels that have been created for the project. + rpc ListNotificationChannels(ListNotificationChannelsRequest) returns (ListNotificationChannelsResponse) { + option (google.api.http) = { + get: "/v3/{name=projects/*}/notificationChannels" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a single notification channel. The channel includes the relevant + // configuration details with which the channel was created. However, the + // response may truncate or omit passwords, API keys, or other private key + // matter and thus the response may not be 100% identical to the information + // that was supplied in the call to the create method. + rpc GetNotificationChannel(GetNotificationChannelRequest) returns (NotificationChannel) { + option (google.api.http) = { + get: "/v3/{name=projects/*/notificationChannels/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new notification channel, representing a single notification + // endpoint such as an email address, SMS number, or PagerDuty service. + rpc CreateNotificationChannel(CreateNotificationChannelRequest) returns (NotificationChannel) { + option (google.api.http) = { + post: "/v3/{name=projects/*}/notificationChannels" + body: "notification_channel" + }; + option (google.api.method_signature) = "name,notification_channel"; + } + + // Updates a notification channel. Fields not specified in the field mask + // remain unchanged. + rpc UpdateNotificationChannel(UpdateNotificationChannelRequest) returns (NotificationChannel) { + option (google.api.http) = { + patch: "/v3/{notification_channel.name=projects/*/notificationChannels/*}" + body: "notification_channel" + }; + option (google.api.method_signature) = "update_mask,notification_channel"; + } + + // Deletes a notification channel. + rpc DeleteNotificationChannel(DeleteNotificationChannelRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=projects/*/notificationChannels/*}" + }; + option (google.api.method_signature) = "name,force"; + } + + // Causes a verification code to be delivered to the channel. The code + // can then be supplied in `VerifyNotificationChannel` to verify the channel. + rpc SendNotificationChannelVerificationCode(SendNotificationChannelVerificationCodeRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v3/{name=projects/*/notificationChannels/*}:sendVerificationCode" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Requests a verification code for an already verified channel that can then + // be used in a call to VerifyNotificationChannel() on a different channel + // with an equivalent identity in the same or in a different project. This + // makes it possible to copy a channel between projects without requiring + // manual reverification of the channel. If the channel is not in the + // verified state, this method will fail (in other words, this may only be + // used if the SendNotificationChannelVerificationCode and + // VerifyNotificationChannel paths have already been used to put the given + // channel into the verified state). + // + // There is no guarantee that the verification codes returned by this method + // will be of a similar structure or form as the ones that are delivered + // to the channel via SendNotificationChannelVerificationCode; while + // VerifyNotificationChannel() will recognize both the codes delivered via + // SendNotificationChannelVerificationCode() and returned from + // GetNotificationChannelVerificationCode(), it is typically the case that + // the verification codes delivered via + // SendNotificationChannelVerificationCode() will be shorter and also + // have a shorter expiration (e.g. codes such as "G-123456") whereas + // GetVerificationCode() will typically return a much longer, websafe base + // 64 encoded string that has a longer expiration time. + rpc GetNotificationChannelVerificationCode(GetNotificationChannelVerificationCodeRequest) returns (GetNotificationChannelVerificationCodeResponse) { + option (google.api.http) = { + post: "/v3/{name=projects/*/notificationChannels/*}:getVerificationCode" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Verifies a `NotificationChannel` by proving receipt of the code + // delivered to the channel as a result of calling + // `SendNotificationChannelVerificationCode`. + rpc VerifyNotificationChannel(VerifyNotificationChannelRequest) returns (NotificationChannel) { + option (google.api.http) = { + post: "/v3/{name=projects/*/notificationChannels/*}:verify" + body: "*" + }; + option (google.api.method_signature) = "name,code"; + } +} + +// The `ListNotificationChannelDescriptors` request. +message ListNotificationChannelDescriptorsRequest { + // Required. The REST resource name of the parent from which to retrieve + // the notification channel descriptors. The expected syntax is: + // + // projects/[PROJECT_ID] + // + // Note that this names the parent container in which to look for the + // descriptors; to retrieve a single descriptor by name, use the + // [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] + // operation, instead. + string name = 4 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/NotificationChannelDescriptor" + } + ]; + + // The maximum number of results to return in a single response. If + // not set to a positive number, a reasonable value will be chosen by the + // service. + int32 page_size = 2; + + // If non-empty, `page_token` must contain a value returned as the + // `next_page_token` in a previous response to request the next set + // of results. + string page_token = 3; +} + +// The `ListNotificationChannelDescriptors` response. +message ListNotificationChannelDescriptorsResponse { + // The monitored resource descriptors supported for the specified + // project, optionally filtered. + repeated NotificationChannelDescriptor channel_descriptors = 1; + + // If not empty, indicates that there may be more results that match + // the request. Use the value in the `page_token` field in a + // subsequent request to fetch the next set of results. If empty, + // all results have been returned. + string next_page_token = 2; +} + +// The `GetNotificationChannelDescriptor` response. +message GetNotificationChannelDescriptorRequest { + // Required. The channel type for which to execute the request. The format is + // `projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannelDescriptor" + } + ]; +} + +// The `CreateNotificationChannel` request. +message CreateNotificationChannelRequest { + // Required. The project on which to execute the request. The format is: + // + // projects/[PROJECT_ID] + // + // Note that this names the container into which the channel will be + // written. This does not name the newly created channel. The resulting + // channel's name will have a normalized version of this field as a prefix, + // but will add `/notificationChannels/[CHANNEL_ID]` to identify the channel. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // Required. The definition of the `NotificationChannel` to create. + NotificationChannel notification_channel = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The `ListNotificationChannels` request. +message ListNotificationChannelsRequest { + // Required. The project on which to execute the request. The format is + // `projects/[PROJECT_ID]`. That is, this names the container + // in which to look for the notification channels; it does not name a + // specific channel. To query a specific channel by REST resource name, use + // the + // [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] + // operation. + string name = 5 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // If provided, this field specifies the criteria that must be met by + // notification channels to be included in the response. + // + // For more details, see [sorting and + // filtering](/monitoring/api/v3/sorting-and-filtering). + string filter = 6; + + // A comma-separated list of fields by which to sort the result. Supports + // the same set of fields as in `filter`. Entries can be prefixed with + // a minus sign to sort in descending rather than ascending order. + // + // For more details, see [sorting and + // filtering](/monitoring/api/v3/sorting-and-filtering). + string order_by = 7; + + // The maximum number of results to return in a single response. If + // not set to a positive number, a reasonable value will be chosen by the + // service. + int32 page_size = 3; + + // If non-empty, `page_token` must contain a value returned as the + // `next_page_token` in a previous response to request the next set + // of results. + string page_token = 4; +} + +// The `ListNotificationChannels` response. +message ListNotificationChannelsResponse { + // The notification channels defined for the specified project. + repeated NotificationChannel notification_channels = 3; + + // If not empty, indicates that there may be more results that match + // the request. Use the value in the `page_token` field in a + // subsequent request to fetch the next set of results. If empty, + // all results have been returned. + string next_page_token = 2; +} + +// The `GetNotificationChannel` request. +message GetNotificationChannelRequest { + // Required. The channel for which to execute the request. The format is + // `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; +} + +// The `UpdateNotificationChannel` request. +message UpdateNotificationChannelRequest { + // The fields to update. + google.protobuf.FieldMask update_mask = 2; + + // Required. A description of the changes to be applied to the specified + // notification channel. The description must provide a definition for + // fields to be updated; the names of these fields should also be + // included in the `update_mask`. + NotificationChannel notification_channel = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The `DeleteNotificationChannel` request. +message DeleteNotificationChannelRequest { + // Required. The channel for which to execute the request. The format is + // `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. + string name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // If true, the notification channel will be deleted regardless of its + // use in alert policies (the policies will be updated to remove the + // channel). If false, channels that are still referenced by an existing + // alerting policy will fail to be deleted in a delete operation. + bool force = 5; +} + +// The `SendNotificationChannelVerificationCode` request. +message SendNotificationChannelVerificationCodeRequest { + // Required. The notification channel to which to send a verification code. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; +} + +// The `GetNotificationChannelVerificationCode` request. +message GetNotificationChannelVerificationCodeRequest { + // Required. The notification channel for which a verification code is to be generated + // and retrieved. This must name a channel that is already verified; if + // the specified channel is not verified, the request will fail. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // The desired expiration time. If specified, the API will guarantee that + // the returned code will not be valid after the specified timestamp; + // however, the API cannot guarantee that the returned code will be + // valid for at least as long as the requested time (the API puts an upper + // bound on the amount of time for which a code may be valid). If omitted, + // a default expiration will be used, which may be less than the max + // permissible expiration (so specifying an expiration may extend the + // code's lifetime over omitting an expiration, even though the API does + // impose an upper limit on the maximum expiration that is permitted). + google.protobuf.Timestamp expire_time = 2; +} + +// The `GetNotificationChannelVerificationCode` request. +message GetNotificationChannelVerificationCodeResponse { + // The verification code, which may be used to verify other channels + // that have an equivalent identity (i.e. other channels of the same + // type with the same fingerprint such as other email channels with + // the same email address or other sms channels with the same number). + string code = 1; + + // The expiration time associated with the code that was returned. If + // an expiration was provided in the request, this is the minimum of the + // requested expiration in the request and the max permitted expiration. + google.protobuf.Timestamp expire_time = 2; +} + +// The `VerifyNotificationChannel` request. +message VerifyNotificationChannelRequest { + // Required. The notification channel to verify. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/NotificationChannel" + } + ]; + + // Required. The verification code that was delivered to the channel as + // a result of invoking the `SendNotificationChannelVerificationCode` API + // method or that was retrieved from a verified channel via + // `GetNotificationChannelVerificationCode`. For example, one might have + // "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only + // guaranteed that the code is valid UTF-8; one should not + // make any assumptions regarding the structure or format of the code). + string code = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/typescript/test/testdata/monitoring/src/index.ts.baseline b/typescript/test/testdata/monitoring/src/index.ts.baseline index 7e05abce5..cf6f9adf2 100644 --- a/typescript/test/testdata/monitoring/src/index.ts.baseline +++ b/typescript/test/testdata/monitoring/src/index.ts.baseline @@ -17,9 +17,13 @@ // ** All changes to this file may be overwritten. ** import * as v3 from './v3'; +const AlertPolicyServiceClient = v3.AlertPolicyServiceClient; +const GroupServiceClient = v3.GroupServiceClient; +const MetricServiceClient = v3.MetricServiceClient; +const NotificationChannelServiceClient = v3.NotificationChannelServiceClient; const ServiceMonitoringServiceClient = v3.ServiceMonitoringServiceClient; const UptimeCheckServiceClient = v3.UptimeCheckServiceClient; -export {v3, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; +export {v3, AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; // For compatibility with JavaScript libraries we need to provide this default export: // tslint:disable-next-line no-default-export -export default {v3, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; +export default {v3, AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline new file mode 100644 index 000000000..50053e1e6 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline @@ -0,0 +1,1588 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './alert_policy_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The AlertPolicyService API is used to manage (list, create, delete, + * edit) alert policies in Stackdriver Monitoring. An alerting policy is + * a description of the conditions under which some aspect of your + * system is considered to be "unhealthy" and the ways to notify + * people or services about this state. In addition to using this API, alert + * policies can also be managed through + * [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), + * which can be reached by clicking the "Monitoring" tab in + * [Cloud Console](https://console.cloud.google.com/). + * @class + * @memberof v3 + */ +export class AlertPolicyServiceClient { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + auth: gax.GoogleAuth; + alertPolicyServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of AlertPolicyServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof AlertPolicyServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof AlertPolicyServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listAlertPolicies: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'alertPolicies') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.AlertPolicyService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.AlertPolicyService. + this.alertPolicyServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.AlertPolicyService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.AlertPolicyService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const alertPolicyServiceStubMethods = + ['listAlertPolicies', 'getAlertPolicy', 'createAlertPolicy', 'deleteAlertPolicy', 'updateAlertPolicy']; + + for (const methodName of alertPolicyServiceStubMethods) { + const innerCallPromise = this.alertPolicyServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + return apiCall(argument, callOptions, callback); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getAlertPolicy( + request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined + ]>; + getAlertPolicy( + request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, + {}|undefined>): void; +/** + * Gets a single alerting policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The alerting policy to retrieve. The format is + * + * projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getAlertPolicy( + request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.getAlertPolicy(request, options, callback); + } + createAlertPolicy( + request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined + ]>; + createAlertPolicy( + request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, + {}|undefined>): void; +/** + * Creates a new alerting policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project in which to create the alerting policy. The format is + * `projects/[PROJECT_ID]`. + * + * Note that this field names the parent container in which the alerting + * policy will be written, not the name of the created policy. The alerting + * policy that is returned will have a name that contains a normalized + * representation of this name as a prefix but adds a suffix of the form + * `/alertPolicies/[POLICY_ID]`, identifying the policy in the container. + * @param {google.monitoring.v3.AlertPolicy} request.alertPolicy + * Required. The requested alerting policy. You should omit the `name` field in this + * policy. The name will be returned in the new policy, including + * a new [ALERT_POLICY_ID] value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createAlertPolicy( + request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.createAlertPolicy(request, options, callback); + } + deleteAlertPolicy( + request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined + ]>; + deleteAlertPolicy( + request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, + {}|undefined>): void; +/** + * Deletes an alerting policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The alerting policy to delete. The format is: + * + * projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + * + * For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteAlertPolicy( + request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.deleteAlertPolicy(request, options, callback); + } + updateAlertPolicy( + request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined + ]>; + updateAlertPolicy( + request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, + {}|undefined>): void; +/** + * Updates an alerting policy. You can either replace the entire policy with + * a new one or replace only certain fields in the current alerting policy by + * specifying the fields to be updated via `updateMask`. Returns the + * updated alerting policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Optional. A list of alerting policy field names. If this field is not + * empty, each listed field in the existing alerting policy is set to the + * value of the corresponding field in the supplied policy (`alert_policy`), + * or to the field's default value if the field is not in the supplied + * alerting policy. Fields not listed retain their previous value. + * + * Examples of valid field masks include `display_name`, `documentation`, + * `documentation.content`, `documentation.mime_type`, `user_labels`, + * `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc. + * + * If this field is empty, then the supplied alerting policy replaces the + * existing policy. It is the same as deleting the existing policy and + * adding the supplied policy, except for the following: + * + * + The new policy will have the same `[ALERT_POLICY_ID]` as the former + * policy. This gives you continuity with the former policy in your + * notifications and incidents. + * + Conditions in the new policy will keep their former `[CONDITION_ID]` if + * the supplied condition includes the `name` field with that + * `[CONDITION_ID]`. If the supplied condition omits the `name` field, + * then a new `[CONDITION_ID]` is created. + * @param {google.monitoring.v3.AlertPolicy} request.alertPolicy + * Required. The updated alerting policy or the updated values for the + * fields listed in `update_mask`. + * If `update_mask` is not empty, any fields in this policy that are + * not in `update_mask` are ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateAlertPolicy( + request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'alert_policy.name': request.alertPolicy!.name || '', + }); + return this._innerApiCalls.updateAlertPolicy(request, options, callback); + } + + listAlertPolicies( + request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + ]>; + listAlertPolicies( + request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse>): void; +/** + * Lists the existing alerting policies for the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project whose alert policies are to be listed. The format is + * + * projects/[PROJECT_ID] + * + * Note that this field names the parent container in which the alerting + * policies to be listed are stored. To retrieve a single alerting policy + * by name, use the + * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy] + * operation, instead. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by + * alert policies to be included in the response. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {string} request.orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of field references as the `filter` field. Entries can be + * prefixed with a minus sign to sort by the field in descending order. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {number} request.pageSize + * The maximum number of results to return in a single response. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return more results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [AlertPolicy]{@link google.monitoring.v3.AlertPolicy} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListAlertPoliciesRequest]{@link google.monitoring.v3.ListAlertPoliciesRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListAlertPoliciesResponse]{@link google.monitoring.v3.ListAlertPoliciesResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listAlertPolicies( + request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse>): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.listAlertPolicies(request, options, callback); + } + +/** + * Equivalent to {@link listAlertPolicies}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listAlertPolicies} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project whose alert policies are to be listed. The format is + * + * projects/[PROJECT_ID] + * + * Note that this field names the parent container in which the alerting + * policies to be listed are stored. To retrieve a single alerting policy + * by name, use the + * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy] + * operation, instead. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by + * alert policies to be included in the response. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {string} request.orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of field references as the `filter` field. Entries can be + * prefixed with a minus sign to sort by the field in descending order. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {number} request.pageSize + * The maximum number of results to return in a single response. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return more results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy} on 'data' event. + */ + listAlertPoliciesStream( + request?: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listAlertPolicies.createStream( + this._innerApiCalls.listAlertPolicies as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.alertPolicyServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline new file mode 100644 index 000000000..5c3935f3c --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.monitoring.v3.AlertPolicyService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListAlertPolicies": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAlertPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateAlertPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteAlertPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateAlertPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline new file mode 100644 index 000000000..0534dc6a0 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline @@ -0,0 +1,18 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/dropped_labels.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/span_context.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline new file mode 100644 index 000000000..f2a3bc7cb --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline @@ -0,0 +1,1711 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './group_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Group API lets you inspect and manage your + * [groups](#google.monitoring.v3.Group). + * + * A group is a named filter that is used to identify + * a collection of monitored resources. Groups are typically used to + * mirror the physical and/or logical topology of the environment. + * Because group membership is computed dynamically, monitored + * resources that are started in the future are automatically placed + * in matching groups. By using a group to name monitored resources in, + * for example, an alert policy, the target of that alert policy is + * updated automatically as monitored resources are added and removed + * from the infrastructure. + * @class + * @memberof v3 + */ +export class GroupServiceClient { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + auth: gax.GoogleAuth; + groupServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GroupServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof GroupServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof GroupServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listGroups: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'group'), + listGroupMembers: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'members') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.GroupService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.GroupService. + this.groupServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.GroupService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.GroupService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const groupServiceStubMethods = + ['listGroups', 'getGroup', 'createGroup', 'updateGroup', 'deleteGroup', 'listGroupMembers']; + + for (const methodName of groupServiceStubMethods) { + const innerCallPromise = this.groupServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + return apiCall(argument, callOptions, callback); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getGroup( + request: protosTypes.google.monitoring.v3.IGetGroupRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined + ]>; + getGroup( + request: protosTypes.google.monitoring.v3.IGetGroupRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, + {}|undefined>): void; +/** + * Gets a single group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The group to retrieve. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getGroup( + request: protosTypes.google.monitoring.v3.IGetGroupRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.getGroup(request, options, callback); + } + createGroup( + request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined + ]>; + createGroup( + request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, + {}|undefined>): void; +/** + * Creates a new group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project in which to create the group. The format is + * `"projects/{project_id_or_number}"`. + * @param {google.monitoring.v3.Group} request.group + * Required. A group definition. It is an error to define the `name` field because + * the system assigns the name. + * @param {boolean} request.validateOnly + * If true, validate this request but do not create the group. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createGroup( + request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.createGroup(request, options, callback); + } + updateGroup( + request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined + ]>; + updateGroup( + request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, + {}|undefined>): void; +/** + * Updates an existing group. + * You can change any group attributes except `name`. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.monitoring.v3.Group} request.group + * Required. The new definition of the group. All fields of the existing group, + * excepting `name`, are replaced with the corresponding fields of this group. + * @param {boolean} request.validateOnly + * If true, validate this request but do not update the existing group. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateGroup( + request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'group.name': request.group!.name || '', + }); + return this._innerApiCalls.updateGroup(request, options, callback); + } + deleteGroup( + request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined + ]>; + deleteGroup( + request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, + {}|undefined>): void; +/** + * Deletes an existing group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The group to delete. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {boolean} request.recursive + * If this field is true, then the request means to delete a group with all + * its descendants. Otherwise, the request means to delete a group only when + * it has no descendants. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteGroup( + request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.deleteGroup(request, options, callback); + } + + listGroups( + request: protosTypes.google.monitoring.v3.IListGroupsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse + ]>; + listGroups( + request: protosTypes.google.monitoring.v3.IListGroupsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse>): void; +/** + * Lists the existing groups. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project whose groups are to be listed. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.childrenOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups whose `parentName` field contains the group + * name. If no groups have this parent, the results are empty. + * @param {string} request.ancestorsOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups that are ancestors of the specified group. + * The groups are returned in order, starting with the immediate parent and + * ending with the most distant ancestor. If the specified group has no + * immediate parent, the results are empty. + * @param {string} request.descendantsOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns the descendants of the specified group. This is a superset of + * the results returned by the `childrenOfGroup` filter, and includes + * children-of-children, and so forth. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Group]{@link google.monitoring.v3.Group}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Group]{@link google.monitoring.v3.Group} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListGroupsRequest]{@link google.monitoring.v3.ListGroupsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListGroupsResponse]{@link google.monitoring.v3.ListGroupsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listGroups( + request: protosTypes.google.monitoring.v3.IListGroupsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse>): + Promise<[ + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.listGroups(request, options, callback); + } + +/** + * Equivalent to {@link listGroups}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listGroups} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project whose groups are to be listed. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.childrenOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups whose `parentName` field contains the group + * name. If no groups have this parent, the results are empty. + * @param {string} request.ancestorsOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups that are ancestors of the specified group. + * The groups are returned in order, starting with the immediate parent and + * ending with the most distant ancestor. If the specified group has no + * immediate parent, the results are empty. + * @param {string} request.descendantsOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns the descendants of the specified group. This is a superset of + * the results returned by the `childrenOfGroup` filter, and includes + * children-of-children, and so forth. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Group]{@link google.monitoring.v3.Group} on 'data' event. + */ + listGroupsStream( + request?: protosTypes.google.monitoring.v3.IListGroupsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listGroups.createStream( + this._innerApiCalls.listGroups as gax.GaxCall, + request, + callSettings + ); + } + listGroupMembers( + request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse + ]>; + listGroupMembers( + request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse>): void; +/** + * Lists the monitored resources that are members of a group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The group whose members are listed. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {string} request.filter + * An optional [list filter](/monitoring/api/learn_more#filtering) describing + * the members to be returned. The filter may reference the type, labels, and + * metadata of monitored resources that comprise the group. + * For example, to return only resources representing Compute Engine VM + * instances, use this filter: + * + * resource.type = "gce_instance" + * @param {google.monitoring.v3.TimeInterval} request.interval + * An optional time interval for which results should be returned. Only + * members that were part of the group during the specified interval are + * included in the response. If no interval is provided then the group + * membership over the last minute is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [MonitoredResource]{@link google.api.MonitoredResource}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [MonitoredResource]{@link google.api.MonitoredResource} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListGroupMembersRequest]{@link google.monitoring.v3.ListGroupMembersRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListGroupMembersResponse]{@link google.monitoring.v3.ListGroupMembersResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listGroupMembers( + request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse>, + callback?: Callback< + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse>): + Promise<[ + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.listGroupMembers(request, options, callback); + } + +/** + * Equivalent to {@link listGroupMembers}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listGroupMembers} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The group whose members are listed. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {string} request.filter + * An optional [list filter](/monitoring/api/learn_more#filtering) describing + * the members to be returned. The filter may reference the type, labels, and + * metadata of monitored resources that comprise the group. + * For example, to return only resources representing Compute Engine VM + * instances, use this filter: + * + * resource.type = "gce_instance" + * @param {google.monitoring.v3.TimeInterval} request.interval + * An optional time interval for which results should be returned. Only + * members that were part of the group during the specified interval are + * included in the response. If no interval is provided then the group + * membership over the last minute is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [MonitoredResource]{@link google.api.MonitoredResource} on 'data' event. + */ + listGroupMembersStream( + request?: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listGroupMembers.createStream( + this._innerApiCalls.listGroupMembers as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.groupServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline new file mode 100644 index 000000000..e63f2afe3 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.monitoring.v3.GroupService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListGroups": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetGroup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateGroup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateGroup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteGroup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListGroupMembers": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline new file mode 100644 index 000000000..0534dc6a0 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline @@ -0,0 +1,18 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/dropped_labels.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/span_context.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/index.ts.baseline b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline index ac6b0b979..bb9e596d2 100644 --- a/typescript/test/testdata/monitoring/src/v3/index.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {ServiceMonitoringServiceClient} from './service_monitoring_service_client';export {UptimeCheckServiceClient} from './uptime_check_service_client'; +export {AlertPolicyServiceClient} from './alert_policy_service_client';export {GroupServiceClient} from './group_service_client';export {MetricServiceClient} from './metric_service_client';export {NotificationChannelServiceClient} from './notification_channel_service_client';export {ServiceMonitoringServiceClient} from './service_monitoring_service_client';export {UptimeCheckServiceClient} from './uptime_check_service_client'; diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline new file mode 100644 index 000000000..188e12a2c --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline @@ -0,0 +1,2172 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './metric_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Manages metric descriptors, monitored resource descriptors, and + * time series data. + * @class + * @memberof v3 + */ +export class MetricServiceClient { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + auth: gax.GoogleAuth; + metricServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of MetricServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof MetricServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof MetricServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + folderMetricDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/metricDescriptors/{metric_descriptor=**}' + ), + folderMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + organizationMetricDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/metricDescriptors/{metric_descriptor=**}' + ), + organizationMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + projectMetricDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/metricDescriptors/{metric_descriptor=**}' + ), + projectMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listMonitoredResourceDescriptors: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resourceDescriptors'), + listMetricDescriptors: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'metricDescriptors'), + listTimeSeries: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'timeSeries') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.MetricService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.MetricService. + this.metricServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.MetricService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.MetricService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const metricServiceStubMethods = + ['listMonitoredResourceDescriptors', 'getMonitoredResourceDescriptor', 'listMetricDescriptors', 'getMetricDescriptor', 'createMetricDescriptor', 'deleteMetricDescriptor', 'listTimeSeries', 'createTimeSeries']; + + for (const methodName of metricServiceStubMethods) { + const innerCallPromise = this.metricServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + return apiCall(argument, callOptions, callback); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getMonitoredResourceDescriptor( + request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined + ]>; + getMonitoredResourceDescriptor( + request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Gets a single monitored resource descriptor. This method does not require a Stackdriver account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The monitored resource descriptor to get. The format is + * `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`. + * The `{resource_type}` is a predefined type, such as + * `cloudsql_database`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getMonitoredResourceDescriptor( + request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.getMonitoredResourceDescriptor(request, options, callback); + } + getMetricDescriptor( + request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined + ]>; + getMetricDescriptor( + request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Gets a single metric descriptor. This method does not require a Stackdriver account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The metric descriptor on which to execute the request. The format is + * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + * An example value of `{metric_id}` is + * `"compute.googleapis.com/instance/disk/read_bytes_count"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [MetricDescriptor]{@link google.api.MetricDescriptor}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getMetricDescriptor( + request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.getMetricDescriptor(request, options, callback); + } + createMetricDescriptor( + request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined + ]>; + createMetricDescriptor( + request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Creates a new metric descriptor. + * User-created metric descriptors define + * [custom metrics](/monitoring/custom-metrics). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {google.api.MetricDescriptor} request.metricDescriptor + * Required. The new [custom metric](/monitoring/custom-metrics) + * descriptor. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [MetricDescriptor]{@link google.api.MetricDescriptor}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createMetricDescriptor( + request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.createMetricDescriptor(request, options, callback); + } + deleteMetricDescriptor( + request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined + ]>; + deleteMetricDescriptor( + request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Deletes a metric descriptor. Only user-created + * [custom metrics](/monitoring/custom-metrics) can be deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The metric descriptor on which to execute the request. The format is + * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + * An example of `{metric_id}` is: + * `"custom.googleapis.com/my_test_metric"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteMetricDescriptor( + request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.deleteMetricDescriptor(request, options, callback); + } + createTimeSeries( + request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined + ]>; + createTimeSeries( + request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, + {}|undefined>): void; +/** + * Creates or adds data to one or more time series. + * The response is empty if all time series in the request were written. + * If any time series could not be written, a corresponding failure message is + * included in the error response. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {number[]} request.timeSeries + * Required. The new data to be added to a list of time series. + * Adds at most one data point to each of several time series. The new data + * point must be more recent than any other point in its time series. Each + * `TimeSeries` value must fully specify a unique time series by supplying + * all label values for the metric and the monitored resource. + * + * The maximum number of `TimeSeries` objects per `Create` request is 200. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createTimeSeries( + request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.createTimeSeries(request, options, callback); + } + + listMonitoredResourceDescriptors( + request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + ]>; + listMonitoredResourceDescriptors( + request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>): void; +/** + * Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.filter + * An optional [filter](/monitoring/api/v3/filters) describing + * the descriptors to be returned. The filter can reference + * the descriptor's type and labels. For example, the + * following filter returns only Google Compute Engine descriptors + * that have an `id` label: + * + * resource.type = starts_with("gce_") AND resource.label:id + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListMonitoredResourceDescriptorsRequest]{@link google.monitoring.v3.ListMonitoredResourceDescriptorsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListMonitoredResourceDescriptorsResponse]{@link google.monitoring.v3.ListMonitoredResourceDescriptorsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listMonitoredResourceDescriptors( + request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>, + callback?: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.listMonitoredResourceDescriptors(request, options, callback); + } + +/** + * Equivalent to {@link listMonitoredResourceDescriptors}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listMonitoredResourceDescriptors} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.filter + * An optional [filter](/monitoring/api/v3/filters) describing + * the descriptors to be returned. The filter can reference + * the descriptor's type and labels. For example, the + * following filter returns only Google Compute Engine descriptors + * that have an `id` label: + * + * resource.type = starts_with("gce_") AND resource.label:id + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} on 'data' event. + */ + listMonitoredResourceDescriptorsStream( + request?: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listMonitoredResourceDescriptors.createStream( + this._innerApiCalls.listMonitoredResourceDescriptors as gax.GaxCall, + request, + callSettings + ); + } + listMetricDescriptors( + request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + ]>; + listMetricDescriptors( + request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>): void; +/** + * Lists metric descriptors that match a filter. This method does not require a Stackdriver account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.filter + * If this field is empty, all custom and + * system-defined metric descriptors are returned. + * Otherwise, the [filter](/monitoring/api/v3/filters) + * specifies which metric descriptors are to be + * returned. For example, the following filter matches all + * [custom metrics](/monitoring/custom-metrics): + * + * metric.type = starts_with("custom.googleapis.com/") + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [MetricDescriptor]{@link google.api.MetricDescriptor}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [MetricDescriptor]{@link google.api.MetricDescriptor} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListMetricDescriptorsRequest]{@link google.monitoring.v3.ListMetricDescriptorsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListMetricDescriptorsResponse]{@link google.monitoring.v3.ListMetricDescriptorsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listMetricDescriptors( + request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>, + callback?: Callback< + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>): + Promise<[ + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.listMetricDescriptors(request, options, callback); + } + +/** + * Equivalent to {@link listMetricDescriptors}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listMetricDescriptors} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.filter + * If this field is empty, all custom and + * system-defined metric descriptors are returned. + * Otherwise, the [filter](/monitoring/api/v3/filters) + * specifies which metric descriptors are to be + * returned. For example, the following filter matches all + * [custom metrics](/monitoring/custom-metrics): + * + * metric.type = starts_with("custom.googleapis.com/") + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [MetricDescriptor]{@link google.api.MetricDescriptor} on 'data' event. + */ + listMetricDescriptorsStream( + request?: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listMetricDescriptors.createStream( + this._innerApiCalls.listMetricDescriptors as gax.GaxCall, + request, + callSettings + ); + } + listTimeSeries( + request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse + ]>; + listTimeSeries( + request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse>): void; +/** + * Lists time series that match a filter. This method does not require a Stackdriver account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * "projects/{project_id_or_number}". + * @param {string} request.filter + * Required. A [monitoring filter](/monitoring/api/v3/filters) that specifies which time + * series should be returned. The filter must specify a single metric type, + * and can additionally specify metric labels and other information. For + * example: + * + * metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + * metric.labels.instance_name = "my-instance-name" + * @param {google.monitoring.v3.TimeInterval} request.interval + * Required. The time interval for which results should be returned. Only time series + * that contain data points in the specified interval are included + * in the response. + * @param {google.monitoring.v3.Aggregation} request.aggregation + * Specifies the alignment of data points in individual time series as + * well as how to combine the retrieved time series across specified labels. + * + * By default (if no `aggregation` is explicitly specified), the raw time + * series data is returned. + * @param {string} request.orderBy + * Unsupported: must be left blank. The points in each time series are + * currently returned in reverse time order (most recent to oldest). + * @param {google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView} request.view + * Required. Specifies which information is returned about the time series. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. If + * `page_size` is empty or more than 100,000 results, the effective + * `page_size` is 100,000 results. If `view` is set to `FULL`, this is the + * maximum number of `Points` returned. If `view` is set to `HEADERS`, this is + * the maximum number of `TimeSeries` returned. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListTimeSeriesRequest]{@link google.monitoring.v3.ListTimeSeriesRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListTimeSeriesResponse]{@link google.monitoring.v3.ListTimeSeriesResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listTimeSeries( + request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse>): + Promise<[ + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.listTimeSeries(request, options, callback); + } + +/** + * Equivalent to {@link listTimeSeries}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listTimeSeries} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * "projects/{project_id_or_number}". + * @param {string} request.filter + * Required. A [monitoring filter](/monitoring/api/v3/filters) that specifies which time + * series should be returned. The filter must specify a single metric type, + * and can additionally specify metric labels and other information. For + * example: + * + * metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + * metric.labels.instance_name = "my-instance-name" + * @param {google.monitoring.v3.TimeInterval} request.interval + * Required. The time interval for which results should be returned. Only time series + * that contain data points in the specified interval are included + * in the response. + * @param {google.monitoring.v3.Aggregation} request.aggregation + * Specifies the alignment of data points in individual time series as + * well as how to combine the retrieved time series across specified labels. + * + * By default (if no `aggregation` is explicitly specified), the raw time + * series data is returned. + * @param {string} request.orderBy + * Unsupported: must be left blank. The points in each time series are + * currently returned in reverse time order (most recent to oldest). + * @param {google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView} request.view + * Required. Specifies which information is returned about the time series. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. If + * `page_size` is empty or more than 100,000 results, the effective + * `page_size` is 100,000 results. If `view` is set to `FULL`, this is the + * maximum number of `Points` returned. If `view` is set to `HEADERS`, this is + * the maximum number of `TimeSeries` returned. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [TimeSeries]{@link google.monitoring.v3.TimeSeries} on 'data' event. + */ + listTimeSeriesStream( + request?: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listTimeSeries.createStream( + this._innerApiCalls.listTimeSeries as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified folderMetricDescriptor resource name string. + * + * @param {string} folder + * @param {string} metric_descriptor + * @returns {string} Resource name string. + */ + folderMetricDescriptorPath(folder:string,metricDescriptor:string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.render({ + folder: folder, + metric_descriptor: metricDescriptor, + }); + } + + /** + * Parse the folder from FolderMetricDescriptor resource. + * + * @param {string} folderMetricDescriptorName + * A fully-qualified path representing folder_metric_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).folder; + } + + /** + * Parse the metric_descriptor from FolderMetricDescriptor resource. + * + * @param {string} folderMetricDescriptorName + * A fully-qualified path representing folder_metric_descriptor resource. + * @returns {string} A string representing the metric_descriptor. + */ + matchMetricDescriptorFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).metric_descriptor; + } + + /** + * Return a fully-qualified folderMonitoredResourceDescriptor resource name string. + * + * @param {string} folder + * @param {string} monitored_resource_descriptor + * @returns {string} Resource name string. + */ + folderMonitoredResourceDescriptorPath(folder:string,monitoredResourceDescriptor:string) { + return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.render({ + folder: folder, + monitored_resource_descriptor: monitoredResourceDescriptor, + }); + } + + /** + * Parse the folder from FolderMonitoredResourceDescriptor resource. + * + * @param {string} folderMonitoredResourceDescriptorName + * A fully-qualified path representing folder_monitored_resource_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderMonitoredResourceDescriptorName(folderMonitoredResourceDescriptorName: string) { + return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match(folderMonitoredResourceDescriptorName).folder; + } + + /** + * Parse the monitored_resource_descriptor from FolderMonitoredResourceDescriptor resource. + * + * @param {string} folderMonitoredResourceDescriptorName + * A fully-qualified path representing folder_monitored_resource_descriptor resource. + * @returns {string} A string representing the monitored_resource_descriptor. + */ + matchMonitoredResourceDescriptorFromFolderMonitoredResourceDescriptorName(folderMonitoredResourceDescriptorName: string) { + return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match(folderMonitoredResourceDescriptorName).monitored_resource_descriptor; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified organizationMetricDescriptor resource name string. + * + * @param {string} organization + * @param {string} metric_descriptor + * @returns {string} Resource name string. + */ + organizationMetricDescriptorPath(organization:string,metricDescriptor:string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.render({ + organization: organization, + metric_descriptor: metricDescriptor, + }); + } + + /** + * Parse the organization from OrganizationMetricDescriptor resource. + * + * @param {string} organizationMetricDescriptorName + * A fully-qualified path representing organization_metric_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).organization; + } + + /** + * Parse the metric_descriptor from OrganizationMetricDescriptor resource. + * + * @param {string} organizationMetricDescriptorName + * A fully-qualified path representing organization_metric_descriptor resource. + * @returns {string} A string representing the metric_descriptor. + */ + matchMetricDescriptorFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).metric_descriptor; + } + + /** + * Return a fully-qualified organizationMonitoredResourceDescriptor resource name string. + * + * @param {string} organization + * @param {string} monitored_resource_descriptor + * @returns {string} Resource name string. + */ + organizationMonitoredResourceDescriptorPath(organization:string,monitoredResourceDescriptor:string) { + return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.render({ + organization: organization, + monitored_resource_descriptor: monitoredResourceDescriptor, + }); + } + + /** + * Parse the organization from OrganizationMonitoredResourceDescriptor resource. + * + * @param {string} organizationMonitoredResourceDescriptorName + * A fully-qualified path representing organization_monitored_resource_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationMonitoredResourceDescriptorName(organizationMonitoredResourceDescriptorName: string) { + return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match(organizationMonitoredResourceDescriptorName).organization; + } + + /** + * Parse the monitored_resource_descriptor from OrganizationMonitoredResourceDescriptor resource. + * + * @param {string} organizationMonitoredResourceDescriptorName + * A fully-qualified path representing organization_monitored_resource_descriptor resource. + * @returns {string} A string representing the monitored_resource_descriptor. + */ + matchMonitoredResourceDescriptorFromOrganizationMonitoredResourceDescriptorName(organizationMonitoredResourceDescriptorName: string) { + return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match(organizationMonitoredResourceDescriptorName).monitored_resource_descriptor; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified projectMetricDescriptor resource name string. + * + * @param {string} project + * @param {string} metric_descriptor + * @returns {string} Resource name string. + */ + projectMetricDescriptorPath(project:string,metricDescriptor:string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.render({ + project: project, + metric_descriptor: metricDescriptor, + }); + } + + /** + * Parse the project from ProjectMetricDescriptor resource. + * + * @param {string} projectMetricDescriptorName + * A fully-qualified path representing project_metric_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).project; + } + + /** + * Parse the metric_descriptor from ProjectMetricDescriptor resource. + * + * @param {string} projectMetricDescriptorName + * A fully-qualified path representing project_metric_descriptor resource. + * @returns {string} A string representing the metric_descriptor. + */ + matchMetricDescriptorFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).metric_descriptor; + } + + /** + * Return a fully-qualified projectMonitoredResourceDescriptor resource name string. + * + * @param {string} project + * @param {string} monitored_resource_descriptor + * @returns {string} Resource name string. + */ + projectMonitoredResourceDescriptorPath(project:string,monitoredResourceDescriptor:string) { + return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.render({ + project: project, + monitored_resource_descriptor: monitoredResourceDescriptor, + }); + } + + /** + * Parse the project from ProjectMonitoredResourceDescriptor resource. + * + * @param {string} projectMonitoredResourceDescriptorName + * A fully-qualified path representing project_monitored_resource_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectMonitoredResourceDescriptorName(projectMonitoredResourceDescriptorName: string) { + return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match(projectMonitoredResourceDescriptorName).project; + } + + /** + * Parse the monitored_resource_descriptor from ProjectMonitoredResourceDescriptor resource. + * + * @param {string} projectMonitoredResourceDescriptorName + * A fully-qualified path representing project_monitored_resource_descriptor resource. + * @returns {string} A string representing the monitored_resource_descriptor. + */ + matchMonitoredResourceDescriptorFromProjectMonitoredResourceDescriptorName(projectMonitoredResourceDescriptorName: string) { + return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match(projectMonitoredResourceDescriptorName).monitored_resource_descriptor; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.metricServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline new file mode 100644 index 000000000..c1826e96c --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.monitoring.v3.MetricService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListMonitoredResourceDescriptors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetMonitoredResourceDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListMetricDescriptors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetMetricDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateMetricDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteMetricDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListTimeSeries": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateTimeSeries": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline new file mode 100644 index 000000000..0534dc6a0 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline @@ -0,0 +1,18 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/dropped_labels.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/span_context.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline new file mode 100644 index 000000000..44ad80442 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline @@ -0,0 +1,1996 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './notification_channel_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Notification Channel API provides access to configuration that + * controls how messages related to incidents are sent. + * @class + * @memberof v3 + */ +export class NotificationChannelServiceClient { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + auth: gax.GoogleAuth; + notificationChannelServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NotificationChannelServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof NotificationChannelServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof NotificationChannelServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listNotificationChannelDescriptors: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'channelDescriptors'), + listNotificationChannels: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'notificationChannels') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.NotificationChannelService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.NotificationChannelService. + this.notificationChannelServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.NotificationChannelService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.NotificationChannelService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const notificationChannelServiceStubMethods = + ['listNotificationChannelDescriptors', 'getNotificationChannelDescriptor', 'listNotificationChannels', 'getNotificationChannel', 'createNotificationChannel', 'updateNotificationChannel', 'deleteNotificationChannel', 'sendNotificationChannelVerificationCode', 'getNotificationChannelVerificationCode', 'verifyNotificationChannel']; + + for (const methodName of notificationChannelServiceStubMethods) { + const innerCallPromise = this.notificationChannelServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + return apiCall(argument, callOptions, callback); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getNotificationChannelDescriptor( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined + ]>; + getNotificationChannelDescriptor( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Gets a single channel descriptor. The descriptor indicates which fields + * are expected / permitted for a notification channel of the given type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The channel type for which to execute the request. The format is + * `projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getNotificationChannelDescriptor( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.getNotificationChannelDescriptor(request, options, callback); + } + getNotificationChannel( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined + ]>; + getNotificationChannel( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Gets a single notification channel. The channel includes the relevant + * configuration details with which the channel was created. However, the + * response may truncate or omit passwords, API keys, or other private key + * matter and thus the response may not be 100% identical to the information + * that was supplied in the call to the create method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The channel for which to execute the request. The format is + * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getNotificationChannel( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.getNotificationChannel(request, options, callback); + } + createNotificationChannel( + request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined + ]>; + createNotificationChannel( + request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Creates a new notification channel, representing a single notification + * endpoint such as an email address, SMS number, or PagerDuty service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is: + * + * projects/[PROJECT_ID] + * + * Note that this names the container into which the channel will be + * written. This does not name the newly created channel. The resulting + * channel's name will have a normalized version of this field as a prefix, + * but will add `/notificationChannels/[CHANNEL_ID]` to identify the channel. + * @param {google.monitoring.v3.NotificationChannel} request.notificationChannel + * Required. The definition of the `NotificationChannel` to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createNotificationChannel( + request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.createNotificationChannel(request, options, callback); + } + updateNotificationChannel( + request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined + ]>; + updateNotificationChannel( + request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Updates a notification channel. Fields not specified in the field mask + * remain unchanged. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * The fields to update. + * @param {google.monitoring.v3.NotificationChannel} request.notificationChannel + * Required. A description of the changes to be applied to the specified + * notification channel. The description must provide a definition for + * fields to be updated; the names of these fields should also be + * included in the `update_mask`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateNotificationChannel( + request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'notification_channel.name': request.notificationChannel!.name || '', + }); + return this._innerApiCalls.updateNotificationChannel(request, options, callback); + } + deleteNotificationChannel( + request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined + ]>; + deleteNotificationChannel( + request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Deletes a notification channel. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The channel for which to execute the request. The format is + * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. + * @param {boolean} request.force + * If true, the notification channel will be deleted regardless of its + * use in alert policies (the policies will be updated to remove the + * channel). If false, channels that are still referenced by an existing + * alerting policy will fail to be deleted in a delete operation. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteNotificationChannel( + request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.deleteNotificationChannel(request, options, callback); + } + sendNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined + ]>; + sendNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, + {}|undefined>): void; +/** + * Causes a verification code to be delivered to the channel. The code + * can then be supplied in `VerifyNotificationChannel` to verify the channel. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The notification channel to which to send a verification code. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + sendNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.sendNotificationChannelVerificationCode(request, options, callback); + } + getNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined + ]>; + getNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, + {}|undefined>): void; +/** + * Requests a verification code for an already verified channel that can then + * be used in a call to VerifyNotificationChannel() on a different channel + * with an equivalent identity in the same or in a different project. This + * makes it possible to copy a channel between projects without requiring + * manual reverification of the channel. If the channel is not in the + * verified state, this method will fail (in other words, this may only be + * used if the SendNotificationChannelVerificationCode and + * VerifyNotificationChannel paths have already been used to put the given + * channel into the verified state). + * + * There is no guarantee that the verification codes returned by this method + * will be of a similar structure or form as the ones that are delivered + * to the channel via SendNotificationChannelVerificationCode; while + * VerifyNotificationChannel() will recognize both the codes delivered via + * SendNotificationChannelVerificationCode() and returned from + * GetNotificationChannelVerificationCode(), it is typically the case that + * the verification codes delivered via + * SendNotificationChannelVerificationCode() will be shorter and also + * have a shorter expiration (e.g. codes such as "G-123456") whereas + * GetVerificationCode() will typically return a much longer, websafe base + * 64 encoded string that has a longer expiration time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The notification channel for which a verification code is to be generated + * and retrieved. This must name a channel that is already verified; if + * the specified channel is not verified, the request will fail. + * @param {google.protobuf.Timestamp} request.expireTime + * The desired expiration time. If specified, the API will guarantee that + * the returned code will not be valid after the specified timestamp; + * however, the API cannot guarantee that the returned code will be + * valid for at least as long as the requested time (the API puts an upper + * bound on the amount of time for which a code may be valid). If omitted, + * a default expiration will be used, which may be less than the max + * permissible expiration (so specifying an expiration may extend the + * code's lifetime over omitting an expiration, even though the API does + * impose an upper limit on the maximum expiration that is permitted). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetNotificationChannelVerificationCodeResponse]{@link google.monitoring.v3.GetNotificationChannelVerificationCodeResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.getNotificationChannelVerificationCode(request, options, callback); + } + verifyNotificationChannel( + request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined + ]>; + verifyNotificationChannel( + request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Verifies a `NotificationChannel` by proving receipt of the code + * delivered to the channel as a result of calling + * `SendNotificationChannelVerificationCode`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The notification channel to verify. + * @param {string} request.code + * Required. The verification code that was delivered to the channel as + * a result of invoking the `SendNotificationChannelVerificationCode` API + * method or that was retrieved from a verified channel via + * `GetNotificationChannelVerificationCode`. For example, one might have + * "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only + * guaranteed that the code is valid UTF-8; one should not + * make any assumptions regarding the structure or format of the code). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + verifyNotificationChannel( + request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.verifyNotificationChannel(request, options, callback); + } + + listNotificationChannelDescriptors( + request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + ]>; + listNotificationChannelDescriptors( + request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse>): void; +/** + * Lists the descriptors for supported channel types. The use of descriptors + * makes it possible for new channel types to be dynamically added. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The REST resource name of the parent from which to retrieve + * the notification channel descriptors. The expected syntax is: + * + * projects/[PROJECT_ID] + * + * Note that this names the parent container in which to look for the + * descriptors; to retrieve a single descriptor by name, use the + * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] + * operation, instead. + * @param {number} request.pageSize + * The maximum number of results to return in a single response. If + * not set to a positive number, a reasonable value will be chosen by the + * service. + * @param {string} request.pageToken + * If non-empty, `page_token` must contain a value returned as the + * `next_page_token` in a previous response to request the next set + * of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListNotificationChannelDescriptorsRequest]{@link google.monitoring.v3.ListNotificationChannelDescriptorsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListNotificationChannelDescriptorsResponse]{@link google.monitoring.v3.ListNotificationChannelDescriptorsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listNotificationChannelDescriptors( + request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.listNotificationChannelDescriptors(request, options, callback); + } + +/** + * Equivalent to {@link listNotificationChannelDescriptors}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listNotificationChannelDescriptors} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The REST resource name of the parent from which to retrieve + * the notification channel descriptors. The expected syntax is: + * + * projects/[PROJECT_ID] + * + * Note that this names the parent container in which to look for the + * descriptors; to retrieve a single descriptor by name, use the + * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] + * operation, instead. + * @param {number} request.pageSize + * The maximum number of results to return in a single response. If + * not set to a positive number, a reasonable value will be chosen by the + * service. + * @param {string} request.pageToken + * If non-empty, `page_token` must contain a value returned as the + * `next_page_token` in a previous response to request the next set + * of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor} on 'data' event. + */ + listNotificationChannelDescriptorsStream( + request?: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listNotificationChannelDescriptors.createStream( + this._innerApiCalls.listNotificationChannelDescriptors as gax.GaxCall, + request, + callSettings + ); + } + listNotificationChannels( + request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + ]>; + listNotificationChannels( + request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse>): void; +/** + * Lists the notification channels that have been created for the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `projects/[PROJECT_ID]`. That is, this names the container + * in which to look for the notification channels; it does not name a + * specific channel. To query a specific channel by REST resource name, use + * the + * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] + * operation. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by + * notification channels to be included in the response. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {string} request.orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of fields as in `filter`. Entries can be prefixed with + * a minus sign to sort in descending rather than ascending order. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {number} request.pageSize + * The maximum number of results to return in a single response. If + * not set to a positive number, a reasonable value will be chosen by the + * service. + * @param {string} request.pageToken + * If non-empty, `page_token` must contain a value returned as the + * `next_page_token` in a previous response to request the next set + * of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [NotificationChannel]{@link google.monitoring.v3.NotificationChannel} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListNotificationChannelsRequest]{@link google.monitoring.v3.ListNotificationChannelsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListNotificationChannelsResponse]{@link google.monitoring.v3.ListNotificationChannelsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listNotificationChannels( + request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.listNotificationChannels(request, options, callback); + } + +/** + * Equivalent to {@link listNotificationChannels}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listNotificationChannels} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `projects/[PROJECT_ID]`. That is, this names the container + * in which to look for the notification channels; it does not name a + * specific channel. To query a specific channel by REST resource name, use + * the + * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] + * operation. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by + * notification channels to be included in the response. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {string} request.orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of fields as in `filter`. Entries can be prefixed with + * a minus sign to sort in descending rather than ascending order. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {number} request.pageSize + * The maximum number of results to return in a single response. If + * not set to a positive number, a reasonable value will be chosen by the + * service. + * @param {string} request.pageToken + * If non-empty, `page_token` must contain a value returned as the + * `next_page_token` in a previous response to request the next set + * of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel} on 'data' event. + */ + listNotificationChannelsStream( + request?: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + options?: gax.CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listNotificationChannels.createStream( + this._innerApiCalls.listNotificationChannels as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.notificationChannelServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline new file mode 100644 index 000000000..781b3f0a6 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.monitoring.v3.NotificationChannelService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListNotificationChannelDescriptors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNotificationChannelDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNotificationChannels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SendNotificationChannelVerificationCode": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNotificationChannelVerificationCode": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "VerifyNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline new file mode 100644 index 000000000..0534dc6a0 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline @@ -0,0 +1,18 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/dropped_labels.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/span_context.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline index 203119e41..476e65efe 100644 --- a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline @@ -134,6 +134,18 @@ export class ServiceMonitoringServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), folderServicePathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/services/{service}' ), @@ -143,6 +155,18 @@ export class ServiceMonitoringServiceClient { folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), organizationServicePathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/services/{service}' ), @@ -152,6 +176,18 @@ export class ServiceMonitoringServiceClient { organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' ), + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), projectServicePathTemplate: new gaxModule.PathTemplate( 'projects/{project}/services/{service}' ), @@ -1101,6 +1137,150 @@ export class ServiceMonitoringServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + /** * Return a fully-qualified folderService resource name string. * @@ -1222,6 +1402,150 @@ export class ServiceMonitoringServiceClient { return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; } + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + /** * Return a fully-qualified organizationService resource name string. * @@ -1343,6 +1667,150 @@ export class ServiceMonitoringServiceClient { return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; } + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + /** * Return a fully-qualified projectService resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline index dae706a8f..0534dc6a0 100644 --- a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline @@ -1,4 +1,15 @@ [ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/dropped_labels.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", "../../protos/google/monitoring/v3/service.proto", "../../protos/google/monitoring/v3/service_service.proto", "../../protos/google/monitoring/v3/span_context.proto", diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline index ce46659fd..4ef8be091 100644 --- a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline @@ -138,6 +138,18 @@ export class UptimeCheckServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), folderServicePathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/services/{service}' ), @@ -147,6 +159,18 @@ export class UptimeCheckServiceClient { folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), organizationServicePathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/services/{service}' ), @@ -156,6 +180,18 @@ export class UptimeCheckServiceClient { organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' ), + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), projectServicePathTemplate: new gaxModule.PathTemplate( 'projects/{project}/services/{service}' ), @@ -809,6 +845,150 @@ export class UptimeCheckServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + /** * Return a fully-qualified folderService resource name string. * @@ -930,6 +1110,150 @@ export class UptimeCheckServiceClient { return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; } + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + /** * Return a fully-qualified organizationService resource name string. * @@ -1051,6 +1375,150 @@ export class UptimeCheckServiceClient { return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; } + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + /** * Return a fully-qualified projectService resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline index dae706a8f..0534dc6a0 100644 --- a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline @@ -1,4 +1,15 @@ [ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/dropped_labels.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", "../../protos/google/monitoring/v3/service.proto", "../../protos/google/monitoring/v3/service_service.proto", "../../protos/google/monitoring/v3/span_context.proto", diff --git a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline index 5cf88f5bf..7b3918c1b 100644 --- a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline +++ b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline @@ -21,6 +21,10 @@ const monitoring = require('monitoring'); function main() { + const alertPolicyServiceClient = new monitoring.AlertPolicyServiceClient(); + const groupServiceClient = new monitoring.GroupServiceClient(); + const metricServiceClient = new monitoring.MetricServiceClient(); + const notificationChannelServiceClient = new monitoring.NotificationChannelServiceClient(); const serviceMonitoringServiceClient = new monitoring.ServiceMonitoringServiceClient(); const uptimeCheckServiceClient = new monitoring.UptimeCheckServiceClient(); } diff --git a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline index 23d96dd99..e6cea60a7 100644 --- a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline +++ b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline @@ -16,9 +16,13 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {ServiceMonitoringServiceClient, UptimeCheckServiceClient} from 'monitoring'; +import {AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient} from 'monitoring'; function main() { + const alertPolicyServiceClient = new AlertPolicyServiceClient(); + const groupServiceClient = new GroupServiceClient(); + const metricServiceClient = new MetricServiceClient(); + const notificationChannelServiceClient = new NotificationChannelServiceClient(); const serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); const uptimeCheckServiceClient = new UptimeCheckServiceClient(); } diff --git a/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline new file mode 100644 index 000000000..13fa999b8 --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline @@ -0,0 +1,323 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protosTypes from '../protos/protos'; +import * as assert from 'assert'; +import { describe, it } from 'mocha'; +const alertpolicyserviceModule = require('../src'); + + +const FAKE_STATUS_CODE = 1; +class FakeError{ + name: string; + message: string; + code: number; + constructor(n: number){ + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError|null, response?: {} | null): void; +} + +export class Operation{ + constructor(){}; + promise() {}; +} +function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +describe('v3.AlertPolicyServiceClient', () => { + it('has servicePath', () => { + const servicePath = alertpolicyserviceModule.v3.AlertPolicyServiceClient.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = alertpolicyserviceModule.v3.AlertPolicyServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = alertpolicyserviceModule.v3.AlertPolicyServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + fallback: true, + }); + assert(client); + }); + describe('getAlertPolicy', () => { + it('invokes getAlertPolicy without error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getAlertPolicy = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getAlertPolicy(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getAlertPolicy with error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getAlertPolicy = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getAlertPolicy(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createAlertPolicy', () => { + it('invokes createAlertPolicy without error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createAlertPolicy = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createAlertPolicy(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createAlertPolicy with error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createAlertPolicy = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createAlertPolicy(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('deleteAlertPolicy', () => { + it('invokes deleteAlertPolicy without error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteAlertPolicy = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteAlertPolicy(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteAlertPolicy with error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteAlertPolicy = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteAlertPolicy(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateAlertPolicy', () => { + it('invokes updateAlertPolicy without error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest = {}; + request.alertPolicy = {}; + request.alertPolicy.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateAlertPolicy = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateAlertPolicy(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateAlertPolicy with error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest = {}; + request.alertPolicy = {}; + request.alertPolicy.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateAlertPolicy = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateAlertPolicy(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('listAlertPolicies', () => { + it('invokes listAlertPolicies without error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listAlertPolicies = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listAlertPolicies(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listAlertPoliciesStream', () => { + it('invokes listAlertPoliciesStream without error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listAlertPolicies = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listAlertPoliciesStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); +}); diff --git a/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline new file mode 100644 index 000000000..df8dfb910 --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline @@ -0,0 +1,371 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protosTypes from '../protos/protos'; +import * as assert from 'assert'; +import { describe, it } from 'mocha'; +const groupserviceModule = require('../src'); + + +const FAKE_STATUS_CODE = 1; +class FakeError{ + name: string; + message: string; + code: number; + constructor(n: number){ + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError|null, response?: {} | null): void; +} + +export class Operation{ + constructor(){}; + promise() {}; +} +function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +describe('v3.GroupServiceClient', () => { + it('has servicePath', () => { + const servicePath = groupserviceModule.v3.GroupServiceClient.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = groupserviceModule.v3.GroupServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = groupserviceModule.v3.GroupServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new groupserviceModule.v3.GroupServiceClient(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + fallback: true, + }); + assert(client); + }); + describe('getGroup', () => { + it('invokes getGroup without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetGroupRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getGroup = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getGroup(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getGroup with error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetGroupRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getGroup = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getGroup(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createGroup', () => { + it('invokes createGroup without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateGroupRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createGroup = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createGroup(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createGroup with error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateGroupRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createGroup = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createGroup(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateGroup', () => { + it('invokes updateGroup without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IUpdateGroupRequest = {}; + request.group = {}; + request.group.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateGroup = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateGroup(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateGroup with error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IUpdateGroupRequest = {}; + request.group = {}; + request.group.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateGroup = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateGroup(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('deleteGroup', () => { + it('invokes deleteGroup without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IDeleteGroupRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteGroup = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteGroup(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteGroup with error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IDeleteGroupRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteGroup = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteGroup(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('listGroups', () => { + it('invokes listGroups without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListGroupsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listGroups = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listGroups(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listGroupsStream', () => { + it('invokes listGroupsStream without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListGroupsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listGroups = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listGroupsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); + describe('listGroupMembers', () => { + it('invokes listGroupMembers without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListGroupMembersRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listGroupMembers = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listGroupMembers(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listGroupMembersStream', () => { + it('invokes listGroupMembersStream without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListGroupMembersRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listGroupMembers = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listGroupMembersStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); +}); diff --git a/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline new file mode 100644 index 000000000..a709a3212 --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline @@ -0,0 +1,465 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protosTypes from '../protos/protos'; +import * as assert from 'assert'; +import { describe, it } from 'mocha'; +const metricserviceModule = require('../src'); + + +const FAKE_STATUS_CODE = 1; +class FakeError{ + name: string; + message: string; + code: number; + constructor(n: number){ + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError|null, response?: {} | null): void; +} + +export class Operation{ + constructor(){}; + promise() {}; +} +function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +describe('v3.MetricServiceClient', () => { + it('has servicePath', () => { + const servicePath = metricserviceModule.v3.MetricServiceClient.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = metricserviceModule.v3.MetricServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = metricserviceModule.v3.MetricServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new metricserviceModule.v3.MetricServiceClient(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + fallback: true, + }); + assert(client); + }); + describe('getMonitoredResourceDescriptor', () => { + it('invokes getMonitoredResourceDescriptor without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getMonitoredResourceDescriptor = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getMonitoredResourceDescriptor(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getMonitoredResourceDescriptor with error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getMonitoredResourceDescriptor = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getMonitoredResourceDescriptor(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('getMetricDescriptor', () => { + it('invokes getMetricDescriptor without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getMetricDescriptor = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getMetricDescriptor(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getMetricDescriptor with error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getMetricDescriptor = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getMetricDescriptor(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createMetricDescriptor', () => { + it('invokes createMetricDescriptor without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createMetricDescriptor = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createMetricDescriptor(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createMetricDescriptor with error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createMetricDescriptor = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createMetricDescriptor(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('deleteMetricDescriptor', () => { + it('invokes deleteMetricDescriptor without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteMetricDescriptor = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteMetricDescriptor(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteMetricDescriptor with error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteMetricDescriptor = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteMetricDescriptor(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createTimeSeries', () => { + it('invokes createTimeSeries without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createTimeSeries = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createTimeSeries(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createTimeSeries with error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createTimeSeries = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createTimeSeries(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('listMonitoredResourceDescriptors', () => { + it('invokes listMonitoredResourceDescriptors without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listMonitoredResourceDescriptors = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listMonitoredResourceDescriptors(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listMonitoredResourceDescriptorsStream', () => { + it('invokes listMonitoredResourceDescriptorsStream without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listMonitoredResourceDescriptors = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listMonitoredResourceDescriptorsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); + describe('listMetricDescriptors', () => { + it('invokes listMetricDescriptors without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listMetricDescriptors = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listMetricDescriptors(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listMetricDescriptorsStream', () => { + it('invokes listMetricDescriptorsStream without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listMetricDescriptors = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listMetricDescriptorsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); + describe('listTimeSeries', () => { + it('invokes listTimeSeries without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listTimeSeries = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listTimeSeries(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listTimeSeriesStream', () => { + it('invokes listTimeSeriesStream without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listTimeSeries = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listTimeSeriesStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); +}); diff --git a/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline new file mode 100644 index 000000000..e3fff90fc --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline @@ -0,0 +1,563 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protosTypes from '../protos/protos'; +import * as assert from 'assert'; +import { describe, it } from 'mocha'; +const notificationchannelserviceModule = require('../src'); + + +const FAKE_STATUS_CODE = 1; +class FakeError{ + name: string; + message: string; + code: number; + constructor(n: number){ + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError|null, response?: {} | null): void; +} + +export class Operation{ + constructor(){}; + promise() {}; +} +function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +describe('v3.NotificationChannelServiceClient', () => { + it('has servicePath', () => { + const servicePath = notificationchannelserviceModule.v3.NotificationChannelServiceClient.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = notificationchannelserviceModule.v3.NotificationChannelServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = notificationchannelserviceModule.v3.NotificationChannelServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + fallback: true, + }); + assert(client); + }); + describe('getNotificationChannelDescriptor', () => { + it('invokes getNotificationChannelDescriptor without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getNotificationChannelDescriptor = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getNotificationChannelDescriptor(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getNotificationChannelDescriptor with error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getNotificationChannelDescriptor = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getNotificationChannelDescriptor(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('getNotificationChannel', () => { + it('invokes getNotificationChannel without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getNotificationChannel = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getNotificationChannel(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getNotificationChannel with error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getNotificationChannel = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getNotificationChannel(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createNotificationChannel', () => { + it('invokes createNotificationChannel without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createNotificationChannel = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createNotificationChannel(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createNotificationChannel with error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createNotificationChannel = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createNotificationChannel(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateNotificationChannel', () => { + it('invokes updateNotificationChannel without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest = {}; + request.notificationChannel = {}; + request.notificationChannel.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateNotificationChannel = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateNotificationChannel(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateNotificationChannel with error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest = {}; + request.notificationChannel = {}; + request.notificationChannel.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateNotificationChannel = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateNotificationChannel(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('deleteNotificationChannel', () => { + it('invokes deleteNotificationChannel without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteNotificationChannel = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteNotificationChannel(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteNotificationChannel with error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteNotificationChannel = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteNotificationChannel(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('sendNotificationChannelVerificationCode', () => { + it('invokes sendNotificationChannelVerificationCode without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.sendNotificationChannelVerificationCode = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.sendNotificationChannelVerificationCode(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes sendNotificationChannelVerificationCode with error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.sendNotificationChannelVerificationCode = mockSimpleGrpcMethod( + request, + null, + error + ); + client.sendNotificationChannelVerificationCode(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('getNotificationChannelVerificationCode', () => { + it('invokes getNotificationChannelVerificationCode without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getNotificationChannelVerificationCode = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getNotificationChannelVerificationCode(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getNotificationChannelVerificationCode with error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getNotificationChannelVerificationCode = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getNotificationChannelVerificationCode(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('verifyNotificationChannel', () => { + it('invokes verifyNotificationChannel without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.verifyNotificationChannel = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.verifyNotificationChannel(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes verifyNotificationChannel with error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.verifyNotificationChannel = mockSimpleGrpcMethod( + request, + null, + error + ); + client.verifyNotificationChannel(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('listNotificationChannelDescriptors', () => { + it('invokes listNotificationChannelDescriptors without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listNotificationChannelDescriptors = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listNotificationChannelDescriptors(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listNotificationChannelDescriptorsStream', () => { + it('invokes listNotificationChannelDescriptorsStream without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listNotificationChannelDescriptors = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listNotificationChannelDescriptorsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); + describe('listNotificationChannels', () => { + it('invokes listNotificationChannels without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listNotificationChannels = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listNotificationChannels(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listNotificationChannelsStream', () => { + it('invokes listNotificationChannelsStream without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest = {}; + request.name = ''; + // Mock response + const expectedResponse = {response: 'data'}; + // Mock Grpc layer + client._innerApiCalls.listNotificationChannels = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listNotificationChannelsStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(expectedResponse); + }); + }); +}); From 7f9bee7496bc0910ceedf3ad7ea1b9cf66c2bcaa Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 11 Feb 2020 11:51:56 -0800 Subject: [PATCH 3/8] get alert_policy_condition in place --- typescript/src/schema/api.ts | 25 ++- .../alert_policy_service_client.ts.baseline | 156 ++++++++++++++++++ .../src/v3/group_service_client.ts.baseline | 156 ++++++++++++++++++ .../src/v3/metric_service_client.ts.baseline | 156 ++++++++++++++++++ ...ication_channel_service_client.ts.baseline | 156 ++++++++++++++++++ ...vice_monitoring_service_client.ts.baseline | 156 ++++++++++++++++++ .../uptime_check_service_client.ts.baseline | 156 ++++++++++++++++++ typescript/test/unit/monitor.ts | 2 +- 8 files changed, 956 insertions(+), 7 deletions(-) diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index cd007af4b..5e38be5f0 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -163,25 +163,38 @@ function getResourceDatabase( `file ${fd.name} resource_definition option` ); } - + let messagesStack: plugin.google.protobuf.IDescriptorProto[] = []; const messages = (fd.messageType ?? []) .filter(message => message.name) .reduce((map, message) => { map['.' + fd.package! + '.' + message.name!] = message; return map; }, {} as MessagesMap); - - for (const property of Object.keys(messages)) { - const m = messages[property]; + // put first layer of messages in the stack + for(const property of Object.keys(messages)){ + messagesStack.push(messages[property]); + } + while(messagesStack.length != 0){ + const m = messagesStack.shift(); + if(!m || !m.name) continue; + if(m && m.options && m.options['.google.api.resource']){ + console.warn('message name: ', m.name); + } + const massgeName = '.' + fd.package + '.' + m.name! resourceDatabase.registerResource( m?.options?.['.google.api.resource'] as ResourceDescriptor | undefined, - `file ${fd.name} message ${property}` + `file ${fd.name} message ${massgeName}` ); allResourceDatabase.registerResource( m?.options?.['.google.api.resource'] as ResourceDescriptor | undefined, - `file ${fd.name} message ${property}` + `file ${fd.name} message ${massgeName}` ); + if(m.nestedType){ + const nestedMessages = m.nestedType; + nestedMessages.map(m => messagesStack.push(m)); + } } } + console.warn('resource database: ', resourceDatabase.patterns); return [allResourceDatabase, resourceDatabase]; } diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline index 50053e1e6..e2ea18a51 100644 --- a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline @@ -142,6 +142,9 @@ export class AlertPolicyServiceClient { folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), + folderAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}' + ), folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -163,6 +166,9 @@ export class AlertPolicyServiceClient { organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/alertPolicies/{alert_policy}' ), + organizationAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}' + ), organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -184,6 +190,9 @@ export class AlertPolicyServiceClient { projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/alertPolicies/{alert_policy}' ), + projectAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}' + ), projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -812,6 +821,55 @@ export class AlertPolicyServiceClient { return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified folderAlertPolicyCondition resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + folderAlertPolicyConditionPath(folder:string,alertPolicy:string,condition:string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the folder from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified folderChannelDescriptor resource name string. * @@ -1077,6 +1135,55 @@ export class AlertPolicyServiceClient { return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified organizationAlertPolicyCondition resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + organizationAlertPolicyConditionPath(organization:string,alertPolicy:string,condition:string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified organizationChannelDescriptor resource name string. * @@ -1342,6 +1449,55 @@ export class AlertPolicyServiceClient { return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified projectAlertPolicyCondition resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + projectAlertPolicyConditionPath(project:string,alertPolicy:string,condition:string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the project from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified projectChannelDescriptor resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline index f2a3bc7cb..dd057c86e 100644 --- a/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline @@ -145,6 +145,9 @@ export class GroupServiceClient { folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), + folderAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}' + ), folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -166,6 +169,9 @@ export class GroupServiceClient { organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/alertPolicies/{alert_policy}' ), + organizationAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}' + ), organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -187,6 +193,9 @@ export class GroupServiceClient { projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/alertPolicies/{alert_policy}' ), + projectAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}' + ), projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -935,6 +944,55 @@ export class GroupServiceClient { return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified folderAlertPolicyCondition resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + folderAlertPolicyConditionPath(folder:string,alertPolicy:string,condition:string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the folder from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified folderChannelDescriptor resource name string. * @@ -1200,6 +1258,55 @@ export class GroupServiceClient { return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified organizationAlertPolicyCondition resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + organizationAlertPolicyConditionPath(organization:string,alertPolicy:string,condition:string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified organizationChannelDescriptor resource name string. * @@ -1465,6 +1572,55 @@ export class GroupServiceClient { return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified projectAlertPolicyCondition resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + projectAlertPolicyConditionPath(project:string,alertPolicy:string,condition:string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the project from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified projectChannelDescriptor resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline index 188e12a2c..15bf8586a 100644 --- a/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline @@ -135,6 +135,9 @@ export class MetricServiceClient { folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), + folderAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}' + ), folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -162,6 +165,9 @@ export class MetricServiceClient { organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/alertPolicies/{alert_policy}' ), + organizationAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}' + ), organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -189,6 +195,9 @@ export class MetricServiceClient { projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/alertPolicies/{alert_policy}' ), + projectAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}' + ), projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -1180,6 +1189,55 @@ export class MetricServiceClient { return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified folderAlertPolicyCondition resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + folderAlertPolicyConditionPath(folder:string,alertPolicy:string,condition:string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the folder from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified folderChannelDescriptor resource name string. * @@ -1517,6 +1575,55 @@ export class MetricServiceClient { return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified organizationAlertPolicyCondition resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + organizationAlertPolicyConditionPath(organization:string,alertPolicy:string,condition:string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified organizationChannelDescriptor resource name string. * @@ -1854,6 +1961,55 @@ export class MetricServiceClient { return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified projectAlertPolicyCondition resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + projectAlertPolicyConditionPath(project:string,alertPolicy:string,condition:string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the project from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified projectChannelDescriptor resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline index 44ad80442..7c04051de 100644 --- a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline @@ -135,6 +135,9 @@ export class NotificationChannelServiceClient { folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), + folderAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}' + ), folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -156,6 +159,9 @@ export class NotificationChannelServiceClient { organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/alertPolicies/{alert_policy}' ), + organizationAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}' + ), organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -177,6 +183,9 @@ export class NotificationChannelServiceClient { projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/alertPolicies/{alert_policy}' ), + projectAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}' + ), projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -1220,6 +1229,55 @@ export class NotificationChannelServiceClient { return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified folderAlertPolicyCondition resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + folderAlertPolicyConditionPath(folder:string,alertPolicy:string,condition:string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the folder from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified folderChannelDescriptor resource name string. * @@ -1485,6 +1543,55 @@ export class NotificationChannelServiceClient { return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified organizationAlertPolicyCondition resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + organizationAlertPolicyConditionPath(organization:string,alertPolicy:string,condition:string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified organizationChannelDescriptor resource name string. * @@ -1750,6 +1857,55 @@ export class NotificationChannelServiceClient { return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified projectAlertPolicyCondition resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + projectAlertPolicyConditionPath(project:string,alertPolicy:string,condition:string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the project from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified projectChannelDescriptor resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline index 476e65efe..b0f487f74 100644 --- a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline @@ -137,6 +137,9 @@ export class ServiceMonitoringServiceClient { folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), + folderAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}' + ), folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -158,6 +161,9 @@ export class ServiceMonitoringServiceClient { organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/alertPolicies/{alert_policy}' ), + organizationAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}' + ), organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -179,6 +185,9 @@ export class ServiceMonitoringServiceClient { projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/alertPolicies/{alert_policy}' ), + projectAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}' + ), projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -1173,6 +1182,55 @@ export class ServiceMonitoringServiceClient { return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified folderAlertPolicyCondition resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + folderAlertPolicyConditionPath(folder:string,alertPolicy:string,condition:string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the folder from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified folderChannelDescriptor resource name string. * @@ -1438,6 +1496,55 @@ export class ServiceMonitoringServiceClient { return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified organizationAlertPolicyCondition resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + organizationAlertPolicyConditionPath(organization:string,alertPolicy:string,condition:string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified organizationChannelDescriptor resource name string. * @@ -1703,6 +1810,55 @@ export class ServiceMonitoringServiceClient { return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified projectAlertPolicyCondition resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + projectAlertPolicyConditionPath(project:string,alertPolicy:string,condition:string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the project from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified projectChannelDescriptor resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline index 4ef8be091..2e5537f54 100644 --- a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline @@ -141,6 +141,9 @@ export class UptimeCheckServiceClient { folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), + folderAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}' + ), folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -162,6 +165,9 @@ export class UptimeCheckServiceClient { organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/alertPolicies/{alert_policy}' ), + organizationAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}' + ), organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -183,6 +189,9 @@ export class UptimeCheckServiceClient { projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/alertPolicies/{alert_policy}' ), + projectAlertPolicyConditionPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}' + ), projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' ), @@ -881,6 +890,55 @@ export class UptimeCheckServiceClient { return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified folderAlertPolicyCondition resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + folderAlertPolicyConditionPath(folder:string,alertPolicy:string,condition:string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the folder from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from FolderAlertPolicyCondition resource. + * + * @param {string} folderAlertPolicyConditionName + * A fully-qualified path representing folder_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromFolderAlertPolicyConditionName(folderAlertPolicyConditionName: string) { + return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match(folderAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified folderChannelDescriptor resource name string. * @@ -1146,6 +1204,55 @@ export class UptimeCheckServiceClient { return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified organizationAlertPolicyCondition resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + organizationAlertPolicyConditionPath(organization:string,alertPolicy:string,condition:string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from OrganizationAlertPolicyCondition resource. + * + * @param {string} organizationAlertPolicyConditionName + * A fully-qualified path representing organization_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromOrganizationAlertPolicyConditionName(organizationAlertPolicyConditionName: string) { + return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match(organizationAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified organizationChannelDescriptor resource name string. * @@ -1411,6 +1518,55 @@ export class UptimeCheckServiceClient { return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; } + /** + * Return a fully-qualified projectAlertPolicyCondition resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @param {string} condition + * @returns {string} Resource name string. + */ + projectAlertPolicyConditionPath(project:string,alertPolicy:string,condition:string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + condition: condition, + }); + } + + /** + * Parse the project from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).alert_policy; + } + + /** + * Parse the condition from ProjectAlertPolicyCondition resource. + * + * @param {string} projectAlertPolicyConditionName + * A fully-qualified path representing project_alert_policy_condition resource. + * @returns {string} A string representing the condition. + */ + matchConditionFromProjectAlertPolicyConditionName(projectAlertPolicyConditionName: string) { + return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match(projectAlertPolicyConditionName).condition; + } + /** * Return a fully-qualified projectChannelDescriptor resource name string. * diff --git a/typescript/test/unit/monitor.ts b/typescript/test/unit/monitor.ts index 2bca28c8e..9a2df4e04 100644 --- a/typescript/test/unit/monitor.ts +++ b/typescript/test/unit/monitor.ts @@ -44,7 +44,7 @@ const PLUGIN = path.join(SRCDIR, 'protoc-gen-typescript_gapic'); describe('MonitoringGenerateTest', () => { describe('Generate Client library', () => { - it('Generated monitoring library have same output with baseline.', function() { + it.only('Generated monitoring library have same output with baseline.', function() { this.timeout(10000); if (fs.existsSync(OUTPUT_DIR)) { rimraf.sync(OUTPUT_DIR); From 3e155efa290d827688b5c62b0d0d2930767b6211 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 11 Feb 2020 12:07:05 -0800 Subject: [PATCH 4/8] clean up --- typescript/src/schema/api.ts | 1 - typescript/test/unit/monitor.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index 5e38be5f0..e384a4737 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -195,6 +195,5 @@ function getResourceDatabase( } } } - console.warn('resource database: ', resourceDatabase.patterns); return [allResourceDatabase, resourceDatabase]; } diff --git a/typescript/test/unit/monitor.ts b/typescript/test/unit/monitor.ts index 9a2df4e04..2bca28c8e 100644 --- a/typescript/test/unit/monitor.ts +++ b/typescript/test/unit/monitor.ts @@ -44,7 +44,7 @@ const PLUGIN = path.join(SRCDIR, 'protoc-gen-typescript_gapic'); describe('MonitoringGenerateTest', () => { describe('Generate Client library', () => { - it.only('Generated monitoring library have same output with baseline.', function() { + it('Generated monitoring library have same output with baseline.', function() { this.timeout(10000); if (fs.existsSync(OUTPUT_DIR)) { rimraf.sync(OUTPUT_DIR); From 4a758d634b1542d5e17f25560d699c63c77a84cd Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 11 Feb 2020 12:13:55 -0800 Subject: [PATCH 5/8] clean --- typescript/src/schema/api.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index e384a4737..4e364d561 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -163,7 +163,7 @@ function getResourceDatabase( `file ${fd.name} resource_definition option` ); } - let messagesStack: plugin.google.protobuf.IDescriptorProto[] = []; + const messagesStack: plugin.google.protobuf.IDescriptorProto[] = []; const messages = (fd.messageType ?? []) .filter(message => message.name) .reduce((map, message) => { @@ -171,16 +171,13 @@ function getResourceDatabase( return map; }, {} as MessagesMap); // put first layer of messages in the stack - for(const property of Object.keys(messages)){ + for (const property of Object.keys(messages)) { messagesStack.push(messages[property]); } - while(messagesStack.length != 0){ - const m = messagesStack.shift(); - if(!m || !m.name) continue; - if(m && m.options && m.options['.google.api.resource']){ - console.warn('message name: ', m.name); - } - const massgeName = '.' + fd.package + '.' + m.name! + while (messagesStack.length !== 0) { + const m = messagesStack.pop(); + if (!m || !m.name) continue; + const massgeName = '.' + fd.package + '.' + m.name!; resourceDatabase.registerResource( m?.options?.['.google.api.resource'] as ResourceDescriptor | undefined, `file ${fd.name} message ${massgeName}` @@ -189,7 +186,7 @@ function getResourceDatabase( m?.options?.['.google.api.resource'] as ResourceDescriptor | undefined, `file ${fd.name} message ${massgeName}` ); - if(m.nestedType){ + if (m.nestedType) { const nestedMessages = m.nestedType; nestedMessages.map(m => messagesStack.push(m)); } From 8432e3abaa5dc2a343c08d5c4722722ff049a217 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 11 Feb 2020 12:23:00 -0800 Subject: [PATCH 6/8] skip docs-test for monitoring --- typescript/src/schema/api.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index 4e364d561..d2c43facd 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -164,27 +164,22 @@ function getResourceDatabase( ); } const messagesStack: plugin.google.protobuf.IDescriptorProto[] = []; - const messages = (fd.messageType ?? []) - .filter(message => message.name) - .reduce((map, message) => { - map['.' + fd.package! + '.' + message.name!] = message; - return map; - }, {} as MessagesMap); + const messages = (fd.messageType ?? []).filter( + (message: plugin.google.protobuf.IDescriptorProto) => message.name + ); // put first layer of messages in the stack - for (const property of Object.keys(messages)) { - messagesStack.push(messages[property]); - } + messagesStack.push(...messages); while (messagesStack.length !== 0) { const m = messagesStack.pop(); if (!m || !m.name) continue; - const massgeName = '.' + fd.package + '.' + m.name!; + const messageName = '.' + fd.package + '.' + m.name!; resourceDatabase.registerResource( m?.options?.['.google.api.resource'] as ResourceDescriptor | undefined, - `file ${fd.name} message ${massgeName}` + `file ${fd.name} message ${messageName}` ); allResourceDatabase.registerResource( m?.options?.['.google.api.resource'] as ResourceDescriptor | undefined, - `file ${fd.name} message ${massgeName}` + `file ${fd.name} message ${messageName}` ); if (m.nestedType) { const nestedMessages = m.nestedType; From 845a85462bf4d9525fc1e55f7fa7362e163177d2 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 11 Feb 2020 12:32:04 -0800 Subject: [PATCH 7/8] fix --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 78848fb0f..8dfd895a6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -139,8 +139,6 @@ jobs: npm run fix npm run compile npm run system-test - npm run docs - npm run docs-test dlpLibTest: docker: - image: circleci/node:10-browsers From f51ccd042afb89b093a4370f747907905bd1717b Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Tue, 11 Feb 2020 12:43:16 -0800 Subject: [PATCH 8/8] feedback --- typescript/src/schema/api.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index d2c43facd..106e9917a 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -181,10 +181,7 @@ function getResourceDatabase( m?.options?.['.google.api.resource'] as ResourceDescriptor | undefined, `file ${fd.name} message ${messageName}` ); - if (m.nestedType) { - const nestedMessages = m.nestedType; - nestedMessages.map(m => messagesStack.push(m)); - } + (m.nestedType ?? []).map(m => messagesStack.push(m)); } } return [allResourceDatabase, resourceDatabase];