Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/api_core/gapic_v1/client_info.py: 75%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

8 statements  

1# Copyright 2017 Google LLC 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15"""Helpers for providing client information. 

16 

17Client information is used to send information about the calling client, 

18such as the library and Python version, to API services. 

19""" 

20 

21from google.api_core import client_info 

22 

23METRICS_METADATA_KEY = "x-goog-api-client" 

24 

25 

26class ClientInfo(client_info.ClientInfo): 

27 """Client information used to generate a user-agent for API calls. 

28 

29 This user-agent information is sent along with API calls to allow the 

30 receiving service to do analytics on which versions of Python and Google 

31 libraries are being used. 

32 

33 Args: 

34 python_version (str): The Python interpreter version, for example, 

35 ``'3.10.0'``. 

36 grpc_version (Optional[str]): The gRPC library version. 

37 api_core_version (str): The google-api-core library version. 

38 gapic_version (Optional[str]): The version of gapic-generated client 

39 library, if the library was generated by gapic. 

40 client_library_version (Optional[str]): The version of the client 

41 library, generally used if the client library was not generated 

42 by gapic or if additional functionality was built on top of 

43 a gapic client library. 

44 user_agent (Optional[str]): Prefix to the user agent header. This is 

45 used to supply information such as application name or partner tool. 

46 Recommended format: ``application-or-tool-ID/major.minor.version``. 

47 rest_version (Optional[str]): A string with labeled versions of the 

48 dependencies used for REST transport. 

49 protobuf_runtime_version (Optional[str]): The protobuf runtime version. 

50 """ 

51 

52 def to_grpc_metadata(self): 

53 """Returns the gRPC metadata for this client info.""" 

54 return (METRICS_METADATA_KEY, self.to_user_agent()) 

55 

56 

57DEFAULT_CLIENT_INFO = ClientInfo()