Skip to content

Commit 3b5d06c

Browse files
author
Benjamin E. Coe
authored
feat!: converts library to TypeScript adding v1p1beta1 surface (#250)
BREAKING CHANGE: removes projectPath helper, instead use "projects/${project}".
1 parent 94448c6 commit 3b5d06c

File tree

79 files changed

+14137
-14984
lines changed

Some content is hidden

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

79 files changed

+14137
-14984
lines changed

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

Lines changed: 1 addition & 1 deletion
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-asset/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ npm install @google-cloud/asset
6262

6363
async function quickstart() {
6464
const projectId = await client.getProjectId();
65-
const projectResource = client.projectPath(projectId);
65+
const projectResource = `projects/${projectId}`;
6666
// TODO(developer): Choose asset names, such as //storage.googleapis.com/[YOUR_BUCKET_NAME].
6767
// const assetNames = ['ASSET_NAME1', 'ASSET_NAME2', ...];
6868

packages/google-cloud-asset/package.json

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
"node": ">=8.10.0"
99
},
1010
"repository": "googleapis/nodejs-asset",
11-
"main": "src/index.js",
11+
"main": "build/src/index.js",
1212
"files": [
13-
"protos",
14-
"src",
15-
"AUTHORS",
16-
"COPYING"
13+
"build/src",
14+
"build/protos"
1715
],
1816
"keywords": [
1917
"google apis client",
@@ -29,34 +27,47 @@
2927
"Cloud Asset API"
3028
],
3129
"scripts": {
32-
"docs": "jsdoc -c .jsdoc.js",
33-
"lint": "eslint '**/*.js'",
3430
"samples-test": "c8 npm run samples-test-suite",
3531
"samples-test-suite": "cd samples/ && npm link ../ && npm test && cd ../",
36-
"system-test": "mocha system-test/*.js smoke-test/*.js --timeout 600000",
37-
"test": "c8 mocha",
38-
"fix": "eslint --fix '**/*.js'",
32+
"clean": "gts clean",
33+
"compile": "tsc -p . && cp -r protos build/",
34+
"compile-protos": "compileProtos src",
35+
"docs": "jsdoc -c .jsdoc.js",
3936
"docs-test": "linkinator docs",
40-
"predocs-test": "npm run docs"
37+
"fix": "gts fix",
38+
"lint": "gts check",
39+
"predocs-test": "npm run docs",
40+
"prepare": "npm run compile",
41+
"system-test": "c8 mocha build/system-test",
42+
"test": "c8 mocha build/test"
4143
},
4244
"dependencies": {
43-
"google-gax": "^1.7.5",
45+
"google-gax": "^1.14.1",
4446
"protobufjs": "^6.8.0"
4547
},
4648
"devDependencies": {
49+
"@types/mocha": "^5.2.5",
50+
"@types/node": "^12.0.0",
51+
"c8": "^7.0.1",
4752
"codecov": "^3.0.4",
4853
"eslint": "^6.0.0",
4954
"eslint-config-prettier": "^6.0.0",
5055
"eslint-plugin-node": "^11.0.0",
5156
"eslint-plugin-prettier": "^3.0.0",
57+
"gts": "^1.0.0",
5258
"intelli-espower-loader": "^1.0.1",
5359
"jsdoc": "^3.6.2",
5460
"jsdoc-fresh": "^1.0.1",
5561
"jsdoc-region-tag": "^1.0.2",
5662
"linkinator": "^1.5.0",
5763
"mocha": "^7.0.0",
58-
"c8": "^7.0.0",
64+
"null-loader": "^3.0.0",
65+
"pack-n-play": "^1.0.0-2",
5966
"power-assert": "^1.6.0",
60-
"prettier": "^1.13.7"
67+
"prettier": "^1.13.7",
68+
"ts-loader": "^6.2.1",
69+
"typescript": "~3.6.4",
70+
"webpack": "^4.41.2",
71+
"webpack-cli": "^3.3.10"
6172
}
6273
}

packages/google-cloud-asset/protos/google/cloud/asset/v1beta1/asset_service.proto

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC.
1+
// Copyright 2019 Google LLC.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -18,6 +18,9 @@ syntax = "proto3";
1818
package google.cloud.asset.v1beta1;
1919

2020
import "google/api/annotations.proto";
21+
import "google/api/client.proto";
22+
import "google/api/field_behavior.proto";
23+
import "google/api/resource.proto";
2124
import "google/cloud/asset/v1beta1/assets.proto";
2225
import "google/longrunning/operations.proto";
2326
import "google/protobuf/timestamp.proto";
@@ -31,6 +34,10 @@ option php_namespace = "Google\\Cloud\\Asset\\V1beta1";
3134

3235
// Asset service definition.
3336
service AssetService {
37+
option (google.api.default_host) = "cloudasset.googleapis.com";
38+
option (google.api.oauth_scopes) =
39+
"https://www.googleapis.com/auth/cloud-platform";
40+
3441
// Exports assets with time and resource types to a given Cloud Storage
3542
// location. The output format is newline-delimited JSON.
3643
// This API implements the
@@ -49,13 +56,19 @@ service AssetService {
4956
body: "*"
5057
}
5158
};
59+
option (google.longrunning.operation_info) = {
60+
response_type: "google.cloud.asset.v1beta1.ExportAssetsResponse"
61+
metadata_type: "google.cloud.asset.v1beta1.ExportAssetsRequest"
62+
};
5263
}
5364

