Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit 0707792

Browse files
authored
feat: add v1 client (#43)
1 parent d5b8dc8 commit 0707792

File tree

14 files changed

+1209
-36
lines changed

14 files changed

+1209
-36
lines changed

.kokoro/continuous/node10/test.cfg

+20-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,30 @@ before_action {
88
}
99
}
1010

11-
# token used by release-please to keep an up-to-date release PR.
11+
# tokens used by release-please to keep an up-to-date release PR.
1212
before_action {
1313
fetch_keystore {
1414
keystore_resource {
1515
keystore_config_id: 73713
16-
keyname: "yoshi-automation-github-key"
16+
keyname: "github-magic-proxy-key-release-please"
17+
}
18+
}
19+
}
20+
21+
before_action {
22+
fetch_keystore {
23+
keystore_resource {
24+
keystore_config_id: 73713
25+
keyname: "github-magic-proxy-token-release-please"
26+
}
27+
}
28+
}
29+
30+
before_action {
31+
fetch_keystore {
32+
keystore_resource {
33+
keystore_config_id: 73713
34+
keyname: "github-magic-proxy-url-release-please"
1735
}
1836
}
1937
}

.kokoro/test.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ else
3636
echo "coverage is only reported for Node $COVERAGE_NODE"
3737
fi
3838

39-
# if the GITHUB_TOKEN is set, we kick off a task to update the release-PR.
40-
GITHUB_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_yoshi-automation-github-key) || true
41-
if [ "$GITHUB_TOKEN" ]; then
42-
npx release-please release-pr --token=$GITHUB_TOKEN \
39+
# if release-please keys set, we kick off a task to update the release-PR.
40+
if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then
41+
npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \
4342
--repo-url=googleapis/nodejs-containeranalysis \
44-
--package-name=@google-cloud/containeranalysis
43+
--package-name=@google-cloud/containeranalysis \
44+
--api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \
45+
--proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please
4546
fi

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"google-gax": "^1.0.0"
2727
},
2828
"devDependencies": {
29+
"c8": "^5.0.1",
2930
"eslint": "^5.16.0",
3031
"eslint-config-prettier": "^4.2.0",
3132
"eslint-plugin-node": "^9.0.1",
@@ -34,18 +35,17 @@
3435
"jsdoc-baseline": "^0.1.0",
3536
"linkinator": "^1.4.2",
3637
"mocha": "^6.1.4",
37-
"nyc": "^14.1.1",
3838
"power-assert": "^1.6.1",
3939
"prettier": "^1.17.1"
4040
},
4141
"scripts": {
4242
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
43-
"test": "nyc mocha",
43+
"test": "c8 mocha",
4444
"lint": "eslint '**/*.js'",
4545
"docs": "jsdoc -c .jsdoc.js",
4646
"system-test": "mocha system-test/ --timeout 600000",
4747
"fix": "eslint '**/*.js' --fix",
48-
"docs-test": "linkinator docs -r --skip 'www.npmjs.org|cloud.google.com/nodejs/docs/reference/containeranalysis/latest/'",
48+
"docs-test": "linkinator docs -r",
4949
"predocs-test": "npm run docs"
5050
},
5151
"license": "Apache-2.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
16+
syntax = "proto3";
17+
18+
package google.devtools.containeranalysis.v1;
19+
20+
import "google/api/annotations.proto";
21+
import "google/iam/v1/iam_policy.proto";
22+
import "google/iam/v1/policy.proto";
23+
import "google/protobuf/timestamp.proto";
24+
25+
option csharp_namespace = "Google.Cloud.DevTools.ContainerAnalysis.V1";
26+
option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1;containeranalysis";
27+
option java_multiple_files = true;
28+
option java_package = "com.google.containeranalysis.v1";
29+
option objc_class_prefix = "GCA";
30+
option ruby_package = "Google::Cloud::ContainerAnalysis::V1";
31+
32+
// Retrieves analysis results of Cloud components such as Docker container
33+
// images. The Container Analysis API is an implementation of the
34+
// [Grafeas](grafeas.io) API.
35+
//
36+
// Analysis results are stored as a series of occurrences. An `Occurrence`
37+
// contains information about a specific analysis instance on a resource. An
38+
// occurrence refers to a `Note`. A note contains details describing the
39+
// analysis and is generally stored in a separate project, called a `Provider`.
40+
// Multiple occurrences can refer to the same note.
41+
//
42+
// For example, an SSL vulnerability could affect multiple images. In this case,
43+
// there would be one note for the vulnerability and an occurrence for each
44+
// image with the vulnerability referring to that note.
45+
service ContainerAnalysis {
46+
// Sets the access control policy on the specified note or occurrence.
47+
// Requires `containeranalysis.notes.setIamPolicy` or
48+
// `containeranalysis.occurrences.setIamPolicy` permission if the resource is
49+
// a note or an occurrence, respectively.
50+
//
51+
// The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
52+
// notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
53+
// occurrences.
54+
rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) {
55+
option (google.api.http) = {
56+
post: "/v1/{resource=projects/*/notes/*}:setIamPolicy"
57+
body: "*"
58+
additional_bindings {
59+
post: "/v1/{resource=projects/*/occurrences/*}:setIamPolicy"
60+
body: "*"
61+
}
62+
};
63+
}
64+
65+
// Gets the access control policy for a note or an occurrence resource.
66+
// Requires `containeranalysis.notes.setIamPolicy` or
67+
// `containeranalysis.occurrences.setIamPolicy` permission if the resource is
68+
// a note or occurrence, respectively.
69+
//
70+
// The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
71+
// notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
72+
// occurrences.
73+
rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) {
74+
option (google.api.http) = {
75+
post: "/v1/{resource=projects/*/notes/*}:getIamPolicy"
76+
body: "*"
77+
additional_bindings {
78+
post: "/v1/{resource=projects/*/occurrences/*}:getIamPolicy"
79+
body: "*"
80+
}
81+
};
82+
}
83+
84+
// Returns the permissions that a caller has on the specified note or
85+
// occurrence. Requires list permission on the project (for example,
86+
// `containeranalysis.notes.list`).
87+
//
88+
// The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
89+
// notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
90+
// occurrences.
91+
rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) {
92+
option (google.api.http) = {
93+
post: "/v1/{resource=projects/*/notes/*}:testIamPermissions"
94+
body: "*"
95+
additional_bindings {
96+
post: "/v1/{resource=projects/*/occurrences/*}:testIamPermissions"
97+
body: "*"
98+
}
99+
};
100+
}
101+
}

