Skip to content

Commit 5092729

Browse files
summer-ji-engbcoe
andauthored
feat!: monitoring convert to typescript (#360)
* feat: monitoring conversion by delete js file and add ts from generator * upgrade package.json * fixed samples test by modify the matched path * prelint, add eslint for samples test * fix upstream proto links, get rid of synth hack Co-authored-by: Benjamin E. Coe <[email protected]>
1 parent e599fc1 commit 5092729

File tree

86 files changed

+47079
-43859
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+47079
-43859
lines changed
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
**/*.log
22
**/node_modules
33
.coverage
4+
coverage
45
.nyc_output
56
docs/
67
out/
@@ -9,7 +10,5 @@ system-test/secrets.js
910
system-test/*key.json
1011
*.lock
1112
.DS_Store
12-
google-cloud-logging-winston-*.tgz
13-
google-cloud-logging-bunyan-*.tgz
1413
package-lock.json
1514
__pycache__

packages/google-cloud-monitoring/.jsdoc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
source: {
3232
excludePattern: '(^|\\/|\\\\)[._]',
3333
include: [
34-
'src'
34+
'build/src'
3535
],
3636
includePattern: '\\.js$'
3737
},

packages/google-cloud-monitoring/linkinator.config.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"skip": [
44
"https://codecov.io/gh/googleapis/",
55
"www.googleapis.com",
6-
"https://cloud.google.com/monitoring/workspaces/tiers",
76
"img.shields.io"
87
]
98
}

packages/google-cloud-monitoring/package.json

+27-14
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"node": ">=8.10.0"
99
},
1010
"repository": "googleapis/nodejs-monitoring",
11-
"main": "src/index.js",
11+
"main": "build/src/index.js",
1212
"files": [
13-
"src",
14-
"protos"
13+
"build/src",
14+
"build/protos"
1515
],
1616
"keywords": [
1717
"google apis client",
@@ -28,30 +28,43 @@
2828
],
2929
"scripts": {
3030
"docs": "jsdoc -c .jsdoc.js",
31-
"lint": "eslint '**/*.js'",
32-
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
33-
"system-test": "mocha system-test/*.js --timeout 600000",
34-
"test": "c8 mocha",
35-
"fix": "eslint '**/*.js' --fix",
31+
"lint": "gts fix && eslint --fix samples/*.js",
32+
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
33+
"system-test": "mocha build/system-test",
34+
"test": "c8 mocha build/test",
35+
"fix": "gts fix && eslint 'samples/**/*.js' --fix",
3636
"docs-test": "linkinator docs",
3737
"predocs-test": "npm run docs",
38-
"prelint": "cd samples; npm link ../; npm i"
38+
"prelint": "cd samples; npm link ../; npm i",
39+
"clean": "gts clean",
40+
"compile": "tsc -p . && cp -r protos build/",
41+
"compile-protos": "compileProtos src",
42+
"prepare": "npm run compile"
3943
},
4044
"dependencies": {
41-
"google-gax": "^1.7.5"
45+
"google-gax": "^1.14.1"
4246
},
4347
"devDependencies": {
44-
"c8": "^7.0.0",
45-
"codecov": "^3.0.0",
48+
"@types/mocha": "^5.2.5",
49+
"@types/node": "^12.12.27",
50+
"c8": "^7.1.0",
51+
"codecov": "^3.6.5",
4652
"eslint": "^6.0.0",
4753
"eslint-config-prettier": "^6.0.0",
4854
"eslint-plugin-node": "^11.0.0",
4955
"eslint-plugin-prettier": "^3.0.0",
56+
"gts": "^1.0.0",
5057
"jsdoc": "^3.5.5",
5158
"jsdoc-fresh": "^1.0.1",
5259
"jsdoc-region-tag": "^1.0.2",
5360
"linkinator": "^2.0.0",
54-
"mocha": "^7.0.0",
55-
"prettier": "^1.7.4"
61+
"mocha": "^7.0.1",
62+
"null-loader": "^3.0.0",
63+
"pack-n-play": "^1.0.0-2",
64+
"prettier": "^1.13.7",
65+
"ts-loader": "^6.2.1",
66+
"typescript": "^3.7.0",
67+
"webpack": "^4.41.6",
68+
"webpack-cli": "^3.3.11"
5669
}
5770
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2019 Google LLC.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// This file contains stub messages for common resources in GCP.
16+
// It is not intended to be directly generated, and is instead used by
17+
// other tooling to be able to match common resource patterns.
18+
syntax = "proto3";
19+
20+
package google.cloud;
21+
22+
import "google/api/resource.proto";
23+
24+
25+
option (google.api.resource_definition) = {
26+
type: "cloudresourcemanager.googleapis.com/Project"
27+
pattern: "projects/{project}"
28+
};
29+
30+
31+
option (google.api.resource_definition) = {
32+
type: "cloudresourcemanager.googleapis.com/Organization"
33+
pattern: "organizations/{organization}"
34+
};
35+
36+
37+
option (google.api.resource_definition) = {
38+
type: "cloudresourcemanager.googleapis.com/Folder"
39+
pattern: "folders/{folder}"
40+
};
41+
42+
43+
option (google.api.resource_definition) = {
44+
type: "cloudbilling.googleapis.com/BillingAccount"
45+
pattern: "billingAccounts/{billing_account}"
46+
};
47+
48+
option (google.api.resource_definition) = {
49+
type: "locations.googleapis.com/Location"
50+
pattern: "projects/{project}/locations/{location}"
51+
};
52+

