Skip to content

Commit

Permalink
Generate the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko committed Aug 1, 2023
1 parent 4d54a30 commit 5553dcd
Showing 1 changed file with 73 additions and 32 deletions.
105 changes: 73 additions & 32 deletions open-api/rest-catalog-open-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,38 +293,7 @@ class RemovePropertiesUpdate(BaseUpdate):


class TableRequirement(BaseModel):
"""
Assertions from the client that must be valid for the commit to succeed. Assertions are identified by `type` -
- `assert-create` - the table must not already exist; used for create transactions
- `assert-table-uuid` - the table UUID must match the requirement's `uuid`
- `assert-ref-snapshot-id` - the table branch or tag identified by the requirement's `ref` must reference the requirement's `snapshot-id`; if `snapshot-id` is `null` or missing, the ref must not already exist
- `assert-last-assigned-field-id` - the table's last assigned column id must match the requirement's `last-assigned-field-id`
- `assert-current-schema-id` - the table's current schema id must match the requirement's `current-schema-id`
- `assert-last-assigned-partition-id` - the table's last assigned partition id must match the requirement's `last-assigned-partition-id`
- `assert-default-spec-id` - the table's default spec id must match the requirement's `default-spec-id`
- `assert-default-sort-order-id` - the table's default sort order id must match the requirement's `default-sort-order-id`
"""

type: Literal[
'assert-create',
'assert-table-uuid',
'assert-ref-snapshot-id',
'assert-last-assigned-field-id',
'assert-current-schema-id',
'assert-last-assigned-partition-id',
'assert-default-spec-id',
'assert-default-sort-order-id',
]
ref: Optional[str] = None
uuid: Optional[str] = None
snapshot_id: Optional[int] = Field(None, alias='snapshot-id')
last_assigned_field_id: Optional[int] = Field(None, alias='last-assigned-field-id')
current_schema_id: Optional[int] = Field(None, alias='current-schema-id')
last_assigned_partition_id: Optional[int] = Field(
None, alias='last-assigned-partition-id'
)
default_spec_id: Optional[int] = Field(None, alias='default-spec-id')
default_sort_order_id: Optional[int] = Field(None, alias='default-sort-order-id')
type: str


class RegisterTableRequest(BaseModel):
Expand Down Expand Up @@ -517,6 +486,78 @@ class TransformTerm(BaseModel):
term: Reference


class AssertCreate(TableRequirement):
"""
The table must not already exist; used for create transactions
"""

type: Literal['assert-create']


class AssertTableUUID(TableRequirement):
"""
The table UUID must match the requirement's `uuid`
"""

type: Literal['assert-table-uuid']
uuid: str


class AssertRefSnapshotId(TableRequirement):
"""
The table branch or tag identified by the requirement's `ref` must reference the requirement's `snapshot-id`; if `snapshot-id` is `null` or missing, the ref must not already exist
"""

type: Literal['assert-ref-snapshot-id']
ref: str
snapshot_id: int = Field(..., alias='snapshot-id')


class AssertLastAssignedFieldId(TableRequirement):
"""
The table's last assigned column id must match the requirement's `last-assigned-field-id`
"""

type: Literal['assert-last-assigned-field-id']
last_assigned_field_id: int = Field(..., alias='last-assigned-field-id')


class AssertCurrentSchemaId(TableRequirement):
"""
The table's current schema id must match the requirement's `current-schema-id`
"""

type: Literal['assert-current-schema-id']
current_schema_id: int = Field(..., alias='current-schema-id')


class AssertLastAssignedPartitionId(TableRequirement):
"""
The table's last assigned partition id must match the requirement's `last-assigned-partition-id`
"""

type: Literal['assert-last-assigned-partition-id']
last_assigned_partition_id: int = Field(..., alias='last-assigned-partition-id')


class AssertDefaultSpecId(TableRequirement):
"""
The table's default spec id must match the requirement's `default-spec-id`
"""

type: Literal['assert-default-spec-id']
default_spec_id: int = Field(..., alias='default-spec-id')


class AssertDefaultSortOrderId(TableRequirement):
"""
The table's default sort order id must match the requirement's `default-sort-order-id`
"""

type: Literal['assert-default-sort-order-id']
default_sort_order_id: int = Field(..., alias='default-sort-order-id')


class ReportMetricsRequest1(CommitReport):
report_type: str = Field(..., alias='report-type')

Expand Down

0 comments on commit 5553dcd

Please sign in to comment.