Skip to content

Commit 318d723

Browse files
committed
Added address to organizationalEntity
Signed-off-by: Paul Horton <[email protected]>
1 parent d294620 commit 318d723

21 files changed

+532
-183
lines changed

cyclonedx/model/__init__.py

Lines changed: 1 addition & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,177 +1069,6 @@ def __repr__(self) -> str:
10691069
return f'<Note id={id(self)}, locale={self.locale}>'
10701070

10711071

1072-
@serializable.serializable_class
1073-
class OrganizationalContact:
1074-
"""
1075-
This is our internal representation of the `organizationalContact` complex type that can be used in multiple places
1076-
within a CycloneDX BOM document.
1077-
1078-
.. note::
1079-
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_organizationalContact
1080-
"""
1081-
1082-
def __init__(self, *, name: Optional[str] = None, phone: Optional[str] = None, email: Optional[str] = None) -> None:
1083-
if not name and not phone and not email:
1084-
raise NoPropertiesProvidedException(
1085-
'One of name, email or phone must be supplied for an OrganizationalContact - none supplied.'
1086-
)
1087-
self.name = name
1088-
self.email = email
1089-
self.phone = phone
1090-
1091-
@property
1092-
@serializable.xml_sequence(1)
1093-
def name(self) -> Optional[str]:
1094-
"""
1095-
Get the name of the contact.
1096-
1097-
Returns:
1098-
`str` if set else `None`
1099-
"""
1100-
return self._name
1101-
1102-
@name.setter
1103-
def name(self, name: Optional[str]) -> None:
1104-
self._name = name
1105-
1106-
@property
1107-
@serializable.xml_sequence(2)
1108-
def email(self) -> Optional[str]:
1109-
"""
1110-
Get the email of the contact.
1111-
1112-
Returns:
1113-
`str` if set else `None`
1114-
"""
1115-
return self._email
1116-
1117-
@email.setter
1118-
def email(self, email: Optional[str]) -> None:
1119-
self._email = email
1120-
1121-
@property
1122-
@serializable.xml_sequence(3)
1123-
def phone(self) -> Optional[str]:
1124-
"""
1125-
Get the phone of the contact.
1126-
1127-
Returns:
1128-
`str` if set else `None`
1129-
"""
1130-
return self._phone
1131-
1132-
@phone.setter
1133-
def phone(self, phone: Optional[str]) -> None:
1134-
self._phone = phone
1135-
1136-
def __eq__(self, other: object) -> bool:
1137-
if isinstance(other, OrganizationalContact):
1138-
return hash(other) == hash(self)
1139-
return False
1140-
1141-
def __lt__(self, other: Any) -> bool:
1142-
if isinstance(other, OrganizationalContact):
1143-
return _ComparableTuple((
1144-
self.name, self.email, self.phone
1145-
)) < _ComparableTuple((
1146-
other.name, other.email, other.phone
1147-
))
1148-
return NotImplemented
1149-
1150-
def __hash__(self) -> int:
1151-
return hash((self.name, self.phone, self.email))
1152-
1153-
def __repr__(self) -> str:
1154-
return f'<OrganizationalContact name={self.name}, email={self.email}, phone={self.phone}>'
1155-
1156-
1157-
@serializable.serializable_class
1158-
class OrganizationalEntity:
1159-
"""
1160-
This is our internal representation of the `organizationalEntity` complex type that can be used in multiple places
1161-
within a CycloneDX BOM document.
1162-
1163-
.. note::
1164-
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_organizationalEntity
1165-
"""
1166-
1167-
def __init__(self, *, name: Optional[str] = None, urls: Optional[Iterable[XsUri]] = None,
1168-
contacts: Optional[Iterable[OrganizationalContact]] = None) -> None:
1169-
if not name and not urls and not contacts:
1170-
raise NoPropertiesProvidedException(
1171-
'One of name, urls or contacts must be supplied for an OrganizationalEntity - none supplied.'
1172-
)
1173-
self.name = name
1174-
self.urls = urls or [] # type:ignore[assignment]
1175-
self.contacts = contacts or [] # type:ignore[assignment]
1176-
1177-
@property
1178-
@serializable.xml_sequence(1)
1179-
def name(self) -> Optional[str]:
1180-
"""
1181-
Get the name of the organization.
1182-
1183-
Returns:
1184-
`str` if set else `None`
1185-
"""
1186-
return self._name
1187-
1188-
@name.setter
1189-
def name(self, name: Optional[str]) -> None:
1190-
self._name = name
1191-
1192-
@property
1193-
@serializable.json_name('url')
1194-
@serializable.xml_array(serializable.XmlArraySerializationType.FLAT, 'url')
1195-
@serializable.xml_sequence(2)
1196-
def urls(self) -> 'SortedSet[XsUri]':
1197-
"""
1198-
Get a list of URLs of the organization. Multiple URLs are allowed.
1199-
1200-
Returns:
1201-
Set of `XsUri`
1202-
"""
1203-
return self._urls
1204-
1205-
@urls.setter
1206-
def urls(self, urls: Iterable[XsUri]) -> None:
1207-
self._urls = SortedSet(urls)
1208-
1209-
@property
1210-
@serializable.json_name('contact')
1211-
@serializable.xml_array(serializable.XmlArraySerializationType.FLAT, 'contact')
1212-
@serializable.xml_sequence(3)
1213-
def contacts(self) -> 'SortedSet[OrganizationalContact]':
1214-
"""
1215-
Get a list of contact person at the organization. Multiple contacts are allowed.
1216-
1217-
Returns:
1218-
Set of `OrganizationalContact`
1219-
"""
1220-
return self._contacts
1221-
1222-
@contacts.setter
1223-
def contacts(self, contacts: Iterable[OrganizationalContact]) -> None:
1224-
self._contacts = SortedSet(contacts)
1225-
1226-
def __eq__(self, other: object) -> bool:
1227-
if isinstance(other, OrganizationalEntity):
1228-
return hash(other) == hash(self)
1229-
return False
1230-
1231-
def __lt__(self, other: Any) -> bool:
1232-
if isinstance(other, OrganizationalEntity):
1233-
return hash(self) < hash(other)
1234-
return NotImplemented
1235-
1236-
def __hash__(self) -> int:
1237-
return hash((self.name, tuple(self.urls), tuple(self.contacts)))
1238-
1239-
def __repr__(self) -> str:
1240-
return f'<OrganizationalEntity name={self.name}>'
1241-
1242-
12431072
@serializable.serializable_class
12441073
class Tool:
12451074
"""
@@ -1332,7 +1161,7 @@ def hashes(self, hashes: Iterable[HashType]) -> None:
13321161
@serializable.xml_sequence(5)
13331162
def external_references(self) -> 'SortedSet[ExternalReference]':
13341163
"""
1335-
External References provide a way to document systems, sites, and information that may be relevant but which
1164+
External References provides a way to document systems, sites, and information that may be relevant but which
13361165
are not included with the BOM.
13371166
13381167
Returns:

cyclonedx/model/bom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
SchemaVersion1Dot6,
3838
)
3939
from ..serialization import LicenseRepositoryHelper, UrnUuidHelper
40-
from . import ExternalReference, OrganizationalContact, OrganizationalEntity, Property, ThisTool, Tool
40+
from . import ExternalReference, Property, ThisTool, Tool
41+
from .contact import OrganizationalContact, OrganizationalEntity
4142
from .bom_ref import BomRef
4243
from .component import Component
4344
from .dependency import Dependable, Dependency

cyclonedx/model/component.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@
5050
HashAlgorithm,
5151
HashType,
5252
IdentifiableAction,
53-
OrganizationalContact,
54-
OrganizationalEntity,
5553
Property,
5654
XsUri,
5755
_HashTypeRepositorySerializationHelper,
5856
)
57+
from .contact import OrganizationalContact, OrganizationalEntity
5958
from .bom_ref import BomRef
6059
from .crypto import CryptoProperties
6160
from .dependency import Dependable

0 commit comments

Comments
 (0)