packages/google-cloud-monitoring/protos/google/monitoring/v3/alert.proto

+18-18
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ message AlertPolicy {
8989
// A condition type that compares a collection of time series
9090
// against a threshold.
9191
message MetricThreshold {
92-
// A [filter](/monitoring/api/v3/filters) that
92+
// A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
9393
// identifies which time series should be compared with the threshold.
9494
//
9595
// The filter is similar to the one that is specified in the
@@ -114,11 +114,11 @@ message AlertPolicy {
114114
// field.
115115
repeated Aggregation aggregations = 8;
116116

117-
// A [filter](/monitoring/api/v3/filters) that identifies a time
118-
// series that should be used as the denominator of a ratio that will be
119-
// compared with the threshold. If a `denominator_filter` is specified,
120-
// the time series specified by the `filter` field will be used as the
121-
// numerator.
117+
// A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
118+
// identifies a time series that should be used as the denominator of a
119+
// ratio that will be compared with the threshold. If a
120+
// `denominator_filter` is specified, the time series specified by the
121+
// `filter` field will be used as the numerator.
122122
//
123123
// The filter must specify the metric type and optionally may contain
124124
// restrictions on resource type, resource labels, and metric labels.
@@ -175,7 +175,7 @@ message AlertPolicy {
175175
// when a time series for the specified metric of a monitored
176176
// resource does not include any data in the specified `duration`.
177177
message MetricAbsence {
178-
// A [filter](/monitoring/api/v3/filters) that
178+
// A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
179179
// identifies which time series should be compared with the threshold.
180180
//
181181
// The filter is similar to the one that is specified in the
@@ -216,9 +216,9 @@ message AlertPolicy {
216216
}
217217

218218
// Required if the condition exists. The unique resource name for this
219-
// condition. Its syntax is:
219+
// condition. Its format is:
220220
//
221-
// projects/[PROJECT_ID]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID]
221+
// projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID]
222222
//
223223
// `[CONDITION_ID]` is assigned by Stackdriver Monitoring when the
224224
// condition is created as part of a new or updated alerting policy.
@@ -264,7 +264,7 @@ message AlertPolicy {
264264
COMBINE_UNSPECIFIED = 0;
265265

266266
// Combine conditions using the logical `AND` operator. An
267-
// incident is created only if all conditions are met
267+
// incident is created only if all the conditions are met
268268
// simultaneously. This combiner is satisfied if all conditions are
269269
// met, even if they are met on completely different resources.
270270
AND = 1;
@@ -280,9 +280,9 @@ message AlertPolicy {
280280
}
281281

282282
// Required if the policy exists. The resource name for this policy. The
283-
// syntax is:
283+
// format is:
284284
//
285-
// projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
285+
// projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
286286
//
287287
// `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy
288288
// is created. When calling the
@@ -317,14 +317,14 @@ message AlertPolicy {
317317
// OR according to the `combiner` field. If the combined conditions evaluate
318318
// to true, then an incident is created. A policy can have from one to six
319319
// conditions.
320-
// If |condition_time_series_uery_language| is present, it must be the only
321-
// |condition|.
320+
// If `condition_time_series_query_language` is present, it must be the only
321+
// `condition`.
322322
repeated Condition conditions = 12;
323323

324324
// How to combine the results of multiple conditions to determine if an
325325
// incident should be opened.
326-
// If condition_time_series_query_language is present, this must be
327-
// COMBINE_UNSPECIFIED.
326+
// If `condition_time_series_query_language` is present, this must be
327+
// `COMBINE_UNSPECIFIED`.
328328
ConditionCombinerType combiner = 6;
329329

330330
// Whether or not the policy is enabled. On write, the default interpretation
@@ -345,9 +345,9 @@ message AlertPolicy {
345345
// [`NotificationChannel`][google.monitoring.v3.NotificationChannel]
346346
// objects that are returned from the [`ListNotificationChannels`]
347347
// [google.monitoring.v3.NotificationChannelService.ListNotificationChannels]
348-
// method. The syntax of the entries in this field is:
348+
// method. The format of the entries in this field is:
349349
//
350-
// projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
350+
// projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
351351
repeated string notification_channels = 14;
352352

353353
// A read-only record of the creation of the alerting policy. If provided

packages/google-cloud-monitoring/protos/google/monitoring/v3/alert_service.proto

+14-12
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ service AlertPolicyService {
9696

9797
// The protocol for the `CreateAlertPolicy` request.
9898
message CreateAlertPolicyRequest {
99-
// Required. The project in which to create the alerting policy. The format is
100-
// `projects/[PROJECT_ID]`.
99+
// Required. The project in which to create the alerting policy. The format is:
100+
//
101+
// projects/[PROJECT_ID_OR_NUMBER]
101102
//
102103
// Note that this field names the parent container in which the alerting
103104
// policy will be written, not the name of the created policy. The alerting
104105
// policy that is returned will have a name that contains a normalized
105106
// representation of this name as a prefix but adds a suffix of the form
106-
// `/alertPolicies/[POLICY_ID]`, identifying the policy in the container.
107+
// `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the
108+
// container.
107109
string name = 3 [
108110
(google.api.field_behavior) = REQUIRED,
109111
(google.api.resource_reference) = {
@@ -113,15 +115,15 @@ message CreateAlertPolicyRequest {
113115

114116
// Required. The requested alerting policy. You should omit the `name` field in this
115117
// policy. The name will be returned in the new policy, including
116-
// a new [ALERT_POLICY_ID] value.
118+
// a new `[ALERT_POLICY_ID]` value.
117119
AlertPolicy alert_policy = 2 [(google.api.field_behavior) = REQUIRED];
118120
}
119121

120122
// The protocol for the `GetAlertPolicy` request.
121123
message GetAlertPolicyRequest {
122-
// Required. The alerting policy to retrieve. The format is
124+
// Required. The alerting policy to retrieve. The format is:
123125
//
124-
// projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
126+
// projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
125127
string name = 3 [
126128
(google.api.field_behavior) = REQUIRED,
127129
(google.api.resource_reference) = {
@@ -132,9 +134,9 @@ message GetAlertPolicyRequest {
132134

133135
// The protocol for the `ListAlertPolicies` request.
134136
message ListAlertPoliciesRequest {
135-
// Required. The project whose alert policies are to be listed. The format is
137+
// Required. The project whose alert policies are to be listed. The format is:
136138
//
137-
// projects/[PROJECT_ID]
139+
// projects/[PROJECT_ID_OR_NUMBER]
138140
//
139141
// Note that this field names the parent container in which the alerting
140142
// policies to be listed are stored. To retrieve a single alerting policy
@@ -152,15 +154,15 @@ message ListAlertPoliciesRequest {
152154
// alert policies to be included in the response.
153155
//
154156
// For more details, see [sorting and
155-
// filtering](/monitoring/api/v3/sorting-and-filtering).
157+
// filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
156158
string filter = 5;
157159

158160
// A comma-separated list of fields by which to sort the result. Supports
159161
// the same set of field references as the `filter` field. Entries can be
160162
// prefixed with a minus sign to sort by the field in descending order.
161163
//
162164
// For more details, see [sorting and
163-
// filtering](/monitoring/api/v3/sorting-and-filtering).
165+
// filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
164166
string order_by = 6;
165167

166168
// The maximum number of results to return in a single response.
@@ -179,7 +181,7 @@ message ListAlertPoliciesResponse {
179181

180182
// If there might be more results than were returned, then this field is set
181183
// to a non-empty value. To see the additional results,
182-
// use that value as `pageToken` in the next call to this method.
184+
// use that value as `page_token` in the next call to this method.
183185
string next_page_token = 2;
184186
}
185187

@@ -219,7 +221,7 @@ message UpdateAlertPolicyRequest {
219221
message DeleteAlertPolicyRequest {
220222
// Required. The alerting policy to delete. The format is:
221223
//
222-
// projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
224+
// projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
223225
//
224226
// For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy].
225227
string name = 3 [

0 commit comments

Comments
 (0)