Skip to content

Commit 4a5f7ee

Browse files
docs(samples): add auto-generated Node samples (#346)
* docs(samples): add auto-generated Node samples build(generator): find protoc based on its bazel location PiperOrigin-RevId: 398604509 Source-Link: googleapis/googleapis@6ef16b9 Source-Link: googleapis/googleapis-gen@8314e1e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODMxNGUxZWFkM2U5MDZkYmYyMDEyY2VkOGQ5MmYyYmM4ZGQ0NWM5NSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 6b81b33 commit 4a5f7ee

File tree

41 files changed

+2329
-8
lines changed

Some content is hidden

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

41 files changed

+2329
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2021 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+
'use strict';
16+
17+
function main(resource) {
18+
// [START containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* REQUIRED: The resource for which the policy is being requested.
24+
* See the operation documentation for the appropriate value for this field.
25+
*/
26+
// const resource = 'abc123'
27+
/**
28+
* OPTIONAL: A `GetPolicyOptions` object for specifying options to
29+
* `GetIamPolicy`. This field is only used by Cloud IAM.
30+
*/
31+
// const options = ''
32+
33+
// Imports the Containeranalysis library
34+
const {ContainerAnalysisClient} =
35+
require('@google-cloud/containeranalysis').v1;
36+
37+
// Instantiates a client
38+
const containeranalysisClient = new ContainerAnalysisClient();
39+
40+
async function getIamPolicy() {
41+
// Construct request
42+
const request = {
43+
resource,
44+
};
45+
46+
// Run request
47+
const response = await containeranalysisClient.getIamPolicy(request);
48+
console.log(response);
49+
}
50+
51+
getIamPolicy();
52+
// [END containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_async]
53+
}
54+
55+
process.on('unhandledRejection', err => {
56+
console.error(err.message);
57+
process.exitCode = 1;
58+
});
59+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2021 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+
'use strict';
16+
17+
function main(parent) {
18+
// [START containeranalysis_v1_generated_ContainerAnalysis_GetVulnerabilityOccurrencesSummary_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* The name of the project to get a vulnerability summary for in the form of
24+
* `projects/[PROJECT_ID]`.
25+
*/
26+
// const parent = 'abc123'
27+
/**
28+
* The filter expression.
29+
*/
30+
// const filter = 'abc123'
31+
32+
// Imports the Containeranalysis library
33+
const {ContainerAnalysisClient} =
34+
require('@google-cloud/containeranalysis').v1;
35+
36+
// Instantiates a client
37+
const containeranalysisClient = new ContainerAnalysisClient();
38+
39+
async function getVulnerabilityOccurrencesSummary() {
40+
// Construct request
41+
const request = {
42+
parent,
43+
};
44+
45+
// Run request
46+
const response =
47+
await containeranalysisClient.getVulnerabilityOccurrencesSummary(request);
48+
console.log(response);
49+
}
50+
51+
getVulnerabilityOccurrencesSummary();
52+
// [END containeranalysis_v1_generated_ContainerAnalysis_GetVulnerabilityOccurrencesSummary_async]
53+
}
54+
55+
process.on('unhandledRejection', err => {
56+
console.error(err.message);
57+
process.exitCode = 1;
58+
});
59+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2021 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+
'use strict';
16+
17+
function main(resource, policy) {
18+
// [START containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* REQUIRED: The resource for which the policy is being specified.
24+
* See the operation documentation for the appropriate value for this field.
25+
*/
26+
// const resource = 'abc123'
27+
/**
28+
* REQUIRED: The complete policy to be applied to the `resource`. The size of
29+
* the policy is limited to a few 10s of KB. An empty policy is a
30+
* valid policy but certain Cloud Platform services (such as Projects)
31+
* might reject them.
32+
*/
33+
// const policy = ''
34+
35+
// Imports the Containeranalysis library
36+
const {ContainerAnalysisClient} =
37+
require('@google-cloud/containeranalysis').v1;
38+
39+
// Instantiates a client
40+
const containeranalysisClient = new ContainerAnalysisClient();
41+
42+
async function setIamPolicy() {
43+
// Construct request
44+
const request = {
45+
resource,
46+
policy,
47+
};
48+
49+
// Run request
50+
const response = await containeranalysisClient.setIamPolicy(request);
51+
console.log(response);
52+
}
53+
54+
setIamPolicy();
55+
// [END containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_async]
56+
}
57+
58+
process.on('unhandledRejection', err => {
59+
console.error(err.message);
60+
process.exitCode = 1;
61+
});
62+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2021 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+
'use strict';
16+
17+
function main(resource, permissions) {
18+
// [START containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* REQUIRED: The resource for which the policy detail is being requested.
24+
* See the operation documentation for the appropriate value for this field.
25+
*/
26+
// const resource = 'abc123'
27+
/**
28+
* The set of permissions to check for the `resource`. Permissions with
29+
* wildcards (such as '*' or 'storage.*') are not allowed. For more
30+
* information see
31+
* [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
32+
*/
33+
// const permissions = 'abc123'
34+
35+
// Imports the Containeranalysis library
36+
const {ContainerAnalysisClient} =
37+
require('@google-cloud/containeranalysis').v1;
38+
39+
// Instantiates a client
40+
const containeranalysisClient = new ContainerAnalysisClient();
41+
42+
async function testIamPermissions() {
43+
// Construct request
44+
const request = {
45+
resource,
46+
permissions,
47+
};
48+
49+
// Run request
50+
const response = await containeranalysisClient.testIamPermissions(request);
51+
console.log(response);
52+
}
53+
54+
testIamPermissions();
55+
// [END containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_async]
56+
}
57+
58+
process.on('unhandledRejection', err => {
59+
console.error(err.message);
60+
process.exitCode = 1;
61+
});
62+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2021 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+
'use strict';
16+
17+
function main(parent, notes) {
18+
// [START containeranalysis_v1_generated_Grafeas_BatchCreateNotes_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* The name of the project in the form of `projects/[PROJECT_ID]`, under which
24+
* the notes are to be created.
25+
*/
26+
// const parent = 'abc123'
27+
/**
28+
* The notes to create. Max allowed length is 1000.
29+
*/
30+
// const notes = 1234
31+
32+
// Imports the Containeranalysis library
33+
const {GrafeasClient} = require('@google-cloud/containeranalysis').v1;
34+
35+
// Instantiates a client
36+
const containeranalysisClient = new GrafeasClient();
37+
38+
async function batchCreateNotes() {
39+
// Construct request
40+
const request = {
41+
parent,
42+
notes,
43+
};
44+
45+
// Run request
46+
const response = await containeranalysisClient.batchCreateNotes(request);
47+
console.log(response);
48+
}
49+
50+
batchCreateNotes();
51+
// [END containeranalysis_v1_generated_Grafeas_BatchCreateNotes_async]
52+
}
53+
54+
process.on('unhandledRejection', err => {
55+
console.error(err.message);
56+
process.exitCode = 1;
57+
});
58+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2021 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+
'use strict';
16+
17+
function main(parent, occurrences) {
18+
// [START containeranalysis_v1_generated_Grafeas_BatchCreateOccurrences_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* The name of the project in the form of `projects/[PROJECT_ID]`, under which
24+
* the occurrences are to be created.
25+
*/
26+
// const parent = 'abc123'
27+
/**
28+
* The occurrences to create. Max allowed length is 1000.
29+
*/
30+
// const occurrences = 1234
31+
32+
// Imports the Containeranalysis library
33+
const {GrafeasClient} = require('@google-cloud/containeranalysis').v1;
34+
35+
// Instantiates a client
36+
const containeranalysisClient = new GrafeasClient();
37+
38+
async function batchCreateOccurrences() {
39+
// Construct request
40+
const request = {
41+
parent,
42+
occurrences,
43+
};
44+
45+
// Run request
46+
const response = await containeranalysisClient.batchCreateOccurrences(
47+
request
48+
);
49+
console.log(response);
50+
}
51+
52+
batchCreateOccurrences();
53+
// [END containeranalysis_v1_generated_Grafeas_BatchCreateOccurrences_async]
54+
}
55+
56+
process.on('unhandledRejection', err => {
57+
console.error(err.message);
58+
process.exitCode = 1;
59+
});
60+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)