metadata
3 years ago
src
3 years ago
.OwlBot.yaml
3 years ago
.repo-metadata.json
3 years ago
CODE_OF_CONDUCT.md
3 years ago
LICENSE
3 years ago
SECURITY.md
3 years ago
VERSION
3 years ago
composer.json
3 years ago
owlbot.py
3 years ago
owlbot.py
88 lines
| 1 | # Copyright 2020 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 logging |
| 18 | from pathlib import Path |
| 19 | import subprocess |
| 20 | |
| 21 | import synthtool as s |
| 22 | from synthtool.languages import php |
| 23 | |
| 24 | logging.basicConfig(level=logging.DEBUG) |
| 25 | |
| 26 | src = Path(f"../{php.STAGING_DIR}/AnalyticsAdmin").resolve() |
| 27 | dest = Path().resolve() |
| 28 | |
| 29 | php.owlbot_main(src=src, dest=dest) |
| 30 | |
| 31 | |
| 32 | |
| 33 | # document and utilize apiEndpoint instead of serviceAddress |
| 34 | s.replace( |
| 35 | "**/Gapic/*GapicClient.php", |
| 36 | r"'serviceAddress' =>", |
| 37 | r"'apiEndpoint' =>") |
| 38 | s.replace( |
| 39 | "**/Gapic/*GapicClient.php", |
| 40 | r"@type string \$serviceAddress\n\s+\*\s+The address", |
| 41 | r"""@type string $serviceAddress |
| 42 | * **Deprecated**. This option will be removed in a future major release. Please |
| 43 | * utilize the `$apiEndpoint` option instead. |
| 44 | * @type string $apiEndpoint |
| 45 | * The address""") |
| 46 | s.replace( |
| 47 | "**/Gapic/*GapicClient.php", |
| 48 | r"\$transportConfig, and any \$serviceAddress", |
| 49 | r"$transportConfig, and any `$apiEndpoint`") |
| 50 | |
| 51 | # Change the wording for the deprecation warning. |
| 52 | s.replace( |
| 53 | 'src/*/*_*.php', |
| 54 | r'will be removed in the next major release', |
| 55 | 'will be removed in a future release') |
| 56 | |
| 57 | ### [START] protoc backwards compatibility fixes |
| 58 | |
| 59 | # roll back to private properties. |
| 60 | s.replace( |
| 61 | "src/**/V*/**/*.php", |
| 62 | r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", |
| 63 | r"""Generated from protobuf field \1 |
| 64 | */ |
| 65 | private $""") |
| 66 | |
| 67 | # prevent proto messages from being marked final |
| 68 | s.replace( |
| 69 | "src/**/V*/**/*.php", |
| 70 | r"final class", |
| 71 | r"class") |
| 72 | |
| 73 | # Replace "Unwrapped" with "Value" for method names. |
| 74 | s.replace( |
| 75 | "src/**/V*/**/*.php", |
| 76 | r"public function ([s|g]\w{3,})Unwrapped", |
| 77 | r"public function \1Value" |
| 78 | ) |
| 79 | |
| 80 | ### [END] protoc backwards compatibility fixes |
| 81 | |
| 82 | # fix relative cloud.google.com links |
| 83 | s.replace( |
| 84 | "src/**/V*/**/*.php", |
| 85 | r"(.{0,})\]\((/.{0,})\)", |
| 86 | r"\1](https://cloud.google.com\2)" |
| 87 | ) |
| 88 |