src/index.js

+17-20
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
/**
2222
* @namespace google.cloud.containeranalysis
2323
*/
24+
/**
25+
* @namespace google.cloud.containeranalysis.v1
26+
*/
2427
/**
2528
* @namespace google.cloud.containeranalysis.v1beta1
2629
*/
@@ -74,22 +77,19 @@
7477

7578
// Import the clients for each version supported by this package.
7679
const gapic = Object.freeze({
80+
v1: require('./v1'),
7781
v1beta1: require('./v1beta1'),
7882
});
7983

8084
/**
8185
* The `@google-cloud/containeranalysis` package has the following named exports:
8286
*
83-
* - `ContainerAnalysisV1Beta1Client` - Reference to
84-
* {@link v1beta1.ContainerAnalysisV1Beta1Client}
85-
* - `GrafeasV1Beta1Client` - Reference to
86-
* {@link v1beta1.GrafeasV1Beta1Client}
87-
* - `v1beta1` - This is used for selecting or pinning a
87+
* - `ContainerAnalysisClient` - Reference to
88+
* {@link v1.ContainerAnalysisClient}
89+
* - `v1` - This is used for selecting or pinning a
8890
* particular backend service version. It exports:
89-
* - `ContainerAnalysisV1Beta1Client` - Reference to
90-
* {@link v1beta1.ContainerAnalysisV1Beta1Client}
91-
* - `GrafeasV1Beta1Client` - Reference to
92-
* {@link v1beta1.GrafeasV1Beta1Client}
91+
* - `ContainerAnalysisClient` - Reference to
92+
* {@link v1.ContainerAnalysisClient}
9393
*
9494
* @module {object} @google-cloud/containeranalysis
9595
* @alias nodejs-containeranalysis
@@ -101,31 +101,28 @@ const gapic = Object.freeze({
101101
* const containeranalysis = require('@google-cloud/containeranalysis');
102102
*
103103
* @example <caption>Create a client that uses <a href="https://goo.gl/64dyYX">Application Default Credentials (ADC)</a>:</caption>
104-
* const client = new containeranalysis.ContainerAnalysisV1Beta1Client();
104+
* const client = new containeranalysis.ContainerAnalysisClient();
105105
*
106106
* @example <caption>Create a client with <a href="https://goo.gl/RXp6VL">explicit credentials</a>:</caption>
107-
* const client = new containeranalysis.ContainerAnalysisV1Beta1Client({
107+
* const client = new containeranalysis.ContainerAnalysisClient({
108108
* projectId: 'your-project-id',
109109
* keyFilename: '/path/to/keyfile.json',
110110
* });
111111
*/
112112

113113
/**
114114
* @type {object}
115-
* @property {constructor} ContainerAnalysisV1Beta1Client
116-
* Reference to {@link v1beta1.ContainerAnalysisV1Beta1Client}
117-
* @property {constructor} GrafeasV1Beta1Client
118-
* Reference to {@link v1beta1.GrafeasV1Beta1Client}
115+
* @property {constructor} ContainerAnalysisClient
116+
* Reference to {@link v1.ContainerAnalysisClient}
119117
*/
120-
module.exports = gapic.v1beta1;
118+
module.exports = gapic.v1;
121119

122120
/**
123121
* @type {object}
124-
* @property {constructor} ContainerAnalysisV1Beta1Client
125-
* Reference to {@link v1beta1.ContainerAnalysisV1Beta1Client}
126-
* @property {constructor} GrafeasV1Beta1Client
127-
* Reference to {@link v1beta1.GrafeasV1Beta1Client}
122+
* @property {constructor} ContainerAnalysisClient
123+
* Reference to {@link v1.ContainerAnalysisClient}
128124
*/
125+
module.exports.v1 = gapic.v1;
129126
module.exports.v1beta1 = gapic.v1beta1;
130127

131128
// Alias `module.exports` as `module.exports.default`, for future-proofing.

0 commit comments

Comments
 (0)