Skip to content

Clarify method naming#1498

Closed
kaibolay wants to merge 2 commits intoaip-dev:masterfrom
kaibolay:patch-1
Closed

Clarify method naming#1498
kaibolay wants to merge 2 commits intoaip-dev:masterfrom
kaibolay:patch-1

Conversation

@kaibolay
Copy link
Copy Markdown

Names for resource-base and collection-based methods can be a verb only.

Names for resource-base and collection-based methods can be a verb only.
@kaibolay kaibolay requested a review from a team as a code owner March 20, 2025 19:15
@kaibolay kaibolay requested a review from noahdietz March 20, 2025 19:15
@kaibolay
Copy link
Copy Markdown
Author

The examples "/v1/{name=publishers/*/books/*}:archive" and ""/v1/{parent=publishers/*}/books:sort" both use only a verb as the method name. Only "/v1/{project=projects/*}:translateText" uses verb+noun.

@noahdietz
Copy link
Copy Markdown
Collaborator

Hi @kaibolay thanks for the proposed change.

Can I ask for the context of the proposed change? The existing guidance is by design, not a mistake needing clarification, so it would be great to understand the motivation for the change. Thanks!

@noahdietz
Copy link
Copy Markdown
Collaborator

Hi @kaibolay thanks for the proposed change.

Can I ask for the context of the proposed change? The existing guidance is by design, not a mistake needing clarification, so it would be great to understand the motivation for the change. Thanks!

Apologies, I opened this prior to your PR comment with an example, and didn't refresh before hitting send.

@noahdietz
Copy link
Copy Markdown
Collaborator

noahdietz commented Mar 20, 2025

The examples "/v1/{name=publishers/*/books/*}:archive" and ""/v1/{parent=publishers/*}/books:sort" both use only a verb as the method name. Only "/v1/{project=projects/*}:translateText" uses verb+noun.

Right, ok, so I think see where things are confusing, and totally see how we got here.

The following guidance:

The name of the method should be a verb followed by a noun.

Is referring to the rpc name in proto - method == rpc. While it might not be obvious, we define an API Method to be as follows:

An individual operation within an API. It is typically represented in Protocol Buffers by an rpc definition, and is mapped to a function in the API in most programming languages.

The examples you've mentioned are referring to the HTTP "custom method suffix" that AIP-136 standardized for differentiating a custom method from a standard method on the same Resource path. This is covered by the following existing guidance:

  • The HTTP URI must use a : character followed by the custom verb
    (:archive in the above example), and the verb in the URI must match the
    verb in the name of the RPC.
    • If word separation is required, camelCase must be used.

and for stateless methods:

  • The URI should place both the verb and noun after the : separator
    (avoid a "faux collection key" in the URI in this case, as there is no
    collection). For example, :translateText is preferable to text:translate.

Does that clarify things?

@kaibolay
Copy link
Copy Markdown
Author

Does that clarify things?

Yes, definitely. Thanks!

@kaibolay kaibolay closed this Mar 20, 2025
@kaibolay kaibolay deleted the patch-1 branch March 20, 2025 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants