-
Notifications
You must be signed in to change notification settings - Fork 130
Less magic pathtemplate strings #2402
Less magic pathtemplate strings #2402
Conversation
PTAL |
Couldn't we also remove I'm pretty concerned about the inconsistency of project name patterns for people using multiple APIs in Cloud. |
I agree that there would be an inconsistency of project name patterns across different Google Cloud APIs, but this change would restore consistency in
I'm generally wary of any kind of magic that happens after configgen; all guessed-at logic should be put in configgen. Removing |
Codecov Report
@@ Coverage Diff @@
## fix_compute_resource_parsing #2402 +/- ##
==================================================================
+ Coverage 86.8% 86.83% +0.02%
+ Complexity 5365 5349 -16
==================================================================
Files 459 459
Lines 21179 21088 -91
Branches 2309 2296 -13
==================================================================
- Hits 18384 18311 -73
+ Misses 1972 1961 -11
+ Partials 823 816 -7
Continue to review full report at Codecov.
|
85dcd3f
to
3980ae0
Compare
3980ae0
to
485f177
Compare
The circleCI compute-discovery-test fails because this PR would require a new version of the compute_gapic.yaml to be generated using this PR. PTAL |
Merging into a separate branch, since this would be a breaking change for the Compute client. |
Partially addresses googleapis/google-cloud-java#3604.
Don't force pathtemplate strings to start with a literal string.
The status quo, for path templates, is to magically append a literal string to templated paths that begin with a bracketed string, e.g. the path
{project}/zones/{zone}
is rendered asprojects/{project}/zones/{zone}
. I don't remember exactly why we decided to do this, though it may have been related to purity of usage of PathTemplates, where all existing Google grpc path templates start with aprojects
(or possiblyorganizations
) substring.More importantly, this PR allows us to parse a resource string returned from the server (see issue googleapis/google-cloud-java#3604), which often looks like
https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}
. The compute.v1.json Discovery API specifies that thebaseUrl
is exactlyhttps://www.googleapis.com/compute/v1/projects
. We can then take a resource string from the server, remove the givenbaseUrl
prefix, and then parse the remaining suffix{project}/zones/{zone}
into a ProjectsZoneName.See googleapis/google-cloud-java#3899 and googleapis/discovery-artifact-manager#95 for the resulting surface diffs from this generator change.