Skip to content

Commit 8e75459

Browse files
committed
feat(internal/serviceconfig): import gapic yaml configs from googleapis
Add a GAPICYaml field to the API struct in sdk.yaml that holds all configuration previously stored in *_gapic.yaml files in googleapis. This includes Java-specific settings (package name, interface names) and language-neutral settings (LRO polling, batching). Java-specific fields have TODOs to move them to librarian.yaml later. An import-gapic-yaml subcommand is added to the importconfigs tool. It reads all *_gapic.yaml files from a local googleapis checkout and merges their data into existing sdk.yaml entries. APIs not already in sdk.yaml are skipped. 69 of 79 gapic yaml files were imported; 10 were skipped because their API paths are not in the allowlist. For #3041
1 parent 6066147 commit 8e75459

File tree

7 files changed

+7779
-1
lines changed

7 files changed

+7779
-1
lines changed

doc/api-allowlist-schema.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,62 @@ This document describes the schema for the API Allowlist.
2020
| `service_name` | string | Is a DNS-like logical identifier for the service, such as `calendar.googleapis.com`. |
2121
| `title` | string | Overrides the API title from the service config. |
2222
| `transports` | map[string]Transport | Defines the supported transports per language. Map key is the language name (e.g., "python", "rust"). Optional. If omitted, all languages use GRPCRest by default. |
23+
| `gapic_yaml` | [GAPICYamlConfig](#gapicyamlconfig-configuration) (optional) | Contains configuration imported from *_gapic.yaml files in googleapis. |
24+
25+
## GAPICBatchDescriptor Configuration
26+
27+
| Field | Type | Description |
28+
| :--- | :--- | :--- |
29+
| `batched_field` | string | |
30+
| `discriminator_fields` | list of string | |
31+
| `subresponse_field` | string | |
32+
33+
## GAPICBatching Configuration
34+
35+
| Field | Type | Description |
36+
| :--- | :--- | :--- |
37+
| `thresholds` | [GAPICBatchingThresholds](#gapicbatchingthresholds-configuration) (optional) | |
38+
| `batch_descriptor` | [GAPICBatchDescriptor](#gapicbatchdescriptor-configuration) (optional) | |
39+
40+
## GAPICBatchingThresholds Configuration
41+
42+
| Field | Type | Description |
43+
| :--- | :--- | :--- |
44+
| `element_count_threshold` | int | |
45+
| `request_byte_threshold` | int | |
46+
| `delay_threshold_millis` | int | |
47+
| `flow_control_element_limit` | int | |
48+
| `flow_control_byte_limit` | int | |
49+
| `flow_control_limit_exceeded_behavior` | string | |
50+
51+
## GAPICInterface Configuration
52+
53+
| Field | Type | Description |
54+
| :--- | :--- | :--- |
55+
| `name` | string | |
56+
| `methods` | list of [GAPICMethod](#gapicmethod-configuration) | |
57+
58+
## GAPICLongRunning Configuration
59+
60+
| Field | Type | Description |
61+
| :--- | :--- | :--- |
62+
| `initial_poll_delay_millis` | int64 | |
63+
| `poll_delay_multiplier` | float64 | |
64+
| `max_poll_delay_millis` | int64 | |
65+
| `total_poll_timeout_millis` | int64 | |
66+
67+
## GAPICMethod Configuration
68+
69+
| Field | Type | Description |
70+
| :--- | :--- | :--- |
71+
| `name` | string | |
72+
| `long_running` | [GAPICLongRunning](#gapiclongrunning-configuration) (optional) | |
73+
| `batching` | [GAPICBatching](#gapicbatching-configuration) (optional) | |
74+
75+
## GAPICYamlConfig Configuration
76+
77+
| Field | Type | Description |
78+
| :--- | :--- | :--- |
79+
| `java_package_name` | string | Is the Java package name. TODO(https://github.com/googleapis/librarian/issues/3041): move to librarian.yaml. |
80+
| `java_interface_names` | map[string]string | Maps fully-qualified interface names to short Java class names. TODO(https://github.com/googleapis/librarian/issues/3041): move to librarian.yaml. |
81+
| `interfaces` | list of [GAPICInterface](#gapicinterface-configuration) | Contains language-neutral per-interface, per-method configuration including long-running operation polling settings and batching config. |

internal/serviceconfig/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ type API struct {
115115
// Map key is the language name (e.g., "python", "rust").
116116
// Optional. If omitted, all languages use GRPCRest by default.
117117
Transports map[string]Transport `yaml:"transports,omitempty"`
118+
119+
// GAPICYaml contains configuration imported from *_gapic.yaml files in
120+
// googleapis.
121+
GAPICYaml *GAPICYamlConfig `yaml:"gapic_yaml,omitempty"`
118122
}
119123

120124
// Transport gets transport for a given language.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright 2026 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+
// https://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+
package serviceconfig
16+
17+
// GAPICYamlConfig contains all configuration imported from a *_gapic.yaml
18+
// file. This groups Java-specific and language-neutral settings so they can
19+
// be written together to a single file during generation.
20+
type GAPICYamlConfig struct {
21+
// JavaPackageName is the Java package name.
22+
// TODO(https://github.com/googleapis/librarian/issues/3041): move to librarian.yaml.
23+
JavaPackageName string `yaml:"java_package_name,omitempty"`
24+
25+
// JavaInterfaceNames maps fully-qualified interface names to short
26+
// Java class names.
27+
// TODO(https://github.com/googleapis/librarian/issues/3041): move to librarian.yaml.
28+
JavaInterfaceNames map[string]string `yaml:"java_interface_names,omitempty"`
29+
30+
// Interfaces contains language-neutral per-interface, per-method
31+
// configuration including long-running operation polling settings and
32+
// batching config.
33+
Interfaces []GAPICInterface `yaml:"interfaces,omitempty"`
34+
}
35+
36+
// GAPICInterface represents a service interface with method-level config
37+
// imported from *_gapic.yaml files in googleapis.
38+
type GAPICInterface struct {
39+
Name string `yaml:"name"`
40+
Methods []GAPICMethod `yaml:"methods,omitempty"`
41+
}
42+
43+
// GAPICMethod represents method-level configuration from a gapic yaml file.
44+
type GAPICMethod struct {
45+
Name string `yaml:"name"`
46+
LongRunning *GAPICLongRunning `yaml:"long_running,omitempty"`
47+
Batching *GAPICBatching `yaml:"batching,omitempty"`
48+
}
49+
50+
// GAPICLongRunning contains polling configuration for long-running operations.
51+
type GAPICLongRunning struct {
52+
InitialPollDelayMillis int64 `yaml:"initial_poll_delay_millis,omitempty"`
53+
PollDelayMultiplier float64 `yaml:"poll_delay_multiplier,omitempty"`
54+
MaxPollDelayMillis int64 `yaml:"max_poll_delay_millis,omitempty"`
55+
TotalPollTimeoutMillis int64 `yaml:"total_poll_timeout_millis,omitempty"`
56+
}
57+
58+
// GAPICBatching contains request batching configuration.
59+
type GAPICBatching struct {
60+
Thresholds *GAPICBatchingThresholds `yaml:"thresholds,omitempty"`
61+
BatchDescriptor *GAPICBatchDescriptor `yaml:"batch_descriptor,omitempty"`
62+
}
63+
64+
// GAPICBatchingThresholds defines when batching should occur.
65+
type GAPICBatchingThresholds struct {
66+
ElementCountThreshold int `yaml:"element_count_threshold,omitempty"`
67+
RequestByteThreshold int `yaml:"request_byte_threshold,omitempty"`
68+
DelayThresholdMillis int `yaml:"delay_threshold_millis,omitempty"`
69+
FlowControlElementLimit int `yaml:"flow_control_element_limit,omitempty"`
70+
FlowControlByteLimit int `yaml:"flow_control_byte_limit,omitempty"`
71+
FlowControlLimitExceededBehavior string `yaml:"flow_control_limit_exceeded_behavior,omitempty"`
72+
}
73+
74+
// GAPICBatchDescriptor describes how requests should be batched together.
75+
type GAPICBatchDescriptor struct {
76+
BatchedField string `yaml:"batched_field,omitempty"`
77+
DiscriminatorFields []string `yaml:"discriminator_fields,omitempty"`
78+
SubresponseField string `yaml:"subresponse_field,omitempty"`
79+
}

0 commit comments

Comments
 (0)