|
| 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 | +""") |
0 commit comments