Skip to content

Commit

Permalink
chore!: promote Monitoring to v2 (#7892)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Jan 11, 2025
1 parent d007922 commit 769c703
Show file tree
Hide file tree
Showing 275 changed files with 1,190 additions and 14,376 deletions.
99 changes: 21 additions & 78 deletions Monitoring/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,84 +30,27 @@
# Added so that we can pass copy_excludes in the owlbot_main() call
_tracked_paths.add(src)

php.owlbot_main(
src=src,
dest=dest,
copy_excludes=[
src / "*/src/V3/AlertPolicyServiceClient.php",
src / "*/src/V3/GroupServiceClient.php",
src / "*/src/V3/NotificationChannelServiceClient.php",
src / "*/src/V3/ServiceMonitoringServiceClient.php",
src / "*/src/V3/UptimeCheckServiceClient.php",
]
)
php.owlbot_main(src=src, dest=dest)


# V3 is GA, so remove @experimental tags
# remove class_alias code
s.replace(
'src/V3/**/*Client.php',
r'^(\s+\*\n)?\s+\*\s@experimental\n',
"src/V*/**/*.php",
r"^// Adding a class alias for backwards compatibility with the previous class name.$"
+ "\n"
+ r"^class_alias\(.*\);$"
+ "\n",
'')

for client in ['AlertPolicyService', 'NotificationChannelService']:
s.replace(
f'**/Gapic/{client}GapicClient.php',
r'Copyright \d{4}',
'Copyright 2018')
s.replace(
f'**/V3/{client}Client.php',
r'Copyright \d{4}',
'Copyright 2018')

s.replace(
'tests/**/V3/*Test.php',
r'Copyright \d{4}',
'Copyright 2018')

# Fix class references in gapic samples
for version in ['V3']:
pathExpr = 'src/' + version + '/Gapic/*GapicClient.php'

types = {
'= new Alert': r'= new Google\\Cloud\\Monitoring\\'+ version + r'\\Alert',
'= new Group': r'= new Google\\Cloud\\Monitoring\\'+ version + r'\\Group',
'= new Metric': r'= new Google\\Cloud\\Monitoring\\'+ version + r'\\Metric',
'= new TimeInterval': r'= new Google\\Cloud\\Monitoring\\'+ version + r'\\TimeInterval',
'= TimeSeriesView::': r'= Google\\Cloud\\Monitoring\\'+ version + r'\\ListTimeSeriesRequest\\TimeSeriesView::',
'= new Notification': r'= new Google\\Cloud\\Monitoring\\'+ version + r'\\Notification',
'= new UptimeCheck': r'= new Google\\Cloud\\Monitoring\\'+ version + r'\\UptimeCheck',

}

for search, replace in types.items():
s.replace(
pathExpr,
search,
replace
)

### [START] protoc backwards compatibility fixes

# roll back to private properties.
s.replace(
"src/**/V*/**/*.php",
r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$",
r"""Generated from protobuf field \1
*/
private $""")

# Replace "Unwrapped" with "Value" for method names.
s.replace(
"src/**/V*/**/*.php",
r"public function ([s|g]\w{3,})Unwrapped",
r"public function \1Value"
)

### [END] protoc backwards compatibility fixes

# fix relative cloud.google.com links
s.replace(
"src/**/V*/**/*.php",
r"(.{0,})\]\((/.{0,})\)",
r"\1](https://cloud.google.com\2)"
)
# format generated clients
subprocess.run([
'npm',
'exec',
'--yes',
'--package=@prettier/plugin-php@^0.16',
'--',
'prettier',
'**/Client/*',
'--write',
'--parser=php',
'--single-quote',
'--print-width=120'])
6 changes: 3 additions & 3 deletions Monitoring/src/V3/Aggregation.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Monitoring/src/V3/Aggregation/Aligner.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Monitoring/src/V3/Aggregation/Reducer.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions Monitoring/src/V3/Aggregation_Aligner.php

This file was deleted.

16 changes: 0 additions & 16 deletions Monitoring/src/V3/Aggregation_Reducer.php

This file was deleted.

24 changes: 12 additions & 12 deletions Monitoring/src/V3/AlertPolicy.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Monitoring/src/V3/AlertPolicy/AlertStrategy.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Monitoring/src/V3/AlertPolicy/Condition.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 769c703

Please sign in to comment.