Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/rekor_types/_internal/rekord.py: 98%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

40 statements  

1# generated by datamodel-codegen: 

2# filename: rekord_schema.json 

3# version: 0.26.3 

4 

5from __future__ import annotations 

6 

7from enum import Enum 

8from typing import Optional, Union 

9 

10from pydantic import BaseModel, ConfigDict, Field, RootModel, StrictStr 

11 

12 

13class Format(str, Enum): 

14 """Specifies the format of the signature""" 

15 

16 PGP = "pgp" 

17 MINISIGN = "minisign" 

18 X509 = "x509" 

19 SSH = "ssh" 

20 

21 

22class PublicKey(BaseModel): 

23 """The public key that can verify the signature""" 

24 

25 model_config = ConfigDict( 

26 populate_by_name=True, 

27 ) 

28 content: str = Field( 

29 ..., 

30 description="Specifies the content of the public key inline within the document", 

31 ) 

32 

33 

34class Signature(BaseModel): 

35 """Information about the detached signature associated with the entry""" 

36 

37 model_config = ConfigDict( 

38 populate_by_name=True, 

39 ) 

40 format: Format = Field(..., description="Specifies the format of the signature") 

41 content: str = Field( 

42 ..., 

43 description="Specifies the content of the signature inline within the document", 

44 ) 

45 public_key: PublicKey = Field( 

46 ..., 

47 alias="publicKey", 

48 description="The public key that can verify the signature", 

49 ) 

50 

51 

52class Algorithm(str, Enum): 

53 """The hashing function used to compute the hash value""" 

54 

55 SHA256 = "sha256" 

56 

57 

58class Hash(BaseModel): 

59 """Specifies the hash algorithm and value for the content""" 

60 

61 model_config = ConfigDict( 

62 populate_by_name=True, 

63 ) 

64 algorithm: Algorithm = Field( 

65 ..., 

66 description="The hashing function used to compute the hash value", 

67 ) 

68 value: StrictStr = Field(..., description="The hash value for the content") 

69 

70 

71class Data(BaseModel): 

72 """Information about the content associated with the entry""" 

73 

74 model_config = ConfigDict( 

75 populate_by_name=True, 

76 ) 

77 hash: Hash = Field(..., description="Specifies the hash algorithm and value for the content") 

78 content: Optional[str] = Field( 

79 default=None, 

80 description="Specifies the content inline within the document", 

81 ) 

82 

83 

84class Hash1(Hash): 

85 """Specifies the hash algorithm and value for the content""" 

86 

87 

88class Data1(BaseModel): 

89 """Information about the content associated with the entry""" 

90 

91 model_config = ConfigDict( 

92 populate_by_name=True, 

93 ) 

94 hash: Optional[Hash1] = Field( 

95 default=None, 

96 description="Specifies the hash algorithm and value for the content", 

97 ) 

98 content: str = Field(..., description="Specifies the content inline within the document") 

99 

100 

101class RekordV001Schema(BaseModel): 

102 """Schema for Rekord object""" 

103 

104 model_config = ConfigDict( 

105 populate_by_name=True, 

106 ) 

107 signature: Signature = Field( 

108 ..., 

109 description="Information about the detached signature associated with the entry", 

110 ) 

111 data: Union[Data, Data1] = Field( 

112 ..., 

113 description="Information about the content associated with the entry", 

114 ) 

115 

116 

117class RekorSchema(RootModel[RekordV001Schema]): 

118 model_config = ConfigDict( 

119 populate_by_name=True, 

120 ) 

121 root: RekordV001Schema = Field( 

122 ..., 

123 description="Schema for Rekord objects", 

124 title="Rekor Schema", 

125 )