Module: migrations¶
Migrations between pydantic model versions, refer to Serialization and Migration
- exception doubleratchet.migrations.InconsistentSerializationException[source]¶
Bases:
Exception
Raised by
parse_double_ratchet_model()
in case data migration from pre-stable serialization format is performed, and the data is structurally correct, but incomplete.
- doubleratchet.migrations.parse_diffie_hellman_ratchet_model(serialized)[source]¶
Parse a serialized
DiffieHellmanRatchet
instance, as returned byjson
, into the most recent pydantic model available for the class. Perform migrations in case the pydantic models were updated.- Parameters
serialized (
Mapping
[str
,Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
]]]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
]]]]]]) – The serialized instance.- Return type
- Returns
The model, which can be used to restore the instance using
from_model()
.
Note
Pre-stable data can only be migrated as a whole using
parse_double_ratchet_model()
.
- doubleratchet.migrations.parse_double_ratchet_model(serialized)[source]¶
Parse a serialized
DoubleRatchet
instance, as returned byjson
, into the most recent pydantic model available for the class. Perform migrations in case the pydantic models were updated. Supports migration of pre-stable data.- Parameters
serialized (
Mapping
[str
,Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
]]]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
]]]]]]) – The serialized instance.- Return type
- Returns
The model, which can be used to restore the instance using
from_model()
.- Raises
InconsistentSerializationException – if migration from pre-stable serialization format is performed, and the data is structurally correct, but incomplete. In pre-stable, it was possible to serialize instances which were not fully initialized yet. Those instances can be treated as non-existent and be replaced without losing information/messages.
Note
The pre-stable serialization format left it up to the user to implement serialization of key pairs. The migration code assumes the format used by pre-stable python-omemo and will raise an exception if a different format was used. In that case, the custom format has to be migrated first by the user.
- doubleratchet.migrations.parse_kdf_chain_model(serialized)[source]¶
Parse a serialized
KDFChain
instance, as returned byjson
, into the most recent pydantic model available for the class. Perform migrations in case the pydantic models were updated.- Parameters
serialized (
Mapping
[str
,Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
]]]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
]]]]]]) – The serialized instance.- Return type
- Returns
The model, which can be used to restore the instance using
from_model()
.
Note
Pre-stable data can only be migrated as a whole using
parse_double_ratchet_model()
.
- doubleratchet.migrations.parse_symmetric_key_ratchet_model(serialized)[source]¶
Parse a serialized
SymmetricKeyRatchet
instance, as returned byjson
, into the most recent pydantic model available for the class. Perform migrations in case the pydantic models were updated.- Parameters
serialized (
Mapping
[str
,Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
]]]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
,List
[Union
[None
,float
,int
,str
,bool
]],Mapping
[str
,Union
[None
,float
,int
,str
,bool
]]]]]]) – The serialized instance.- Return type
- Returns
The model, which can be used to restore the instance using
from_model()
.
Note
Pre-stable data can only be migrated as a whole using
parse_double_ratchet_model()
.