Skip to content

Commit cea1a05

Browse files
authored
Merge branch 'main' into rebeccaellis-write-user-event
2 parents 1ff19ba + d3a3e3c commit cea1a05

14 files changed

+838
-3
lines changed

retail/interactive-tutorials/test/search-with-pagination.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ describe('Search with pagination', () => {
3838
assert.match(stdout, /Search start/);
3939
});
4040

41-
it('should contain next page token', () => {
41+
// TODO(#4136): Re-enable this test. See https://github.com/GoogleCloudPlatform/nodejs-docs-samples/issues/4136
42+
it.skip('should contain next page token', () => {
4243
assert.match(stdout, /Next page token/);
4344
});
4445

retail/interactive-tutorials/test/search-with-query-expansion-spec.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ describe('Search with query expansion spec', () => {
9797
}
9898
});
9999

100-
it('should contain expanded query', () => {
100+
// TODO(#4136): Re-enable this test. See https://github.com/GoogleCloudPlatform/nodejs-docs-samples/issues/4136
101+
it.skip('should contain expanded query', () => {
101102
const searchResponse = response[IResponseParams.ISearchResponse];
102103
expect(
103104
searchResponse.queryExpansionInfo,

secret-manager/bindTagsToSecret.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2025 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+
// https://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+
async function main(projectId, secretId, tagValue) {
18+
// [START secretmanager_bind_tags_to_secret]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const projectId = 'my-project';
23+
// const secretId = 'my-secret';
24+
// const tagValue = 'tagValues/281476592621530';
25+
const parent = `projects/${projectId}`;
26+
27+
// Imports the library
28+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
29+
const {TagBindingsClient} = require('@google-cloud/resource-manager').v3;
30+
31+
// Instantiates a client
32+
const client = new SecretManagerServiceClient();
33+
const resourcemanagerClient = new TagBindingsClient();
34+
35+
async function bindTagsToSecret() {
36+
const [secret] = await client.createSecret({
37+
parent: parent,
38+
secretId: secretId,
39+
secret: {
40+
replication: {
41+
automatic: {},
42+
},
43+
},
44+
});
45+
46+
console.log(`Created secret ${secret.name}`);
47+
48+
const [operation] = await resourcemanagerClient.createTagBinding({
49+
tagBinding: {
50+
parent: `//secretmanager.googleapis.com/${secret.name}`,
51+
tagValue: tagValue,
52+
},
53+
});
54+
const [response] = await operation.promise();
55+
console.log('Created Tag Binding', response.name);
56+
}
57+
58+
bindTagsToSecret();
59+
// [END secretmanager_bind_tags_to_secret]
60+
}
61+
62+
const args = process.argv.slice(2);
63+
main(...args).catch(console.error);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2025 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+
// https://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+
async function main(parent, secretId, timeToLive) {
18+
// [START secretmanager_create_secret_with_delayed_destroy]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const parent = 'projects/my-project';
23+
// const secretId = 'my-secret';
24+
// const timeToLive = 86400;
25+
26+
// Imports the Secret Manager library
27+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
28+
29+
// Instantiates a client
30+
const client = new SecretManagerServiceClient();
31+
32+
async function createSecretWithDelayedDestroy() {
33+
const [secret] = await client.createSecret({
34+
parent: parent,
35+
secretId: secretId,
36+
secret: {
37+
replication: {
38+
automatic: {},
39+
},
40+
version_destroy_ttl: {
41+
seconds: timeToLive,
42+
},
43+
},
44+
});
45+
46+
console.log(`Created secret ${secret.name}`);
47+
}
48+
49+
createSecretWithDelayedDestroy();
50+
// [END secretmanager_create_secret_with_delayed_destroy]
51+
}
52+
53+
const args = process.argv.slice(2);
54+
main(...args).catch(console.error);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2025 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+
// https://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+
async function main(projectId, secretId, tagKey, tagValue) {
18+
// [START secretmanager_create_secret_with_tags]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const projectId = 'my-project';
23+
// const secretId = 'my-secret';
24+
// const tagKey = 'tagKeys/281475012216835';
25+
// const tagValue = 'tagValues/281476592621530';
26+
const parent = `projects/${projectId}`;
27+
28+
// Imports the library
29+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
30+
31+
// Instantiates a client
32+
const client = new SecretManagerServiceClient();
33+
34+
async function createSecretWithTags() {
35+
const [secret] = await client.createSecret({
36+
parent: parent,
37+
secretId: secretId,
38+
secret: {
39+
replication: {
40+
automatic: {},
41+
},
42+
tags: {
43+
[tagKey]: tagValue,
44+
},
45+
},
46+
});
47+
48+
console.log(`Created secret ${secret.name}`);
49+
}
50+
51+
createSecretWithTags();
52+
// [END secretmanager_create_secret_with_tags]
53+
}
54+
55+
const args = process.argv.slice(2);
56+
main(...args).catch(console.error);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2025 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+
// https://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+
async function main(name = 'projects/my-project/secrets/my-secret') {
18+
// [START secretmanager_disable_secret_delayed_destroy]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const name = 'projects/my-project/secrets/my-secret';
23+
24+
// Imports the Secret Manager library
25+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
26+
27+
// Instantiates a client
28+
const client = new SecretManagerServiceClient();
29+
30+
async function disableSecretDelayedDestroy() {
31+
const [secret] = await client.updateSecret({
32+
secret: {
33+
name: name,
34+
},
35+
updateMask: {
36+
paths: ['version_destroy_ttl'],
37+
},
38+
});
39+
40+
console.info(`Disabled delayed destroy ${secret.name}`);
41+
}
42+
43+
disableSecretDelayedDestroy();
44+
// [END secretmanager_disable_secret_delayed_destroy]
45+
}
46+
47+
const args = process.argv.slice(2);
48+
main(...args).catch(console.error);

secret-manager/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"test": "c8 mocha -p -j 2 --recursive test/ --timeout=800000"
1515
},
1616
"dependencies": {
17-
"@google-cloud/secret-manager": "^5.6.0"
17+
"@google-cloud/secret-manager": "^6.1.0",
18+
"@google-cloud/resource-manager": "^6.2.0"
1819
},
1920
"devDependencies": {
2021
"c8": "^10.0.0",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright 2025 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+
// https://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+
async function main(projectId, locationId, secretId, tagValue) {
18+
// [START secretmanager_bind_tags_to_regional_secret]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const projectId = 'my-project';
23+
// const locationId = 'my-location';
24+
// const secretId = 'my-secret';
25+
// const tagValue = 'tagValues/281476592621530';
26+
const parent = `projects/${projectId}/locations/${locationId}`;
27+
28+
// Imports the library
29+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
30+
const {TagBindingsClient} = require('@google-cloud/resource-manager').v3;
31+
32+
// Adding the endpoint to call the regional
33+
const options = {};
34+
const bindingOptions = {};
35+
options.apiEndpoint = `secretmanager.${locationId}.rep.googleapis.com`;
36+
bindingOptions.apiEndpoint = `${locationId}-cloudresourcemanager.googleapis.com`;
37+
38+
// Instantiates a client
39+
const client = new SecretManagerServiceClient(options);
40+
const resourcemanagerClient = new TagBindingsClient(bindingOptions);
41+
42+
async function bindTagsToRegionalSecret() {
43+
const [secret] = await client.createSecret({
44+
parent: parent,
45+
secretId: secretId,
46+
});
47+
48+
console.log(`Created secret ${secret.name}`);
49+
50+
const [operation] = await resourcemanagerClient.createTagBinding({
51+
tagBinding: {
52+
parent: `//secretmanager.googleapis.com/${secret.name}`,
53+
tagValue: tagValue,
54+
},
55+
});
56+
const [response] = await operation.promise();
57+
console.log('Created Tag Binding', response.name);
58+
}
59+
60+
bindTagsToRegionalSecret();
61+
// [END secretmanager_bind_tags_to_regional_secret]
62+
}
63+
64+
const args = process.argv.slice(2);
65+
main(...args).catch(console.error);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2025 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+
// https://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+
async function main(projectId, locationId, secretId, timeToLive) {
18+
// [START secretmanager_create_regional_secret_with_delayed_destroy]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const project = 'my-project';
23+
// const locationId = 'my-location';
24+
// const secretId = 'my-secret';
25+
// const timeToLive = 86400;
26+
const parent = `projects/${projectId}/locations/${locationId}`;
27+
28+
// Imports the Secret Manager library
29+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
30+
31+
// Adding the endpoint to call the regional secret manager server
32+
const options = {};
33+
options.apiEndpoint = `secretmanager.${locationId}.rep.googleapis.com`;
34+
35+
// Instantiates a client
36+
const client = new SecretManagerServiceClient(options);
37+
38+
async function createRegionalSecretWithDelayedDestroy() {
39+
const [secret] = await client.createSecret({
40+
parent: parent,
41+
secretId: secretId,
42+
secret: {
43+
version_destroy_ttl: {
44+
seconds: timeToLive,
45+
},
46+
},
47+
});
48+
49+
console.log(`Created regional secret ${secret.name}`);
50+
}
51+
52+
createRegionalSecretWithDelayedDestroy();
53+
// [END secretmanager_create_regional_secret_with_delayed_destroy]
54+
}
55+
56+
const args = process.argv.slice(2);
57+
main(...args).catch(console.error);

0 commit comments

Comments
 (0)