Skip to content

Commit

Permalink
docs(samples): include metadata file, add exclusions for samples to h…
Browse files Browse the repository at this point in the history
…andwritten libraries (#106)

- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 429395631

Source-Link: googleapis/googleapis@84594b3

Source-Link: googleapis/googleapis-gen@ed74f97
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWQ3NGY5NzBmZDgyOTE0ODc0ZTZiMjdiMDQ3NjNjZmE2NmJhZmU5YiJ9
  • Loading branch information
gcf-owl-bot[bot] committed Feb 18, 2022
1 parent ee81b06 commit c937f4a
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
// Copyright 2021 Google LLC
// Copyright 2022 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
// https://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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **



'use strict';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"clientLibrary": {
"name": "nodejs-policytroubleshooter",
"version": "0.1.0",
"language": "TYPESCRIPT",
"apis": [
{
"id": "google.cloud.policytroubleshooter.v1",
"version": "v1"
}
]
},
"snippets": [
{
"regionTag": "policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async",
"title": "IamChecker troubleshootIamPolicy Sample",
"origin": "API_DEFINITION",
"description": " Checks whether a member has a specific permission for a specific resource, and explains why the member does or does not have that permission.",
"canonical": true,
"file": "iam_checker.troubleshoot_iam_policy.js",
"language": "JAVASCRIPT",
"segments": [
{
"start": 25,
"end": 50,
"type": "FULL"
}
],
"clientMethod": {
"shortName": "TroubleshootIamPolicy",
"fullName": "google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy",
"async": true,
"parameters": [
{
"name": "access_tuple",
"type": ".google.cloud.policytroubleshooter.v1.AccessTuple"
}
],
"resultType": ".google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse",
"client": {
"shortName": "IamCheckerClient",
"fullName": "google.cloud.policytroubleshooter.v1.IamCheckerClient"
},
"method": {
"shortName": "TroubleshootIamPolicy",
"fullName": "google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy",
"service": {
"shortName": "IamChecker",
"fullName": "google.cloud.policytroubleshooter.v1.IamChecker"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,8 @@ export class IamCheckerClient {
* @returns {Promise} A promise that resolves when the client is closed.
*/
close(): Promise<void> {
this.initialize();
if (!this._terminated) {
return this.iamCheckerStub!.then(stub => {
if (this.iamCheckerStub && !this._terminated) {
return this.iamCheckerStub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,27 @@ describe('v1.IamCheckerClient', () => {
assert(client.iamCheckerStub);
});

it('has close method', () => {
it('has close method for the initialized client', done => {
const client = new iamcheckerModule.v1.IamCheckerClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.close();
client.initialize();
assert(client.iamCheckerStub);
client.close().then(() => {
done();
});
});

it('has close method for the non-initialized client', done => {
const client = new iamcheckerModule.v1.IamCheckerClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
assert.strictEqual(client.iamCheckerStub, undefined);
client.close().then(() => {
done();
});
});

it('has getProjectId method', async () => {
Expand Down Expand Up @@ -219,5 +234,22 @@ describe('v1.IamCheckerClient', () => {
.calledWith(request, expectedOptions, undefined)
);
});

it('invokes troubleshootIamPolicy with closed client', async () => {
const client = new iamcheckerModule.v1.IamCheckerClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(
new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest()
);
const expectedError = new Error('The client has already been closed.');
client.close();
await assert.rejects(
client.troubleshootIamPolicy(request),
expectedError
);
});
});
});

0 comments on commit c937f4a

Please sign in to comment.