Skip to content

Commit

Permalink
docs(samples): add auto-generated Node samples (#346)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Sep 24, 2021
1 parent 6b81b33 commit 4a5f7ee
Show file tree
Hide file tree
Showing 41 changed files with 2,329 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2021 Google LLC
//
// 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';

function main(resource) {
// [START containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* REQUIRED: The resource for which the policy is being requested.
* See the operation documentation for the appropriate value for this field.
*/
// const resource = 'abc123'
/**
* OPTIONAL: A `GetPolicyOptions` object for specifying options to
* `GetIamPolicy`. This field is only used by Cloud IAM.
*/
// const options = ''

// Imports the Containeranalysis library
const {ContainerAnalysisClient} =
require('@google-cloud/containeranalysis').v1;

// Instantiates a client
const containeranalysisClient = new ContainerAnalysisClient();

async function getIamPolicy() {
// Construct request
const request = {
resource,
};

// Run request
const response = await containeranalysisClient.getIamPolicy(request);
console.log(response);
}

getIamPolicy();
// [END containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2021 Google LLC
//
// 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';

function main(parent) {
// [START containeranalysis_v1_generated_ContainerAnalysis_GetVulnerabilityOccurrencesSummary_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* The name of the project to get a vulnerability summary for in the form of
* `projects/[PROJECT_ID]`.
*/
// const parent = 'abc123'
/**
* The filter expression.
*/
// const filter = 'abc123'

// Imports the Containeranalysis library
const {ContainerAnalysisClient} =
require('@google-cloud/containeranalysis').v1;

// Instantiates a client
const containeranalysisClient = new ContainerAnalysisClient();

async function getVulnerabilityOccurrencesSummary() {
// Construct request
const request = {
parent,
};

// Run request
const response =
await containeranalysisClient.getVulnerabilityOccurrencesSummary(request);
console.log(response);
}

getVulnerabilityOccurrencesSummary();
// [END containeranalysis_v1_generated_ContainerAnalysis_GetVulnerabilityOccurrencesSummary_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2021 Google LLC
//
// 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';

function main(resource, policy) {
// [START containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* REQUIRED: The resource for which the policy is being specified.
* See the operation documentation for the appropriate value for this field.
*/
// const resource = 'abc123'
/**
* REQUIRED: The complete policy to be applied to the `resource`. The size of
* the policy is limited to a few 10s of KB. An empty policy is a
* valid policy but certain Cloud Platform services (such as Projects)
* might reject them.
*/
// const policy = ''

// Imports the Containeranalysis library
const {ContainerAnalysisClient} =
require('@google-cloud/containeranalysis').v1;

// Instantiates a client
const containeranalysisClient = new ContainerAnalysisClient();

async function setIamPolicy() {
// Construct request
const request = {
resource,
policy,
};

// Run request
const response = await containeranalysisClient.setIamPolicy(request);
console.log(response);
}

setIamPolicy();
// [END containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2021 Google LLC
//
// 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';

function main(resource, permissions) {
// [START containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* REQUIRED: The resource for which the policy detail is being requested.
* See the operation documentation for the appropriate value for this field.
*/
// const resource = 'abc123'
/**
* The set of permissions to check for the `resource`. Permissions with
* wildcards (such as '*' or 'storage.*') are not allowed. For more
* information see
* [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
*/
// const permissions = 'abc123'

// Imports the Containeranalysis library
const {ContainerAnalysisClient} =
require('@google-cloud/containeranalysis').v1;

// Instantiates a client
const containeranalysisClient = new ContainerAnalysisClient();

async function testIamPermissions() {
// Construct request
const request = {
resource,
permissions,
};

// Run request
const response = await containeranalysisClient.testIamPermissions(request);
console.log(response);
}

testIamPermissions();
// [END containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2021 Google LLC
//
// 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';

function main(parent, notes) {
// [START containeranalysis_v1_generated_Grafeas_BatchCreateNotes_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* The name of the project in the form of `projects/[PROJECT_ID]`, under which
* the notes are to be created.
*/
// const parent = 'abc123'
/**
* The notes to create. Max allowed length is 1000.
*/
// const notes = 1234

// Imports the Containeranalysis library
const {GrafeasClient} = require('@google-cloud/containeranalysis').v1;

// Instantiates a client
const containeranalysisClient = new GrafeasClient();

async function batchCreateNotes() {
// Construct request
const request = {
parent,
notes,
};

// Run request
const response = await containeranalysisClient.batchCreateNotes(request);
console.log(response);
}

batchCreateNotes();
// [END containeranalysis_v1_generated_Grafeas_BatchCreateNotes_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2021 Google LLC
//
// 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';

function main(parent, occurrences) {
// [START containeranalysis_v1_generated_Grafeas_BatchCreateOccurrences_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* The name of the project in the form of `projects/[PROJECT_ID]`, under which
* the occurrences are to be created.
*/
// const parent = 'abc123'
/**
* The occurrences to create. Max allowed length is 1000.
*/
// const occurrences = 1234

// Imports the Containeranalysis library
const {GrafeasClient} = require('@google-cloud/containeranalysis').v1;

// Instantiates a client
const containeranalysisClient = new GrafeasClient();

async function batchCreateOccurrences() {
// Construct request
const request = {
parent,
occurrences,
};

// Run request
const response = await containeranalysisClient.batchCreateOccurrences(
request
);
console.log(response);
}

batchCreateOccurrences();
// [END containeranalysis_v1_generated_Grafeas_BatchCreateOccurrences_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Loading

0 comments on commit 4a5f7ee

Please sign in to comment.