Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update new client generation instructions #9931

Merged
merged 6 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions generation/new_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,19 @@ The example in this README uses AlloyDB's [Cloud Drop](https://github.com/google
### API short name

For convenience of the subsequent commands, define a variable for API short name.
This value will be used by default to generate the following:
* `--distribution-name`
* `--destination-name`

The corresponding value in the Cloud Drop page is `api_short_name`.

Example: `alloydb`

> [!IMPORTANT]
> `api_short_name` is not always unique across client libraries.
> In the instance that the `api_short_name` is already in use by an existing client library, you will need to determine a unique name.
> See example under [Advanced Options](#Example with duplicate api_short_name).

### Proto path

The script takes "proto path" parameter. This is the path from the internal `google3/third_party/googleapis/stable` root to the
Expand Down Expand Up @@ -312,6 +321,31 @@ generated Google Maps Routes API Java client library.
--requires-billing=true \
--distribution-name="com.google.maps:google-maps-routing"
```
### Example with duplicate api_short_name

Let's say you get a new library request where the Cloud Drop value for `api_short_name` is `maps-routing`.

You discover that `maps-routing` is already in use by an existing client library!

You need to determine a unique `destination_name` for the new library's subdirectory as well as a unique `distribution_name` for the artifact to be published. There is no hard and fast rule for determining a unique name, so some discussion will be necessary. Confirm the `distribution_name` with the service team on the buganizer ticket before proceeding, as this name is visible to customers as the Maven artifact name.

You will **still use** the non-unique `api_short_name` for the `api_short_name` flag. This is important because the `api_short_name` is used to derive links within cloud.google.com to enable the API.

Let's say that after some discussion, `maps-routing-gps` is selected as a suitable unique subdirectory name and `com.google.maps:google-maps-routing-gps` is selected as a suitable unique artifact name. You would then use the following command:

```
~/google-cloud-java$ python3.9 generation/new_client/new-client.py generate \
--api_shortname=maps-routing \
--proto-path=google/maps/routing \
--name-pretty="Routes API" \
--product-docs="https://developers.google.com/maps/documentation/routes" \
--api-description="Routes API is the next generation, performance optimized version of the existing Directions API and Distance Matrix API. It helps you find the ideal route from A to Z, calculates ETAs and distances for matrices of origin and destination locations, and also offers new features." \
--api-id=routes.googleapis.com \
--cloud-api=false \
--requires-billing=true \
--distribution-name="com.google.maps:google-maps-routing-gps" \
--destination-name="maps-routing-gps"
```

# Principles

Expand Down
3 changes: 0 additions & 3 deletions generation/new_client/new-client.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ def generate(
f"https://cloud.google.com/{language}/docs/reference/{distribution_name_short}/latest/overview"
)

if proto_path is None:
proto_path = f"/google/cloud/{api_shortname}"

if api_shortname == "":
sys.exit("api_shortname is empty")

Expand Down
Loading