Skip to content

refactor(data_classes): Add base class with common code #6297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def scopes(self) -> list[str]:
return self.get("scopes") or []


class ClaimsOverrideDetails(DictWrapper):
class ClaimsOverrideBase(DictWrapper):
@property
def claims_to_add_or_override(self) -> dict[str, str]:
return self.get("claimsToAddOrOverride") or {}
Expand All @@ -515,6 +515,8 @@ def claims_to_suppress(self, value: list[str]):
"""A list that contains claims to be suppressed from the identity token."""
self._data["claimsToSuppress"] = value


class GroupConfigurationBase(DictWrapper):
@property
def group_configuration(self) -> GroupOverrideDetails | None:
group_override_details = self.get("groupOverrideDetails")
Expand Down Expand Up @@ -549,26 +551,11 @@ def set_group_configuration_preferred_role(self, value: str):
self["groupOverrideDetails"]["preferredRole"] = value


class TokenClaimsAndScopeOverrideDetails(DictWrapper):
@property
def claims_to_add_or_override(self) -> dict[str, str]:
return self.get("claimsToAddOrOverride") or {}

@claims_to_add_or_override.setter
def claims_to_add_or_override(self, value: dict[str, str]):
"""A map of one or more key-value pairs of claims to add or override.
For group related claims, use groupOverrideDetails instead."""
self._data["claimsToAddOrOverride"] = value

@property
def claims_to_suppress(self) -> list[str]:
return self.get("claimsToSuppress") or []
class ClaimsOverrideDetails(ClaimsOverrideBase, GroupConfigurationBase):
pass

@claims_to_suppress.setter
def claims_to_suppress(self, value: list[str]):
"""A list that contains claims to be suppressed from the identity token."""
self._data["claimsToSuppress"] = value

class TokenClaimsAndScopeOverrideDetails(ClaimsOverrideBase):
@property
def scopes_to_add(self) -> list[str]:
return self.get("scopesToAdd") or []
Expand All @@ -586,8 +573,7 @@ def scopes_to_suppress(self, value: list[str]):
self._data["scopesToSuppress"] = value


class ClaimsAndScopeOverrideDetails(DictWrapper):

class ClaimsAndScopeOverrideDetails(GroupConfigurationBase):
@property
def id_token_generation(self) -> TokenClaimsAndScopeOverrideDetails | None:
id_token_generation_details = self._data.get("idTokenGeneration")
Expand Down Expand Up @@ -632,39 +618,6 @@ def access_token_generation(self, value: dict[str, Any]):
"""
self._data["accessTokenGeneration"] = value

@property
def group_configuration(self) -> GroupOverrideDetails | None:
group_override_details = self.get("groupOverrideDetails")
return None if group_override_details is None else GroupOverrideDetails(group_override_details)

@group_configuration.setter
def group_configuration(self, value: dict[str, Any]):
"""The output object containing the current group configuration.

It includes groupsToOverride, iamRolesToOverride, and preferredRole.

The groupOverrideDetails object is replaced with the one you provide. If you provide an empty or null
object in the response, then the groups are suppressed. To leave the existing group configuration
as is, copy the value of the request's groupConfiguration object to the groupOverrideDetails object
in the response, and pass it back to the service.
"""
self._data["groupOverrideDetails"] = value

def set_group_configuration_groups_to_override(self, value: list[str]):
"""A list of the group names that are associated with the user that the identity token is issued for."""
self._data.setdefault("groupOverrideDetails", {})
self["groupOverrideDetails"]["groupsToOverride"] = value

def set_group_configuration_iam_roles_to_override(self, value: list[str]):
"""A list of the current IAM roles associated with these groups."""
self._data.setdefault("groupOverrideDetails", {})
self["groupOverrideDetails"]["iamRolesToOverride"] = value

def set_group_configuration_preferred_role(self, value: str):
"""A string indicating the preferred IAM role."""
self._data.setdefault("groupOverrideDetails", {})
self["groupOverrideDetails"]["preferredRole"] = value


class PreTokenGenerationTriggerEventResponse(DictWrapper):
@property
Expand Down
Loading