2323from awscli .topictags import TopicTagDB
2424from awscli .utils import (
2525 find_service_and_method_in_event_name , is_document_type ,
26- operation_uses_document_types , is_streaming_blob_type
26+ operation_uses_document_types , is_streaming_blob_type ,
27+ is_tagged_union_type
2728)
2829
2930LOG = logging .getLogger (__name__ )
@@ -56,6 +57,8 @@ def _get_argument_type_name(self, shape, default):
5657 return 'document'
5758 if is_streaming_blob_type (shape ):
5859 return 'streaming blob'
60+ if is_tagged_union_type (shape ):
61+ return 'tagged union structure'
5962 return default
6063
6164 def _map_handlers (self , session , event_class , mapfn ):
@@ -185,6 +188,8 @@ def doc_option(self, arg_name, help_command, **kwargs):
185188 doc .include_doc_string (argument .documentation )
186189 if is_streaming_blob_type (argument .argument_model ):
187190 self ._add_streaming_blob_note (doc )
191+ if is_tagged_union_type (argument .argument_model ):
192+ self ._add_tagged_union_note (argument .argument_model , doc )
188193 if hasattr (argument , 'argument_model' ):
189194 self ._document_enums (argument .argument_model , doc )
190195 self ._document_nested_structure (argument .argument_model , doc )
@@ -264,6 +269,8 @@ def _do_doc_member(self, doc, member_name, member_shape, stack):
264269 doc .style .indent ()
265270 doc .style .new_paragraph ()
266271 doc .include_doc_string (docs )
272+ if is_tagged_union_type (member_shape ):
273+ self ._add_tagged_union_note (member_shape , doc )
267274 doc .style .new_paragraph ()
268275 member_type_name = member_shape .type_name
269276 if member_type_name == 'structure' :
@@ -290,6 +297,16 @@ def _add_streaming_blob_note(self, doc):
290297 doc .writeln (msg )
291298 doc .style .end_note ()
292299
300+ def _add_tagged_union_note (self , shape , doc ):
301+ doc .style .start_note ()
302+ members_str = ", " .join (
303+ [f'``{ key } ``' for key in shape .members .keys ()]
304+ )
305+ msg = ("This is a Tagged Union structure. Only one of the "
306+ f"following top level keys can be set: { members_str } ." )
307+ doc .writeln (msg )
308+ doc .style .end_note ()
309+
293310
294311class ProviderDocumentEventHandler (CLIDocumentEventHandler ):
295312
0 commit comments