5465
// Batch gets the update history of assets that overlap a time window.
5566
// For RESOURCE content, this API outputs history with asset in both
5667
// non-delete or deleted status.
5768
// For IAM_POLICY content, this API outputs history when the asset and its
5869
// attached IAM POLICY both exist. This can create gaps in the output history.
70+
// If a specified asset does not exist, this API returns an INVALID_ARGUMENT
71+
// error.
5972
rpc BatchGetAssetsHistory(BatchGetAssetsHistoryRequest)
6073
returns (BatchGetAssetsHistoryResponse) {
6174
option (google.api.http) = {
@@ -73,7 +86,12 @@ message ExportAssetsRequest {
7386
// organization number (such as "organizations/123"), a project ID (such as
7487
// "projects/my-project-id"), a project number (such as "projects/12345"), or
7588
// a folder number (such as "folders/123").
76-
string parent = 1;
89+
string parent = 1 [
90+
(google.api.field_behavior) = REQUIRED,
91+
(google.api.resource_reference) = {
92+
child_type: "cloudasset.googleapis.com/Asset"
93+
}
94+
];
7795

7896
// Timestamp to take an asset snapshot. This can only be set to a timestamp
7997
// between 2018-10-02 UTC (inclusive) and the current time. If not specified,
@@ -95,7 +113,7 @@ message ExportAssetsRequest {
95113

96114
// Required. Output configuration indicating where the results will be output
97115
// to. All results will be in newline delimited JSON format.
98-
OutputConfig output_config = 5;
116+
OutputConfig output_config = 5 [(google.api.field_behavior) = REQUIRED];
99117
}
100118

101119
// The export asset response. This message is returned by the
@@ -117,7 +135,12 @@ message BatchGetAssetsHistoryRequest {
117135
// Required. The relative name of the root asset. It can only be an
118136
// organization number (such as "organizations/123"), a project ID (such as
119137
// "projects/my-project-id")", or a project number (such as "projects/12345").
120-
string parent = 1;
138+
string parent = 1 [
139+
(google.api.field_behavior) = REQUIRED,
140+
(google.api.resource_reference) = {
141+
child_type: "cloudasset.googleapis.com/Asset"
142+
}
143+
];
121144

122145
// A list of the full names of the assets. For example:
123146
// `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`.
@@ -129,16 +152,16 @@ message BatchGetAssetsHistoryRequest {
129152
// size of the asset name list is 100 in one request.
130153
repeated string asset_names = 2;
131154

132-
// Required. The content type.
133-
ContentType content_type = 3;
155+
// Optional. The content type.
156+
ContentType content_type = 3 [(google.api.field_behavior) = OPTIONAL];
134157

135158
// Optional. The time window for the asset history. Both start_time and
136159
// end_time are optional and if set, it must be after 2018-10-02 UTC. If
137160
// end_time is not set, it is default to current timestamp. If start_time is
138161
// not set, the snapshot of the assets at end_time will be returned. The
139162
// returned results contain all temporal assets whose time window overlap with
140163
// read_time_window.
141-
TimeWindow read_time_window = 4;
164+
TimeWindow read_time_window = 4 [(google.api.field_behavior) = OPTIONAL];
142165
}
143166

144167
// Batch get assets history response.
@@ -166,6 +189,16 @@ message GcsDestination {
166189
// Metadata](https://cloud.google.com/storage/docs/viewing-editing-metadata)
167190
// for more information.
168191
string uri = 1;
192+
193+
// The uri prefix of all generated Cloud Storage objects. For example:
194+
// "gs://bucket_name/object_name_prefix". Each object uri is in format:
195+
// "gs://bucket_name/object_name_prefix/<asset type>/<shard number> and only
196+
// contains assets for that type. <shard number> starts from 0. For example:
197+
// "gs://bucket_name/object_name_prefix/google.compute.disk/0" is the first
198+
// shard of output objects containing all google.compute.disk assets.
199+
// An INVALID_ARGUMENT error will be returned if file with the same name
200+
// "gs://bucket_name/object_name_prefix" already exists.
201+
string uri_prefix = 2;
169202
}
170203
}
171204

packages/google-cloud-asset/protos/google/cloud/asset/v1beta1/assets.proto

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC.
1+
// Copyright 2019 Google LLC.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -18,11 +18,13 @@ syntax = "proto3";
1818
package google.cloud.asset.v1beta1;
1919

2020
import "google/api/annotations.proto";
21+
import "google/api/resource.proto";
2122
import "google/iam/v1/policy.proto";
2223
import "google/protobuf/any.proto";
2324
import "google/protobuf/struct.proto";
2425
import "google/protobuf/timestamp.proto";
2526

27+
option cc_enable_arenas = true;
2628
option csharp_namespace = "Google.Cloud.Asset.V1Beta1";
2729
option go_package = "google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset";
2830
option java_multiple_files = true;
@@ -56,6 +58,11 @@ message TimeWindow {
5658
// Cloud asset. This includes all Google Cloud Platform resources,
5759
// Cloud IAM policies, and other non-GCP assets.
5860
message Asset {
61+
option (google.api.resource) = {
62+
type: "cloudasset.googleapis.com/Asset"
63+
pattern: "*"
64+
};
65+
5966
// The full name of the asset. For example:
6067
// `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`.
6168
// See [Resource

0 commit comments

Comments
 (0)