4343if TYPE_CHECKING :
4444 from scim2_models .messages .response_parameters import ResponseParameters
4545 from scim2_models .path import Path
46+ from scim2_models .provider import ScimProvider
47+ from scim2_models .resources .service_provider_config import ServiceProviderConfig
4648
4749
4850def _short_attr_path (urn : str ) -> str :
@@ -810,11 +812,15 @@ def _prepare_model_validate(
810812 cls ,
811813 scim_ctx : Context | None = Context .DEFAULT ,
812814 scim_policy : ScimPolicy | None = None ,
815+ scim_provider : "ScimProvider | None" = None ,
816+ scim_spc : "ServiceProviderConfig | None" = None ,
813817 ** kwargs : Any ,
814818 ) -> dict [str , Any ]:
815819 context = kwargs .setdefault ("context" , {})
816820 context .setdefault ("scim" , scim_ctx )
817821 context .setdefault ("scim_policy" , scim_policy )
822+ context .setdefault ("scim_provider" , scim_provider )
823+ context .setdefault ("scim_spc" , scim_spc )
818824 return kwargs
819825
820826 @classmethod
@@ -823,15 +829,29 @@ def model_validate(
823829 * args : Any ,
824830 scim_ctx : Context | None = Context .DEFAULT ,
825831 scim_policy : ScimPolicy | None = None ,
832+ scim_provider : "ScimProvider | None" = None ,
833+ scim_spc : "ServiceProviderConfig | None" = None ,
826834 ** kwargs : Any ,
827835 ) -> Self :
828836 """Validate SCIM payloads and generate model representation by using Pydantic :meth:`~pydantic.BaseModel.model_validate`.
829837
830838 :param scim_ctx: The SCIM :class:`~scim2_models.Context` in which the validation happens.
831839 :param scim_policy: The :class:`~scim2_models.ScimPolicy` the validation
832840 runs under. Defaults to the strict reading of the specification.
841+ :param scim_provider: The :class:`~scim2_models.ScimProvider` describing
842+ the service the payload belongs to. Defaults to the provider of the
843+ innermost open block, if any.
844+ :param scim_spc: The
845+ :class:`~scim2_models.ServiceProviderConfig` the peer publishes,
846+ which overrides the one *scim_provider* carries.
833847 """
834- validate_kwargs = cls ._prepare_model_validate (scim_ctx , scim_policy , ** kwargs )
848+ validate_kwargs = cls ._prepare_model_validate (
849+ scim_ctx ,
850+ scim_policy ,
851+ scim_provider = scim_provider ,
852+ scim_spc = scim_spc ,
853+ ** kwargs ,
854+ )
835855 return super ().model_validate (* args , ** validate_kwargs )
836856
837857 @classmethod
@@ -840,6 +860,8 @@ def model_validate_json(
840860 * args : Any ,
841861 scim_ctx : Context | None = Context .DEFAULT ,
842862 scim_policy : ScimPolicy | None = None ,
863+ scim_provider : "ScimProvider | None" = None ,
864+ scim_spc : "ServiceProviderConfig | None" = None ,
843865 ** kwargs : Any ,
844866 ) -> Self :
845867 """Validate SCIM JSON payloads and generate model representation by using Pydantic :meth:`~pydantic.BaseModel.model_validate_json`.
@@ -850,9 +872,19 @@ def model_validate_json(
850872 :param scim_ctx: The SCIM :class:`~scim2_models.Context` in which the validation happens.
851873 :param scim_policy: The :class:`~scim2_models.ScimPolicy` the validation
852874 runs under. Defaults to the strict reading of the specification.
875+ :param scim_provider: The :class:`~scim2_models.ScimProvider` describing
876+ the service the payload belongs to. Defaults to the provider of the
877+ innermost open block, if any.
878+ :param scim_spc: The
879+ :class:`~scim2_models.ServiceProviderConfig` the peer publishes,
880+ which overrides the one *scim_provider* carries.
853881 """
854882 validate_kwargs = cls ._prepare_model_validate (
855- scim_ctx , scim_policy = scim_policy , ** kwargs
883+ scim_ctx ,
884+ scim_policy = scim_policy ,
885+ scim_provider = scim_provider ,
886+ scim_spc = scim_spc ,
887+ ** kwargs ,
856888 )
857889 return super ().model_validate_json (* args , ** validate_kwargs )
858890
@@ -862,11 +894,15 @@ def _prepare_model_dump(
862894 attributes : list ["str | Path[Any]" ] | None = None ,
863895 excluded_attributes : list ["str | Path[Any]" ] | None = None ,
864896 scim_policy : ScimPolicy | None = None ,
897+ scim_provider : "ScimProvider | None" = None ,
898+ scim_spc : "ServiceProviderConfig | None" = None ,
865899 ** kwargs : Any ,
866900 ) -> dict [str , Any ]:
867901 context = kwargs .setdefault ("context" , {})
868902 context .setdefault ("scim" , scim_ctx )
869903 context .setdefault ("scim_policy" , scim_policy )
904+ context .setdefault ("scim_provider" , scim_provider )
905+ context .setdefault ("scim_spc" , scim_spc )
870906
871907 if scim_ctx :
872908 kwargs .setdefault ("exclude_none" , True )
@@ -925,6 +961,8 @@ def model_dump(
925961 attributes : list ["str | Path[Any]" ] | None = None ,
926962 excluded_attributes : list ["str | Path[Any]" ] | None = None ,
927963 scim_policy : ScimPolicy | None = None ,
964+ scim_provider : "ScimProvider | None" = None ,
965+ scim_spc : "ServiceProviderConfig | None" = None ,
928966 ** kwargs : Any ,
929967 ) -> dict [str , Any ]:
930968 """Create a model representation that can be included in SCIM messages by using Pydantic :code:`BaseModel.model_dump`.
@@ -953,6 +991,12 @@ def model_dump(
953991 :param scim_policy: The :class:`~scim2_models.ScimPolicy` the
954992 serialization runs under. Defaults to the strict reading of the
955993 specification.
994+ :param scim_provider: The :class:`~scim2_models.ScimProvider` describing
995+ the service the payload belongs to. Defaults to the provider of the
996+ innermost open block, if any.
997+ :param scim_spc: The
998+ :class:`~scim2_models.ServiceProviderConfig` the peer publishes,
999+ which overrides the one *scim_provider* carries.
9561000 """
9571001 attributes , excluded_attributes = self ._attribute_selection (
9581002 response_parameters , attributes , excluded_attributes
@@ -962,6 +1006,8 @@ def model_dump(
9621006 attributes = attributes ,
9631007 excluded_attributes = excluded_attributes ,
9641008 scim_policy = scim_policy ,
1009+ scim_provider = scim_provider ,
1010+ scim_spc = scim_spc ,
9651011 ** kwargs ,
9661012 )
9671013 if scim_ctx :
@@ -976,6 +1022,8 @@ def model_dump_json(
9761022 attributes : list ["str | Path[Any]" ] | None = None ,
9771023 excluded_attributes : list ["str | Path[Any]" ] | None = None ,
9781024 scim_policy : ScimPolicy | None = None ,
1025+ scim_provider : "ScimProvider | None" = None ,
1026+ scim_spc : "ServiceProviderConfig | None" = None ,
9791027 ** kwargs : Any ,
9801028 ) -> str :
9811029 """Create a JSON model representation that can be included in SCIM messages by using Pydantic :code:`BaseModel.model_dump_json`.
@@ -1004,6 +1052,12 @@ def model_dump_json(
10041052 :param scim_policy: The :class:`~scim2_models.ScimPolicy` the
10051053 serialization runs under. Defaults to the strict reading of the
10061054 specification.
1055+ :param scim_provider: The :class:`~scim2_models.ScimProvider` describing
1056+ the service the payload belongs to. Defaults to the provider of the
1057+ innermost open block, if any.
1058+ :param scim_spc: The
1059+ :class:`~scim2_models.ServiceProviderConfig` the peer publishes,
1060+ which overrides the one *scim_provider* carries.
10071061 """
10081062 attributes , excluded_attributes = self ._attribute_selection (
10091063 response_parameters , attributes , excluded_attributes
@@ -1013,6 +1067,8 @@ def model_dump_json(
10131067 attributes = attributes ,
10141068 excluded_attributes = excluded_attributes ,
10151069 scim_policy = scim_policy ,
1070+ scim_provider = scim_provider ,
1071+ scim_spc = scim_spc ,
10161072 ** kwargs ,
10171073 )
10181074 return super ().model_dump_json (* args , ** dump_kwargs )
0 commit comments