Skip to content

Commit 5e14553

Browse files
fix: (secretmanaer) readd legacy path templates (#5290)
* fix: readd legacy path templates --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent e769b8b commit 5e14553

2 files changed

Lines changed: 158 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Copyright 2024 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+
# http://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+
"""This script is used to synthesize generated parts of this library."""
16+
17+
import synthtool as s
18+
import synthtool.languages.node_mono_repo as node
19+
import pathlib
20+
21+
22+
node.owlbot_main(relative_dir="packages/google-cloud-secretmanager",
23+
staging_excludes=["README.md", "package.json"]
24+
)
25+
26+
s.replace('packages/google-cloud-secretmanager/src/v1/secret_manager_service_client.ts',
27+
r"return\sPromise\.resolve\(\);\s+}\s+}",
28+
r"""return Promise.resolve();
29+
}
30+
31+
/**
32+
* Return a fully-qualified project resource name string.
33+
*
34+
* @param {string} project
35+
* @returns {string} Resource name string.
36+
*/
37+
secretPath(project: string, secret: string) {
38+
return this.pathTemplates.secretPathTemplate.render({
39+
project: project,
40+
secret: secret,
41+
});
42+
}
43+
44+
/**
45+
* Parse the project from Secret resource.
46+
*
47+
* @param {string} secretName
48+
* A fully-qualified path representing Secret resource.
49+
* @returns {string} A string representing the project.
50+
*/
51+
matchProjectFromSecretName(secretName: string) {
52+
return this.pathTemplates.secretPathTemplate.match(secretName).project;
53+
}
54+
55+
/**
56+
* Parse the secret from Secret resource.
57+
*
58+
* @param {string} secretName
59+
* A fully-qualified path representing Secret resource.
60+
* @returns {string} A string representing the secret.
61+
*/
62+
matchSecretFromSecretName(secretName: string) {
63+
return this.pathTemplates.secretPathTemplate.match(secretName).secret;
64+
}
65+
66+
/**
67+
* Return a fully-qualified secretVersion resource name string.
68+
*
69+
* @param {string} project
70+
* @param {string} secret
71+
* @param {string} secret_version
72+
* @returns {string} Resource name string.
73+
*/
74+
secretVersionPath(project: string, secret: string, secretVersion: string) {
75+
return this.pathTemplates.secretVersionPathTemplate.render({
76+
project: project,
77+
secret: secret,
78+
secret_version: secretVersion,
79+
});
80+
}
81+
82+
/**
83+
* Parse the project from SecretVersion resource.
84+
*
85+
* @param {string} secretVersionName
86+
* A fully-qualified path representing SecretVersion resource.
87+
* @returns {string} A string representing the project.
88+
*/
89+
matchProjectFromSecretVersionName(secretVersionName: string) {
90+
return this.pathTemplates.secretVersionPathTemplate.match(secretVersionName)
91+
.project;
92+
}
93+
94+
}
95+
""")

packages/google-cloud-secretmanager/src/v1/secret_manager_service_client.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,4 +2566,67 @@ export class SecretManagerServiceClient {
25662566
}
25672567
return Promise.resolve();
25682568
}
2569+
2570+
/**
2571+
* Return a fully-qualified project resource name string.
2572+
*
2573+
* @param {string} project
2574+
* @returns {string} Resource name string.
2575+
*/
2576+
secretPath(project: string, secret: string) {
2577+
return this.pathTemplates.secretPathTemplate.render({
2578+
project: project,
2579+
secret: secret,
2580+
});
2581+
}
2582+
2583+
/**
2584+
* Parse the project from Secret resource.
2585+
*
2586+
* @param {string} secretName
2587+
* A fully-qualified path representing Secret resource.
2588+
* @returns {string} A string representing the project.
2589+
*/
2590+
matchProjectFromSecretName(secretName: string) {
2591+
return this.pathTemplates.secretPathTemplate.match(secretName).project;
2592+
}
2593+
2594+
/**
2595+
* Parse the secret from Secret resource.
2596+
*
2597+
* @param {string} secretName
2598+
* A fully-qualified path representing Secret resource.
2599+
* @returns {string} A string representing the secret.
2600+
*/
2601+
matchSecretFromSecretName(secretName: string) {
2602+
return this.pathTemplates.secretPathTemplate.match(secretName).secret;
2603+
}
2604+
2605+
/**
2606+
* Return a fully-qualified secretVersion resource name string.
2607+
*
2608+
* @param {string} project
2609+
* @param {string} secret
2610+
* @param {string} secret_version
2611+
* @returns {string} Resource name string.
2612+
*/
2613+
secretVersionPath(project: string, secret: string, secretVersion: string) {
2614+
return this.pathTemplates.secretVersionPathTemplate.render({
2615+
project: project,
2616+
secret: secret,
2617+
secret_version: secretVersion,
2618+
});
2619+
}
2620+
2621+
/**
2622+
* Parse the project from SecretVersion resource.
2623+
*
2624+
* @param {string} secretVersionName
2625+
* A fully-qualified path representing SecretVersion resource.
2626+
* @returns {string} A string representing the project.
2627+
*/
2628+
matchProjectFromSecretVersionName(secretVersionName: string) {
2629+
return this.pathTemplates.secretVersionPathTemplate.match(secretVersionName)
2630+
.project;
2631+
}
25692632
}

0 commit comments

Comments
 (0)