@@ -2240,46 +2240,6 @@ def oauth_scopes(self) -> Sequence[str]:
22402240 for i in self .options .Extensions [client_pb2 .oauth_scopes ].split ("," )
22412241 if i
22422242 )
2243-
2244- @utils .cached_property
2245- def deterministic_resource_messages (self ) -> Sequence [MessageType ]:
2246- """Returns a sorted sequence of resource messages to guarantee deterministic output order."""
2247- return tuple (
2248- sorted (
2249- self .resource_messages ,
2250- key = lambda r : r .resource_type_full_path or r .name
2251- )
2252- )
2253-
2254- @utils .cached_property
2255- def resource_path_method_names (self ) -> Dict [str , str ]:
2256- """Returns a mapping of resource_type_full_path to its disambiguated Python method base name."""
2257- import collections
2258- from gapic import utils
2259-
2260- type_counts = collections .Counter (
2261- r .resource_type for r in self .resource_messages_dict .values () if r .resource_type
2262- )
2263-
2264- method_names = {}
2265- for full_path , resource in self .resource_messages_dict .items ():
2266- if not resource .resource_type :
2267- continue
2268-
2269- base_name = utils .to_snake_case (resource .resource_type )
2270-
2271- # Collision detection
2272- if type_counts [resource .resource_type ] > 1 :
2273- domain = full_path .split ("." )[0 ]
2274-
2275- # THE MAGIC FIX: Only prefix if the resource belongs to a foreign API
2276- if domain != self .shortname :
2277- domain_prefix = domain .replace ("-" , "_" )
2278- base_name = f"{ domain_prefix } _{ base_name } "
2279-
2280- method_names [full_path ] = base_name
2281-
2282- return method_names
22832243
22842244 @property
22852245 def module_name (self ) -> str :
@@ -2318,13 +2278,14 @@ def names(self) -> FrozenSet[str]:
23182278 return frozenset (answer )
23192279
23202280 @utils .cached_property
2321- def resource_messages (self ) -> Sequence [MessageType ]:
2281+ def resource_messages (self ) -> FrozenSet [MessageType ]:
23222282 """Returns all the resource message types used in all
2323- request and response fields in the service in a deterministic order ."""
2283+ request and response fields in the service."""
23242284
23252285 def gen_resources (message ):
23262286 if message .resource_path :
23272287 yield message
2288+
23282289 for type_ in message .recursive_field_types :
23292290 if type_ .resource_path :
23302291 yield type_
@@ -2333,12 +2294,14 @@ def gen_indirect_resources_used(message):
23332294 for field in message .recursive_resource_fields :
23342295 resource = field .options .Extensions [resource_pb2 .resource_reference ]
23352296 resource_type = resource .type or resource .child_type
2297+ # The resource may not be visible if the resource type is one of
2298+ # the common_resources (see the class var in class definition)
2299+ # or if it's something unhelpful like '*'.
23362300 resource = self .visible_resources .get (resource_type )
23372301 if resource :
23382302 yield resource
23392303
2340- # Collect all resources into an unordered set to remove duplicates
2341- unsorted_resources = set (
2304+ return frozenset (
23422305 msg
23432306 for method in self .methods .values ()
23442307 for msg in chain (
@@ -2352,14 +2315,6 @@ def gen_indirect_resources_used(message):
23522315 ),
23532316 )
23542317 )
2355-
2356- # Return them deterministically sorted by their full path
2357- return tuple (
2358- sorted (
2359- unsorted_resources ,
2360- key = lambda r : r .resource_type_full_path or r .name
2361- )
2362- )
23632318
23642319 @utils .cached_property
23652320 def resource_messages_dict (self ) -> Dict [str , MessageType ]:
0 commit comments