MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / _retrieve_discovery_doc

Function _retrieve_discovery_doc

googleapiclient/discovery.py:372–453  ·  view source on GitHub ↗

Retrieves the discovery_doc from cache or the internet. Args: url: string, the URL of the discovery document. http: httplib2.Http, An instance of httplib2.Http or something that acts like it through which HTTP requests will be made. cache_discovery: Boolean, whether or

(
    url,
    http,
    cache_discovery,
    serviceName,
    version,
    cache=None,
    developerKey=None,
    num_retries=1,
    static_discovery=True,
)

Source from the content-addressed store, hash-verified

370
371
372def _retrieve_discovery_doc(
373 url,
374 http,
375 cache_discovery,
376 serviceName,
377 version,
378 cache=None,
379 developerKey=None,
380 num_retries=1,
381 static_discovery=True,
382):
383 """Retrieves the discovery_doc from cache or the internet.
384
385 Args:
386 url: string, the URL of the discovery document.
387 http: httplib2.Http, An instance of httplib2.Http or something that acts
388 like it through which HTTP requests will be made.
389 cache_discovery: Boolean, whether or not to cache the discovery doc.
390 serviceName: string, name of the service.
391 version: string, the version of the service.
392 cache: googleapiclient.discovery_cache.base.Cache, an optional cache
393 object for the discovery documents.
394 developerKey: string, Key for controlling API usage, generated
395 from the API Console.
396 num_retries: Integer, number of times to retry discovery with
397 randomized exponential backoff in case of intermittent/connection issues.
398 static_discovery: Boolean, whether or not to use the static discovery docs
399 included in the library.
400
401 Returns:
402 A unicode string representation of the discovery document.
403 """
404 from . import discovery_cache
405
406 if cache_discovery:
407 if cache is None:
408 cache = discovery_cache.autodetect()
409 if cache:
410 content = cache.get(url)
411 if content:
412 return content
413
414 # When `static_discovery=True`, use static discovery artifacts included
415 # with the library
416 if static_discovery:
417 content = discovery_cache.get_static_doc(serviceName, version)
418 if content:
419 return content
420 else:
421 raise UnknownApiNameOrVersion(
422 "name: %s version: %s" % (serviceName, version)
423 )
424
425 actual_url = url
426 # REMOTE_ADDR is defined by the CGI spec [RFC3875] as the environment
427 # variable that contains the network address of the client sending the
428 # request. If it exists then add that to the request for the discovery
429 # document to avoid exceeding the quota on discovery requests.

Callers 1

buildFunction · 0.85

Calls 8

executeMethod · 0.95
_add_query_parameterFunction · 0.90
HttpRequestClass · 0.90
InvalidJsonErrorClass · 0.90
debugMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…