gapic-generator-typescript
gapic-generator-typescript copied to clipboard
Generated path templates should include all valid patterns for child_type resource references
In #488, we noticed that no path template exists for projects/{project}/locations/{location}
, even though this is a valid input for the parent field on DLP API calls.
Based on https://google.aip.dev/122 and https://google.aip.dev/123, it seems like a path template should have been generated for the DLP API.
What I'd naively expect to happen, is that given the following in the DLP proto:
message InspectTemplate {
option (google.api.resource) = {
type: "dlp.googleapis.com/InspectTemplate"
pattern: "organizations/{organization}/inspectTemplates/{inspect_template}"
pattern: "projects/{project}/inspectTemplates/{inspect_template}"
pattern: "organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}"
pattern: "projects/{project}/locations/{location}/inspectTemplates/{inspect_template}"
};
message CreateInspectTemplateRequest {
// Parent resource name.
// - Format:projects/[PROJECT-ID]
// - Format:organizations/[ORGANIZATION-ID]
// - Format:projects/[PROJECT-ID]/locations/[LOCATION-ID]
// - Format:organizations/[ORGANIZATION-ID]/locations/[LOCATION-ID]
string parent = 1 [
(google.api.authz).permissions = "dlp.inspectTemplates.create",
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).child_type =
"dlp.googleapis.com/InspectTemplate",
(google.api.field_auditing).directive = "AUDIT"
];
I would end up with the following NodeJS path templates:
projectPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}'
),
projectLocationPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}'
),
organizationPathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}'
),
organizationLocationPathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/locations/{location}'
),
As far as I can tell, this conforms with the API guidance linked above, and it seems like this should result in usable path templates for all of the valid forms of parent. However, we don't see all the templates described above. (Current set of generated path templates)
As the current logic was explained to me, path templates are only generated if they are directly referenced in a resource. Since this doesn't happen (and there's no reason in the API definition that it needs to happen), no path templates are generated. The existing projectPathTemplate that does exist occurs because many of our APIs (like CreateDlpJob) annotate with (google.api.resource_reference) = { type: "cloudresourcemanager.googleapis.com/Project"
, which is the kind of direct reference that the current generation logic is looking for.
Request:
Should the client generation code create templates for all of the patterns in the message being used in a (google.api.resource_reference).child_type
annotation? (With the last segment trimmed, of course).
Or, as put by @alexander-fenster :
so long story short, you suggest that if we have a child_type, we generate helpers for all subtemplates no matter what?
any updates as we are out of slo
Not in my plan for this month, and no real complaints from users - I'll downgrade this to a feature request.