@@ -2,9 +2,9 @@ from __future__ import annotations
2
2
from typing import Optional, Dict, Any, List, Literal
3
3
from pydantic import Field
4
4
from datetime import date
5
- from pyatlan.model.core import AtlanObject, Classification
5
+ from pyatlan.model.core import AtlanObject, Classification, Announcement
6
6
from pyatlan.model.enums import CertificateStatus, EntityStatus, google_datastudio_asset_type, powerbi_endorsement, \
7
- icon_type
7
+ icon_type, AnnouncementType
8
8
9
9
class Internal(AtlanObject):
10
10
"""For internal usage"""
@@ -35,7 +35,7 @@ class {{ entity_def.name }}({{super_classes[0]}}):
35
35
{% - set type = attribute_def .typeName | get_type %}
36
36
{{attribute_def.name | to_snake_case }}: {% if attribute_def .isOptional %} Optional[{% endif %} {{type}}{% if attribute_def .isOptional %} ]{% endif %} = Field(None, description='', alias='{{attribute_def.name}}') # relationship
37
37
{% - endfor %}
38
- attributes: Optional[ '{{entity_def.name}}.Attributes'] = Field(
38
+ attributes: '{{entity_def.name}}.Attributes' = Field(
39
39
None,
40
40
description='Map of attributes in the instance and their values. The specific keys of this map will vary '
41
41
'by type, so are described in the sub-types of this schema.\n',
@@ -135,11 +135,41 @@ class {{ entity_def.name }}({{super_classes[0]}}):
135
135
{% - set type = attribute_def .typeName | get_type %}
136
136
{{attribute_def.name | to_snake_case }}: {% if attribute_def .isOptional %} Optional[{% endif %} {{type}}{% if attribute_def .isOptional %} ]{% endif %} = Field(None, description='', alias='{{attribute_def.name}}') # relationship
137
137
{% - endfor %}
138
- attributes: Optional[ '{{entity_def.name}}.Attributes'] = Field(
138
+ attributes: '{{entity_def.name}}.Attributes' = Field(
139
139
None,
140
140
description='Map of attributes in the instance and their values. The specific keys of this map will vary by '
141
141
'type, so are described in the sub-types of this schema.\n',
142
142
)
143
+ {% if entity_def .name == "Asset" %}
144
+ def has_announcement(self) -> bool:
145
+ if self.attributes and (
146
+ self.attributes.announcement_title or self.attributes.announcement_type
147
+ ):
148
+ return True
149
+ else:
150
+ return False
151
+
152
+ def set_announcement(self, announcement: Announcement) -> None:
153
+ self.attributes.announcement_type = announcement.announcement_type.value
154
+ self.attributes.announcement_title = announcement.announcement_title
155
+ self.attributes.announcement_message = announcement.announcement_message
156
+
157
+ def get_announcment(self) -> Optional[Announcement]:
158
+ if self.attributes.announcement_type and self.attributes.announcement_title:
159
+ return Announcement(
160
+ announcement_type=AnnouncementType[
161
+ self.attributes.announcement_type.upper()
162
+ ],
163
+ announcement_title=self.attributes.announcement_title,
164
+ announcement_message=self.attributes.announcement_message,
165
+ )
166
+ return None
167
+
168
+ def clear_announcment(self):
169
+ self.attributes.announcement_message = None
170
+ self.attributes.announcement_title = None
171
+ self.attributes.announcement_type = None
172
+ {% endif %}
143
173
{% endif %}
144
174
{% - endif %}
145
175
{% endfor %}
0 commit comments