Skip to content

Commit 3db8d23

Browse files
committed
typeage, more codegen tweaks
Signed-off-by: William Woodruff <[email protected]>
1 parent de3419b commit 3db8d23

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

codegen/codegen.sh

+3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ datamodel-codegen \
5555
--capitalize-enum-members \
5656
--field-constraints \
5757
--use-schema-description \
58+
--use-subclass-enum \
5859
--disable-timestamp \
60+
--reuse-model \
61+
--use-default-kwarg \
5962
--strict-types str bytes int float bool \
6063
--output-model-type pydantic_v2.BaseModel \
6164
--output "${pkg_dir}/_internal.py"

sigstore_rekor_types/_internal.py

+38-41
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ProposedEntry(BaseModel):
1212
kind: StrictStr
1313

1414

15-
class Format(Enum):
15+
class Format(str, Enum):
1616
"""Specifies the format of the signature."""
1717

1818
PGP = "pgp"
@@ -58,7 +58,7 @@ class PublicKey1(BaseModel):
5858
"""The public key that can verify the signature; this can also be an X509 code signing certificate that contains the raw public key information."""
5959

6060
content: Optional[str] = Field(
61-
None,
61+
default=None,
6262
description=(
6363
"Specifies the content of the public key or code signing certificate inline within the"
6464
" document"
@@ -70,11 +70,11 @@ class Signature1(BaseModel):
7070
"""Information about the detached signature associated with the entry."""
7171

7272
content: Optional[str] = Field(
73-
None,
73+
default=None,
7474
description="Specifies the content of the signature inline within the document",
7575
)
7676
public_key: Optional[PublicKey1] = Field(
77-
None,
77+
default=None,
7878
alias="publicKey",
7979
description=(
8080
"The public key that can verify the signature; this can also be an X509 code signing"
@@ -83,7 +83,7 @@ class Signature1(BaseModel):
8383
)
8484

8585

86-
class Algorithm(Enum):
86+
class Algorithm(str, Enum):
8787
"""The hashing function used to compute the hash value."""
8888

8989
SHA256 = "sha256"
@@ -103,7 +103,7 @@ class Data(BaseModel):
103103
"""Information about the content associated with the entry."""
104104

105105
hash: Optional[Hash] = Field(
106-
None,
106+
default=None,
107107
description="Specifies the hash algorithm and value for the content",
108108
)
109109

@@ -158,7 +158,7 @@ class Root(BaseModel):
158158
class TufV001Schema(BaseModel):
159159
"""Schema for TUF metadata entries."""
160160

161-
spec_version: Optional[StrictStr] = Field(None, description="TUF specification version")
161+
spec_version: Optional[StrictStr] = Field(default=None, description="TUF specification version")
162162
metadata: Metadata = Field(..., description="TUF metadata")
163163
root: Root = Field(
164164
...,
@@ -199,7 +199,7 @@ class Chart(BaseModel):
199199
"""Information about the Helm chart associated with the entry."""
200200

201201
hash: Optional[Hash1] = Field(
202-
None,
202+
default=None,
203203
description="Specifies the hash algorithm and value for the chart",
204204
)
205205

@@ -239,16 +239,16 @@ class PayloadHash(BaseModel):
239239

240240

241241
class Content(BaseModel):
242-
envelope: Optional[StrictStr] = Field(None, description="envelope")
242+
envelope: Optional[StrictStr] = Field(default=None, description="envelope")
243243
hash: Optional[Hash2] = Field(
244-
None,
244+
default=None,
245245
description=(
246246
"Specifies the hash algorithm and value encompassing the entire signed envelope; this"
247247
" is computed by the rekor server, client-provided values are ignored"
248248
),
249249
)
250250
payload_hash: Optional[PayloadHash] = Field(
251-
None,
251+
default=None,
252252
alias="payloadHash",
253253
description=(
254254
"Specifies the hash algorithm and value covering the payload within the DSSE envelope;"
@@ -272,7 +272,7 @@ class Signature2(BaseModel):
272272
"""a signature of the envelope's payload along with the public key for the signature."""
273273

274274
keyid: Optional[StrictStr] = Field(
275-
None,
275+
default=None,
276276
description="optional id of the key used to create the signature",
277277
)
278278
sig: str = Field(..., description="signature of the payload")
@@ -286,7 +286,7 @@ class Signature2(BaseModel):
286286
class Envelope(BaseModel):
287287
"""dsse envelope."""
288288

289-
payload: Optional[str] = Field(None, description="payload of the envelope")
289+
payload: Optional[str] = Field(default=None, description="payload of the envelope")
290290
payload_type: StrictStr = Field(
291291
...,
292292
alias="payloadType",
@@ -322,13 +322,13 @@ class PayloadHash1(BaseModel):
322322
class Content1(BaseModel):
323323
envelope: Envelope = Field(..., description="dsse envelope")
324324
hash: Optional[Hash3] = Field(
325-
None,
325+
default=None,
326326
description=(
327327
"Specifies the hash algorithm and value encompassing the entire signed envelope"
328328
),
329329
)
330330
payload_hash: Optional[PayloadHash1] = Field(
331-
None,
331+
default=None,
332332
alias="payloadHash",
333333
description=(
334334
"Specifies the hash algorithm and value covering the payload within the DSSE envelope"
@@ -342,15 +342,9 @@ class IntotoV002Schema(BaseModel):
342342
content: Content1
343343

344344

345-
class PayloadHash2(BaseModel):
345+
class PayloadHash2(Hash):
346346
"""Specifies the hash algorithm and value for the content."""
347347

348-
algorithm: Algorithm = Field(
349-
...,
350-
description="The hashing function used to compute the hash value",
351-
)
352-
value: StrictStr = Field(..., description="The hash value for the content")
353-
354348

355349
class EnvelopeHash(BaseModel):
356350
"""Specifies the hash algorithm and value for the COSE envelope."""
@@ -366,25 +360,25 @@ class Data1(BaseModel):
366360
"""Information about the content associated with the entry."""
367361

368362
payload_hash: Optional[PayloadHash2] = Field(
369-
None,
363+
default=None,
370364
alias="payloadHash",
371365
description="Specifies the hash algorithm and value for the content",
372366
)
373367
envelope_hash: Optional[EnvelopeHash] = Field(
374-
None,
368+
default=None,
375369
alias="envelopeHash",
376370
description="Specifies the hash algorithm and value for the COSE envelope",
377371
)
378372
aad: Optional[str] = Field(
379-
None,
373+
default=None,
380374
description="Specifies the additional authenticated data required to verify the signature",
381375
)
382376

383377

384378
class CoseV001Schema(BaseModel):
385379
"""Schema for cose object."""
386380

387-
message: Optional[str] = Field(None, description="The COSE Sign1 Message")
381+
message: Optional[str] = Field(default=None, description="The COSE Sign1 Message")
388382
public_key: str = Field(
389383
...,
390384
alias="publicKey",
@@ -426,7 +420,7 @@ class JarV001Schema(BaseModel):
426420
"""Schema for JAR entries."""
427421

428422
signature: Optional[Signature3] = Field(
429-
None,
423+
default=None,
430424
description="Information about the included signature in the JAR file",
431425
)
432426

@@ -503,24 +497,24 @@ class PayloadHash3(BaseModel):
503497
class DsseV001Schema(BaseModel):
504498
"""Schema for DSSE envelopes."""
505499

506-
proposed_content: Optional[ProposedContent] = Field(None, alias="proposedContent")
500+
proposed_content: Optional[ProposedContent] = Field(default=None, alias="proposedContent")
507501
signatures: Optional[List[Signature4]] = Field(
508-
None,
502+
default=None,
509503
description=(
510504
"extracted collection of all signatures of the envelope's payload; elements will be"
511505
" sorted by lexicographical order of the base64 encoded signature strings"
512506
),
513507
min_length=1,
514508
)
515509
envelope_hash: Optional[EnvelopeHash1] = Field(
516-
None,
510+
default=None,
517511
alias="envelopeHash",
518512
description=(
519513
"Specifies the hash algorithm and value encompassing the entire envelope sent to Rekor"
520514
),
521515
)
522516
payload_hash: Optional[PayloadHash3] = Field(
523-
None,
517+
default=None,
524518
alias="payloadHash",
525519
description=(
526520
"Specifies the hash algorithm and value covering the payload within the DSSE envelope"
@@ -532,7 +526,7 @@ class Attestation(BaseModel):
532526
data: Optional[Dict[str, Any]] = None
533527

534528

535-
class Format1(Enum):
529+
class Format1(str, Enum):
536530
PGP = "pgp"
537531
X509 = "x509"
538532
MINISIGN = "minisign"
@@ -543,20 +537,20 @@ class Format1(Enum):
543537
class PublicKey6(BaseModel):
544538
format: Format1
545539
content: Optional[str] = Field(
546-
None,
540+
default=None,
547541
pattern="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
548542
)
549543
url: Optional[AnyUrl] = None
550544

551545

552-
class Operator(Enum):
546+
class Operator(str, Enum):
553547
AND_ = "and"
554548
OR_ = "or"
555549

556550

557551
class SearchIndex(BaseModel):
558552
email: Optional[EmailStr] = None
559-
public_key: Optional[PublicKey6] = Field(None, alias="publicKey")
553+
public_key: Optional[PublicKey6] = Field(default=None, alias="publicKey")
560554
hash: Optional[StrictStr] = None
561555
operator: Optional[Operator] = None
562556

@@ -571,18 +565,18 @@ class LogIndex(RootModel[StrictInt]):
571565

572566
class SearchLogQuery(BaseModel):
573567
entry_uui_ds: Optional[List[EntryUuiD]] = Field(
574-
None,
568+
default=None,
575569
alias="entryUUIDs",
576570
max_length=10,
577571
min_length=1,
578572
)
579573
log_indexes: Optional[List[LogIndex]] = Field(
580-
None,
574+
default=None,
581575
alias="logIndexes",
582576
max_length=10,
583577
min_length=1,
584578
)
585-
entries: Optional[List[ProposedEntry]] = Field(None, max_length=10, min_length=1)
579+
entries: Optional[List[ProposedEntry]] = Field(default=None, max_length=10, min_length=1)
586580

587581

588582
class InactiveShardLogInfo(BaseModel):
@@ -730,9 +724,9 @@ class DsseSchema(RootModel[DsseV001Schema]):
730724

731725

732726
class Verification(BaseModel):
733-
inclusion_proof: Optional[InclusionProof] = Field(None, alias="inclusionProof")
727+
inclusion_proof: Optional[InclusionProof] = Field(default=None, alias="inclusionProof")
734728
signed_entry_timestamp: Optional[str] = Field(
735-
None,
729+
default=None,
736730
alias="signedEntryTimestamp",
737731
description="Signature over the logID, logIndex, body and integratedTime.",
738732
pattern="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
@@ -780,7 +774,10 @@ class LogInfo(BaseModel):
780774
description="The current signed tree head",
781775
)
782776
tree_id: StrictStr = Field(..., alias="treeID", description="The current treeID")
783-
inactive_shards: Optional[List[InactiveShardLogInfo]] = Field(None, alias="inactiveShards")
777+
inactive_shards: Optional[List[InactiveShardLogInfo]] = Field(
778+
default=None,
779+
alias="inactiveShards",
780+
)
784781

785782

786783
class Rekord(ProposedEntry):

sigstore_rekor_types/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)