Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/rekor_types/__init__.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

50 statements  

1"""The `sigstore_rekor_types` APIs.""" 

2 

3from __future__ import annotations 

4 

5import sys 

6from typing import Literal, Union 

7 

8from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr 

9 

10from ._internal import ( 

11 alpine, 

12 cose, 

13 dsse, 

14 hashedrekord, 

15 helm, 

16 intoto, 

17 jar, 

18 rekord, 

19 rfc3161, 

20 rpm, 

21 tuf, 

22) 

23 

24if sys.version_info < (3, 9): 

25 from typing_extensions import Annotated 

26else: 

27 from typing import Annotated 

28 

29__version__ = "0.0.18" 

30 

31 

32class Error(BaseModel): 

33 """A Rekor server error.""" 

34 

35 code: StrictInt 

36 message: StrictStr 

37 

38 

39class _ProposedEntryMixin(BaseModel): 

40 model_config = ConfigDict( 

41 populate_by_name=True, 

42 ) 

43 api_version: StrictStr = Field( 

44 pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", 

45 default="0.0.1", 

46 alias="apiVersion", 

47 ) 

48 

49 

50class Alpine(_ProposedEntryMixin): 

51 """Proposed entry model for an `alpine` record.""" 

52 

53 kind: Literal["alpine"] = "alpine" 

54 spec: alpine.AlpinePackageSchema 

55 

56 

57class Cose(_ProposedEntryMixin): 

58 """Proposed entry model for a `cose` record.""" 

59 

60 kind: Literal["cose"] = "cose" 

61 spec: cose.CoseSchema 

62 

63 

64class Dsse(_ProposedEntryMixin): 

65 """Proposed entry model for a `dsse` record.""" 

66 

67 kind: Literal["dsse"] = "dsse" 

68 spec: dsse.DsseSchema 

69 

70 

71class Hashedrekord(_ProposedEntryMixin): 

72 """Proposed entry model for a `dsse` record.""" 

73 

74 kind: Literal["hashedrekord"] = "hashedrekord" 

75 spec: hashedrekord.HashedrekordSchema 

76 

77 

78class Helm(_ProposedEntryMixin): 

79 """Proposed entry model for a `dsse` record.""" 

80 

81 kind: Literal["helm"] = "helm" 

82 spec: helm.HelmSchema 

83 

84 

85class Intoto(_ProposedEntryMixin): 

86 """Proposed entry model for a `dsse` record.""" 

87 

88 kind: Literal["intoto"] = "intoto" 

89 spec: intoto.IntotoSchema 

90 

91 

92class Jar(_ProposedEntryMixin): 

93 """Proposed entry model for a `jar` record.""" 

94 

95 kind: Literal["jar"] = "jar" 

96 spec: jar.JarSchema 

97 

98 

99class Rekord(_ProposedEntryMixin): 

100 """Proposed entry model for a `rekord` record.""" 

101 

102 kind: Literal["rekord"] = "rekord" 

103 spec: rekord.RekorSchema 

104 

105 

106class Rfc3161(_ProposedEntryMixin): 

107 """Proposed entry model for a `rfc3161` record.""" 

108 

109 kind: Literal["rfc3161"] = "rfc3161" 

110 spec: rfc3161.TimestampSchema 

111 

112 

113class Rpm(_ProposedEntryMixin): 

114 """Proposed entry model for an `rpm` record.""" 

115 

116 kind: Literal["rpm"] = "rpm" 

117 spec: rpm.RpmSchema 

118 

119 

120class Tuf(_ProposedEntryMixin): 

121 """Proposed entry model for a `tuf` record.""" 

122 

123 kind: Literal["tuf"] = "tuf" 

124 spec: tuf.TufSchema 

125 

126 

127ProposedEntry = Annotated[ 

128 Union[Alpine, Cose, Dsse, Hashedrekord, Helm, Intoto, Jar, Rekord, Rfc3161, Rpm, Tuf], 

129 Field(discriminator="kind"), 

130]