Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 4ecf34d

Browse files
committed
Create an internal method for both client_output and client_output_async
1 parent f7f35b1 commit 4ecf34d

1 file changed

Lines changed: 8 additions & 58 deletions

File tree

gapic/schema/wrappers.py

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -538,63 +538,13 @@ def __getattr__(self, name):
538538

539539
@utils.cached_property
540540
def client_output(self):
541-
"""Return the output from the client layer.
542-
543-
This takes into account transformations made by the outer GAPIC
544-
client to transform the output from the transport.
545-
546-
Returns:
547-
Union[~.MessageType, ~.PythonType]:
548-
A description of the return type.
549-
"""
550-
# Void messages ultimately return None.
551-
if self.void:
552-
return PrimitiveType.build(None)
553-
554-
# If this method is an LRO, return a PythonType instance representing
555-
# that.
556-
if self.lro:
557-
return PythonType(meta=metadata.Metadata(
558-
address=metadata.Address(
559-
name='Operation',
560-
module='operation',
561-
package=('google', 'api_core'),
562-
collisions=self.lro.response_type.ident.collisions,
563-
),
564-
documentation=utils.doc(
565-
'An object representing a long-running operation. \n\n'
566-
'The result type for the operation will be '
567-
':class:`{ident}`: {doc}'.format(
568-
doc=self.lro.response_type.meta.doc,
569-
ident=self.lro.response_type.ident.sphinx,
570-
),
571-
),
572-
))
573-
574-
# If this method is paginated, return that method's pager class.
575-
if self.paged_result_field:
576-
return PythonType(meta=metadata.Metadata(
577-
address=metadata.Address(
578-
name=f'{self.name}Pager',
579-
package=self.ident.api_naming.module_namespace + (self.ident.api_naming.versioned_module_name,) + self.ident.subpackage + (
580-
'services',
581-
utils.to_snake_case(self.ident.parent[-1]),
582-
),
583-
module='pagers',
584-
collisions=self.input.ident.collisions,
585-
),
586-
documentation=utils.doc(
587-
f'{self.output.meta.doc}\n\n'
588-
'Iterating over this object will yield results and '
589-
'resolve additional pages automatically.',
590-
),
591-
))
592-
593-
# Return the usual output.
594-
return self.output
541+
return self._client_output(enable_asyncio=False)
595542

596543
@utils.cached_property
597544
def client_output_async(self):
545+
return self._client_output(enable_asyncio=True)
546+
547+
def _client_output(self, enable_asyncio: bool):
598548
"""Return the output from the client layer.
599549
600550
This takes into account transformations made by the outer GAPIC
@@ -613,8 +563,8 @@ def client_output_async(self):
613563
if self.lro:
614564
return PythonType(meta=metadata.Metadata(
615565
address=metadata.Address(
616-
name='AsyncOperation',
617-
module='operation_async',
566+
name='AsyncOperation' if enable_asyncio else 'Operation',
567+
module='operation_async' if enable_asyncio else 'operation',
618568
package=('google', 'api_core'),
619569
collisions=self.lro.response_type.ident.collisions,
620570
),
@@ -628,11 +578,11 @@ def client_output_async(self):
628578
),
629579
))
630580

631-
# # If this method is paginated, return that method's pager class.
581+
# If this method is paginated, return that method's pager class.
632582
if self.paged_result_field:
633583
return PythonType(meta=metadata.Metadata(
634584
address=metadata.Address(
635-
name=f'{self.name}AsyncPager',
585+
name=f'{self.name}AsyncPager' if enable_asyncio else f'{self.name}Pager',
636586
package=self.ident.api_naming.module_namespace + (self.ident.api_naming.versioned_module_name,) + self.ident.subpackage + (
637587
'services',
638588
utils.to_snake_case(self.ident.parent[-1]),

0 commit comments

Comments
 (0)