Skip to content

Commit

Permalink
handle undefined roles
Browse files Browse the repository at this point in the history
  • Loading branch information
vegu committed Aug 1, 2024
1 parent b9e275c commit aff5dbf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rdap/schema/normalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class ROLE(str, enum.Enum):
policy = "policy"
technical = "technical"
registrant = "registrant"
billing = "billing"
sponsor = "sponsor"


NORMALIZED_ROLES = {
Expand All @@ -64,6 +66,9 @@ class ROLE(str, enum.Enum):
}


VALID_ROLES = [str(r) for r in ROLE]


class DNSSEC(str, enum.Enum):
secure = "secure"
insecure = "insecure"
Expand Down Expand Up @@ -122,9 +127,11 @@ def normalize_roles(cls, data: Any) -> Any:
data["roles"] = roles

# drop duplicates

data["roles"] = list(set(data["roles"]))

# drop any invalid roles
data["roles"] = [role for role in data["roles"] if f"ROLE.{role}" in VALID_ROLES]

return data

def __hash__(self):
Expand Down

0 comments on commit aff5dbf

Please sign in to comment.