虽然 Mutate
、Search
和 SearchStream
是 Google Ads API 中最常用的方法,但还有许多其他方法可用于特定用途。所有服务及其 API 均记录在参考文档中。
Protocol Buffer RPC 到 REST 的映射
所有服务端点(无论使用 REST 还是 gRPC)最终都是使用 proto3 接口定义语言在服务软件包的 .proto 文件中定义的。
示例:ListAccessibleCustomers
例如,customer_service.proto
文件定义了一个 ListAccessibleCustomers
方法,以及标准 Mutate
。其 google.api.http
注释描述了该方法如何映射到 HTTP。它使用带有自定义动词 listAccessibleCustomers
的 HTTP GET
:
rpc ListAccessibleCustomers(ListAccessibleCustomersRequest) returns (ListAccessibleCustomersResponse) { option (google.api.http) = { get: "/v21/customers:listAccessibleCustomers" }; }
此方法会映射到 customers.listAccessibleCustomers REST 方法。
示例:CreateCustomerClient
customer_service.proto
中的另一个示例是 CreateCustomerClient
方法。其 google.api.http
注释使用自定义动词 createCustomerClient
描述了 HTTP POST
:
rpc CreateCustomerClient(CreateCustomerClientRequest) returns (CreateCustomerClientResponse) { option (google.api.http) = { post: "/v21/customers/{customer_id=*}:createCustomerClient" body: "*" }; option (google.api.method_signature) = "customer_id,customer_client"; }
这会映射到 customers.createCustomerClient REST 方法。