diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json
index e965ff1ac4e..0f003e8139f 100644
--- a/packages/monitoring/package.json
+++ b/packages/monitoring/package.json
@@ -25,8 +25,9 @@
],
"dependencies": {
"extend": "^3.0",
- "google-gax": "^0.13.2",
- "google-proto-files": "^0.12.0"
+ "google-gax": "^0.14.2",
+ "lodash.merge": "^4.6.0",
+ "lodash.union": "^4.6.0"
},
"devDependencies": {
"mocha": "^3.2.0"
diff --git a/packages/monitoring/protos/google/monitoring/v3/common.proto b/packages/monitoring/protos/google/monitoring/v3/common.proto
new file mode 100644
index 00000000000..c8f701eeaaf
--- /dev/null
+++ b/packages/monitoring/protos/google/monitoring/v3/common.proto
@@ -0,0 +1,323 @@
+// Copyright 2016 Google Inc.
+//
+// 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";
+
+
+// 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 time interval extending just after a start time through an end time.
+// If the start time is the same as the end time, then the interval
+// represents a single point in 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 different views of
+// the data. Aggregation consists of an alignment step on individual time
+// series (`per_series_aligner`) followed by an optional reduction of the data
+// across different time series (`cross_series_reducer`). For more details, see
+// [Aggregation](/monitoring/api/learn_more#aggregation).
+message Aggregation {
+ // The Aligner describes how to bring the data points in a single
+ // time series into temporal alignment.
+ enum Aligner {
+ // No alignment. Raw data is returned. Not valid if cross-time
+ // 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 metric type. This alignment is valid
+ // for cumulative metrics and delta metrics. Aligning an existing
+ // delta metric to a delta metric requires that the alignment
+ // period be increased. The value type of the result is the same
+ // as the value type of the input.
+ ALIGN_DELTA = 1;
+
+ // Align and convert to a rate. This alignment is valid for
+ // cumulative metrics and delta metrics with numeric values. The output is a
+ // gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_RATE = 2;
+
+ // Align by interpolating between adjacent points around the
+ // period boundary. This alignment is valid for gauge
+ // metrics with numeric values. The value type of the result is the same
+ // as the value type of the input.
+ ALIGN_INTERPOLATE = 3;
+
+ // Align by shifting the oldest data point before the period
+ // boundary to the boundary. This alignment is valid for gauge
+ // metrics. The value type of the result is the same as the
+ // value type of the input.
+ ALIGN_NEXT_OLDER = 4;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the minimum of all data points in the
+ // period. This alignment is valid for gauge and delta metrics with numeric
+ // values. The value type of the result is the same as the value
+ // type of the input.
+ ALIGN_MIN = 10;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the maximum of all data points in the
+ // period. This alignment is valid for gauge and delta metrics with numeric
+ // values. The value type of the result is the same as the value
+ // type of the input.
+ ALIGN_MAX = 11;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the average or arithmetic mean of all
+ // data points in the period. This alignment is valid for gauge and delta
+ // metrics with numeric values. The value type of the output is
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_MEAN = 12;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the count of all data points in the
+ // period. This alignment is valid for gauge and delta metrics with numeric
+ // or Boolean values. The value type of the output is
+ // [INT64][google.api.MetricDescriptor.ValueType.INT64].
+ ALIGN_COUNT = 13;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the sum of all data points in the
+ // period. This alignment is valid for gauge and delta metrics with numeric
+ // and distribution values. The value type of the output is the
+ // same as the value type of the input.
+ ALIGN_SUM = 14;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the standard deviation of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with numeric values. The value type of the output is
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_STDDEV = 15;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the count of True-valued data points in the
+ // period. This alignment is valid for gauge metrics with
+ // Boolean values. The value type of the output is
+ // [INT64][google.api.MetricDescriptor.ValueType.INT64].
+ ALIGN_COUNT_TRUE = 16;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the fraction of True-valued data points in the
+ // period. This alignment is valid for gauge metrics with Boolean values.
+ // The output value is in the range [0, 1] and has value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_FRACTION_TRUE = 17;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the 99th percentile of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with distribution values. The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENTILE_99 = 18;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the 95th percentile of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with distribution values. The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENTILE_95 = 19;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the 50th percentile of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with distribution values. The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENTILE_50 = 20;
+
+ // Align time series via aggregation. The resulting data point in
+ // the alignment period is the 5th percentile of all data
+ // points in the period. This alignment is valid for gauge and delta metrics
+ // with distribution values. The output is a gauge metric with value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ ALIGN_PERCENTILE_05 = 21;
+ }
+
+ // A Reducer describes how to aggregate data points from multiple
+ // time series into a single time series.
+ enum Reducer {
+ // No cross-time series reduction. The output of the aligner is
+ // returned.
+ REDUCE_NONE = 0;
+
+ // Reduce by computing the mean 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][google.api.MetricDescriptor.ValueType.DOUBLE].
+ REDUCE_MEAN = 1;
+
+ // Reduce by computing the minimum 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 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][google.api.MetricDescriptor.ValueType.DOUBLE].
+ REDUCE_STDDEV = 5;
+
+ // Reduce by computing the count 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][google.api.MetricDescriptor.ValueType.INT64].
+ REDUCE_COUNT = 6;
+
+ // Reduce by computing the count 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][google.api.MetricDescriptor.ValueType.INT64].
+ REDUCE_COUNT_TRUE = 7;
+
+ // Reduce by computing the fraction 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 output value is in the
+ // range [0, 1] and has value type
+ // [DOUBLE][google.api.MetricDescriptor.ValueType.DOUBLE].
+ REDUCE_FRACTION_TRUE = 8;
+
+ // Reduce by computing 99th 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][google.api.MetricDescriptor.ValueType.DOUBLE]
+ REDUCE_PERCENTILE_99 = 9;
+
+ // Reduce by computing 95th 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][google.api.MetricDescriptor.ValueType.DOUBLE]
+ REDUCE_PERCENTILE_95 = 10;
+
+ // Reduce by computing 50th 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][google.api.MetricDescriptor.ValueType.DOUBLE]
+ REDUCE_PERCENTILE_50 = 11;
+
+ // Reduce by computing 5th 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][google.api.MetricDescriptor.ValueType.DOUBLE]
+ REDUCE_PERCENTILE_05 = 12;
+ }
+
+ // The alignment period for per-[time series][google.monitoring.v3.TimeSeries]
+ // alignment. If present, `alignmentPeriod` must be at least 60
+ // seconds. After per-time series alignment, each time series will
+ // contain data points only on the period boundaries. If
+ // `perSeriesAligner` is not specified or equals `ALIGN_NONE`, then
+ // this field is ignored. If `perSeriesAligner` is specified and
+ // does not equal `ALIGN_NONE`, then this field must be defined;
+ // otherwise an error is returned.
+ google.protobuf.Duration alignment_period = 1;
+
+ // The approach to be used to align individual time series. Not all
+ // alignment functions may be applied to all time series, depending
+ // on the metric type and value type of the original time
+ // series. Alignment may change the metric type or the value type of
+ // the time series.
+ //
+ // Time series data must be aligned in order to perform cross-time
+ // series reduction. If `crossSeriesReducer` is specified, then
+ // `perSeriesAligner` must be specified and not equal `ALIGN_NONE`
+ // and `alignmentPeriod` must be specified; otherwise, an error is
+ // returned.
+ Aligner per_series_aligner = 2;
+
+ // The approach to be used to combine time series. Not all reducer
+ // functions may be applied to all time series, depending on the
+ // metric type and the value type of the original time
+ // series. Reduction may change the metric type of value type of the
+ // time series.
+ //
+ // Time series data must be aligned in order to perform cross-time
+ // series reduction. If `crossSeriesReducer` is specified, then
+ // `perSeriesAligner` must be specified and not equal `ALIGN_NONE`
+ // and `alignmentPeriod` must be specified; otherwise, an error is
+ // returned.
+ Reducer cross_series_reducer = 4;
+
+ // The set of fields to preserve when `crossSeriesReducer` is
+ // specified. The `groupByFields` determine how the time series are
+ // partitioned into subsets prior to applying the aggregation
+ // function. 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
+ // `crossSeriesReducer` 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 `groupByFields` are aggregated away. If
+ // `groupByFields` 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 `crossSeriesReducer` is not
+ // defined, this field is ignored.
+ repeated string group_by_fields = 5;
+}
diff --git a/packages/monitoring/protos/google/monitoring/v3/group.proto b/packages/monitoring/protos/google/monitoring/v3/group.proto
new file mode 100644
index 00000000000..b6a6cfc45c0
--- /dev/null
+++ b/packages/monitoring/protos/google/monitoring/v3/group.proto
@@ -0,0 +1,74 @@
+// Copyright 2016 Google Inc.
+//
+// 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 = "GroupProto";
+option java_package = "com.google.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 {
+ // 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/packages/monitoring/protos/google/monitoring/v3/group_service.proto b/packages/monitoring/protos/google/monitoring/v3/group_service.proto
new file mode 100644
index 00000000000..3450580cd83
--- /dev/null
+++ b/packages/monitoring/protos/google/monitoring/v3/group_service.proto
@@ -0,0 +1,206 @@
+// Copyright 2016 Google Inc.
+//
+// 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/monitored_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";
+
+
+// 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 {
+ // Lists the existing groups.
+ rpc ListGroups(ListGroupsRequest) returns (ListGroupsResponse) {
+ option (google.api.http) = { get: "/v3/{name=projects/*}/groups" };
+ }
+
+ // Gets a single group.
+ rpc GetGroup(GetGroupRequest) returns (Group) {
+ option (google.api.http) = { get: "/v3/{name=projects/*/groups/*}" };
+ }
+
+ // Creates a new group.
+ rpc CreateGroup(CreateGroupRequest) returns (Group) {
+ option (google.api.http) = { post: "/v3/{name=projects/*}/groups" body: "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" };
+ }
+
+ // Deletes an existing group.
+ rpc DeleteGroup(DeleteGroupRequest) returns (google.protobuf.Empty) {
+ option (google.api.http) = { delete: "/v3/{name=projects/*/groups/*}" };
+ }
+
+ // 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" };
+ }
+}
+
+// The `ListGroup` request.
+message ListGroupsRequest {
+ // The project whose groups are to be listed. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 7;
+
+ // 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;
+
+ // 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;
+
+ // 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;
+ }
+
+ // 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 {
+ // The group to retrieve. The format is
+ // `"projects/{project_id_or_number}/groups/{group_id}"`.
+ string name = 3;
+}
+
+// The `CreateGroup` request.
+message CreateGroupRequest {
+ // The project in which to create the group. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 4;
+
+ // A group definition. It is an error to define the `name` field because
+ // the system assigns the name.
+ Group group = 2;
+
+ // If true, validate this request but do not create the group.
+ bool validate_only = 3;
+}
+
+// The `UpdateGroup` request.
+message UpdateGroupRequest {
+ // 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;
+
+ // If true, validate this request but do not update the existing group.
+ bool validate_only = 3;
+}
+
+// The `DeleteGroup` request. You can only delete a group if it has no children.
+message DeleteGroupRequest {
+ // The group to delete. The format is
+ // `"projects/{project_id_or_number}/groups/{group_id}"`.
+ string name = 3;
+}
+
+// The `ListGroupMembers` request.
+message ListGroupMembersRequest {
+ // The group whose members are listed. The format is
+ // `"projects/{project_id_or_number}/groups/{group_id}"`.
+ string name = 7;
+
+ // 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/packages/monitoring/protos/google/monitoring/v3/metric.proto b/packages/monitoring/protos/google/monitoring/v3/metric.proto
new file mode 100644
index 00000000000..73ae6037493
--- /dev/null
+++ b/packages/monitoring/protos/google/monitoring/v3/metric.proto
@@ -0,0 +1,87 @@
+// Copyright 2016 Google Inc.
+//
+// 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/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";
+
+
+// A single data point in a time series.
+message Point {
+ // The time interval to which the data point applies. For GAUGE metrics, only
+ // the end time of the interval is used. 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 resource. A fully-specified monitored resource used to
+ // identify the time series.
+ google.api.MonitoredResource resource = 2;
+
+ // 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, the order of
+ // the points is specified by the list method.
+ //
+ // 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/packages/monitoring/protos/google/monitoring/v3/metric_service.proto b/packages/monitoring/protos/google/monitoring/v3/metric_service.proto
new file mode 100644
index 00000000000..0dd0b19d315
--- /dev/null
+++ b/packages/monitoring/protos/google/monitoring/v3/metric_service.proto
@@ -0,0 +1,286 @@
+// Copyright 2016 Google Inc.
+//
+// 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/metric.proto";
+import "google/api/monitored_resource.proto";
+import "google/monitoring/v3/common.proto";
+import "google/monitoring/v3/metric.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";
+
+
+// Manages metric descriptors, monitored resource descriptors, and
+// time series data.
+service MetricService {
+ // 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" };
+ }
+
+ // 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/*}" };
+ }
+
+ // 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" };
+ }
+
+ // 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/**}" };
+ }
+
+ // 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" };
+ }
+
+ // 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/**}" };
+ }
+
+ // 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" };
+ }
+
+ // 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: "*" };
+ }
+}
+
+// The `ListMonitoredResourceDescriptors` request.
+message ListMonitoredResourceDescriptorsRequest {
+ // The project on which to execute the request. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 5;
+
+ // 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 `ListMonitoredResourcDescriptors` 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 {
+ // 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;
+}
+
+// The `ListMetricDescriptors` request.
+message ListMetricDescriptorsRequest {
+ // The project on which to execute the request. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 5;
+
+ // 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 {
+ // 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;
+}
+
+// The `CreateMetricDescriptor` request.
+message CreateMetricDescriptorRequest {
+ // The project on which to execute the request. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 3;
+
+ // The new [custom metric](/monitoring/custom-metrics)
+ // descriptor.
+ google.api.MetricDescriptor metric_descriptor = 2;
+}
+
+// The `DeleteMetricDescriptor` request.
+message DeleteMetricDescriptorRequest {
+ // 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;
+}
+
+// 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;
+ }
+
+ // The project on which to execute the request. The format is
+ // "projects/{project_id_or_number}".
+ string name = 10;
+
+ // 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.label.instance_name = "my-instance-name"
+ string filter = 2;
+
+ // 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;
+
+ // By default, the raw time series data is returned.
+ // Use this field to combine multiple time series for different
+ // views of the data.
+ Aggregation aggregation = 5;
+
+ // Specifies the order in which the points of the time series should
+ // be returned. By default, results are not ordered. Currently,
+ // this field must be left blank.
+ string order_by = 6;
+
+ // Specifies which information is returned about the time series.
+ TimeSeriesView view = 7;
+
+ // A positive number that is the maximum number of results to return.
+ // When `view` field sets to `FULL`, it limits the number of `Points` server
+ // will return; if `view` field is `HEADERS`, it limits the number of
+ // `TimeSeries` server will return.
+ 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;
+}
+
+// The `CreateTimeSeries` request.
+message CreateTimeSeriesRequest {
+ // The project on which to execute the request. The format is
+ // `"projects/{project_id_or_number}"`.
+ string name = 3;
+
+ // 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.
+ repeated TimeSeries time_series = 2;
+}
+
+// Describes the result of a failed request to write data to a time series.
+message CreateTimeSeriesError {
+ // The time series, including the `Metric`, `MonitoredResource`,
+ // and `Point`s (including timestamp and value) that resulted
+ // in the error. This field provides all of the context that
+ // would be needed to retry the operation.
+ TimeSeries time_series = 1;
+
+ // The status of the requested write operation.
+ google.rpc.Status status = 2;
+}
diff --git a/packages/monitoring/smoke-test/metric_service_smoke_test.js b/packages/monitoring/smoke-test/metric_service_smoke_test.js
index 546683030bc..7abf92f6cc5 100644
--- a/packages/monitoring/smoke-test/metric_service_smoke_test.js
+++ b/packages/monitoring/smoke-test/metric_service_smoke_test.js
@@ -1,50 +1,50 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
+
'use strict';
-describe('MetricServiceSmokeTest', function() {
+describe('MetricServiceSmokeTest', () => {
if (!process.env.SMOKE_TEST_PROJECT) {
throw new Error("Usage: SMOKE_TEST_PROJECT= node #{$0}");
}
var projectId = process.env.SMOKE_TEST_PROJECT;
- it('successfully makes a call to the service using promises', function(done) {
- var monitoring = require('../src');
+ it('successfully makes a call to the service using promises', done => {
+ const monitoring = require('../src');
- var client = monitoring.v3.metric({
+ var client = new monitoring.v3.MetricServiceClient({
// optional auth parameters.
});
// Iterate over all elements.
var formattedName = client.projectPath(projectId);
- client.listMonitoredResourceDescriptors({name: formattedName}).then(function(responses) {
+ client.listMonitoredResourceDescriptors({name: formattedName})
+ .then(responses => {
var resources = responses[0];
- for (var i = 0; i < resources.length; ++i) {
- console.log(resources[i]);
+ for (let i = 0; i < resources.length; i += 1) {
+ console.log(resources[i]);
}
- })
- .then(done)
- .catch(done);
+ })
+ .then(done)
+ .catch(done);
});
- it('successfully makes a call to the service using callbacks', function(done) {
- var monitoring = require('../src');
+ it('successfully makes a call to the service using callbacks', done => {
+ const monitoring = require('../src');
- var client = monitoring.v3.metric({
+ var client = new monitoring.v3.MetricServiceClient({
// optional auth parameters.
});
@@ -53,40 +53,40 @@ describe('MetricServiceSmokeTest', function() {
var options = {autoPaginate: false};
- function callback(responses) {
- // The actual resources in a response.
- var resources = responses[0];
- // The next request if the response shows there's more responses.
- var nextRequest = responses[1];
- // The actual response object, if necessary.
- // var rawResponse = responses[2];
- for (var i = 0; i < resources.length; ++i) {
- console.log(resources[i])
- }
- if (nextRequest) {
- // Fetch the next page.
- return client.listMonitoredResourceDescriptors(nextRequest, options).then(callback);
- }
+ var callback = responses => {
+ // The actual resources in a response.
+ var resources = responses[0];
+ // The next request if the response shows that there are more responses.
+ var nextRequest = responses[1];
+ // The actual response object, if necessary.
+ // var rawResponse = responses[2];
+ for (let i = 0; i < resources.length; i += 1) {
+ console.log(resources[i]);
+ }
+ if (nextRequest) {
+ // Fetch the next page.
+ return client.listMonitoredResourceDescriptors(nextRequest, options).then(callback);
+ }
}
client.listMonitoredResourceDescriptors({name: formattedName}, options)
- .then(callback)
- .then(done)
- .catch(done);
+ .then(callback)
+ .then(done)
+ .catch(done);
});
- it('successfully makes a call to the service using streaming', function(done) {
- var monitoring = require('../src');
+ it('successfully makes a call to the service using streaming', done => {
+ const monitoring = require('../src');
- var client = monitoring.v3.metric({
+ var client = new monitoring.v3.MetricServiceClient({
// optional auth parameters.
});
var formattedName = client.projectPath(projectId);
client.listMonitoredResourceDescriptorsStream({name: formattedName})
- .on('data', function(element) {
+ .on('data', element => {
console.log(element);
- })
- .on('error', done)
- .on('end', done);
+ })
+ .on('error', done)
+ .on('end', done);
});
-});
\ No newline at end of file
+});
diff --git a/packages/monitoring/src/index.js b/packages/monitoring/src/index.js
index b8978b9457b..c876082b475 100644
--- a/packages/monitoring/src/index.js
+++ b/packages/monitoring/src/index.js
@@ -1,111 +1,91 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-/*!
- * @module monitoring
- * @name Monitoring
+/**
+ * @namespace google
+ */
+/**
+ * @namespace google.cloud
+ */
+/**
+ * @namespace google.cloud.monitoring
+ */
+/**
+ * @namespace google.cloud.monitoring.v3
*/
'use strict';
-var extend = require('extend');
-var gapic = {
- v3: require('./v3')
-};
-var gaxGrpc = require('google-gax').grpc();
-
-const VERSION = require('../package.json').version;
+// Import the clients for each version supported by this package.
+const gapic = Object.freeze({
+ v3: require('./v3'),
+});
/**
- * Create a groupServiceClient with additional helpers for common
- * tasks.
+ * The `@google-cloud/monitoring` package has the following named exports:
*
- * The Group API lets you inspect and manage your
- * [groups](https://cloud.google.comgoogle.monitoring.v3.Group).
+ * - `GroupServiceClient` - Reference to
+ * {@link v3.GroupServiceClient}
+ * - `MetricServiceClient` - Reference to
+ * {@link v3.MetricServiceClient}
+ * - `v3` - This is used for selecting or pinning a
+ * particular backend service version. It exports:
+ * - `GroupServiceClient` - Reference to
+ * {@link v3.GroupServiceClient}
+ * - `MetricServiceClient` - Reference to
+ * {@link v3.MetricServiceClient}
*
- * 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.
+ * @module {object} @google-cloud/monitoring
+ * @alias nodejs-monitoring
*
- * @param {object=} options - [Configuration object](#/docs).
- * @param {number=} options.port - The port on which to connect to
- * the remote host.
- * @param {string=} options.servicePath - The domain name of the
- * API remote host.
- */
-function groupV3(options) {
- // Define the header options.
- options = extend({}, options, {
- libName: 'gccl',
- libVersion: VERSION
- });
-
- // Create the client with the provided options.
- var client = gapic.v3(options).groupServiceClient(options);
- return client;
-}
-
-/**
- * Create a metricServiceClient with additional helpers for common
- * tasks.
+ * @example Install the client library with
+ * npm:
+ * npm install --save @google-cloud/monitoring
+ *
+ * @example Import the client library:
+ * const monitoring = require('@google-cloud/monitoring');
*
- * Manages metric descriptors, monitored resource descriptors, and
- * time series data.
+ * @example Create a client that uses
+ * Application Default Credentials
+ * (ADC):
+ * let client = new monitoring.GroupServiceClient();
*
- * @param {object=} options - [Configuration object](#/docs).
- * @param {number=} options.port - The port on which to connect to
- * the remote host.
- * @param {string=} options.servicePath - The domain name of the
- * API remote host.
+ * @example Create a client with
+ * explicit credentials:
+ * let client = new monitoring.GroupServiceClient({
+ * projectId: 'your-project-id',
+ * keyFilename: '/path/to/keyfile.json',
+ * });
*/
-function metricV3(options) {
- // Define the header options.
- options = extend({}, options, {
- libName: 'gccl',
- libVersion: VERSION
- });
-
- // Create the client with the provided options.
- var client = gapic.v3(options).metricServiceClient(options);
- return client;
-}
-var v3Protos = {};
-
-extend(v3Protos, gaxGrpc.load([{
- root: require('google-proto-files')('..'),
- file: 'google/monitoring/v3/group_service.proto'
-}]).google.monitoring.v3);
-
-extend(v3Protos, gaxGrpc.load([{
- root: require('google-proto-files')('..'),
- file: 'google/monitoring/v3/metric_service.proto'
-}]).google.monitoring.v3);
+/**
+ * @type {object}
+ * @property {constructor} GroupServiceClient
+ * Reference to {@link v3.GroupServiceClient}
+ * @property {constructor} MetricServiceClient
+ * Reference to {@link v3.MetricServiceClient}
+ */
+module.exports = gapic.v3;
-module.exports.group = groupV3;
-module.exports.metric = metricV3;
-module.exports.types = v3Protos;
+/**
+ * @type {object}
+ * @property {constructor} GroupServiceClient
+ * Reference to {@link v3.GroupServiceClient}
+ * @property {constructor} MetricServiceClient
+ * Reference to {@link v3.MetricServiceClient}
+ */
+module.exports.v3 = gapic.v3;
-module.exports.v3 = {};
-module.exports.v3.group = groupV3;
-module.exports.v3.metric = metricV3;
-module.exports.v3.types = v3Protos;
\ No newline at end of file
+// Alias `module.exports` as `module.exports.default`, for future-proofing.
+module.exports.default = Object.assign({}, module.exports);
diff --git a/packages/monitoring/src/v3/doc/doc_google_api_distribution.js b/packages/monitoring/src/v3/doc/doc_google_api_distribution.js
deleted file mode 100644
index b2e14518ae4..00000000000
--- a/packages/monitoring/src/v3/doc/doc_google_api_distribution.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
-
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
-
-/**
- * Distribution contains summary statistics for a population of values and,
- * optionally, a histogram representing the distribution of those values across
- * a specified set of histogram buckets.
- *
- * The summary statistics are the count, mean, sum of the squared deviation from
- * the mean, the minimum, and the maximum of the set of population of values.
- *
- * The histogram is based on a sequence of buckets and gives a count of values
- * that fall into each bucket. The boundaries of the buckets are given either
- * explicitly or by specifying parameters for a method of computing them
- * (buckets of fixed width or buckets of exponentially increasing width).
- *
- * Although it is not forbidden, it is generally a bad idea to include
- * non-finite values (infinities or NaNs) in the population of values, as this
- * will render the `mean` and `sum_of_squared_deviation` fields meaningless.
- *
- * @external "google.api.Distribution"
- * @property {number} count
- * The number of values in the population. Must be non-negative.
- *
- * @property {number} mean
- * The arithmetic mean of the values in the population. If `count` is zero
- * then this field must be zero.
- *
- * @property {number} sumOfSquaredDeviation
- * The sum of squared deviations from the mean of the values in the
- * population. For values x_i this is:
- *
- * Sum[i=1..n](https://cloud.google.com(x_i - mean)^2)
- *
- * Knuth, "The Art of Computer Programming", Vol. 2, page 323, 3rd edition
- * describes Welford's method for accumulating this sum in one pass.
- *
- * If `count` is zero then this field must be zero.
- *
- * @property {Object} range
- * If specified, contains the range of the population values. The field
- * must not be present if the `count` is zero.
- *
- * This object should have the same structure as [google.api.Distribution.Range]{@link external:"google.api.Distribution.Range"}
- *
- * @property {Object} bucketOptions
- * Defines the histogram bucket boundaries.
- *
- * This object should have the same structure as [google.api.Distribution.BucketOptions]{@link external:"google.api.Distribution.BucketOptions"}
- *
- * @property {number[]} bucketCounts
- * If `bucket_options` is given, then the sum of the values in `bucket_counts`
- * must equal the value in `count`. If `bucket_options` is not given, no
- * `bucket_counts` fields may be given.
- *
- * Bucket counts are given in order under the numbering scheme described
- * above (the underflow bucket has number 0; the finite buckets, if any,
- * have numbers 1 through N-2; the overflow bucket has number N-1).
- *
- * The size of `bucket_counts` must be no greater than N as defined in
- * `bucket_options`.
- *
- * Any suffix of trailing zero bucket_count fields may be omitted.
- *
- * @see [google.api.Distribution definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/distribution.proto}
- */
\ No newline at end of file
diff --git a/packages/monitoring/src/v3/doc/doc_google_api_label.js b/packages/monitoring/src/v3/doc/doc_google_api_label.js
deleted file mode 100644
index 64701d613ac..00000000000
--- a/packages/monitoring/src/v3/doc/doc_google_api_label.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
-
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
-
-/**
- * A description of a label.
- *
- * @external "google.api.LabelDescriptor"
- * @property {string} key
- * The label key.
- *
- * @property {number} valueType
- * The type of data that can be assigned to the label.
- *
- * The number should be among the values of [google.api.LabelDescriptor.ValueType]{@link external:"google.api.LabelDescriptor.ValueType"}
- *
- * @property {string} description
- * A human-readable description for the label.
- *
- * @see [google.api.LabelDescriptor definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/label.proto}
- */
\ No newline at end of file
diff --git a/packages/monitoring/src/v3/doc/google/api/doc_distribution.js b/packages/monitoring/src/v3/doc/google/api/doc_distribution.js
new file mode 100644
index 00000000000..2ebda08c4d9
--- /dev/null
+++ b/packages/monitoring/src/v3/doc/google/api/doc_distribution.js
@@ -0,0 +1,229 @@
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
+
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
+
+/**
+ * Distribution contains summary statistics for a population of values and,
+ * optionally, a histogram representing the distribution of those values across
+ * a specified set of histogram buckets.
+ *
+ * The summary statistics are the count, mean, sum of the squared deviation from
+ * the mean, the minimum, and the maximum of the set of population of values.
+ *
+ * The histogram is based on a sequence of buckets and gives a count of values
+ * that fall into each bucket. The boundaries of the buckets are given either
+ * explicitly or by specifying parameters for a method of computing them
+ * (buckets of fixed width or buckets of exponentially increasing width).
+ *
+ * Although it is not forbidden, it is generally a bad idea to include
+ * non-finite values (infinities or NaNs) in the population of values, as this
+ * will render the `mean` and `sum_of_squared_deviation` fields meaningless.
+ *
+ * @property {number} count
+ * The number of values in the population. Must be non-negative.
+ *
+ * @property {number} mean
+ * The arithmetic mean of the values in the population. If `count` is zero
+ * then this field must be zero.
+ *
+ * @property {number} sumOfSquaredDeviation
+ * The sum of squared deviations from the mean of the values in the
+ * population. For values x_i this is:
+ *
+ * Sum[i=1..n](https://cloud.google.com(x_i - mean)^2)
+ *
+ * Knuth, "The Art of Computer Programming", Vol. 2, page 323, 3rd edition
+ * describes Welford's method for accumulating this sum in one pass.
+ *
+ * If `count` is zero then this field must be zero.
+ *
+ * @property {Object} range
+ * If specified, contains the range of the population values. The field
+ * must not be present if the `count` is zero.
+ *
+ * This object should have the same structure as [Range]{@link google.api.Range}
+ *
+ * @property {Object} bucketOptions
+ * Defines the histogram bucket boundaries.
+ *
+ * This object should have the same structure as [BucketOptions]{@link google.api.BucketOptions}
+ *
+ * @property {number[]} bucketCounts
+ * If `bucket_options` is given, then the sum of the values in `bucket_counts`
+ * must equal the value in `count`. If `bucket_options` is not given, no
+ * `bucket_counts` fields may be given.
+ *
+ * Bucket counts are given in order under the numbering scheme described
+ * above (the underflow bucket has number 0; the finite buckets, if any,
+ * have numbers 1 through N-2; the overflow bucket has number N-1).
+ *
+ * The size of `bucket_counts` must be no greater than N as defined in
+ * `bucket_options`.
+ *
+ * Any suffix of trailing zero bucket_count fields may be omitted.
+ *
+ * @typedef Distribution
+ * @memberof google.api
+ * @see [google.api.Distribution definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/distribution.proto}
+ */
+var Distribution = {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+
+ /**
+ * The range of the population values.
+ *
+ * @property {number} min
+ * The minimum of the population values.
+ *
+ * @property {number} max
+ * The maximum of the population values.
+ *
+ * @typedef Range
+ * @memberof google.api
+ * @see [google.api.Distribution.Range definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/distribution.proto}
+ */
+ Range: {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+ },
+
+ /**
+ * A Distribution may optionally contain a histogram of the values in the
+ * population. The histogram is given in `bucket_counts` as counts of values
+ * that fall into one of a sequence of non-overlapping buckets. The sequence
+ * of buckets is described by `bucket_options`.
+ *
+ * A bucket specifies an inclusive lower bound and exclusive upper bound for
+ * the values that are counted for that bucket. The upper bound of a bucket
+ * is strictly greater than the lower bound.
+ *
+ * The sequence of N buckets for a Distribution consists of an underflow
+ * bucket (number 0), zero or more finite buckets (number 1 through N - 2) and
+ * an overflow bucket (number N - 1). The buckets are contiguous: the lower
+ * bound of bucket i (i > 0) is the same as the upper bound of bucket i - 1.
+ * The buckets span the whole range of finite values: lower bound of the
+ * underflow bucket is -infinity and the upper bound of the overflow bucket is
+ * +infinity. The finite buckets are so-called because both bounds are
+ * finite.
+ *
+ * `BucketOptions` describes bucket boundaries in one of three ways. Two
+ * describe the boundaries by giving parameters for a formula to generate
+ * boundaries and one gives the bucket boundaries explicitly.
+ *
+ * If `bucket_boundaries` is not given, then no `bucket_counts` may be given.
+ *
+ * @property {Object} linearBuckets
+ * The linear bucket.
+ *
+ * This object should have the same structure as [Linear]{@link google.api.Linear}
+ *
+ * @property {Object} exponentialBuckets
+ * The exponential buckets.
+ *
+ * This object should have the same structure as [Exponential]{@link google.api.Exponential}
+ *
+ * @property {Object} explicitBuckets
+ * The explicit buckets.
+ *
+ * This object should have the same structure as [Explicit]{@link google.api.Explicit}
+ *
+ * @typedef BucketOptions
+ * @memberof google.api
+ * @see [google.api.Distribution.BucketOptions definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/distribution.proto}
+ */
+ BucketOptions: {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+
+ /**
+ * Specify a sequence of buckets that all have the same width (except
+ * overflow and underflow). Each bucket represents a constant absolute
+ * uncertainty on the specific value in the bucket.
+ *
+ * Defines `num_finite_buckets + 2` (= N) buckets with these boundaries for
+ * bucket `i`:
+ *
+ * Upper bound (0 <= i < N-1): offset + (width * i).
+ * Lower bound (1 <= i < N): offset + (width * (i - 1)).
+ *
+ * @property {number} numFiniteBuckets
+ * Must be greater than 0.
+ *
+ * @property {number} width
+ * Must be greater than 0.
+ *
+ * @property {number} offset
+ * Lower bound of the first bucket.
+ *
+ * @typedef Linear
+ * @memberof google.api
+ * @see [google.api.Distribution.BucketOptions.Linear definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/distribution.proto}
+ */
+ Linear: {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+ },
+
+ /**
+ * Specify a sequence of buckets that have a width that is proportional to
+ * the value of the lower bound. Each bucket represents a constant relative
+ * uncertainty on a specific value in the bucket.
+ *
+ * Defines `num_finite_buckets + 2` (= N) buckets with these boundaries for
+ * bucket i:
+ *
+ * Upper bound (0 <= i < N-1): scale * (growth_factor ^ i).
+ * Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)).
+ *
+ * @property {number} numFiniteBuckets
+ * Must be greater than 0.
+ *
+ * @property {number} growthFactor
+ * Must be greater than 1.
+ *
+ * @property {number} scale
+ * Must be greater than 0.
+ *
+ * @typedef Exponential
+ * @memberof google.api
+ * @see [google.api.Distribution.BucketOptions.Exponential definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/distribution.proto}
+ */
+ Exponential: {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+ },
+
+ /**
+ * A set of buckets with arbitrary widths.
+ *
+ * Defines `size(bounds) + 1` (= N) buckets with these boundaries for
+ * bucket i:
+ *
+ * Upper bound (0 <= i < N-1): bounds[i]
+ * Lower bound (1 <= i < N); bounds[i - 1]
+ *
+ * There must be at least one element in `bounds`. If `bounds` has only one
+ * element, there are no finite buckets, and that single element is the
+ * common boundary of the overflow and underflow buckets.
+ *
+ * @property {number[]} bounds
+ * The values must be monotonically increasing.
+ *
+ * @typedef Explicit
+ * @memberof google.api
+ * @see [google.api.Distribution.BucketOptions.Explicit definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/distribution.proto}
+ */
+ Explicit: {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+ }
+ }
+};
\ No newline at end of file
diff --git a/packages/monitoring/src/v3/doc/google/api/doc_label.js b/packages/monitoring/src/v3/doc/google/api/doc_label.js
new file mode 100644
index 00000000000..602286cb52b
--- /dev/null
+++ b/packages/monitoring/src/v3/doc/google/api/doc_label.js
@@ -0,0 +1,62 @@
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
+
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
+
+/**
+ * A description of a label.
+ *
+ * @property {string} key
+ * The label key.
+ *
+ * @property {number} valueType
+ * The type of data that can be assigned to the label.
+ *
+ * The number should be among the values of [ValueType]{@link google.api.ValueType}
+ *
+ * @property {string} description
+ * A human-readable description for the label.
+ *
+ * @typedef LabelDescriptor
+ * @memberof google.api
+ * @see [google.api.LabelDescriptor definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/label.proto}
+ */
+var LabelDescriptor = {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+
+ /**
+ * Value types that can be used as label values.
+ *
+ * @enum {number}
+ * @memberof google.api
+ */
+ ValueType: {
+
+ /**
+ * A variable-length string. This is the default.
+ */
+ STRING: 0,
+
+ /**
+ * Boolean; true or false.
+ */
+ BOOL: 1,
+
+ /**
+ * A 64-bit signed integer.
+ */
+ INT64: 2
+ }
+};
\ No newline at end of file
diff --git a/packages/monitoring/src/v3/doc/doc_google_api_metric.js b/packages/monitoring/src/v3/doc/google/api/doc_metric.js
similarity index 63%
rename from packages/monitoring/src/v3/doc/doc_google_api_metric.js
rename to packages/monitoring/src/v3/doc/google/api/doc_metric.js
index ea7d0f941eb..7a7247a2397 100644
--- a/packages/monitoring/src/v3/doc/doc_google_api_metric.js
+++ b/packages/monitoring/src/v3/doc/google/api/doc_metric.js
@@ -1,30 +1,25 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
/**
* Defines a metric type and its schema. Once a metric descriptor is created,
* deleting or altering it stops data collection and makes the metric type's
* existing data unusable.
*
- * @external "google.api.MetricDescriptor"
* @property {string} name
* The resource name of the metric descriptor. Depending on the
* implementation, the name typically includes: (1) the parent resource name
@@ -52,19 +47,19 @@
* you can look at latencies for successful responses or just
* for responses that failed.
*
- * This object should have the same structure as [google.api.LabelDescriptor]{@link external:"google.api.LabelDescriptor"}
+ * This object should have the same structure as [LabelDescriptor]{@link google.api.LabelDescriptor}
*
* @property {number} metricKind
* Whether the metric records instantaneous values, changes to a value, etc.
* Some combinations of `metric_kind` and `value_type` might not be supported.
*
- * The number should be among the values of [google.api.MetricDescriptor.MetricKind]{@link external:"google.api.MetricDescriptor.MetricKind"}
+ * The number should be among the values of [MetricKind]{@link google.api.MetricKind}
*
* @property {number} valueType
* Whether the measurement is an integer, a floating-point number, etc.
* Some combinations of `metric_kind` and `value_type` might not be supported.
*
- * The number should be among the values of [google.api.MetricDescriptor.ValueType]{@link external:"google.api.MetricDescriptor.ValueType"}
+ * The number should be among the values of [ValueType]{@link google.api.ValueType}
*
* @property {string} unit
* The unit in which the metric value is reported. It is only applicable
@@ -139,21 +134,109 @@
* A concise name for the metric, which can be displayed in user interfaces.
* Use sentence case without an ending period, for example "Request count".
*
+ * @typedef MetricDescriptor
+ * @memberof google.api
* @see [google.api.MetricDescriptor definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/metric.proto}
*/
+var MetricDescriptor = {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+
+ /**
+ * The kind of measurement. It describes how the data is reported.
+ *
+ * @enum {number}
+ * @memberof google.api
+ */
+ MetricKind: {
+
+ /**
+ * Do not use this default value.
+ */
+ METRIC_KIND_UNSPECIFIED: 0,
+
+ /**
+ * An instantaneous measurement of a value.
+ */
+ GAUGE: 1,
+
+ /**
+ * The change in a value during a time interval.
+ */
+ DELTA: 2,
+
+ /**
+ * A value accumulated over a time interval. Cumulative
+ * measurements in a time series should have 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.
+ */
+ CUMULATIVE: 3
+ },
+
+ /**
+ * The value type of a metric.
+ *
+ * @enum {number}
+ * @memberof google.api
+ */
+ ValueType: {
+
+ /**
+ * Do not use this default value.
+ */
+ VALUE_TYPE_UNSPECIFIED: 0,
+
+ /**
+ * The value is a boolean.
+ * This value type can be used only if the metric kind is `GAUGE`.
+ */
+ BOOL: 1,
+
+ /**
+ * The value is a signed 64-bit integer.
+ */
+ INT64: 2,
+
+ /**
+ * The value is a double precision floating point number.
+ */
+ DOUBLE: 3,
+
+ /**
+ * The value is a text string.
+ * This value type can be used only if the metric kind is `GAUGE`.
+ */
+ STRING: 4,
+
+ /**
+ * The value is a `Distribution`.
+ */
+ DISTRIBUTION: 5,
+
+ /**
+ * The value is money.
+ */
+ MONEY: 6
+ }
+};
/**
* A specific metric, identified by specifying values for all of the
- * labels of a {@link `MetricDescriptor`}.
+ * labels of a `MetricDescriptor`.
*
- * @external "google.api.Metric"
* @property {string} type
- * An existing metric type, see {@link google.api.MetricDescriptor}.
+ * An existing metric type, see google.api.MetricDescriptor.
* For example, `custom.googleapis.com/invoice/paid/amount`.
*
* @property {Object.} labels
* The set of label values that uniquely identify this metric. All
* labels listed in the `MetricDescriptor` must be assigned values.
*
+ * @typedef Metric
+ * @memberof google.api
* @see [google.api.Metric definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/metric.proto}
- */
\ No newline at end of file
+ */
+var Metric = {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+};
\ No newline at end of file
diff --git a/packages/monitoring/src/v3/doc/doc_google_api_monitored_resource.js b/packages/monitoring/src/v3/doc/google/api/doc_monitored_resource.js
similarity index 70%
rename from packages/monitoring/src/v3/doc/doc_google_api_monitored_resource.js
rename to packages/monitoring/src/v3/doc/google/api/doc_monitored_resource.js
index bb2c3107f8f..31d25663448 100644
--- a/packages/monitoring/src/v3/doc/doc_google_api_monitored_resource.js
+++ b/packages/monitoring/src/v3/doc/google/api/doc_monitored_resource.js
@@ -1,26 +1,22 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
/**
- * An object that describes the schema of a {@link MonitoredResource} object using a
+ * An object that describes the schema of a MonitoredResource object using a
* type name and a set of labels. For example, the monitored resource
* descriptor for Google Compute Engine VM instances has a type of
* `"gce_instance"` and specifies the use of the labels `"instance_id"` and
@@ -30,7 +26,6 @@
* provide a `list` method that returns the monitored resource descriptors used
* by the API.
*
- * @external "google.api.MonitoredResourceDescriptor"
* @property {string} name
* Optional. The resource name of the monitored resource descriptor:
* `"projects/{project_id}/monitoredResourceDescriptors/{type}"` where
@@ -59,30 +54,34 @@
* resource type. For example, an individual Google Cloud SQL database is
* identified by values for the labels `"database_id"` and `"zone"`.
*
- * This object should have the same structure as [google.api.LabelDescriptor]{@link external:"google.api.LabelDescriptor"}
+ * This object should have the same structure as [LabelDescriptor]{@link google.api.LabelDescriptor}
*
+ * @typedef MonitoredResourceDescriptor
+ * @memberof google.api
* @see [google.api.MonitoredResourceDescriptor definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/monitored_resource.proto}
*/
+var MonitoredResourceDescriptor = {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+};
/**
* An object representing a resource that can be used for monitoring, logging,
* billing, or other purposes. Examples include virtual machine instances,
* databases, and storage devices such as disks. The `type` field identifies a
- * {@link MonitoredResourceDescriptor} object that describes the resource's
+ * MonitoredResourceDescriptor object that describes the resource's
* schema. Information in the `labels` field identifies the actual resource and
* its attributes according to the schema. For example, a particular Compute
* Engine VM instance could be represented by the following object, because the
- * {@link MonitoredResourceDescriptor} for `"gce_instance"` has labels
+ * MonitoredResourceDescriptor for `"gce_instance"` has labels
* `"instance_id"` and `"zone"`:
*
* { "type": "gce_instance",
* "labels": { "instance_id": "12345678901234",
* "zone": "us-central1-a" }}
*
- * @external "google.api.MonitoredResource"
* @property {string} type
* Required. The monitored resource type. This field must match
- * the `type` field of a {@link MonitoredResourceDescriptor} object. For
+ * the `type` field of a MonitoredResourceDescriptor object. For
* example, the type of a Cloud SQL database is `"cloudsql_database"`.
*
* @property {Object.} labels
@@ -90,5 +89,10 @@
* resource descriptor. For example, Cloud SQL databases use the labels
* `"database_id"` and `"zone"`.
*
+ * @typedef MonitoredResource
+ * @memberof google.api
* @see [google.api.MonitoredResource definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/api/monitored_resource.proto}
- */
\ No newline at end of file
+ */
+var MonitoredResource = {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+};
\ No newline at end of file
diff --git a/packages/monitoring/src/v3/doc/doc_common.js b/packages/monitoring/src/v3/doc/google/monitoring/v3/doc_common.js
similarity index 88%
rename from packages/monitoring/src/v3/doc/doc_common.js
rename to packages/monitoring/src/v3/doc/google/monitoring/v3/doc_common.js
index aa8010c30a3..21ad4b6b5ec 100644
--- a/packages/monitoring/src/v3/doc/doc_common.js
+++ b/packages/monitoring/src/v3/doc/google/monitoring/v3/doc_common.js
@@ -1,23 +1,19 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
-
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
+
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
/**
* A single strongly-typed value.
@@ -39,9 +35,10 @@
* @property {Object} distributionValue
* A distribution value.
*
- * This object should have the same structure as [google.api.Distribution]{@link external:"google.api.Distribution"}
+ * This object should have the same structure as [Distribution]{@link google.api.Distribution}
*
- * @class
+ * @typedef TypedValue
+ * @memberof google.monitoring.v3
* @see [google.monitoring.v3.TypedValue definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/common.proto}
*/
var TypedValue = {
@@ -56,16 +53,17 @@ var TypedValue = {
* @property {Object} endTime
* Required. The end of the time interval.
*
- * This object should have the same structure as [google.protobuf.Timestamp]{@link external:"google.protobuf.Timestamp"}
+ * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp}
*
* @property {Object} startTime
* 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.
*
- * This object should have the same structure as [google.protobuf.Timestamp]{@link external:"google.protobuf.Timestamp"}
+ * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp}
*
- * @class
+ * @typedef TimeInterval
+ * @memberof google.monitoring.v3
* @see [google.monitoring.v3.TimeInterval definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/common.proto}
*/
var TimeInterval = {
@@ -80,7 +78,7 @@ var TimeInterval = {
* [Aggregation](https://cloud.google.com/monitoring/api/learn_more#aggregation).
*
* @property {Object} alignmentPeriod
- * The alignment period for per-{@link time series}
+ * The alignment period for per-time series
* alignment. If present, `alignmentPeriod` must be at least 60
* seconds. After per-time series alignment, each time series will
* contain data points only on the period boundaries. If
@@ -89,7 +87,7 @@ var TimeInterval = {
* does not equal `ALIGN_NONE`, then this field must be defined;
* otherwise an error is returned.
*
- * This object should have the same structure as [google.protobuf.Duration]{@link external:"google.protobuf.Duration"}
+ * This object should have the same structure as [Duration]{@link google.protobuf.Duration}
*
* @property {number} perSeriesAligner
* The approach to be used to align individual time series. Not all
@@ -104,7 +102,7 @@ var TimeInterval = {
* and `alignmentPeriod` must be specified; otherwise, an error is
* returned.
*
- * The number should be among the values of [Aligner]{@link Aligner}
+ * The number should be among the values of [Aligner]{@link google.monitoring.v3.Aligner}
*
* @property {number} crossSeriesReducer
* The approach to be used to combine time series. Not all reducer
@@ -119,7 +117,7 @@ var TimeInterval = {
* and `alignmentPeriod` must be specified; otherwise, an error is
* returned.
*
- * The number should be among the values of [Reducer]{@link Reducer}
+ * The number should be among the values of [Reducer]{@link google.monitoring.v3.Reducer}
*
* @property {string[]} groupByFields
* The set of fields to preserve when `crossSeriesReducer` is
@@ -137,7 +135,8 @@ var TimeInterval = {
* a single output time series. If `crossSeriesReducer` is not
* defined, this field is ignored.
*
- * @class
+ * @typedef Aggregation
+ * @memberof google.monitoring.v3
* @see [google.monitoring.v3.Aggregation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/common.proto}
*/
var Aggregation = {
@@ -148,6 +147,7 @@ var Aggregation = {
* time series into temporal alignment.
*
* @enum {number}
+ * @memberof google.monitoring.v3
*/
Aligner: {
@@ -171,7 +171,7 @@ var Aggregation = {
* Align and convert to a rate. This alignment is valid for
* cumulative metrics and delta metrics with numeric values. The output is a
* gauge metric with value type
- * {@link DOUBLE}.
+ * DOUBLE.
*/
ALIGN_RATE: 2,
@@ -214,7 +214,7 @@ var Aggregation = {
* the alignment period is the average or arithmetic mean of all
* data points in the period. This alignment is valid for gauge and delta
* metrics with numeric values. The value type of the output is
- * {@link DOUBLE}.
+ * DOUBLE.
*/
ALIGN_MEAN: 12,
@@ -223,7 +223,7 @@ var Aggregation = {
* the alignment period is the count of all data points in the
* period. This alignment is valid for gauge and delta metrics with numeric
* or Boolean values. The value type of the output is
- * {@link INT64}.
+ * INT64.
*/
ALIGN_COUNT: 13,
@@ -241,7 +241,7 @@ var Aggregation = {
* the alignment period is the standard deviation of all data
* points in the period. This alignment is valid for gauge and delta metrics
* with numeric values. The value type of the output is
- * {@link DOUBLE}.
+ * DOUBLE.
*/
ALIGN_STDDEV: 15,
@@ -250,7 +250,7 @@ var Aggregation = {
* the alignment period is the count of True-valued data points in the
* period. This alignment is valid for gauge metrics with
* Boolean values. The value type of the output is
- * {@link INT64}.
+ * INT64.
*/
ALIGN_COUNT_TRUE: 16,
@@ -259,7 +259,7 @@ var Aggregation = {
* the alignment period is the fraction of True-valued data points in the
* period. This alignment is valid for gauge metrics with Boolean values.
* The output value is in the range [0, 1] and has value type
- * {@link DOUBLE}.
+ * DOUBLE.
*/
ALIGN_FRACTION_TRUE: 17,
@@ -268,7 +268,7 @@ var Aggregation = {
* the alignment period is the 99th percentile of all data
* points in the period. This alignment is valid for gauge and delta metrics
* with distribution values. The output is a gauge metric with value type
- * {@link DOUBLE}.
+ * DOUBLE.
*/
ALIGN_PERCENTILE_99: 18,
@@ -277,7 +277,7 @@ var Aggregation = {
* the alignment period is the 95th percentile of all data
* points in the period. This alignment is valid for gauge and delta metrics
* with distribution values. The output is a gauge metric with value type
- * {@link DOUBLE}.
+ * DOUBLE.
*/
ALIGN_PERCENTILE_95: 19,
@@ -286,7 +286,7 @@ var Aggregation = {
* the alignment period is the 50th percentile of all data
* points in the period. This alignment is valid for gauge and delta metrics
* with distribution values. The output is a gauge metric with value type
- * {@link DOUBLE}.
+ * DOUBLE.
*/
ALIGN_PERCENTILE_50: 20,
@@ -295,7 +295,7 @@ var Aggregation = {
* the alignment period is the 5th percentile of all data
* points in the period. This alignment is valid for gauge and delta metrics
* with distribution values. The output is a gauge metric with value type
- * {@link DOUBLE}.
+ * DOUBLE.
*/
ALIGN_PERCENTILE_05: 21
},
@@ -305,6 +305,7 @@ var Aggregation = {
* time series into a single time series.
*
* @enum {number}
+ * @memberof google.monitoring.v3
*/
Reducer: {
@@ -318,7 +319,7 @@ var Aggregation = {
* Reduce by computing the mean 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 {@link DOUBLE}.
+ * output is DOUBLE.
*/
REDUCE_MEAN: 1,
@@ -350,7 +351,7 @@ var Aggregation = {
* 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 {@link DOUBLE}.
+ * the output is DOUBLE.
*/
REDUCE_STDDEV: 5,
@@ -359,7 +360,7 @@ var Aggregation = {
* 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
- * {@link INT64}.
+ * INT64.
*/
REDUCE_COUNT: 6,
@@ -367,7 +368,7 @@ var Aggregation = {
* Reduce by computing the count 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 {@link INT64}.
+ * the output is INT64.
*/
REDUCE_COUNT_TRUE: 7,
@@ -376,7 +377,7 @@ var Aggregation = {
* series 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, 1] and has value type
- * {@link DOUBLE}.
+ * DOUBLE.
*/
REDUCE_FRACTION_TRUE: 8,
@@ -384,7 +385,7 @@ var Aggregation = {
* Reduce by computing 99th 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
- * {@link DOUBLE}
+ * DOUBLE
*/
REDUCE_PERCENTILE_99: 9,
@@ -392,7 +393,7 @@ var Aggregation = {
* Reduce by computing 95th 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
- * {@link DOUBLE}
+ * DOUBLE
*/
REDUCE_PERCENTILE_95: 10,
@@ -400,7 +401,7 @@ var Aggregation = {
* Reduce by computing 50th 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
- * {@link DOUBLE}
+ * DOUBLE
*/
REDUCE_PERCENTILE_50: 11,
@@ -408,7 +409,7 @@ var Aggregation = {
* Reduce by computing 5th 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
- * {@link DOUBLE}
+ * DOUBLE
*/
REDUCE_PERCENTILE_05: 12
}
diff --git a/packages/monitoring/src/v3/doc/doc_group.js b/packages/monitoring/src/v3/doc/google/monitoring/v3/doc_group.js
similarity index 79%
rename from packages/monitoring/src/v3/doc/doc_group.js
rename to packages/monitoring/src/v3/doc/google/monitoring/v3/doc_group.js
index 2d03ff78472..4a7d944bc0d 100644
--- a/packages/monitoring/src/v3/doc/doc_group.js
+++ b/packages/monitoring/src/v3/doc/google/monitoring/v3/doc_group.js
@@ -1,23 +1,19 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
/**
* The description of a dynamic collection of monitored resources. Each group
@@ -69,7 +65,8 @@
* If true, the members of this group are considered to be a cluster.
* The system can perform additional analysis on groups that are clusters.
*
- * @class
+ * @typedef Group
+ * @memberof google.monitoring.v3
* @see [google.monitoring.v3.Group definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/group.proto}
*/
var Group = {
diff --git a/packages/monitoring/src/v3/doc/doc_metric.js b/packages/monitoring/src/v3/doc/google/monitoring/v3/doc_metric.js
similarity index 73%
rename from packages/monitoring/src/v3/doc/doc_metric.js
rename to packages/monitoring/src/v3/doc/google/monitoring/v3/doc_metric.js
index 0f4a2ef51e0..c884210a8b5 100644
--- a/packages/monitoring/src/v3/doc/doc_metric.js
+++ b/packages/monitoring/src/v3/doc/google/monitoring/v3/doc_metric.js
@@ -1,23 +1,19 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
/**
* A single data point in a time series.
@@ -32,14 +28,15 @@
* event resets the cumulative value to zero and sets a new start time for the
* following points.
*
- * This object should have the same structure as [TimeInterval]{@link TimeInterval}
+ * This object should have the same structure as [TimeInterval]{@link google.monitoring.v3.TimeInterval}
*
* @property {Object} value
* The value of the data point.
*
- * This object should have the same structure as [TypedValue]{@link TypedValue}
+ * This object should have the same structure as [TypedValue]{@link google.monitoring.v3.TypedValue}
*
- * @class
+ * @typedef Point
+ * @memberof google.monitoring.v3
* @see [google.monitoring.v3.Point definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/metric.proto}
*/
var Point = {
@@ -56,13 +53,13 @@ var Point = {
* The associated metric. A fully-specified metric used to identify the time
* series.
*
- * This object should have the same structure as [google.api.Metric]{@link external:"google.api.Metric"}
+ * This object should have the same structure as [Metric]{@link google.api.Metric}
*
* @property {Object} resource
* The associated resource. A fully-specified monitored resource used to
* identify the time series.
*
- * This object should have the same structure as [google.api.MonitoredResource]{@link external:"google.api.MonitoredResource"}
+ * This object should have the same structure as [MonitoredResource]{@link google.api.MonitoredResource}
*
* @property {number} metricKind
* The metric kind of the time series. When listing time series, this metric
@@ -75,7 +72,7 @@ var Point = {
* metric kind of the new descriptor and must be either `GAUGE` (the default)
* or `CUMULATIVE`.
*
- * The number should be among the values of [google.api.MetricDescriptor.MetricKind]{@link external:"google.api.MetricDescriptor.MetricKind"}
+ * The number should be among the values of [MetricKind]{@link google.api.MetricKind}
*
* @property {number} valueType
* The value type of the time series. When listing time series, this value
@@ -85,7 +82,7 @@ var Point = {
* 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.
*
- * The number should be among the values of [google.api.MetricDescriptor.ValueType]{@link external:"google.api.MetricDescriptor.ValueType"}
+ * The number should be among the values of [ValueType]{@link google.api.ValueType}
*
* @property {Object[]} points
* The data points of this time series. When listing time series, the order of
@@ -97,9 +94,10 @@ var Point = {
* the value type of the descriptor is determined by the point's type, which
* must be `BOOL`, `INT64`, `DOUBLE`, or `DISTRIBUTION`.
*
- * This object should have the same structure as [Point]{@link Point}
+ * This object should have the same structure as [Point]{@link google.monitoring.v3.Point}
*
- * @class
+ * @typedef TimeSeries
+ * @memberof google.monitoring.v3
* @see [google.monitoring.v3.TimeSeries definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/metric.proto}
*/
var TimeSeries = {
diff --git a/packages/monitoring/src/v3/doc/doc_google_protobuf_duration.js b/packages/monitoring/src/v3/doc/google/protobuf/doc_duration.js
similarity index 61%
rename from packages/monitoring/src/v3/doc/doc_google_protobuf_duration.js
rename to packages/monitoring/src/v3/doc/google/protobuf/doc_duration.js
index b81fd71f130..6b107097540 100644
--- a/packages/monitoring/src/v3/doc/doc_google_protobuf_duration.js
+++ b/packages/monitoring/src/v3/doc/google/protobuf/doc_duration.js
@@ -1,23 +1,19 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
/**
* A Duration represents a signed, fixed-length span of time represented
@@ -27,6 +23,8 @@
* two Timestamp values is a Duration and it can be added or subtracted
* from a Timestamp. Range is approximately +-10,000 years.
*
+ * # Examples
+ *
* Example 1: Compute Duration from two Timestamps in pseudo code.
*
* Timestamp start = ...;
@@ -67,10 +65,20 @@
* duration = Duration()
* duration.FromTimedelta(td)
*
- * @external "google.protobuf.Duration"
+ * # JSON Mapping
+ *
+ * In JSON format, the Duration type is encoded as a string rather than an
+ * object, where the string ends in the suffix "s" (indicating seconds) and
+ * is preceded by the number of seconds, with nanoseconds expressed as
+ * fractional seconds. For example, 3 seconds with 0 nanoseconds should be
+ * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
+ * be expressed in JSON format as "3.000000001s", and 3 seconds and 1
+ * microsecond should be expressed in JSON format as "3.000001s".
+ *
* @property {number} seconds
* Signed seconds of the span of time. Must be from -315,576,000,000
- * to +315,576,000,000 inclusive.
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
*
* @property {number} nanos
* Signed fractions of a second at nanosecond resolution of the span
@@ -80,5 +88,10 @@
* of the same sign as the `seconds` field. Must be from -999,999,999
* to +999,999,999 inclusive.
*
+ * @typedef Duration
+ * @memberof google.protobuf
* @see [google.protobuf.Duration definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/duration.proto}
- */
\ No newline at end of file
+ */
+var Duration = {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+};
\ No newline at end of file
diff --git a/packages/monitoring/src/v3/doc/doc_google_protobuf_timestamp.js b/packages/monitoring/src/v3/doc/google/protobuf/doc_timestamp.js
similarity index 54%
rename from packages/monitoring/src/v3/doc/doc_google_protobuf_timestamp.js
rename to packages/monitoring/src/v3/doc/google/protobuf/doc_timestamp.js
index ed8fc627b92..431e2fd5892 100644
--- a/packages/monitoring/src/v3/doc/doc_google_protobuf_timestamp.js
+++ b/packages/monitoring/src/v3/doc/google/protobuf/doc_timestamp.js
@@ -1,23 +1,19 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-/*
- * Note: this file is purely for documentation. Any contents are not expected
- * to be loaded as the JS file.
- */
+// Note: this file is purely for documentation. Any contents are not expected
+// to be loaded as the JS file.
/**
* A Timestamp represents a point in time independent of any time zone
@@ -32,6 +28,8 @@
* and from RFC 3339 date strings.
* See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
*
+ * # Examples
+ *
* Example 1: Compute Timestamp from POSIX `time()`.
*
* Timestamp timestamp;
@@ -72,7 +70,29 @@
* timestamp = Timestamp()
* timestamp.GetCurrentTime()
*
- * @external "google.protobuf.Timestamp"
+ * # JSON Mapping
+ *
+ * In JSON format, the Timestamp type is encoded as a string in the
+ * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
+ * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
+ * where {year} is always expressed using four digits while {month}, {day},
+ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
+ * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
+ * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
+ * is required, though only UTC (as indicated by "Z") is presently supported.
+ *
+ * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
+ * 01:30 UTC on January 15, 2017.
+ *
+ * In JavaScript, one can convert a Date object to this format using the
+ * standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
+ * method. In Python, a standard `datetime.datetime` object can be converted
+ * to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
+ * with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
+ * can use the Joda Time's [`ISODateTimeFormat.dateTime()`](https://cloud.google.com
+ * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
+ * to obtain a formatter capable of generating timestamps in this format.
+ *
* @property {number} seconds
* Represents seconds of UTC time since Unix epoch
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
@@ -84,5 +104,10 @@
* that count forward in time. Must be from 0 to 999,999,999
* inclusive.
*
+ * @typedef Timestamp
+ * @memberof google.protobuf
* @see [google.protobuf.Timestamp definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto}
- */
\ No newline at end of file
+ */
+var Timestamp = {
+ // This is for documentation. Actual contents will be loaded by gRPC.
+};
\ No newline at end of file
diff --git a/packages/monitoring/src/v3/group_service_client.js b/packages/monitoring/src/v3/group_service_client.js
index 4f11033ae72..84324dea810 100644
--- a/packages/monitoring/src/v3/group_service_client.js
+++ b/packages/monitoring/src/v3/group_service_client.js
@@ -1,63 +1,25 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- *
- * EDITING INSTRUCTIONS
- * This file was generated from the file
- * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/group_service.proto,
- * and updates to that file get reflected here through a refresh process.
- * For the short term, the refresh process will only be runnable by Google
- * engineers.
- *
- * The only allowed edits are to method and file documentation. A 3-way
- * merge preserves those additions if the generated source changes.
- */
-/* TODO: introduce line-wrapping so that it never exceeds the limit. */
-/* jscs: disable maximumLineLength */
-'use strict';
-
-var configData = require('./group_service_client_config');
-var extend = require('extend');
-var gax = require('google-gax');
-
-var SERVICE_ADDRESS = 'monitoring.googleapis.com';
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-var DEFAULT_SERVICE_PORT = 443;
-
-var CODE_GEN_NAME_VERSION = 'gapic/0.0.5';
+'use strict';
-var PAGE_DESCRIPTORS = {
- listGroups: new gax.PageDescriptor(
- 'pageToken',
- 'nextPageToken',
- 'group'),
- listGroupMembers: new gax.PageDescriptor(
- 'pageToken',
- 'nextPageToken',
- 'members')
-};
+const gapicConfig = require('./group_service_client_config');
+const gax = require('google-gax');
+const merge = require('lodash.merge');
+const path = require('path');
-/**
- * The scopes needed to make gRPC calls to all of the methods defined in
- * this service.
- */
-var ALL_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'
-];
+const VERSION = require('../../package.json').version;
/**
* The Group API lets you inspect and manage your
@@ -73,727 +35,813 @@ var ALL_SCOPES = [
* updated automatically as monitored resources are added and removed
* from the infrastructure.
*
- *
* @class
+ * @memberof v3
*/
-function GroupServiceClient(gaxGrpc, grpcClients, opts) {
- opts = extend({
- servicePath: SERVICE_ADDRESS,
- port: DEFAULT_SERVICE_PORT,
- clientConfig: {}
- }, opts);
-
- var googleApiClient = [
- 'gl-node/' + process.versions.node
- ];
- if (opts.libName && opts.libVersion) {
- googleApiClient.push(opts.libName + '/' + opts.libVersion);
- }
- googleApiClient.push(
- CODE_GEN_NAME_VERSION,
- 'gax/' + gax.version,
- 'grpc/' + gaxGrpc.grpcVersion
- );
-
- var defaults = gaxGrpc.constructSettings(
+class GroupServiceClient {
+ /**
+ * 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
+ * usaing 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 above 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.servicePath - The domain name of the
+ * API remote host.
+ */
+ constructor(opts) {
+ this._descriptors = {};
+
+ // Ensure that options include the service address and port.
+ opts = Object.assign(
+ {
+ clientConfig: {},
+ port: this.constructor.port,
+ servicePath: this.constructor.servicePath,
+ },
+ opts
+ );
+
+ // Create a `gaxGrpc` object, with any grpc-specific options
+ // sent to the client.
+ opts.scopes = this.constructor.scopes;
+ var gaxGrpc = gax.grpc(opts);
+
+ // Save the auth object to the client, for use by other methods.
+ this.auth = gaxGrpc.auth;
+
+ // Determine the client header string.
+ var clientHeader = [
+ `gl-node/${process.version.node}`,
+ `grpc/${gaxGrpc.grpcVersion}`,
+ `gax/${gax.version}`,
+ `gapic/${VERSION}`,
+ ];
+ if (opts.libName && opts.libVersion) {
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
+ }
+
+ // Load the applicable protos.
+ var protos = merge(
+ {},
+ gaxGrpc.loadProto(
+ path.join(__dirname, '..', '..', 'protos'),
+ 'google/monitoring/v3/group_service.proto'
+ )
+ );
+
+ // This API contains "path templates"; forward-slash-separated
+ // identifiers to uniquely identify resources within the API.
+ // Create useful helper objects for these.
+ this._pathTemplates = {
+ projectPathTemplate: new gax.PathTemplate(
+ 'projects/{project}'
+ ),
+ groupPathTemplate: new gax.PathTemplate(
+ 'projects/{project}/groups/{group}'
+ ),
+ };
+
+ // 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 gax.PageDescriptor(
+ 'pageToken',
+ 'nextPageToken',
+ 'group'
+ ),
+ listGroupMembers: new gax.PageDescriptor(
+ 'pageToken',
+ 'nextPageToken',
+ 'members'
+ ),
+ };
+
+ // Put together the default options sent with requests.
+ var defaults = gaxGrpc.constructSettings(
'google.monitoring.v3.GroupService',
- configData,
+ gapicConfig,
opts.clientConfig,
- {'x-goog-api-client': googleApiClient.join(' ')});
-
- var self = this;
-
- this.auth = gaxGrpc.auth;
- var groupServiceStub = gaxGrpc.createStub(
- grpcClients.google.monitoring.v3.GroupService,
- opts);
- var groupServiceStubMethods = [
- 'listGroups',
- 'getGroup',
- 'createGroup',
- 'updateGroup',
- 'deleteGroup',
- 'listGroupMembers'
- ];
- groupServiceStubMethods.forEach(function(methodName) {
- self['_' + methodName] = gax.createApiCall(
- groupServiceStub.then(function(groupServiceStub) {
- return function() {
- var args = Array.prototype.slice.call(arguments, 0);
- return groupServiceStub[methodName].apply(groupServiceStub, args);
- };
- }),
- defaults[methodName],
- PAGE_DESCRIPTORS[methodName]);
- });
-}
-
-// Path templates
-
-var PROJECT_PATH_TEMPLATE = new gax.PathTemplate(
- 'projects/{project}');
-
-var GROUP_PATH_TEMPLATE = new gax.PathTemplate(
- 'projects/{project}/groups/{group}');
-
-/**
- * Returns a fully-qualified project resource name string.
- * @param {String} project
- * @returns {String}
- */
-GroupServiceClient.prototype.projectPath = function(project) {
- return PROJECT_PATH_TEMPLATE.render({
- project: project
- });
-};
-
-/**
- * Returns a fully-qualified group resource name string.
- * @param {String} project
- * @param {String} group
- * @returns {String}
- */
-GroupServiceClient.prototype.groupPath = function(project, group) {
- return GROUP_PATH_TEMPLATE.render({
- project: project,
- group: group
- });
-};
-
-/**
- * Parses the projectName from a project resource.
- * @param {String} projectName
- * A fully-qualified path representing a project resources.
- * @returns {String} - A string representing the project.
- */
-GroupServiceClient.prototype.matchProjectFromProjectName = function(projectName) {
- return PROJECT_PATH_TEMPLATE.match(projectName).project;
-};
-
-/**
- * Parses the groupName from a group resource.
- * @param {String} groupName
- * A fully-qualified path representing a group resources.
- * @returns {String} - A string representing the project.
- */
-GroupServiceClient.prototype.matchProjectFromGroupName = function(groupName) {
- return GROUP_PATH_TEMPLATE.match(groupName).project;
-};
-
-/**
- * Parses the groupName from a group resource.
- * @param {String} groupName
- * A fully-qualified path representing a group resources.
- * @returns {String} - A string representing the group.
- */
-GroupServiceClient.prototype.matchGroupFromGroupName = function(groupName) {
- return GROUP_PATH_TEMPLATE.match(groupName).group;
-};
-
-/**
- * Get the project ID used by this class.
- * @param {function(Error, string)} callback - the callback to be called with
- * the current project Id.
- */
-GroupServiceClient.prototype.getProjectId = function(callback) {
- return this.auth.getProjectId(callback);
-};
-
-// Service calls
-
-/**
- * Lists the existing groups.
- *
- * @param {Object} request
- * The request object that will be sent.
- * @param {string} request.name
- * 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
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is Array of [Group]{@link Group}.
- *
- * When autoPaginate: false is specified through options, it contains the result
- * in a single response. If the response indicates the next page exists, the third
- * parameter is set to be used for the next request object. The fourth parameter keeps
- * the raw response object of an object representing [ListGroupsResponse]{@link ListGroupsResponse}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is Array of [Group]{@link Group}.
- *
- * When autoPaginate: false is specified through options, the array has three elements.
- * The first element is Array of [Group]{@link Group} in a single response.
- * The second element is the next request object if the response
- * indicates the next page exists, or null. The third element is
- * an object representing [ListGroupsResponse]{@link ListGroupsResponse}.
- *
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.group({
- * // optional auth parameters.
- * });
- *
- * // Iterate over all elements.
- * var formattedName = client.projectPath("[PROJECT]");
- *
- * client.listGroups({name: formattedName}).then(function(responses) {
- * var resources = responses[0];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i])
- * }
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- *
- * // Or obtain the paged response.
- * var formattedName = client.projectPath("[PROJECT]");
- *
- *
- * var options = {autoPaginate: false};
- * function callback(responses) {
- * // The actual resources in a response.
- * var resources = responses[0];
- * // The next request if the response shows there's more responses.
- * var nextRequest = responses[1];
- * // The actual response object, if necessary.
- * // var rawResponse = responses[2];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i]);
- * }
- * if (nextRequest) {
- * // Fetch the next page.
- * return client.listGroups(nextRequest, options).then(callback);
- * }
- * }
- * client.listGroups({name: formattedName}, options)
- * .then(callback)
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-GroupServiceClient.prototype.listGroups = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
+ {'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.
+ var groupServiceStub = gaxGrpc.createStub(
+ protos.google.monitoring.v3.GroupService,
+ opts
+ );
+
+ // Iterate over each of the methods that the service provides
+ // and create an API call method for each.
+ var groupServiceStubMethods = [
+ 'listGroups',
+ 'getGroup',
+ 'createGroup',
+ 'updateGroup',
+ 'deleteGroup',
+ 'listGroupMembers',
+ ];
+ for (let methodName of groupServiceStubMethods) {
+ this._innerApiCalls[methodName] = gax.createApiCall(
+ groupServiceStub.then(
+ stub =>
+ function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ return stub[methodName].apply(stub, args);
+ }
+ ),
+ defaults[methodName],
+ this._descriptors.page[methodName]
+ );
+ }
}
- if (options === undefined) {
- options = {};
- }
-
- return this._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
- * 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
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @return {Stream}
- * An object stream which emits an object representing [Group]{@link Group} on 'data' event.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.group({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.projectPath("[PROJECT]");
- * client.listGroupsStream({name: formattedName})
- * .on('data', function(element) {
- * // doThingsWith(element)
- * }).on('error', function(err) {
- * console.log(err);
- * });
- */
-GroupServiceClient.prototype.listGroupsStream = function(request, options) {
- if (options === undefined) {
- options = {};
+ /**
+ * The DNS address for this API service.
+ */
+ static get servicePath() {
+ return 'monitoring.googleapis.com';
}
- return PAGE_DESCRIPTORS.listGroups.createStream(this._listGroups, request, options);
-};
-
-/**
- * Gets a single group.
- *
- * @param {Object} request
- * The request object that will be sent.
- * @param {string} request.name
- * The group to retrieve. The format is
- * `"projects/{project_id_or_number}/groups/{group_id}"`.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is an object representing [Group]{@link Group}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is an object representing [Group]{@link Group}.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.group({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
- * client.getGroup({name: formattedName}).then(function(responses) {
- * var response = responses[0];
- * // doThingsWith(response)
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-GroupServiceClient.prototype.getGroup = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ /**
+ * The port for this API service.
+ */
+ static get port() {
+ return 443;
}
- return this._getGroup(request, options, callback);
-};
-
-/**
- * Creates a new group.
- *
- * @param {Object} request
- * The request object that will be sent.
- * @param {string} request.name
- * The project in which to create the group. The format is
- * `"projects/{project_id_or_number}"`.
- * @param {Object} request.group
- * A group definition. It is an error to define the `name` field because
- * the system assigns the name.
- *
- * This object should have the same structure as [Group]{@link Group}
- * @param {boolean=} request.validateOnly
- * If true, validate this request but do not create the group.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is an object representing [Group]{@link Group}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is an object representing [Group]{@link Group}.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.group({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.projectPath("[PROJECT]");
- * var group = {};
- * var request = {
- * name: formattedName,
- * group: group
- * };
- * client.createGroup(request).then(function(responses) {
- * var response = responses[0];
- * // doThingsWith(response)
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-GroupServiceClient.prototype.createGroup = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
+ /**
+ * 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',
+ ];
}
- if (options === undefined) {
- options = {};
+
+ /**
+ * 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) {
+ return this.auth.getProjectId(callback);
}
- return this._createGroup(request, options, callback);
-};
+ // -------------------
+ // -- Service calls --
+ // -------------------
-/**
- * Updates an existing group.
- * You can change any group attributes except `name`.
- *
- * @param {Object} request
- * The request object that will be sent.
- * @param {Object} request.group
- * The new definition of the group. All fields of the existing group,
- * excepting `name`, are replaced with the corresponding fields of this group.
- *
- * This object should have the same structure as [Group]{@link Group}
- * @param {boolean=} request.validateOnly
- * If true, validate this request but do not update the existing group.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is an object representing [Group]{@link Group}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is an object representing [Group]{@link Group}.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.group({
- * // optional auth parameters.
- * });
- *
- * var group = {};
- * client.updateGroup({group: group}).then(function(responses) {
- * var response = responses[0];
- * // doThingsWith(response)
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-GroupServiceClient.prototype.updateGroup = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ /**
+ * Lists the existing groups.
+ *
+ * @param {Object} request
+ * The request object that will be sent.
+ * @param {string} request.name
+ * 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
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is Array of [Group]{@link google.monitoring.v3.Group}.
+ *
+ * When autoPaginate: false is specified through options, it contains the result
+ * in a single response. If the response indicates the next page exists, the third
+ * parameter is set to be used for the next request object. The fourth parameter keeps
+ * the raw response object of an object representing [ListGroupsResponse]{@link google.monitoring.v3.ListGroupsResponse}.
+ * @returns {Promise} - The promise which resolves to an array.
+ * The first element of the array is Array of [Group]{@link google.monitoring.v3.Group}.
+ *
+ * When autoPaginate: false is specified through options, the array has three elements.
+ * The first element is Array of [Group]{@link google.monitoring.v3.Group} in a single response.
+ * The second element is the next request object if the response
+ * indicates the next page exists, or null. The third element is
+ * an object representing [ListGroupsResponse]{@link google.monitoring.v3.ListGroupsResponse}.
+ *
+ * The promise has a method named "cancel" which cancels the ongoing API call.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.GroupServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * // Iterate over all elements.
+ * var formattedName = client.projectPath('[PROJECT]');
+ *
+ * client.listGroups({name: formattedName})
+ * .then(responses => {
+ * var resources = responses[0];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i])
+ * }
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ *
+ * // Or obtain the paged response.
+ * var formattedName = client.projectPath('[PROJECT]');
+ *
+ *
+ * var options = {autoPaginate: false};
+ * var callback = responses => {
+ * // The actual resources in a response.
+ * var resources = responses[0];
+ * // The next request if the response shows that there are more responses.
+ * var nextRequest = responses[1];
+ * // The actual response object, if necessary.
+ * // var rawResponse = responses[2];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i]);
+ * }
+ * if (nextRequest) {
+ * // Fetch the next page.
+ * return client.listGroups(nextRequest, options).then(callback);
+ * }
+ * }
+ * client.listGroups({name: formattedName}, options)
+ * .then(callback)
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ listGroups(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ return this._innerApiCalls.listGroups(request, options, callback);
}
- return this._updateGroup(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
+ * 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
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @returns {Stream}
+ * An object stream which emits an object representing [Group]{@link google.monitoring.v3.Group} on 'data' event.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.GroupServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.projectPath('[PROJECT]');
+ * client.listGroupsStream({name: formattedName})
+ * .on('data', element => {
+ * // doThingsWith(element)
+ * }).on('error', err => {
+ * console.log(err);
+ * });
+ */
+ listGroupsStream(request, options) {
+ options = options || {};
+
+ return this._descriptors.page.listGroups.createStream(
+ this._innerApiCalls.listGroups,
+ request,
+ options
+ );
+ };
-/**
- * Deletes an existing group.
- *
- * @param {Object} request
- * The request object that will be sent.
- * @param {string} request.name
- * The group to delete. The format is
- * `"projects/{project_id_or_number}/groups/{group_id}"`.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error)=} callback
- * The function which will be called with the result of the API call.
- * @return {Promise} - The promise which resolves when API call finishes.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.group({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
- * client.deleteGroup({name: formattedName}).catch(function(err) {
- * console.error(err);
- * });
- */
-GroupServiceClient.prototype.deleteGroup = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
+ /**
+ * Gets a single group.
+ *
+ * @param {Object} request
+ * The request object that will be sent.
+ * @param {string} request.name
+ * The group to retrieve. The format is
+ * `"projects/{project_id_or_number}/groups/{group_id}"`.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is an object representing [Group]{@link google.monitoring.v3.Group}.
+ * @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.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.GroupServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
+ * client.getGroup({name: formattedName})
+ * .then(responses => {
+ * var response = responses[0];
+ * // doThingsWith(response)
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ getGroup(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ return this._innerApiCalls.getGroup(request, options, callback);
}
- if (options === undefined) {
- options = {};
+
+ /**
+ * Creates a new group.
+ *
+ * @param {Object} request
+ * The request object that will be sent.
+ * @param {string} request.name
+ * The project in which to create the group. The format is
+ * `"projects/{project_id_or_number}"`.
+ * @param {Object} request.group
+ * A group definition. It is an error to define the `name` field because
+ * the system assigns the name.
+ *
+ * This object should have the same structure as [Group]{@link google.monitoring.v3.Group}
+ * @param {boolean=} request.validateOnly
+ * If true, validate this request but do not create the group.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is an object representing [Group]{@link google.monitoring.v3.Group}.
+ * @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.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.GroupServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.projectPath('[PROJECT]');
+ * var group = {};
+ * var request = {
+ * name: formattedName,
+ * group: group,
+ * };
+ * client.createGroup(request)
+ * .then(responses => {
+ * var response = responses[0];
+ * // doThingsWith(response)
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ createGroup(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ return this._innerApiCalls.createGroup(request, options, callback);
}
- return this._deleteGroup(request, options, callback);
-};
+ /**
+ * Updates an existing group.
+ * You can change any group attributes except `name`.
+ *
+ * @param {Object} request
+ * The request object that will be sent.
+ * @param {Object} request.group
+ * The new definition of the group. All fields of the existing group,
+ * excepting `name`, are replaced with the corresponding fields of this group.
+ *
+ * This object should have the same structure as [Group]{@link google.monitoring.v3.Group}
+ * @param {boolean=} request.validateOnly
+ * If true, validate this request but do not update the existing group.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is an object representing [Group]{@link google.monitoring.v3.Group}.
+ * @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.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.GroupServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var group = {};
+ * client.updateGroup({group: group})
+ * .then(responses => {
+ * var response = responses[0];
+ * // doThingsWith(response)
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ updateGroup(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ return this._innerApiCalls.updateGroup(request, options, callback);
+ }
-/**
- * Lists the monitored resources that are members of a group.
- *
- * @param {Object} request
- * The request object that will be sent.
- * @param {string} request.name
- * The group whose members are listed. The format is
- * `"projects/{project_id_or_number}/groups/{group_id}"`.
- * @param {number=} request.pageSize
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {string=} request.filter
- * An optional [list filter](https://cloud.google.com/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 {Object=} 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.
- *
- * This object should have the same structure as [TimeInterval]{@link TimeInterval}
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is Array of [google.api.MonitoredResource]{@link external:"google.api.MonitoredResource"}.
- *
- * When autoPaginate: false is specified through options, it contains the result
- * in a single response. If the response indicates the next page exists, the third
- * parameter is set to be used for the next request object. The fourth parameter keeps
- * the raw response object of an object representing [ListGroupMembersResponse]{@link ListGroupMembersResponse}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is Array of [google.api.MonitoredResource]{@link external:"google.api.MonitoredResource"}.
- *
- * When autoPaginate: false is specified through options, the array has three elements.
- * The first element is Array of [google.api.MonitoredResource]{@link external:"google.api.MonitoredResource"} in a single response.
- * The second element is the next request object if the response
- * indicates the next page exists, or null. The third element is
- * an object representing [ListGroupMembersResponse]{@link ListGroupMembersResponse}.
- *
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.group({
- * // optional auth parameters.
- * });
- *
- * // Iterate over all elements.
- * var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
- *
- * client.listGroupMembers({name: formattedName}).then(function(responses) {
- * var resources = responses[0];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i])
- * }
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- *
- * // Or obtain the paged response.
- * var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
- *
- *
- * var options = {autoPaginate: false};
- * function callback(responses) {
- * // The actual resources in a response.
- * var resources = responses[0];
- * // The next request if the response shows there's more responses.
- * var nextRequest = responses[1];
- * // The actual response object, if necessary.
- * // var rawResponse = responses[2];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i]);
- * }
- * if (nextRequest) {
- * // Fetch the next page.
- * return client.listGroupMembers(nextRequest, options).then(callback);
- * }
- * }
- * client.listGroupMembers({name: formattedName}, options)
- * .then(callback)
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-GroupServiceClient.prototype.listGroupMembers = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
+ /**
+ * Deletes an existing group.
+ *
+ * @param {Object} request
+ * The request object that will be sent.
+ * @param {string} request.name
+ * The group to delete. The format is
+ * `"projects/{project_id_or_number}/groups/{group_id}"`.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error)=} callback
+ * The function which will be called with the result of the API call.
+ * @returns {Promise} - The promise which resolves when API call finishes.
+ * The promise has a method named "cancel" which cancels the ongoing API call.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.GroupServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
+ * client.deleteGroup({name: formattedName}).catch(err => {
+ * console.error(err);
+ * });
+ */
+ deleteGroup(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ return this._innerApiCalls.deleteGroup(request, options, callback);
}
- if (options === undefined) {
- options = {};
+
+ /**
+ * Lists the monitored resources that are members of a group.
+ *
+ * @param {Object} request
+ * The request object that will be sent.
+ * @param {string} request.name
+ * The group whose members are listed. The format is
+ * `"projects/{project_id_or_number}/groups/{group_id}"`.
+ * @param {number=} request.pageSize
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {string=} request.filter
+ * An optional [list filter](https://cloud.google.com/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 {Object=} 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.
+ *
+ * This object should have the same structure as [TimeInterval]{@link google.monitoring.v3.TimeInterval}
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is Array of [MonitoredResource]{@link google.api.MonitoredResource}.
+ *
+ * When autoPaginate: false is specified through options, it contains the result
+ * in a single response. If the response indicates the next page exists, the third
+ * parameter is set to be used for the next request object. The fourth parameter keeps
+ * the raw response object of an object representing [ListGroupMembersResponse]{@link google.monitoring.v3.ListGroupMembersResponse}.
+ * @returns {Promise} - The promise which resolves to an array.
+ * The first element of the array is Array of [MonitoredResource]{@link google.api.MonitoredResource}.
+ *
+ * When autoPaginate: false is specified through options, the array has three elements.
+ * The first element is Array of [MonitoredResource]{@link google.api.MonitoredResource} in a single response.
+ * The second element is the next request object if the response
+ * indicates the next page exists, or null. The third element is
+ * an object representing [ListGroupMembersResponse]{@link google.monitoring.v3.ListGroupMembersResponse}.
+ *
+ * The promise has a method named "cancel" which cancels the ongoing API call.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.GroupServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * // Iterate over all elements.
+ * var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
+ *
+ * client.listGroupMembers({name: formattedName})
+ * .then(responses => {
+ * var resources = responses[0];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i])
+ * }
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ *
+ * // Or obtain the paged response.
+ * var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
+ *
+ *
+ * var options = {autoPaginate: false};
+ * var callback = responses => {
+ * // The actual resources in a response.
+ * var resources = responses[0];
+ * // The next request if the response shows that there are more responses.
+ * var nextRequest = responses[1];
+ * // The actual response object, if necessary.
+ * // var rawResponse = responses[2];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i]);
+ * }
+ * if (nextRequest) {
+ * // Fetch the next page.
+ * return client.listGroupMembers(nextRequest, options).then(callback);
+ * }
+ * }
+ * client.listGroupMembers({name: formattedName}, options)
+ * .then(callback)
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ listGroupMembers(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ return this._innerApiCalls.listGroupMembers(request, options, callback);
}
- return this._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
+ * The group whose members are listed. The format is
+ * `"projects/{project_id_or_number}/groups/{group_id}"`.
+ * @param {number=} request.pageSize
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {string=} request.filter
+ * An optional [list filter](https://cloud.google.com/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 {Object=} 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.
+ *
+ * This object should have the same structure as [TimeInterval]{@link google.monitoring.v3.TimeInterval}
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @returns {Stream}
+ * An object stream which emits an object representing [MonitoredResource]{@link google.api.MonitoredResource} on 'data' event.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.GroupServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
+ * client.listGroupMembersStream({name: formattedName})
+ * .on('data', element => {
+ * // doThingsWith(element)
+ * }).on('error', err => {
+ * console.log(err);
+ * });
+ */
+ listGroupMembersStream(request, options) {
+ options = options || {};
+
+ return this._descriptors.page.listGroupMembers.createStream(
+ this._innerApiCalls.listGroupMembers,
+ request,
+ options
+ );
+ };
-/**
- * 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
- * The group whose members are listed. The format is
- * `"projects/{project_id_or_number}/groups/{group_id}"`.
- * @param {number=} request.pageSize
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {string=} request.filter
- * An optional [list filter](https://cloud.google.com/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 {Object=} 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.
- *
- * This object should have the same structure as [TimeInterval]{@link TimeInterval}
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @return {Stream}
- * An object stream which emits an object representing [google.api.MonitoredResource]{@link external:"google.api.MonitoredResource"} on 'data' event.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.group({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
- * client.listGroupMembersStream({name: formattedName})
- * .on('data', function(element) {
- * // doThingsWith(element)
- * }).on('error', function(err) {
- * console.log(err);
- * });
- */
-GroupServiceClient.prototype.listGroupMembersStream = function(request, options) {
- if (options === undefined) {
- options = {};
- }
+ // --------------------
+ // -- Path templates --
+ // --------------------
- return PAGE_DESCRIPTORS.listGroupMembers.createStream(this._listGroupMembers, request, options);
-};
+ /**
+ * Return a fully-qualified project resource name string.
+ *
+ * @param {String} project
+ * @returns {String}
+ */
+ projectPath(project) {
+ return this._pathTemplates.projectPathTemplate.render({
+ project: project,
+ });
+ }
-function GroupServiceClientBuilder(gaxGrpc) {
- if (!(this instanceof GroupServiceClientBuilder)) {
- return new GroupServiceClientBuilder(gaxGrpc);
+ /**
+ * Return a fully-qualified group resource name string.
+ *
+ * @param {String} project
+ * @param {String} group
+ * @returns {String}
+ */
+ groupPath(project, group) {
+ return this._pathTemplates.groupPathTemplate.render({
+ project: project,
+ group: group,
+ });
}
- var groupServiceClient = gaxGrpc.load([{
- root: require('google-proto-files')('..'),
- file: 'google/monitoring/v3/group_service.proto'
- }]);
- extend(this, groupServiceClient.google.monitoring.v3);
+ /**
+ * Parse the projectName from a project resource.
+ *
+ * @param {String} projectName
+ * A fully-qualified path representing a project resources.
+ * @returns {String} - A string representing the project.
+ */
+ matchProjectFromProjectName(projectName) {
+ return projectPathTemplate.match(projectName).project;
+ }
+ /**
+ * Parse the groupName from a group resource.
+ *
+ * @param {String} groupName
+ * A fully-qualified path representing a group resources.
+ * @returns {String} - A string representing the project.
+ */
+ matchProjectFromGroupName(groupName) {
+ return groupPathTemplate.match(groupName).project;
+ }
/**
- * Build a new instance of {@link GroupServiceClient}.
- *
- * @param {Object=} opts - The optional parameters.
- * @param {String=} opts.servicePath
- * The domain name of the API remote host.
- * @param {number=} opts.port
- * The port on which to connect to the remote host.
- * @param {grpc.ClientCredentials=} opts.sslCreds
- * A ClientCredentials for use with an SSL-enabled channel.
- * @param {Object=} opts.clientConfig
- * The customized config to build the call settings. See
- * {@link gax.constructSettings} for the format.
+ * Parse the groupName from a group resource.
+ *
+ * @param {String} groupName
+ * A fully-qualified path representing a group resources.
+ * @returns {String} - A string representing the group.
*/
- this.groupServiceClient = function(opts) {
- return new GroupServiceClient(gaxGrpc, groupServiceClient, opts);
- };
- extend(this.groupServiceClient, GroupServiceClient);
+ matchGroupFromGroupName(groupName) {
+ return groupPathTemplate.match(groupName).group;
+ }
}
-module.exports = GroupServiceClientBuilder;
-module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS;
-module.exports.ALL_SCOPES = ALL_SCOPES;
\ No newline at end of file
+
+
+module.exports = GroupServiceClient;
diff --git a/packages/monitoring/src/v3/index.js b/packages/monitoring/src/v3/index.js
index c639c388578..f568dc718c8 100644
--- a/packages/monitoring/src/v3/index.js
+++ b/packages/monitoring/src/v3/index.js
@@ -1,38 +1,21 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
-'use strict';
-
-var groupServiceClient = require('./group_service_client');
-var metricServiceClient = require('./metric_service_client');
-var gax = require('google-gax');
-var extend = require('extend');
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-function v3(options) {
- options = extend({
- scopes: v3.ALL_SCOPES
- }, options);
- var gaxGrpc = gax.grpc(options);
- var result = {};
- extend(result, groupServiceClient(gaxGrpc));
- extend(result, metricServiceClient(gaxGrpc));
- return result;
-}
+'use strict';
-v3.GAPIC_VERSION = '0.0.5';
-v3.SERVICE_ADDRESS = groupServiceClient.SERVICE_ADDRESS;
-v3.ALL_SCOPES = groupServiceClient.ALL_SCOPES;
+const GroupServiceClient = require('./group_service_client');
+const MetricServiceClient = require('./metric_service_client');
-module.exports = v3;
\ No newline at end of file
+module.exports.GroupServiceClient = GroupServiceClient;
+module.exports.MetricServiceClient = MetricServiceClient;
diff --git a/packages/monitoring/src/v3/metric_service_client.js b/packages/monitoring/src/v3/metric_service_client.js
index 59d0eb01631..5d1faaf29f6 100644
--- a/packages/monitoring/src/v3/metric_service_client.js
+++ b/packages/monitoring/src/v3/metric_service_client.js
@@ -1,1097 +1,1148 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- *
- * EDITING INSTRUCTIONS
- * This file was generated from the file
- * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/metric_service.proto,
- * and updates to that file get reflected here through a refresh process.
- * For the short term, the refresh process will only be runnable by Google
- * engineers.
- *
- * The only allowed edits are to method and file documentation. A 3-way
- * merge preserves those additions if the generated source changes.
- */
-/* TODO: introduce line-wrapping so that it never exceeds the limit. */
-/* jscs: disable maximumLineLength */
-'use strict';
-
-var configData = require('./metric_service_client_config');
-var extend = require('extend');
-var gax = require('google-gax');
-
-var SERVICE_ADDRESS = 'monitoring.googleapis.com';
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
-var DEFAULT_SERVICE_PORT = 443;
+'use strict';
-var CODE_GEN_NAME_VERSION = 'gapic/0.0.5';
+const gapicConfig = require('./metric_service_client_config');
+const gax = require('google-gax');
+const merge = require('lodash.merge');
+const path = require('path');
-var PAGE_DESCRIPTORS = {
- listMonitoredResourceDescriptors: new gax.PageDescriptor(
- 'pageToken',
- 'nextPageToken',
- 'resourceDescriptors'),
- listMetricDescriptors: new gax.PageDescriptor(
- 'pageToken',
- 'nextPageToken',
- 'metricDescriptors'),
- listTimeSeries: new gax.PageDescriptor(
- 'pageToken',
- 'nextPageToken',
- 'timeSeries')
-};
-
-/**
- * The scopes needed to make gRPC calls to all of the methods defined in
- * this service.
- */
-var ALL_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'
-];
+const VERSION = require('../../package.json').version;
/**
* Manages metric descriptors, monitored resource descriptors, and
* time series data.
*
- *
* @class
+ * @memberof v3
*/
-function MetricServiceClient(gaxGrpc, grpcClients, opts) {
- opts = extend({
- servicePath: SERVICE_ADDRESS,
- port: DEFAULT_SERVICE_PORT,
- clientConfig: {}
- }, opts);
-
- var googleApiClient = [
- 'gl-node/' + process.versions.node
- ];
- if (opts.libName && opts.libVersion) {
- googleApiClient.push(opts.libName + '/' + opts.libVersion);
- }
- googleApiClient.push(
- CODE_GEN_NAME_VERSION,
- 'gax/' + gax.version,
- 'grpc/' + gaxGrpc.grpcVersion
- );
+class MetricServiceClient {
+ /**
+ * 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
+ * usaing 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 above 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.servicePath - The domain name of the
+ * API remote host.
+ */
+ constructor(opts) {
+ this._descriptors = {};
- var defaults = gaxGrpc.constructSettings(
- 'google.monitoring.v3.MetricService',
- configData,
- opts.clientConfig,
- {'x-goog-api-client': googleApiClient.join(' ')});
+ // Ensure that options include the service address and port.
+ opts = Object.assign(
+ {
+ clientConfig: {},
+ port: this.constructor.port,
+ servicePath: this.constructor.servicePath,
+ },
+ opts
+ );
- var self = this;
+ // Create a `gaxGrpc` object, with any grpc-specific options
+ // sent to the client.
+ opts.scopes = this.constructor.scopes;
+ var gaxGrpc = gax.grpc(opts);
- this.auth = gaxGrpc.auth;
- var metricServiceStub = gaxGrpc.createStub(
- grpcClients.google.monitoring.v3.MetricService,
- opts);
- var metricServiceStubMethods = [
- 'listMonitoredResourceDescriptors',
- 'getMonitoredResourceDescriptor',
- 'listMetricDescriptors',
- 'getMetricDescriptor',
- 'createMetricDescriptor',
- 'deleteMetricDescriptor',
- 'listTimeSeries',
- 'createTimeSeries'
- ];
- metricServiceStubMethods.forEach(function(methodName) {
- self['_' + methodName] = gax.createApiCall(
- metricServiceStub.then(function(metricServiceStub) {
- return function() {
- var args = Array.prototype.slice.call(arguments, 0);
- return metricServiceStub[methodName].apply(metricServiceStub, args);
- };
- }),
- defaults[methodName],
- PAGE_DESCRIPTORS[methodName]);
- });
-}
+ // Save the auth object to the client, for use by other methods.
+ this.auth = gaxGrpc.auth;
-// Path templates
+ // Determine the client header string.
+ var clientHeader = [
+ `gl-node/${process.version.node}`,
+ `grpc/${gaxGrpc.grpcVersion}`,
+ `gax/${gax.version}`,
+ `gapic/${VERSION}`,
+ ];
+ if (opts.libName && opts.libVersion) {
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
+ }
-var PROJECT_PATH_TEMPLATE = new gax.PathTemplate(
- 'projects/{project}');
+ // Load the applicable protos.
+ var protos = merge(
+ {},
+ gaxGrpc.loadProto(
+ path.join(__dirname, '..', '..', 'protos'),
+ 'google/monitoring/v3/metric_service.proto'
+ )
+ );
-var METRIC_DESCRIPTOR_PATH_TEMPLATE = new gax.PathTemplate(
- 'projects/{project}/metricDescriptors/{metric_descriptor=**}');
+ // This API contains "path templates"; forward-slash-separated
+ // identifiers to uniquely identify resources within the API.
+ // Create useful helper objects for these.
+ this._pathTemplates = {
+ projectPathTemplate: new gax.PathTemplate(
+ 'projects/{project}'
+ ),
+ metricDescriptorPathTemplate: new gax.PathTemplate(
+ 'projects/{project}/metricDescriptors/{metric_descriptor=**}'
+ ),
+ monitoredResourceDescriptorPathTemplate: new gax.PathTemplate(
+ 'projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}'
+ ),
+ };
-var MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = new gax.PathTemplate(
- 'projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}');
+ // 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 gax.PageDescriptor(
+ 'pageToken',
+ 'nextPageToken',
+ 'resourceDescriptors'
+ ),
+ listMetricDescriptors: new gax.PageDescriptor(
+ 'pageToken',
+ 'nextPageToken',
+ 'metricDescriptors'
+ ),
+ listTimeSeries: new gax.PageDescriptor(
+ 'pageToken',
+ 'nextPageToken',
+ 'timeSeries'
+ ),
+ };
-/**
- * Returns a fully-qualified project resource name string.
- * @param {String} project
- * @returns {String}
- */
-MetricServiceClient.prototype.projectPath = function(project) {
- return PROJECT_PATH_TEMPLATE.render({
- project: project
- });
-};
+ // Put together the default options sent with requests.
+ var defaults = gaxGrpc.constructSettings(
+ 'google.monitoring.v3.MetricService',
+ gapicConfig,
+ opts.clientConfig,
+ {'x-goog-api-client': clientHeader.join(' ')}
+ );
-/**
- * Returns a fully-qualified metric_descriptor resource name string.
- * @param {String} project
- * @param {String} metricDescriptor
- * @returns {String}
- */
-MetricServiceClient.prototype.metricDescriptorPath = function(project, metricDescriptor) {
- return METRIC_DESCRIPTOR_PATH_TEMPLATE.render({
- project: project,
- metric_descriptor: metricDescriptor
- });
-};
+ // 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 = {};
-/**
- * Returns a fully-qualified monitored_resource_descriptor resource name string.
- * @param {String} project
- * @param {String} monitoredResourceDescriptor
- * @returns {String}
- */
-MetricServiceClient.prototype.monitoredResourceDescriptorPath = function(project, monitoredResourceDescriptor) {
- return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.render({
- project: project,
- monitored_resource_descriptor: monitoredResourceDescriptor
- });
-};
+ // Put together the "service stub" for
+ // google.monitoring.v3.MetricService.
+ var metricServiceStub = gaxGrpc.createStub(
+ protos.google.monitoring.v3.MetricService,
+ opts
+ );
-/**
- * Parses the projectName from a project resource.
- * @param {String} projectName
- * A fully-qualified path representing a project resources.
- * @returns {String} - A string representing the project.
- */
-MetricServiceClient.prototype.matchProjectFromProjectName = function(projectName) {
- return PROJECT_PATH_TEMPLATE.match(projectName).project;
-};
+ // Iterate over each of the methods that the service provides
+ // and create an API call method for each.
+ var metricServiceStubMethods = [
+ 'listMonitoredResourceDescriptors',
+ 'getMonitoredResourceDescriptor',
+ 'listMetricDescriptors',
+ 'getMetricDescriptor',
+ 'createMetricDescriptor',
+ 'deleteMetricDescriptor',
+ 'listTimeSeries',
+ 'createTimeSeries',
+ ];
+ for (let methodName of metricServiceStubMethods) {
+ this._innerApiCalls[methodName] = gax.createApiCall(
+ metricServiceStub.then(
+ stub =>
+ function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ return stub[methodName].apply(stub, args);
+ }
+ ),
+ defaults[methodName],
+ this._descriptors.page[methodName]
+ );
+ }
+ }
-/**
- * Parses the metricDescriptorName from a metric_descriptor resource.
- * @param {String} metricDescriptorName
- * A fully-qualified path representing a metric_descriptor resources.
- * @returns {String} - A string representing the project.
- */
-MetricServiceClient.prototype.matchProjectFromMetricDescriptorName = function(metricDescriptorName) {
- return METRIC_DESCRIPTOR_PATH_TEMPLATE.match(metricDescriptorName).project;
-};
+ /**
+ * The DNS address for this API service.
+ */
+ static get servicePath() {
+ return 'monitoring.googleapis.com';
+ }
-/**
- * Parses the metricDescriptorName from a metric_descriptor resource.
- * @param {String} metricDescriptorName
- * A fully-qualified path representing a metric_descriptor resources.
- * @returns {String} - A string representing the metric_descriptor.
- */
-MetricServiceClient.prototype.matchMetricDescriptorFromMetricDescriptorName = function(metricDescriptorName) {
- return METRIC_DESCRIPTOR_PATH_TEMPLATE.match(metricDescriptorName).metric_descriptor;
-};
+ /**
+ * The port for this API service.
+ */
+ static get port() {
+ return 443;
+ }
-/**
- * Parses the monitoredResourceDescriptorName from a monitored_resource_descriptor resource.
- * @param {String} monitoredResourceDescriptorName
- * A fully-qualified path representing a monitored_resource_descriptor resources.
- * @returns {String} - A string representing the project.
- */
-MetricServiceClient.prototype.matchProjectFromMonitoredResourceDescriptorName = function(monitoredResourceDescriptorName) {
- return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitoredResourceDescriptorName).project;
-};
+ /**
+ * 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',
+ ];
+ }
-/**
- * Parses the monitoredResourceDescriptorName from a monitored_resource_descriptor resource.
- * @param {String} monitoredResourceDescriptorName
- * A fully-qualified path representing a monitored_resource_descriptor resources.
- * @returns {String} - A string representing the monitored_resource_descriptor.
- */
-MetricServiceClient.prototype.matchMonitoredResourceDescriptorFromMonitoredResourceDescriptorName = function(monitoredResourceDescriptorName) {
- return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitoredResourceDescriptorName).monitored_resource_descriptor;
-};
+ /**
+ * 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) {
+ return this.auth.getProjectId(callback);
+ }
-/**
- * Get the project ID used by this class.
- * @param {function(Error, string)} callback - the callback to be called with
- * the current project Id.
- */
-MetricServiceClient.prototype.getProjectId = function(callback) {
- return this.auth.getProjectId(callback);
-};
+ // -------------------
+ // -- Service calls --
+ // -------------------
-// Service calls
+ /**
+ * 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
+ * The project on which to execute the request. The format is
+ * `"projects/{project_id_or_number}"`.
+ * @param {string=} request.filter
+ * An optional [filter](https://cloud.google.com/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
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}.
+ *
+ * When autoPaginate: false is specified through options, it contains the result
+ * in a single response. If the response indicates the next page exists, the third
+ * parameter is set to be used for the next request object. The fourth parameter keeps
+ * the raw response object of an object representing [ListMonitoredResourceDescriptorsResponse]{@link google.monitoring.v3.ListMonitoredResourceDescriptorsResponse}.
+ * @returns {Promise} - The promise which resolves to an array.
+ * The first element of the array is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}.
+ *
+ * When autoPaginate: false is specified through options, the array has three elements.
+ * The first element is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} in a single response.
+ * The second element is the next request object if the response
+ * indicates the next page exists, or null. The third element is
+ * an object representing [ListMonitoredResourceDescriptorsResponse]{@link google.monitoring.v3.ListMonitoredResourceDescriptorsResponse}.
+ *
+ * The promise has a method named "cancel" which cancels the ongoing API call.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * // Iterate over all elements.
+ * var formattedName = client.projectPath('[PROJECT]');
+ *
+ * client.listMonitoredResourceDescriptors({name: formattedName})
+ * .then(responses => {
+ * var resources = responses[0];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i])
+ * }
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ *
+ * // Or obtain the paged response.
+ * var formattedName = client.projectPath('[PROJECT]');
+ *
+ *
+ * var options = {autoPaginate: false};
+ * var callback = responses => {
+ * // The actual resources in a response.
+ * var resources = responses[0];
+ * // The next request if the response shows that there are more responses.
+ * var nextRequest = responses[1];
+ * // The actual response object, if necessary.
+ * // var rawResponse = responses[2];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i]);
+ * }
+ * if (nextRequest) {
+ * // Fetch the next page.
+ * return client.listMonitoredResourceDescriptors(nextRequest, options).then(callback);
+ * }
+ * }
+ * client.listMonitoredResourceDescriptors({name: formattedName}, options)
+ * .then(callback)
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ listMonitoredResourceDescriptors(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
-/**
- * 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
- * The project on which to execute the request. The format is
- * `"projects/{project_id_or_number}"`.
- * @param {string=} request.filter
- * An optional [filter](https://cloud.google.com/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
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is Array of [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"}.
- *
- * When autoPaginate: false is specified through options, it contains the result
- * in a single response. If the response indicates the next page exists, the third
- * parameter is set to be used for the next request object. The fourth parameter keeps
- * the raw response object of an object representing [ListMonitoredResourceDescriptorsResponse]{@link ListMonitoredResourceDescriptorsResponse}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is Array of [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"}.
- *
- * When autoPaginate: false is specified through options, the array has three elements.
- * The first element is Array of [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"} in a single response.
- * The second element is the next request object if the response
- * indicates the next page exists, or null. The third element is
- * an object representing [ListMonitoredResourceDescriptorsResponse]{@link ListMonitoredResourceDescriptorsResponse}.
- *
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * // Iterate over all elements.
- * var formattedName = client.projectPath("[PROJECT]");
- *
- * client.listMonitoredResourceDescriptors({name: formattedName}).then(function(responses) {
- * var resources = responses[0];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i])
- * }
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- *
- * // Or obtain the paged response.
- * var formattedName = client.projectPath("[PROJECT]");
- *
- *
- * var options = {autoPaginate: false};
- * function callback(responses) {
- * // The actual resources in a response.
- * var resources = responses[0];
- * // The next request if the response shows there's more responses.
- * var nextRequest = responses[1];
- * // The actual response object, if necessary.
- * // var rawResponse = responses[2];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i]);
- * }
- * if (nextRequest) {
- * // Fetch the next page.
- * return client.listMonitoredResourceDescriptors(nextRequest, options).then(callback);
- * }
- * }
- * client.listMonitoredResourceDescriptors({name: formattedName}, options)
- * .then(callback)
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-MetricServiceClient.prototype.listMonitoredResourceDescriptors = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ return this._innerApiCalls.listMonitoredResourceDescriptors(request, options, callback);
}
- return this._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
+ * The project on which to execute the request. The format is
+ * `"projects/{project_id_or_number}"`.
+ * @param {string=} request.filter
+ * An optional [filter](https://cloud.google.com/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
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @returns {Stream}
+ * An object stream which emits an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} on 'data' event.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.projectPath('[PROJECT]');
+ * client.listMonitoredResourceDescriptorsStream({name: formattedName})
+ * .on('data', element => {
+ * // doThingsWith(element)
+ * }).on('error', err => {
+ * console.log(err);
+ * });
+ */
+ listMonitoredResourceDescriptorsStream(request, options) {
+ options = options || {};
-/**
- * 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
- * The project on which to execute the request. The format is
- * `"projects/{project_id_or_number}"`.
- * @param {string=} request.filter
- * An optional [filter](https://cloud.google.com/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
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @return {Stream}
- * An object stream which emits an object representing [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"} on 'data' event.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.projectPath("[PROJECT]");
- * client.listMonitoredResourceDescriptorsStream({name: formattedName})
- * .on('data', function(element) {
- * // doThingsWith(element)
- * }).on('error', function(err) {
- * console.log(err);
- * });
- */
-MetricServiceClient.prototype.listMonitoredResourceDescriptorsStream = function(request, options) {
- if (options === undefined) {
- options = {};
- }
+ return this._descriptors.page.listMonitoredResourceDescriptors.createStream(
+ this._innerApiCalls.listMonitoredResourceDescriptors,
+ request,
+ options
+ );
+ };
- return PAGE_DESCRIPTORS.listMonitoredResourceDescriptors.createStream(this._listMonitoredResourceDescriptors, request, options);
-};
+ /**
+ * 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
+ * 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
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}.
+ * @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.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.monitoredResourceDescriptorPath('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]');
+ * client.getMonitoredResourceDescriptor({name: formattedName})
+ * .then(responses => {
+ * var response = responses[0];
+ * // doThingsWith(response)
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ getMonitoredResourceDescriptor(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
-/**
- * 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
- * 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
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is an object representing [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is an object representing [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"}.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.monitoredResourceDescriptorPath("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
- * client.getMonitoredResourceDescriptor({name: formattedName}).then(function(responses) {
- * var response = responses[0];
- * // doThingsWith(response)
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-MetricServiceClient.prototype.getMonitoredResourceDescriptor = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ return this._innerApiCalls.getMonitoredResourceDescriptor(request, options, callback);
}
- return this._getMonitoredResourceDescriptor(request, options, callback);
-};
+ /**
+ * 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
+ * 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](https://cloud.google.com/monitoring/api/v3/filters)
+ * specifies which metric descriptors are to be
+ * returned. For example, the following filter matches all
+ * [custom metrics](https://cloud.google.com/monitoring/custom-metrics):
+ *
+ * metric.type = starts_with("custom.googleapis.com/")
+ * @param {number=} request.pageSize
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is Array of [MetricDescriptor]{@link google.api.MetricDescriptor}.
+ *
+ * When autoPaginate: false is specified through options, it contains the result
+ * in a single response. If the response indicates the next page exists, the third
+ * parameter is set to be used for the next request object. The fourth parameter keeps
+ * the raw response object of an object representing [ListMetricDescriptorsResponse]{@link google.monitoring.v3.ListMetricDescriptorsResponse}.
+ * @returns {Promise} - The promise which resolves to an array.
+ * The first element of the array is Array of [MetricDescriptor]{@link google.api.MetricDescriptor}.
+ *
+ * When autoPaginate: false is specified through options, the array has three elements.
+ * The first element is Array of [MetricDescriptor]{@link google.api.MetricDescriptor} in a single response.
+ * The second element is the next request object if the response
+ * indicates the next page exists, or null. The third element is
+ * an object representing [ListMetricDescriptorsResponse]{@link google.monitoring.v3.ListMetricDescriptorsResponse}.
+ *
+ * The promise has a method named "cancel" which cancels the ongoing API call.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * // Iterate over all elements.
+ * var formattedName = client.projectPath('[PROJECT]');
+ *
+ * client.listMetricDescriptors({name: formattedName})
+ * .then(responses => {
+ * var resources = responses[0];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i])
+ * }
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ *
+ * // Or obtain the paged response.
+ * var formattedName = client.projectPath('[PROJECT]');
+ *
+ *
+ * var options = {autoPaginate: false};
+ * var callback = responses => {
+ * // The actual resources in a response.
+ * var resources = responses[0];
+ * // The next request if the response shows that there are more responses.
+ * var nextRequest = responses[1];
+ * // The actual response object, if necessary.
+ * // var rawResponse = responses[2];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i]);
+ * }
+ * if (nextRequest) {
+ * // Fetch the next page.
+ * return client.listMetricDescriptors(nextRequest, options).then(callback);
+ * }
+ * }
+ * client.listMetricDescriptors({name: formattedName}, options)
+ * .then(callback)
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ listMetricDescriptors(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
-/**
- * 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
- * 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](https://cloud.google.com/monitoring/api/v3/filters)
- * specifies which metric descriptors are to be
- * returned. For example, the following filter matches all
- * [custom metrics](https://cloud.google.com/monitoring/custom-metrics):
- *
- * metric.type = starts_with("custom.googleapis.com/")
- * @param {number=} request.pageSize
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is Array of [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"}.
- *
- * When autoPaginate: false is specified through options, it contains the result
- * in a single response. If the response indicates the next page exists, the third
- * parameter is set to be used for the next request object. The fourth parameter keeps
- * the raw response object of an object representing [ListMetricDescriptorsResponse]{@link ListMetricDescriptorsResponse}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is Array of [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"}.
- *
- * When autoPaginate: false is specified through options, the array has three elements.
- * The first element is Array of [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"} in a single response.
- * The second element is the next request object if the response
- * indicates the next page exists, or null. The third element is
- * an object representing [ListMetricDescriptorsResponse]{@link ListMetricDescriptorsResponse}.
- *
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * // Iterate over all elements.
- * var formattedName = client.projectPath("[PROJECT]");
- *
- * client.listMetricDescriptors({name: formattedName}).then(function(responses) {
- * var resources = responses[0];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i])
- * }
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- *
- * // Or obtain the paged response.
- * var formattedName = client.projectPath("[PROJECT]");
- *
- *
- * var options = {autoPaginate: false};
- * function callback(responses) {
- * // The actual resources in a response.
- * var resources = responses[0];
- * // The next request if the response shows there's more responses.
- * var nextRequest = responses[1];
- * // The actual response object, if necessary.
- * // var rawResponse = responses[2];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i]);
- * }
- * if (nextRequest) {
- * // Fetch the next page.
- * return client.listMetricDescriptors(nextRequest, options).then(callback);
- * }
- * }
- * client.listMetricDescriptors({name: formattedName}, options)
- * .then(callback)
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-MetricServiceClient.prototype.listMetricDescriptors = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ return this._innerApiCalls.listMetricDescriptors(request, options, callback);
}
- return this._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
+ * 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](https://cloud.google.com/monitoring/api/v3/filters)
+ * specifies which metric descriptors are to be
+ * returned. For example, the following filter matches all
+ * [custom metrics](https://cloud.google.com/monitoring/custom-metrics):
+ *
+ * metric.type = starts_with("custom.googleapis.com/")
+ * @param {number=} request.pageSize
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @returns {Stream}
+ * An object stream which emits an object representing [MetricDescriptor]{@link google.api.MetricDescriptor} on 'data' event.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.projectPath('[PROJECT]');
+ * client.listMetricDescriptorsStream({name: formattedName})
+ * .on('data', element => {
+ * // doThingsWith(element)
+ * }).on('error', err => {
+ * console.log(err);
+ * });
+ */
+ listMetricDescriptorsStream(request, options) {
+ options = options || {};
-/**
- * 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
- * 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](https://cloud.google.com/monitoring/api/v3/filters)
- * specifies which metric descriptors are to be
- * returned. For example, the following filter matches all
- * [custom metrics](https://cloud.google.com/monitoring/custom-metrics):
- *
- * metric.type = starts_with("custom.googleapis.com/")
- * @param {number=} request.pageSize
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @return {Stream}
- * An object stream which emits an object representing [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"} on 'data' event.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.projectPath("[PROJECT]");
- * client.listMetricDescriptorsStream({name: formattedName})
- * .on('data', function(element) {
- * // doThingsWith(element)
- * }).on('error', function(err) {
- * console.log(err);
- * });
- */
-MetricServiceClient.prototype.listMetricDescriptorsStream = function(request, options) {
- if (options === undefined) {
- options = {};
- }
+ return this._descriptors.page.listMetricDescriptors.createStream(
+ this._innerApiCalls.listMetricDescriptors,
+ request,
+ options
+ );
+ };
- return PAGE_DESCRIPTORS.listMetricDescriptors.createStream(this._listMetricDescriptors, request, options);
-};
+ /**
+ * 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
+ * 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
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is an object representing [MetricDescriptor]{@link google.api.MetricDescriptor}.
+ * @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.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.metricDescriptorPath('[PROJECT]', '[METRIC_DESCRIPTOR]');
+ * client.getMetricDescriptor({name: formattedName})
+ * .then(responses => {
+ * var response = responses[0];
+ * // doThingsWith(response)
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ getMetricDescriptor(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
-/**
- * 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
- * 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
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is an object representing [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is an object representing [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"}.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.metricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]");
- * client.getMetricDescriptor({name: formattedName}).then(function(responses) {
- * var response = responses[0];
- * // doThingsWith(response)
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-MetricServiceClient.prototype.getMetricDescriptor = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ return this._innerApiCalls.getMetricDescriptor(request, options, callback);
}
- return this._getMetricDescriptor(request, options, callback);
-};
+ /**
+ * Creates a new metric descriptor.
+ * User-created metric descriptors define
+ * [custom metrics](https://cloud.google.com/monitoring/custom-metrics).
+ *
+ * @param {Object} request
+ * The request object that will be sent.
+ * @param {string} request.name
+ * The project on which to execute the request. The format is
+ * `"projects/{project_id_or_number}"`.
+ * @param {Object} request.metricDescriptor
+ * The new [custom metric](https://cloud.google.com/monitoring/custom-metrics)
+ * descriptor.
+ *
+ * This object should have the same structure as [MetricDescriptor]{@link google.api.MetricDescriptor}
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is an object representing [MetricDescriptor]{@link google.api.MetricDescriptor}.
+ * @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.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.projectPath('[PROJECT]');
+ * var metricDescriptor = {};
+ * var request = {
+ * name: formattedName,
+ * metricDescriptor: metricDescriptor,
+ * };
+ * client.createMetricDescriptor(request)
+ * .then(responses => {
+ * var response = responses[0];
+ * // doThingsWith(response)
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ createMetricDescriptor(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
-/**
- * Creates a new metric descriptor.
- * User-created metric descriptors define
- * [custom metrics](https://cloud.google.com/monitoring/custom-metrics).
- *
- * @param {Object} request
- * The request object that will be sent.
- * @param {string} request.name
- * The project on which to execute the request. The format is
- * `"projects/{project_id_or_number}"`.
- * @param {Object} request.metricDescriptor
- * The new [custom metric](https://cloud.google.com/monitoring/custom-metrics)
- * descriptor.
- *
- * This object should have the same structure as [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"}
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is an object representing [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is an object representing [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"}.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.projectPath("[PROJECT]");
- * var metricDescriptor = {};
- * var request = {
- * name: formattedName,
- * metricDescriptor: metricDescriptor
- * };
- * client.createMetricDescriptor(request).then(function(responses) {
- * var response = responses[0];
- * // doThingsWith(response)
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-MetricServiceClient.prototype.createMetricDescriptor = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ return this._innerApiCalls.createMetricDescriptor(request, options, callback);
}
- return this._createMetricDescriptor(request, options, callback);
-};
+ /**
+ * Deletes a metric descriptor. Only user-created
+ * [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be deleted.
+ *
+ * @param {Object} request
+ * The request object that will be sent.
+ * @param {string} request.name
+ * 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
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error)=} callback
+ * The function which will be called with the result of the API call.
+ * @returns {Promise} - The promise which resolves when API call finishes.
+ * The promise has a method named "cancel" which cancels the ongoing API call.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.metricDescriptorPath('[PROJECT]', '[METRIC_DESCRIPTOR]');
+ * client.deleteMetricDescriptor({name: formattedName}).catch(err => {
+ * console.error(err);
+ * });
+ */
+ deleteMetricDescriptor(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
-/**
- * Deletes a metric descriptor. Only user-created
- * [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be deleted.
- *
- * @param {Object} request
- * The request object that will be sent.
- * @param {string} request.name
- * 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
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error)=} callback
- * The function which will be called with the result of the API call.
- * @return {Promise} - The promise which resolves when API call finishes.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.metricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]");
- * client.deleteMetricDescriptor({name: formattedName}).catch(function(err) {
- * console.error(err);
- * });
- */
-MetricServiceClient.prototype.deleteMetricDescriptor = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ return this._innerApiCalls.deleteMetricDescriptor(request, options, callback);
}
- return this._deleteMetricDescriptor(request, options, callback);
-};
+ /**
+ * 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
+ * The project on which to execute the request. The format is
+ * "projects/{project_id_or_number}".
+ * @param {string} request.filter
+ * A [monitoring filter](https://cloud.google.com/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.label.instance_name = "my-instance-name"
+ * @param {Object} request.interval
+ * 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.
+ *
+ * This object should have the same structure as [TimeInterval]{@link google.monitoring.v3.TimeInterval}
+ * @param {number} request.view
+ * Specifies which information is returned about the time series.
+ *
+ * The number should be among the values of [TimeSeriesView]{@link google.monitoring.v3.TimeSeriesView}
+ * @param {Object=} request.aggregation
+ * By default, the raw time series data is returned.
+ * Use this field to combine multiple time series for different
+ * views of the data.
+ *
+ * This object should have the same structure as [Aggregation]{@link google.monitoring.v3.Aggregation}
+ * @param {string=} request.orderBy
+ * Specifies the order in which the points of the time series should
+ * be returned. By default, results are not ordered. Currently,
+ * this field must be left blank.
+ * @param {number=} request.pageSize
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
+ * The function which will be called with the result of the API call.
+ *
+ * The second parameter to the callback is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries}.
+ *
+ * When autoPaginate: false is specified through options, it contains the result
+ * in a single response. If the response indicates the next page exists, the third
+ * parameter is set to be used for the next request object. The fourth parameter keeps
+ * the raw response object of an object representing [ListTimeSeriesResponse]{@link google.monitoring.v3.ListTimeSeriesResponse}.
+ * @returns {Promise} - The promise which resolves to an array.
+ * The first element of the array is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries}.
+ *
+ * When autoPaginate: false is specified through options, the array has three elements.
+ * The first element is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries} in a single response.
+ * The second element is the next request object if the response
+ * indicates the next page exists, or null. The third element is
+ * an object representing [ListTimeSeriesResponse]{@link google.monitoring.v3.ListTimeSeriesResponse}.
+ *
+ * The promise has a method named "cancel" which cancels the ongoing API call.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * // Iterate over all elements.
+ * var formattedName = client.projectPath('[PROJECT]');
+ * var filter = '';
+ * var interval = {};
+ * var view = 'FULL';
+ * var request = {
+ * name: formattedName,
+ * filter: filter,
+ * interval: interval,
+ * view: view,
+ * };
+ *
+ * client.listTimeSeries(request)
+ * .then(responses => {
+ * var resources = responses[0];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i])
+ * }
+ * })
+ * .catch(err => {
+ * console.error(err);
+ * });
+ *
+ * // Or obtain the paged response.
+ * var formattedName = client.projectPath('[PROJECT]');
+ * var filter = '';
+ * var interval = {};
+ * var view = 'FULL';
+ * var request = {
+ * name: formattedName,
+ * filter: filter,
+ * interval: interval,
+ * view: view,
+ * };
+ *
+ *
+ * var options = {autoPaginate: false};
+ * var callback = responses => {
+ * // The actual resources in a response.
+ * var resources = responses[0];
+ * // The next request if the response shows that there are more responses.
+ * var nextRequest = responses[1];
+ * // The actual response object, if necessary.
+ * // var rawResponse = responses[2];
+ * for (let i = 0; i < resources.length; i += 1) {
+ * // doThingsWith(resources[i]);
+ * }
+ * if (nextRequest) {
+ * // Fetch the next page.
+ * return client.listTimeSeries(nextRequest, options).then(callback);
+ * }
+ * }
+ * client.listTimeSeries(request, options)
+ * .then(callback)
+ * .catch(err => {
+ * console.error(err);
+ * });
+ */
+ listTimeSeries(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
-/**
- * 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
- * The project on which to execute the request. The format is
- * "projects/{project_id_or_number}".
- * @param {string} request.filter
- * A [monitoring filter](https://cloud.google.com/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.label.instance_name = "my-instance-name"
- * @param {Object} request.interval
- * 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.
- *
- * This object should have the same structure as [TimeInterval]{@link TimeInterval}
- * @param {number} request.view
- * Specifies which information is returned about the time series.
- *
- * The number should be among the values of [TimeSeriesView]{@link TimeSeriesView}
- * @param {Object=} request.aggregation
- * By default, the raw time series data is returned.
- * Use this field to combine multiple time series for different
- * views of the data.
- *
- * This object should have the same structure as [Aggregation]{@link Aggregation}
- * @param {string=} request.orderBy
- * Specifies the order in which the points of the time series should
- * be returned. By default, results are not ordered. Currently,
- * this field must be left blank.
- * @param {number=} request.pageSize
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error, ?Array, ?Object, ?Object)=} callback
- * The function which will be called with the result of the API call.
- *
- * The second parameter to the callback is Array of [TimeSeries]{@link TimeSeries}.
- *
- * When autoPaginate: false is specified through options, it contains the result
- * in a single response. If the response indicates the next page exists, the third
- * parameter is set to be used for the next request object. The fourth parameter keeps
- * the raw response object of an object representing [ListTimeSeriesResponse]{@link ListTimeSeriesResponse}.
- * @return {Promise} - The promise which resolves to an array.
- * The first element of the array is Array of [TimeSeries]{@link TimeSeries}.
- *
- * When autoPaginate: false is specified through options, the array has three elements.
- * The first element is Array of [TimeSeries]{@link TimeSeries} in a single response.
- * The second element is the next request object if the response
- * indicates the next page exists, or null. The third element is
- * an object representing [ListTimeSeriesResponse]{@link ListTimeSeriesResponse}.
- *
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * // Iterate over all elements.
- * var formattedName = client.projectPath("[PROJECT]");
- * var filter = '';
- * var interval = {};
- * var view = monitoring.v3.types.ListTimeSeriesRequest.TimeSeriesView.FULL;
- * var request = {
- * name: formattedName,
- * filter: filter,
- * interval: interval,
- * view: view
- * };
- *
- * client.listTimeSeries(request).then(function(responses) {
- * var resources = responses[0];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i])
- * }
- * })
- * .catch(function(err) {
- * console.error(err);
- * });
- *
- * // Or obtain the paged response.
- * var formattedName = client.projectPath("[PROJECT]");
- * var filter = '';
- * var interval = {};
- * var view = monitoring.v3.types.ListTimeSeriesRequest.TimeSeriesView.FULL;
- * var request = {
- * name: formattedName,
- * filter: filter,
- * interval: interval,
- * view: view
- * };
- *
- *
- * var options = {autoPaginate: false};
- * function callback(responses) {
- * // The actual resources in a response.
- * var resources = responses[0];
- * // The next request if the response shows there's more responses.
- * var nextRequest = responses[1];
- * // The actual response object, if necessary.
- * // var rawResponse = responses[2];
- * for (var i = 0; i < resources.length; ++i) {
- * // doThingsWith(resources[i]);
- * }
- * if (nextRequest) {
- * // Fetch the next page.
- * return client.listTimeSeries(nextRequest, options).then(callback);
- * }
- * }
- * client.listTimeSeries(request, options)
- * .then(callback)
- * .catch(function(err) {
- * console.error(err);
- * });
- */
-MetricServiceClient.prototype.listTimeSeries = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
- }
- if (options === undefined) {
- options = {};
+ return this._innerApiCalls.listTimeSeries(request, options, callback);
}
- return this._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
+ * The project on which to execute the request. The format is
+ * "projects/{project_id_or_number}".
+ * @param {string} request.filter
+ * A [monitoring filter](https://cloud.google.com/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.label.instance_name = "my-instance-name"
+ * @param {Object} request.interval
+ * 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.
+ *
+ * This object should have the same structure as [TimeInterval]{@link google.monitoring.v3.TimeInterval}
+ * @param {number} request.view
+ * Specifies which information is returned about the time series.
+ *
+ * The number should be among the values of [TimeSeriesView]{@link google.monitoring.v3.TimeSeriesView}
+ * @param {Object=} request.aggregation
+ * By default, the raw time series data is returned.
+ * Use this field to combine multiple time series for different
+ * views of the data.
+ *
+ * This object should have the same structure as [Aggregation]{@link google.monitoring.v3.Aggregation}
+ * @param {string=} request.orderBy
+ * Specifies the order in which the points of the time series should
+ * be returned. By default, results are not ordered. Currently,
+ * this field must be left blank.
+ * @param {number=} request.pageSize
+ * The maximum number of resources contained in the underlying API
+ * response. If page streaming is performed per-resource, this
+ * parameter does not affect the return value. If page streaming is
+ * performed per-page, this determines the maximum number of
+ * resources in a page.
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @returns {Stream}
+ * An object stream which emits an object representing [TimeSeries]{@link google.monitoring.v3.TimeSeries} on 'data' event.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.projectPath('[PROJECT]');
+ * var filter = '';
+ * var interval = {};
+ * var view = 'FULL';
+ * var request = {
+ * name: formattedName,
+ * filter: filter,
+ * interval: interval,
+ * view: view,
+ * };
+ * client.listTimeSeriesStream(request)
+ * .on('data', element => {
+ * // doThingsWith(element)
+ * }).on('error', err => {
+ * console.log(err);
+ * });
+ */
+ listTimeSeriesStream(request, options) {
+ options = options || {};
-/**
- * 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
- * The project on which to execute the request. The format is
- * "projects/{project_id_or_number}".
- * @param {string} request.filter
- * A [monitoring filter](https://cloud.google.com/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.label.instance_name = "my-instance-name"
- * @param {Object} request.interval
- * 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.
- *
- * This object should have the same structure as [TimeInterval]{@link TimeInterval}
- * @param {number} request.view
- * Specifies which information is returned about the time series.
- *
- * The number should be among the values of [TimeSeriesView]{@link TimeSeriesView}
- * @param {Object=} request.aggregation
- * By default, the raw time series data is returned.
- * Use this field to combine multiple time series for different
- * views of the data.
- *
- * This object should have the same structure as [Aggregation]{@link Aggregation}
- * @param {string=} request.orderBy
- * Specifies the order in which the points of the time series should
- * be returned. By default, results are not ordered. Currently,
- * this field must be left blank.
- * @param {number=} request.pageSize
- * The maximum number of resources contained in the underlying API
- * response. If page streaming is performed per-resource, this
- * parameter does not affect the return value. If page streaming is
- * performed per-page, this determines the maximum number of
- * resources in a page.
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @return {Stream}
- * An object stream which emits an object representing [TimeSeries]{@link TimeSeries} on 'data' event.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.projectPath("[PROJECT]");
- * var filter = '';
- * var interval = {};
- * var view = monitoring.v3.types.ListTimeSeriesRequest.TimeSeriesView.FULL;
- * var request = {
- * name: formattedName,
- * filter: filter,
- * interval: interval,
- * view: view
- * };
- * client.listTimeSeriesStream(request)
- * .on('data', function(element) {
- * // doThingsWith(element)
- * }).on('error', function(err) {
- * console.log(err);
- * });
- */
-MetricServiceClient.prototype.listTimeSeriesStream = function(request, options) {
- if (options === undefined) {
- options = {};
+ return this._descriptors.page.listTimeSeries.createStream(
+ this._innerApiCalls.listTimeSeries,
+ request,
+ options
+ );
+ };
+
+ /**
+ * 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
+ * The project on which to execute the request. The format is
+ * `"projects/{project_id_or_number}"`.
+ * @param {Object[]} request.timeSeries
+ * 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.
+ *
+ * This object should have the same structure as [TimeSeries]{@link google.monitoring.v3.TimeSeries}
+ * @param {Object=} options
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
+ * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
+ * @param {function(?Error)=} callback
+ * The function which will be called with the result of the API call.
+ * @returns {Promise} - The promise which resolves when API call finishes.
+ * The promise has a method named "cancel" which cancels the ongoing API call.
+ *
+ * @example
+ *
+ * const monitoring = require('@google-cloud/monitoring');
+ *
+ * var client = new monitoring.v3.MetricServiceClient({
+ * // optional auth parameters.
+ * });
+ *
+ * var formattedName = client.projectPath('[PROJECT]');
+ * var timeSeries = [];
+ * var request = {
+ * name: formattedName,
+ * timeSeries: timeSeries,
+ * };
+ * client.createTimeSeries(request).catch(err => {
+ * console.error(err);
+ * });
+ */
+ createTimeSeries(request, options, callback) {
+ if (options instanceof Function && callback === undefined) {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ return this._innerApiCalls.createTimeSeries(request, options, callback);
}
- return PAGE_DESCRIPTORS.listTimeSeries.createStream(this._listTimeSeries, request, options);
-};
+ // --------------------
+ // -- Path templates --
+ // --------------------
-/**
- * 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
- * The project on which to execute the request. The format is
- * `"projects/{project_id_or_number}"`.
- * @param {Object[]} request.timeSeries
- * 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.
- *
- * This object should have the same structure as [TimeSeries]{@link TimeSeries}
- * @param {Object=} options
- * Optional parameters. You can override the default settings for this call, e.g, timeout,
- * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
- * @param {function(?Error)=} callback
- * The function which will be called with the result of the API call.
- * @return {Promise} - The promise which resolves when API call finishes.
- * The promise has a method named "cancel" which cancels the ongoing API call.
- *
- * @example
- *
- * var monitoring = require('@google-cloud/monitoring');
- *
- * var client = monitoring.v3.metric({
- * // optional auth parameters.
- * });
- *
- * var formattedName = client.projectPath("[PROJECT]");
- * var timeSeries = [];
- * var request = {
- * name: formattedName,
- * timeSeries: timeSeries
- * };
- * client.createTimeSeries(request).catch(function(err) {
- * console.error(err);
- * });
- */
-MetricServiceClient.prototype.createTimeSeries = function(request, options, callback) {
- if (options instanceof Function && callback === undefined) {
- callback = options;
- options = {};
+ /**
+ * Return a fully-qualified project resource name string.
+ *
+ * @param {String} project
+ * @returns {String}
+ */
+ projectPath(project) {
+ return this._pathTemplates.projectPathTemplate.render({
+ project: project,
+ });
}
- if (options === undefined) {
- options = {};
+
+ /**
+ * Return a fully-qualified metric_descriptor resource name string.
+ *
+ * @param {String} project
+ * @param {String} metricDescriptor
+ * @returns {String}
+ */
+ metricDescriptorPath(project, metricDescriptor) {
+ return this._pathTemplates.metricDescriptorPathTemplate.render({
+ project: project,
+ metric_descriptor: metricDescriptor,
+ });
}
- return this._createTimeSeries(request, options, callback);
-};
+ /**
+ * Return a fully-qualified monitored_resource_descriptor resource name string.
+ *
+ * @param {String} project
+ * @param {String} monitoredResourceDescriptor
+ * @returns {String}
+ */
+ monitoredResourceDescriptorPath(project, monitoredResourceDescriptor) {
+ return this._pathTemplates.monitoredResourceDescriptorPathTemplate.render({
+ project: project,
+ monitored_resource_descriptor: monitoredResourceDescriptor,
+ });
+ }
-function MetricServiceClientBuilder(gaxGrpc) {
- if (!(this instanceof MetricServiceClientBuilder)) {
- return new MetricServiceClientBuilder(gaxGrpc);
+ /**
+ * Parse the projectName from a project resource.
+ *
+ * @param {String} projectName
+ * A fully-qualified path representing a project resources.
+ * @returns {String} - A string representing the project.
+ */
+ matchProjectFromProjectName(projectName) {
+ return projectPathTemplate.match(projectName).project;
}
- var metricServiceClient = gaxGrpc.load([{
- root: require('google-proto-files')('..'),
- file: 'google/monitoring/v3/metric_service.proto'
- }]);
- extend(this, metricServiceClient.google.monitoring.v3);
+ /**
+ * Parse the metricDescriptorName from a metric_descriptor resource.
+ *
+ * @param {String} metricDescriptorName
+ * A fully-qualified path representing a metric_descriptor resources.
+ * @returns {String} - A string representing the project.
+ */
+ matchProjectFromMetricDescriptorName(metricDescriptorName) {
+ return metricDescriptorPathTemplate.match(metricDescriptorName).project;
+ }
+
+ /**
+ * Parse the metricDescriptorName from a metric_descriptor resource.
+ *
+ * @param {String} metricDescriptorName
+ * A fully-qualified path representing a metric_descriptor resources.
+ * @returns {String} - A string representing the metric_descriptor.
+ */
+ matchMetricDescriptorFromMetricDescriptorName(metricDescriptorName) {
+ return metricDescriptorPathTemplate.match(metricDescriptorName).metric_descriptor;
+ }
+ /**
+ * Parse the monitoredResourceDescriptorName from a monitored_resource_descriptor resource.
+ *
+ * @param {String} monitoredResourceDescriptorName
+ * A fully-qualified path representing a monitored_resource_descriptor resources.
+ * @returns {String} - A string representing the project.
+ */
+ matchProjectFromMonitoredResourceDescriptorName(monitoredResourceDescriptorName) {
+ return monitoredResourceDescriptorPathTemplate.match(monitoredResourceDescriptorName).project;
+ }
/**
- * Build a new instance of {@link MetricServiceClient}.
- *
- * @param {Object=} opts - The optional parameters.
- * @param {String=} opts.servicePath
- * The domain name of the API remote host.
- * @param {number=} opts.port
- * The port on which to connect to the remote host.
- * @param {grpc.ClientCredentials=} opts.sslCreds
- * A ClientCredentials for use with an SSL-enabled channel.
- * @param {Object=} opts.clientConfig
- * The customized config to build the call settings. See
- * {@link gax.constructSettings} for the format.
+ * Parse the monitoredResourceDescriptorName from a monitored_resource_descriptor resource.
+ *
+ * @param {String} monitoredResourceDescriptorName
+ * A fully-qualified path representing a monitored_resource_descriptor resources.
+ * @returns {String} - A string representing the monitored_resource_descriptor.
*/
- this.metricServiceClient = function(opts) {
- return new MetricServiceClient(gaxGrpc, metricServiceClient, opts);
- };
- extend(this.metricServiceClient, MetricServiceClient);
+ matchMonitoredResourceDescriptorFromMonitoredResourceDescriptorName(monitoredResourceDescriptorName) {
+ return monitoredResourceDescriptorPathTemplate.match(monitoredResourceDescriptorName).monitored_resource_descriptor;
+ }
}
-module.exports = MetricServiceClientBuilder;
-module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS;
-module.exports.ALL_SCOPES = ALL_SCOPES;
\ No newline at end of file
+
+
+module.exports = MetricServiceClient;
diff --git a/packages/monitoring/test/gapic-v3.js b/packages/monitoring/test/gapic-v3.js
index 838498b3bc8..398ce6a3064 100644
--- a/packages/monitoring/test/gapic-v3.js
+++ b/packages/monitoring/test/gapic-v3.js
@@ -1,36 +1,39 @@
-/*
- * Copyright 2017, Google Inc. All rights reserved.
- *
- * 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.
- */
+// Copyright 2017, Google Inc. All rights reserved.
+//
+// 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.
+
'use strict';
-var assert = require('assert');
-var monitoring = require('../src');
+const assert = require('assert');
+
+const monitoringModule = require('../src');
var FAKE_STATUS_CODE = 1;
var error = new Error();
error.code = FAKE_STATUS_CODE;
-describe('GroupServiceClient', function() {
- describe('listGroups', function() {
- it('invokes listGroups without error', function(done) {
- var client = monitoring.v3.group();
+describe('GroupServiceClient', () => {
+ describe('listGroups', () => {
+ it('invokes listGroups without error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock response
@@ -38,51 +41,62 @@ describe('GroupServiceClient', function() {
var groupElement = {};
var group = [groupElement];
var expectedResponse = {
- nextPageToken : nextPageToken,
- group : group
+ nextPageToken: nextPageToken,
+ group: group,
};
// Mock Grpc layer
- client._listGroups = function(actualRequest, options, callback) {
+ client._innerApiCalls.listGroups = (actualRequest, options, callback) => {
assert.deepStrictEqual(actualRequest, request);
callback(null, expectedResponse.group);
};
- client.listGroups(request, function(err, response) {
+ client.listGroups(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse.group);
done();
});
});
- it('invokes listGroups with error', function(done) {
- var client = monitoring.v3.group();
+ it('invokes listGroups with error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._listGroups = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.listGroups = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.listGroups(request, function(err, response) {
+ client.listGroups(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('getGroup', function() {
- it('invokes getGroup without error', function(done) {
- var client = monitoring.v3.group();
+ describe('getGroup', () => {
+ it('invokes getGroup without error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
+ var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock response
@@ -92,53 +106,67 @@ describe('GroupServiceClient', function() {
var filter = 'filter-1274492040';
var isCluster = false;
var expectedResponse = {
- name : name2,
- displayName : displayName,
- parentName : parentName,
- filter : filter,
- isCluster : isCluster
+ name: name2,
+ displayName: displayName,
+ parentName: parentName,
+ filter: filter,
+ isCluster: isCluster,
};
// Mock Grpc layer
- client._getGroup = mockSimpleGrpcMethod(request, expectedResponse);
+ client._innerApiCalls.getGroup = mockSimpleGrpcMethod(
+ request,
+ expectedResponse
+ );
- client.getGroup(request, function(err, response) {
+ client.getGroup(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse);
done();
});
});
- it('invokes getGroup with error', function(done) {
- var client = monitoring.v3.group();
+ it('invokes getGroup with error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
+ var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._getGroup = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.getGroup = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.getGroup(request, function(err, response) {
+ client.getGroup(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('createGroup', function() {
- it('invokes createGroup without error', function(done) {
- var client = monitoring.v3.group();
+ describe('createGroup', () => {
+ it('invokes createGroup without error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var group = {};
var request = {
- name : formattedName,
- group : group
+ name: formattedName,
+ group: group,
};
// Mock response
@@ -148,53 +176,67 @@ describe('GroupServiceClient', function() {
var filter = 'filter-1274492040';
var isCluster = false;
var expectedResponse = {
- name : name2,
- displayName : displayName,
- parentName : parentName,
- filter : filter,
- isCluster : isCluster
+ name: name2,
+ displayName: displayName,
+ parentName: parentName,
+ filter: filter,
+ isCluster: isCluster,
};
// Mock Grpc layer
- client._createGroup = mockSimpleGrpcMethod(request, expectedResponse);
+ client._innerApiCalls.createGroup = mockSimpleGrpcMethod(
+ request,
+ expectedResponse
+ );
- client.createGroup(request, function(err, response) {
+ client.createGroup(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse);
done();
});
});
- it('invokes createGroup with error', function(done) {
- var client = monitoring.v3.group();
+ it('invokes createGroup with error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var group = {};
var request = {
- name : formattedName,
- group : group
+ name: formattedName,
+ group: group,
};
// Mock Grpc layer
- client._createGroup = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.createGroup = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.createGroup(request, function(err, response) {
+ client.createGroup(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('updateGroup', function() {
- it('invokes updateGroup without error', function(done) {
- var client = monitoring.v3.group();
+ describe('updateGroup', () => {
+ it('invokes updateGroup without error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
var group = {};
var request = {
- group : group
+ group: group,
};
// Mock response
@@ -204,75 +246,96 @@ describe('GroupServiceClient', function() {
var filter = 'filter-1274492040';
var isCluster = false;
var expectedResponse = {
- name : name,
- displayName : displayName,
- parentName : parentName,
- filter : filter,
- isCluster : isCluster
+ name: name,
+ displayName: displayName,
+ parentName: parentName,
+ filter: filter,
+ isCluster: isCluster,
};
// Mock Grpc layer
- client._updateGroup = mockSimpleGrpcMethod(request, expectedResponse);
+ client._innerApiCalls.updateGroup = mockSimpleGrpcMethod(
+ request,
+ expectedResponse
+ );
- client.updateGroup(request, function(err, response) {
+ client.updateGroup(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse);
done();
});
});
- it('invokes updateGroup with error', function(done) {
- var client = monitoring.v3.group();
+ it('invokes updateGroup with error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
var group = {};
var request = {
- group : group
+ group: group,
};
// Mock Grpc layer
- client._updateGroup = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.updateGroup = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.updateGroup(request, function(err, response) {
+ client.updateGroup(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('deleteGroup', function() {
- it('invokes deleteGroup without error', function(done) {
- var client = monitoring.v3.group();
+ describe('deleteGroup', () => {
+ it('invokes deleteGroup without error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
+ var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._deleteGroup = mockSimpleGrpcMethod(request);
+ client._innerApiCalls.deleteGroup = mockSimpleGrpcMethod(request);
- client.deleteGroup(request, function(err) {
+ client.deleteGroup(request, err => {
assert.ifError(err);
done();
});
});
- it('invokes deleteGroup with error', function(done) {
- var client = monitoring.v3.group();
+ it('invokes deleteGroup with error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
+ var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._deleteGroup = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.deleteGroup = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.deleteGroup(request, function(err) {
+ client.deleteGroup(request, err => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
done();
@@ -280,14 +343,17 @@ describe('GroupServiceClient', function() {
});
});
- describe('listGroupMembers', function() {
- it('invokes listGroupMembers without error', function(done) {
- var client = monitoring.v3.group();
+ describe('listGroupMembers', () => {
+ it('invokes listGroupMembers without error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
+ var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock response
@@ -296,54 +362,65 @@ describe('GroupServiceClient', function() {
var membersElement = {};
var members = [membersElement];
var expectedResponse = {
- nextPageToken : nextPageToken,
- totalSize : totalSize,
- members : members
+ nextPageToken: nextPageToken,
+ totalSize: totalSize,
+ members: members,
};
// Mock Grpc layer
- client._listGroupMembers = function(actualRequest, options, callback) {
+ client._innerApiCalls.listGroupMembers = (actualRequest, options, callback) => {
assert.deepStrictEqual(actualRequest, request);
callback(null, expectedResponse.members);
};
- client.listGroupMembers(request, function(err, response) {
+ client.listGroupMembers(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse.members);
done();
});
});
- it('invokes listGroupMembers with error', function(done) {
- var client = monitoring.v3.group();
+ it('invokes listGroupMembers with error', done => {
+ var client = new monitoringModule.v3.GroupServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.groupPath("[PROJECT]", "[GROUP]");
+ var formattedName = client.groupPath('[PROJECT]', '[GROUP]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._listGroupMembers = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.listGroupMembers = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.listGroupMembers(request, function(err, response) {
+ client.listGroupMembers(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
});
-describe('MetricServiceClient', function() {
- describe('listMonitoredResourceDescriptors', function() {
- it('invokes listMonitoredResourceDescriptors without error', function(done) {
- var client = monitoring.v3.metric();
+describe('MetricServiceClient', () => {
+ describe('listMonitoredResourceDescriptors', () => {
+ it('invokes listMonitoredResourceDescriptors without error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock response
@@ -351,51 +428,62 @@ describe('MetricServiceClient', function() {
var resourceDescriptorsElement = {};
var resourceDescriptors = [resourceDescriptorsElement];
var expectedResponse = {
- nextPageToken : nextPageToken,
- resourceDescriptors : resourceDescriptors
+ nextPageToken: nextPageToken,
+ resourceDescriptors: resourceDescriptors,
};
// Mock Grpc layer
- client._listMonitoredResourceDescriptors = function(actualRequest, options, callback) {
+ client._innerApiCalls.listMonitoredResourceDescriptors = (actualRequest, options, callback) => {
assert.deepStrictEqual(actualRequest, request);
callback(null, expectedResponse.resourceDescriptors);
};
- client.listMonitoredResourceDescriptors(request, function(err, response) {
+ client.listMonitoredResourceDescriptors(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse.resourceDescriptors);
done();
});
});
- it('invokes listMonitoredResourceDescriptors with error', function(done) {
- var client = monitoring.v3.metric();
+ it('invokes listMonitoredResourceDescriptors with error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._listMonitoredResourceDescriptors = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.listMonitoredResourceDescriptors = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.listMonitoredResourceDescriptors(request, function(err, response) {
+ client.listMonitoredResourceDescriptors(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('getMonitoredResourceDescriptor', function() {
- it('invokes getMonitoredResourceDescriptor without error', function(done) {
- var client = monitoring.v3.metric();
+ describe('getMonitoredResourceDescriptor', () => {
+ it('invokes getMonitoredResourceDescriptor without error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.monitoredResourceDescriptorPath("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
+ var formattedName = client.monitoredResourceDescriptorPath('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock response
@@ -404,50 +492,64 @@ describe('MetricServiceClient', function() {
var displayName = 'displayName1615086568';
var description = 'description-1724546052';
var expectedResponse = {
- name : name2,
- type : type,
- displayName : displayName,
- description : description
+ name: name2,
+ type: type,
+ displayName: displayName,
+ description: description,
};
// Mock Grpc layer
- client._getMonitoredResourceDescriptor = mockSimpleGrpcMethod(request, expectedResponse);
+ client._innerApiCalls.getMonitoredResourceDescriptor = mockSimpleGrpcMethod(
+ request,
+ expectedResponse
+ );
- client.getMonitoredResourceDescriptor(request, function(err, response) {
+ client.getMonitoredResourceDescriptor(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse);
done();
});
});
- it('invokes getMonitoredResourceDescriptor with error', function(done) {
- var client = monitoring.v3.metric();
+ it('invokes getMonitoredResourceDescriptor with error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.monitoredResourceDescriptorPath("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
+ var formattedName = client.monitoredResourceDescriptorPath('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._getMonitoredResourceDescriptor = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.getMonitoredResourceDescriptor = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.getMonitoredResourceDescriptor(request, function(err, response) {
+ client.getMonitoredResourceDescriptor(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('listMetricDescriptors', function() {
- it('invokes listMetricDescriptors without error', function(done) {
- var client = monitoring.v3.metric();
+ describe('listMetricDescriptors', () => {
+ it('invokes listMetricDescriptors without error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock response
@@ -455,51 +557,62 @@ describe('MetricServiceClient', function() {
var metricDescriptorsElement = {};
var metricDescriptors = [metricDescriptorsElement];
var expectedResponse = {
- nextPageToken : nextPageToken,
- metricDescriptors : metricDescriptors
+ nextPageToken: nextPageToken,
+ metricDescriptors: metricDescriptors,
};
// Mock Grpc layer
- client._listMetricDescriptors = function(actualRequest, options, callback) {
+ client._innerApiCalls.listMetricDescriptors = (actualRequest, options, callback) => {
assert.deepStrictEqual(actualRequest, request);
callback(null, expectedResponse.metricDescriptors);
};
- client.listMetricDescriptors(request, function(err, response) {
+ client.listMetricDescriptors(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse.metricDescriptors);
done();
});
});
- it('invokes listMetricDescriptors with error', function(done) {
- var client = monitoring.v3.metric();
+ it('invokes listMetricDescriptors with error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._listMetricDescriptors = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.listMetricDescriptors = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.listMetricDescriptors(request, function(err, response) {
+ client.listMetricDescriptors(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('getMetricDescriptor', function() {
- it('invokes getMetricDescriptor without error', function(done) {
- var client = monitoring.v3.metric();
+ describe('getMetricDescriptor', () => {
+ it('invokes getMetricDescriptor without error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.metricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]");
+ var formattedName = client.metricDescriptorPath('[PROJECT]', '[METRIC_DESCRIPTOR]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock response
@@ -509,53 +622,67 @@ describe('MetricServiceClient', function() {
var description = 'description-1724546052';
var displayName = 'displayName1615086568';
var expectedResponse = {
- name : name2,
- type : type,
- unit : unit,
- description : description,
- displayName : displayName
+ name: name2,
+ type: type,
+ unit: unit,
+ description: description,
+ displayName: displayName,
};
// Mock Grpc layer
- client._getMetricDescriptor = mockSimpleGrpcMethod(request, expectedResponse);
+ client._innerApiCalls.getMetricDescriptor = mockSimpleGrpcMethod(
+ request,
+ expectedResponse
+ );
- client.getMetricDescriptor(request, function(err, response) {
+ client.getMetricDescriptor(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse);
done();
});
});
- it('invokes getMetricDescriptor with error', function(done) {
- var client = monitoring.v3.metric();
+ it('invokes getMetricDescriptor with error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.metricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]");
+ var formattedName = client.metricDescriptorPath('[PROJECT]', '[METRIC_DESCRIPTOR]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._getMetricDescriptor = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.getMetricDescriptor = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.getMetricDescriptor(request, function(err, response) {
+ client.getMetricDescriptor(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('createMetricDescriptor', function() {
- it('invokes createMetricDescriptor without error', function(done) {
- var client = monitoring.v3.metric();
+ describe('createMetricDescriptor', () => {
+ it('invokes createMetricDescriptor without error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var metricDescriptor = {};
var request = {
- name : formattedName,
- metricDescriptor : metricDescriptor
+ name: formattedName,
+ metricDescriptor: metricDescriptor,
};
// Mock response
@@ -565,77 +692,98 @@ describe('MetricServiceClient', function() {
var description = 'description-1724546052';
var displayName = 'displayName1615086568';
var expectedResponse = {
- name : name2,
- type : type,
- unit : unit,
- description : description,
- displayName : displayName
+ name: name2,
+ type: type,
+ unit: unit,
+ description: description,
+ displayName: displayName,
};
// Mock Grpc layer
- client._createMetricDescriptor = mockSimpleGrpcMethod(request, expectedResponse);
+ client._innerApiCalls.createMetricDescriptor = mockSimpleGrpcMethod(
+ request,
+ expectedResponse
+ );
- client.createMetricDescriptor(request, function(err, response) {
+ client.createMetricDescriptor(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse);
done();
});
});
- it('invokes createMetricDescriptor with error', function(done) {
- var client = monitoring.v3.metric();
+ it('invokes createMetricDescriptor with error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var metricDescriptor = {};
var request = {
- name : formattedName,
- metricDescriptor : metricDescriptor
+ name: formattedName,
+ metricDescriptor: metricDescriptor,
};
// Mock Grpc layer
- client._createMetricDescriptor = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.createMetricDescriptor = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.createMetricDescriptor(request, function(err, response) {
+ client.createMetricDescriptor(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('deleteMetricDescriptor', function() {
- it('invokes deleteMetricDescriptor without error', function(done) {
- var client = monitoring.v3.metric();
+ describe('deleteMetricDescriptor', () => {
+ it('invokes deleteMetricDescriptor without error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.metricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]");
+ var formattedName = client.metricDescriptorPath('[PROJECT]', '[METRIC_DESCRIPTOR]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._deleteMetricDescriptor = mockSimpleGrpcMethod(request);
+ client._innerApiCalls.deleteMetricDescriptor = mockSimpleGrpcMethod(request);
- client.deleteMetricDescriptor(request, function(err) {
+ client.deleteMetricDescriptor(request, err => {
assert.ifError(err);
done();
});
});
- it('invokes deleteMetricDescriptor with error', function(done) {
- var client = monitoring.v3.metric();
+ it('invokes deleteMetricDescriptor with error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.metricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]");
+ var formattedName = client.metricDescriptorPath('[PROJECT]', '[METRIC_DESCRIPTOR]');
var request = {
- name : formattedName
+ name: formattedName,
};
// Mock Grpc layer
- client._deleteMetricDescriptor = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.deleteMetricDescriptor = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.deleteMetricDescriptor(request, function(err) {
+ client.deleteMetricDescriptor(request, err => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
done();
@@ -643,20 +791,23 @@ describe('MetricServiceClient', function() {
});
});
- describe('listTimeSeries', function() {
- it('invokes listTimeSeries without error', function(done) {
- var client = monitoring.v3.metric();
+ describe('listTimeSeries', () => {
+ it('invokes listTimeSeries without error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var filter = 'filter-1274492040';
var interval = {};
- var view = monitoring.v3.types.ListTimeSeriesRequest.TimeSeriesView.FULL;
+ var view = 'FULL';
var request = {
- name : formattedName,
- filter : filter,
- interval : interval,
- view : view
+ name: formattedName,
+ filter: filter,
+ interval: interval,
+ view: view,
};
// Mock response
@@ -664,85 +815,103 @@ describe('MetricServiceClient', function() {
var timeSeriesElement = {};
var timeSeries = [timeSeriesElement];
var expectedResponse = {
- nextPageToken : nextPageToken,
- timeSeries : timeSeries
+ nextPageToken: nextPageToken,
+ timeSeries: timeSeries,
};
// Mock Grpc layer
- client._listTimeSeries = function(actualRequest, options, callback) {
+ client._innerApiCalls.listTimeSeries = (actualRequest, options, callback) => {
assert.deepStrictEqual(actualRequest, request);
callback(null, expectedResponse.timeSeries);
};
- client.listTimeSeries(request, function(err, response) {
+ client.listTimeSeries(request, (err, response) => {
assert.ifError(err);
assert.deepStrictEqual(response, expectedResponse.timeSeries);
done();
});
});
- it('invokes listTimeSeries with error', function(done) {
- var client = monitoring.v3.metric();
+ it('invokes listTimeSeries with error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var filter = 'filter-1274492040';
var interval = {};
- var view = monitoring.v3.types.ListTimeSeriesRequest.TimeSeriesView.FULL;
+ var view = 'FULL';
var request = {
- name : formattedName,
- filter : filter,
- interval : interval,
- view : view
+ name: formattedName,
+ filter: filter,
+ interval: interval,
+ view: view,
};
// Mock Grpc layer
- client._listTimeSeries = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.listTimeSeries = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.listTimeSeries(request, function(err, response) {
+ client.listTimeSeries(request, (err, response) => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
+ assert(typeof response === 'undefined');
done();
});
});
});
- describe('createTimeSeries', function() {
- it('invokes createTimeSeries without error', function(done) {
- var client = monitoring.v3.metric();
+ describe('createTimeSeries', () => {
+ it('invokes createTimeSeries without error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var timeSeries = [];
var request = {
- name : formattedName,
- timeSeries : timeSeries
+ name: formattedName,
+ timeSeries: timeSeries,
};
// Mock Grpc layer
- client._createTimeSeries = mockSimpleGrpcMethod(request);
+ client._innerApiCalls.createTimeSeries = mockSimpleGrpcMethod(request);
- client.createTimeSeries(request, function(err) {
+ client.createTimeSeries(request, err => {
assert.ifError(err);
done();
});
});
- it('invokes createTimeSeries with error', function(done) {
- var client = monitoring.v3.metric();
+ it('invokes createTimeSeries with error', done => {
+ var client = new monitoringModule.v3.MetricServiceClient({
+ credentials: {client_email: 'bogus', private_key: 'bogus'},
+ projectId: 'bogus',
+ });
// Mock request
- var formattedName = client.projectPath("[PROJECT]");
+ var formattedName = client.projectPath('[PROJECT]');
var timeSeries = [];
var request = {
- name : formattedName,
- timeSeries : timeSeries
+ name: formattedName,
+ timeSeries: timeSeries,
};
// Mock Grpc layer
- client._createTimeSeries = mockSimpleGrpcMethod(request, null, error);
+ client._innerApiCalls.createTimeSeries = mockSimpleGrpcMethod(
+ request,
+ null,
+ error
+ );
- client.createTimeSeries(request, function(err) {
+ client.createTimeSeries(request, err => {
assert(err instanceof Error);
assert.equal(err.code, FAKE_STATUS_CODE);
done();