@@ -50,35 +50,28 @@ def autodetect():
50
50
exc_info = False )
51
51
return None
52
52
53
- def get_static_doc (uri ):
53
+ def get_static_doc (serviceName , version ):
54
54
"""Retrieves the discovery document from the directory defined in
55
55
DISCOVERY_DOC_STATIC_DIR corresponding to the uri provided.
56
56
57
57
Args:
58
- uri : string, The URI of the discovery document in the format
59
- https://{domain}/discovery/{discoveryVer}/apis/{api}/{apiVersion}/rest
58
+ serviceName : string, name of the service.
59
+ version: string, the version of the service.
60
60
61
61
Returns:
62
62
A string containing the contents of the JSON discovery document,
63
63
otherwise None if the JSON discovery document was not found.
64
64
"""
65
65
66
- doc_name = None
67
66
content = None
67
+ doc_name = "{}.{}.json" .format (serviceName , version )
68
68
69
- # Extract the {apiVersion} and {api} from the uri which are the 2nd and 3rd
70
- # last parts of the uri respectively.
71
- # https://www.googleapis.com/discovery/v1/apis/{api}/{apiVersion}/rest
72
- uri_parts = uri .split ('/' )
73
- if len (uri_parts ) > 3 :
74
- doc_name = "{}.{}.json" .format (uri_parts [- 3 ], uri_parts [- 2 ])
75
-
76
- try :
77
- with open (os .path .join (DISCOVERY_DOC_DIR , doc_name ), 'r' ) as f :
78
- content = f .read ()
79
- except FileNotFoundError :
80
- # File does not exist. Nothing to do here.
81
- pass
69
+ try :
70
+ with open (os .path .join (DISCOVERY_DOC_DIR , doc_name ), 'r' ) as f :
71
+ content = f .read ()
72
+ except FileNotFoundError :
73
+ # File does not exist. Nothing to do here.
74
+ pass
82
75
83
76
return content
84
77
0 commit comments