|
| 1 | +--- |
| 2 | +name: new-client-library-generator |
| 3 | +description: Generates new Google Cloud Java client libraries by processing service information and updating the hermetic build configuration. Use this skill when tasked with onboarding a new service or version to the google-cloud-java repository. |
| 4 | +--- |
| 5 | + |
| 6 | +# New Client Library Generator |
| 7 | + |
| 8 | +This skill automates the process of adding a new client library to the `google-cloud-java` repository using the hermetic build system. It retrieves service information from a Buganizer ticket (which links to a Service YAML file) and runs the configuration script to update `generation_config.yaml`. |
| 9 | + |
| 10 | +## Workflow |
| 11 | + |
| 12 | +### 1. Retrieve Service Information from Buganizer |
| 13 | + |
| 14 | +Use the available Buganizer MCP server to fetch the ticket content. The ticket will contain a link to a Service YAML file. Parse this YAML file to extract the fields below. |
| 15 | + |
| 16 | +> [!IMPORTANT] |
| 17 | +> Not all fields in the Service YAML file may exist. You must ensure that all **Required** fields are identified and populated before executing the generation script. |
| 18 | +
|
| 19 | +**Required:** |
| 20 | +- `api_shortname`: Unique service identifier (e.g., `alloydb`). |
| 21 | +- `name_pretty`: Human-friendly name (e.g., `AlloyDB API`). |
| 22 | +- `proto_path`: Versioned path to protos (e.g., `google/cloud/alloydb/v1`). Must include the version component — root-level paths like `google/cloud/alloydb` are not supported. |
| 23 | +- `product_docs`: Product documentation URL (must start with `https://`). |
| 24 | +- `api_description`: First sentence of the service summary. |
| 25 | + |
| 26 | +**Optional:** |
| 27 | +- `rest_docs`: REST reference documentation URL. |
| 28 | +- `rpc_docs`: RPC/proto reference documentation URL. |
| 29 | +- `library_name`: Override the default `java-<api_shortname>` directory name. |
| 30 | +- `distribution_name`: Override Maven coordinates (default: `com.google.cloud:google-cloud-<api_shortname>`). |
| 31 | + |
| 32 | +For the field-to-flag mapping, see [references/service_yaml_mapping.md](references/service_yaml_mapping.md) (Service YAML fields → script flags). |
| 33 | + |
| 34 | +### 2. Check for Conflicts |
| 35 | + |
| 36 | +Before running the script, verify `api_shortname` is not already in use: |
| 37 | + |
| 38 | +```bash |
| 39 | +grep "api_shortname: <API_SHORTNAME>" generation_config.yaml |
| 40 | +``` |
| 41 | + |
| 42 | +If a conflict exists, determine a unique name or use `--library-name` to set a distinct directory. See [references/generation_guide.md](references/generation_guide.md) for examples. |
| 43 | + |
| 44 | +### 3. Special Cases |
| 45 | + |
| 46 | +Some APIs require non-default Maven coordinates and `api_shortname` values: |
| 47 | + |
| 48 | +| Proto path prefix | `--api-shortname` | `--distribution-name` | |
| 49 | +|---------------------|------------------------------|----------------------------------------------------------| |
| 50 | +| `google/maps/*` | `maps-<api_short_name>` | `com.google.maps:google-maps-<api_short_name>` | |
| 51 | +| `google/shopping/*` | `shopping-<api_short_name>` | `com.google.shopping:google-shopping-<api_short_name>` | |
| 52 | + |
| 53 | +where `<api_short_name>` is the value from the Service YAML. |
| 54 | + |
| 55 | +### 4. Execution |
| 56 | + |
| 57 | +#### Adding a new library |
| 58 | + |
| 59 | +If the library does not exist yet, run the script with the gathered information: |
| 60 | + |
| 61 | +```bash |
| 62 | +python3 generation/new_client_hermetic_build/add-new-client-config.py add-new-library \ |
| 63 | + --api-shortname="[API_SHORTNAME]" \ |
| 64 | + --name-pretty="[NAME_PRETTY]" \ |
| 65 | + --proto-path="[PROTO_PATH]" \ |
| 66 | + --product-docs="[PRODUCT_DOCS]" \ |
| 67 | + --api-description="[API_DESCRIPTION]" \ |
| 68 | + [OPTIONAL_FLAGS] |
| 69 | +``` |
| 70 | + |
| 71 | +The script modifies `generation_config.yaml` and sorts the `libraries` list alphabetically. |
| 72 | + |
| 73 | +To see all available flags: |
| 74 | +```bash |
| 75 | +python3 generation/new_client_hermetic_build/add-new-client-config.py add-new-library --help |
| 76 | +``` |
| 77 | + |
| 78 | +#### Adding a new version to an existing library |
| 79 | + |
| 80 | +If the client library module already exists and the request is to add a new version, do NOT run the script. Instead, manually add the corresponding `proto_path` for the new version to the `GAPICs` list of the existing library entry in `generation_config.yaml`. |
| 81 | + |
| 82 | +Example entry update: |
| 83 | +```yaml |
| 84 | +- api_shortname: myapi |
| 85 | + ... |
| 86 | + GAPICs: |
| 87 | + - proto_path: google/cloud/myapi/v1 |
| 88 | + - proto_path: google/cloud/myapi/v2 # Manually added |
| 89 | +``` |
| 90 | +
|
| 91 | +### 5. Verification |
| 92 | +
|
| 93 | +After execution or manual update: |
| 94 | +1. Confirm `generation_config.yaml` has a new or updated entry with the correct fields. See [references/generation_config_schema.md](references/generation_config_schema.md). |
| 95 | +2. Confirm `proto_path` under `GAPICs` includes a version component (e.g., `v1`, `v1beta`, `v1alpha`). |
| 96 | +3. Confirm `product_documentation` starts with `https://`. |
| 97 | + |
| 98 | +### 6. Create a Branch and PR |
| 99 | + |
| 100 | +After verifying the changes: |
| 101 | + |
| 102 | +```bash |
| 103 | +git checkout -b "new-library/[API_SHORTNAME]" |
| 104 | +git add generation_config.yaml |
| 105 | +git commit -m "feat: new module for [API_SHORTNAME]" |
| 106 | +``` |
| 107 | + |
| 108 | +Then open a pull request. The Pull Request body must only contain the `add-new-library` command used. |
| 109 | + |
| 110 | +**PR Body Template:** |
| 111 | + |
| 112 | +```text |
| 113 | +Command used: |
| 114 | +
|
| 115 | +python3 generation/new_client_hermetic_build/add-new-client-config.py add-new-library \ |
| 116 | + --api-shortname="[API_SHORTNAME]" \ |
| 117 | + --name-pretty="[NAME_PRETTY]" \ |
| 118 | + --proto-path="[PROTO_PATH]" \ |
| 119 | + --product-docs="[PRODUCT_DOCS]" \ |
| 120 | + --api-description="[API_DESCRIPTION]" \ |
| 121 | + [OPTIONAL_FLAGS] |
| 122 | +``` |
| 123 | + |
| 124 | +The hermetic library generation workflow will be triggered automatically upon changes to `generation_config.yaml`. |
0 commit comments