The client_info constructor argument is the standard argument for changing user agent headers in GAPIC clients. Adding a user_agent prefix identifying an app or tool is required for many partners who use Google APIs.
Handwritten clients should provide a similar client_info argument to the client constructor. See how this was done in BigQuery at https://github.com/googleapis/google-cloud-python/pull/7806.
Clients that need client_info:
**kwargs)user_agent argument already, but it's currently a no-op. Should mark that as deprecated. (#7878)v3beta1 is pure-autogen)I've heard requests for this feature in the Storage client, so I'd prioritize that one above the others, but we do need this feature across all clients.
My current plan:
google.cloud._http.JSONConnection base class. (#7849)USER_AGENT and _EXTRA_HEADERS class-scope constants in that class, in favor of new instance properties, user_agent / extra_headers. Replace the deprecated class-scope names with properties which emit warnings when assigned. (#7849)client_info parameter in all classes which derive from JSONConnection.client_info to the constructor of those clients which use connections based on JSONConnection, and pass it through to the connections (storage, dns, logging, resource_manager, runtimeconnection, translate).JSONConnection, add client_info to their constructors and forward it to their GAPIC clients.@tswast One thing I've noticed while deprecating the _EXTRA_HEADERS variable: you bend over backwards to allow self._EXTRA_HEADERS["foo"] = "bar". I think I'd rather avoid supporting that, and instead just allow assignment to it. WDYT?
I think I'd rather avoid supporting that, and instead just allow assignment to it. WDYT?
Seems reasonable, since we're making a new property name now. I bent over backwards because we had some tests that did key assignment and I wanted to maintain compatibility.
@tswast I just realized that since we've hoisted the logic for adding the X-Goog-API-Client header into the base class, we can avoid jamming it into the extra_headers return value, which makes allowing assignment into it simple.
@tswast I think we should leave this feature out of the firestore_v1beta1 client object: the Firestore team really doesn't want to encourage new users for that version of the API.
Thanks @tseaver ! The REST clients LGTM. A few questions on the gapic clients.
馃帀 Thanks! 馃帀
Are we following-up with a bunch of releases next (or at least for api_core)?