Skip to content

Commit

Permalink
docs(samples): add example tags to generated samples (#89)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 408439482

Source-Link: googleapis/googleapis@b9f6184

Source-Link: googleapis/googleapis-gen@eb888bc
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWI4ODhiYzIxNGVmYzdiZjQzYmY0NjM0YjQ3MDI1NDU2NWE2NTlhNSJ9
  • Loading branch information
gcf-owl-bot[bot] authored Nov 10, 2021
1 parent 6e2ba00 commit 775376c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"img.shields.io"
],
"silent": true,
"concurrency": 10
"concurrency": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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() {
// [START policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* The information to use for checking whether a member has a permission for a
* resource.
*/
// const accessTuple = {}

// Imports the Policytroubleshooter library
const {IamCheckerClient} = require('@google-cloud/policy-troubleshooter').v1;

// Instantiates a client
const policytroubleshooterClient = new IamCheckerClient();

async function callTroubleshootIamPolicy() {
// Construct request
const request = {};

// Run request
const response = await policytroubleshooterClient.troubleshootIamPolicy(
request
);
console.log(response);
}

callTroubleshootIamPolicy();
// [END policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_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
Expand Up @@ -283,6 +283,25 @@ export class IamCheckerClient {
// -------------------
// -- Service calls --
// -------------------
/**
* Checks whether a member has a specific permission for a specific resource,
* and explains why the member does or does not have that permission.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.cloud.policytroubleshooter.v1.AccessTuple} request.accessTuple
* The information to use for checking whether a member has a permission for a
* resource.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [TroubleshootIamPolicyResponse]{@link google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example <caption>include:samples/generated/v1/iam_checker.troubleshoot_iam_policy.js</caption>
* region_tag:policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async
*/
troubleshootIamPolicy(
request?: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest,
options?: CallOptions
Expand Down Expand Up @@ -317,25 +336,6 @@ export class IamCheckerClient {
{} | null | undefined
>
): void;
/**
* Checks whether a member has a specific permission for a specific resource,
* and explains why the member does or does not have that permission.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.cloud.policytroubleshooter.v1.AccessTuple} request.accessTuple
* The information to use for checking whether a member has a permission for a
* resource.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [TroubleshootIamPolicyResponse]{@link google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example
* const [response] = await client.troubleshootIamPolicy(request);
*/
troubleshootIamPolicy(
request?: protos.google.cloud.policytroubleshooter.v1.ITroubleshootIamPolicyRequest,
optionsOrCallback?:
Expand Down Expand Up @@ -373,6 +373,8 @@ export class IamCheckerClient {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
this.initialize();
return this.innerApiCalls.troubleshootIamPolicy(request, options, callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('v1.IamCheckerClient', () => {
const request = generateSampleMessage(
new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest()
);
const expectedOptions = {};
const expectedOptions = {otherArgs: {headers: {}}};
const expectedResponse = generateSampleMessage(
new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse()
);
Expand All @@ -164,7 +164,7 @@ describe('v1.IamCheckerClient', () => {
const request = generateSampleMessage(
new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest()
);
const expectedOptions = {};
const expectedOptions = {otherArgs: {headers: {}}};
const expectedResponse = generateSampleMessage(
new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse()
);
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('v1.IamCheckerClient', () => {
const request = generateSampleMessage(
new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest()
);
const expectedOptions = {};
const expectedOptions = {otherArgs: {headers: {}}};
const expectedError = new Error('expected');
client.innerApiCalls.troubleshootIamPolicy = stubSimpleCall(
undefined,
Expand Down

0 comments on commit 775376c

Please sign in to comment.