File tree Expand file tree Collapse file tree 3 files changed +63
-2
lines changed
docs/cloud_providers/models Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -638,12 +638,26 @@ class PromoResourcesVideo(BaseResources):
638638 """The promotional video title."""
639639
640640
641+ @define
642+ class PromotionalMedia (BaseResources ):
643+ """Represent a single element of promotional media from class :class:`~cloudpub.models.aws.PromotionalResources`.""" # noqa: E501
644+
645+ title : str = field (validator = instance_of (str ), metadata = {"alias" : "Title" })
646+ """The title of the promotional media resource."""
647+
648+ description : Optional [str ] = field (
649+ validator = optional (instance_of (str )), metadata = {"alias" : "Description" }
650+ )
651+ """The description of the promotional media resource."""
652+
653+
641654@define
642655class PromotionalResources (AttrsJSONDecodeMixin ):
643656 """Represent the "PromotionalResources" section of the :class:`~cloudpub.models.aws.ProductDetailResponse`.""" # noqa: E501
644657
645- promotional_media : Optional [str ] = field (
646- validator = optional (instance_of (str )),
658+ promotional_media : Optional [List [PromotionalMedia ]] = field (
659+ converter = lambda x : [PromotionalMedia .from_json (a ) for a in x ] if x else None ,
660+ on_setattr = NO_OP ,
647661 metadata = {"alias" : "PromotionalMedia" , "hide_unset" : True },
648662 )
649663 """The product's promotional media."""
Original file line number Diff line number Diff line change @@ -122,6 +122,9 @@ Resources internal elements
122122.. autoclass:: cloudpub.models.aws.PromoResourcesVideo()
123123 :members:
124124
125+ .. autoclass:: cloudpub.models.aws.PromotionalMedia()
126+ :members:
127+
125128.. autoclass:: cloudpub.models.aws.PositiveTargeting()
126129 :members:
127130
Original file line number Diff line number Diff line change 1616 ProductVersionsBase ,
1717 ProductVersionsCloudFormationSource ,
1818 ProductVersionsVirtualizationSource ,
19+ PromotionalMedia ,
20+ PromotionalResources ,
1921 SecurityGroup ,
2022 Version ,
2123 VersionMapping ,
@@ -125,3 +127,45 @@ def test_describe_entity_response_parsed_details(
125127def test_list_changeset_response_parsed (list_changeset_response : Dict [str , Any ]) -> None :
126128 resp = ListChangeSetsResponse .from_json (list_changeset_response )
127129 assert len (resp .change_set_list ) == 1
130+
131+
132+ @pytest .mark .parametrize (
133+ "promotional_media" ,
134+ [
135+ None ,
136+ [
137+ {
138+ 'Type' : 'Image' ,
139+ 'Url' : 'https://foo.com/bar.png' ,
140+ 'Title' : 'Logo1' ,
141+ 'Description' : None ,
142+ }
143+ ],
144+ [
145+ {
146+ 'Type' : 'Image' ,
147+ 'Url' : 'https://foo.com/bar.png' ,
148+ 'Title' : 'Logo1' ,
149+ 'Description' : 'This is the logo1' ,
150+ },
151+ {
152+ 'Type' : 'Video' ,
153+ 'Url' : 'https://foo.com/video.mp4' ,
154+ 'Title' : 'Video' ,
155+ 'Description' : 'This is the promotional video' ,
156+ },
157+ ],
158+ ],
159+ )
160+ def test_promotional_resources_promotional_media (
161+ promotional_media , promotional_resource : Dict [str , Any ]
162+ ) -> None :
163+ promotional_resource ["PromotionalMedia" ] = promotional_media
164+
165+ obj = PromotionalResources .from_json (promotional_resource )
166+
167+ assert obj
168+ if not promotional_media :
169+ assert obj .promotional_media is None
170+ else :
171+ assert obj .promotional_media == [PromotionalMedia .from_json (x ) for x in promotional_media ]
You can’t perform that action at this time.
0 commit comments