Skip to content

Commit c937f4a

Browse files
docs(samples): include metadata file, add exclusions for samples to handwritten libraries (#106)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 429395631 Source-Link: googleapis/googleapis@84594b3 Source-Link: googleapis/googleapis-gen@ed74f97 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWQ3NGY5NzBmZDgyOTE0ODc0ZTZiMjdiMDQ3NjNjZmE2NmJhZmU5YiJ9
1 parent ee81b06 commit c937f4a

4 files changed

Lines changed: 98 additions & 7 deletions

File tree

packages/google-cloud-policytroubleshooter/samples/generated/v1/iam_checker.troubleshoot_iam_policy.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
// Copyright 2021 Google LLC
1+
// Copyright 2022 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// https://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
1419

1520

1621
'use strict';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"clientLibrary": {
3+
"name": "nodejs-policytroubleshooter",
4+
"version": "0.1.0",
5+
"language": "TYPESCRIPT",
6+
"apis": [
7+
{
8+
"id": "google.cloud.policytroubleshooter.v1",
9+
"version": "v1"
10+
}
11+
]
12+
},
13+
"snippets": [
14+
{
15+
"regionTag": "policytroubleshooter_v1_generated_IamChecker_TroubleshootIamPolicy_async",
16+
"title": "IamChecker troubleshootIamPolicy Sample",
17+
"origin": "API_DEFINITION",
18+
"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.",
19+
"canonical": true,
20+
"file": "iam_checker.troubleshoot_iam_policy.js",
21+
"language": "JAVASCRIPT",
22+
"segments": [
23+
{
24+
"start": 25,
25+
"end": 50,
26+
"type": "FULL"
27+
}
28+
],
29+
"clientMethod": {
30+
"shortName": "TroubleshootIamPolicy",
31+
"fullName": "google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy",
32+
"async": true,
33+
"parameters": [
34+
{
35+
"name": "access_tuple",
36+
"type": ".google.cloud.policytroubleshooter.v1.AccessTuple"
37+
}
38+
],
39+
"resultType": ".google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse",
40+
"client": {
41+
"shortName": "IamCheckerClient",
42+
"fullName": "google.cloud.policytroubleshooter.v1.IamCheckerClient"
43+
},
44+
"method": {
45+
"shortName": "TroubleshootIamPolicy",
46+
"fullName": "google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy",
47+
"service": {
48+
"shortName": "IamChecker",
49+
"fullName": "google.cloud.policytroubleshooter.v1.IamChecker"
50+
}
51+
}
52+
}
53+
}
54+
]
55+
}

packages/google-cloud-policytroubleshooter/src/v1/iam_checker_client.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,8 @@ export class IamCheckerClient {
386386
* @returns {Promise} A promise that resolves when the client is closed.
387387
*/
388388
close(): Promise<void> {
389-
this.initialize();
390-
if (!this._terminated) {
391-
return this.iamCheckerStub!.then(stub => {
389+
if (this.iamCheckerStub && !this._terminated) {
390+
return this.iamCheckerStub.then(stub => {
392391
this._terminated = true;
393392
stub.close();
394393
});

packages/google-cloud-policytroubleshooter/test/gapic_iam_checker_v1.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,27 @@ describe('v1.IamCheckerClient', () => {
8888
assert(client.iamCheckerStub);
8989
});
9090

91-
it('has close method', () => {
91+
it('has close method for the initialized client', done => {
9292
const client = new iamcheckerModule.v1.IamCheckerClient({
9393
credentials: {client_email: 'bogus', private_key: 'bogus'},
9494
projectId: 'bogus',
9595
});
96-
client.close();
96+
client.initialize();
97+
assert(client.iamCheckerStub);
98+
client.close().then(() => {
99+
done();
100+
});
101+
});
102+
103+
it('has close method for the non-initialized client', done => {
104+
const client = new iamcheckerModule.v1.IamCheckerClient({
105+
credentials: {client_email: 'bogus', private_key: 'bogus'},
106+
projectId: 'bogus',
107+
});
108+
assert.strictEqual(client.iamCheckerStub, undefined);
109+
client.close().then(() => {
110+
done();
111+
});
97112
});
98113

99114
it('has getProjectId method', async () => {
@@ -219,5 +234,22 @@ describe('v1.IamCheckerClient', () => {
219234
.calledWith(request, expectedOptions, undefined)
220235
);
221236
});
237+
238+
it('invokes troubleshootIamPolicy with closed client', async () => {
239+
const client = new iamcheckerModule.v1.IamCheckerClient({
240+
credentials: {client_email: 'bogus', private_key: 'bogus'},
241+
projectId: 'bogus',
242+
});
243+
client.initialize();
244+
const request = generateSampleMessage(
245+
new protos.google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest()
246+
);
247+
const expectedError = new Error('The client has already been closed.');
248+
client.close();
249+
await assert.rejects(
250+
client.troubleshootIamPolicy(request),
251+
expectedError
252+
);
253+
});
222254
});
223255
});

0 commit comments

Comments
 (0)