Skip to content

Commit

Permalink
Workaround Erratum shipped_dt nullability
Browse files Browse the repository at this point in the history
Will be addressed properly in the OSIDB eventually
  • Loading branch information
JakubFrejlach committed Oct 17, 2023
1 parent 1fecc3b commit ee966f2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed
- add workaround for Erratum shipped_dt which is marked as non-nullable
despite being nullable

## [3.5.0] - 2023-10-12
### Added
Expand Down
36 changes: 19 additions & 17 deletions osidb_bindings/bindings/python_client/models/erratum.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
from typing import Any, Dict, List, Type, TypeVar
from typing import Any, Dict, List, Optional, Type, TypeVar

import attr
from dateutil.parser import isoparse
Expand All @@ -15,18 +15,14 @@ class Erratum(OSIDBModel):

et_id: int
advisory_name: str
shipped_dt: datetime.datetime
created_dt: datetime.datetime
updated_dt: datetime.datetime
shipped_dt: Optional[datetime.datetime]
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
et_id = self.et_id
advisory_name = self.advisory_name
shipped_dt: str = UNSET
if not isinstance(self.shipped_dt, Unset):
shipped_dt = self.shipped_dt.isoformat()

created_dt: str = UNSET
if not isinstance(self.created_dt, Unset):
created_dt = self.created_dt.isoformat()
Expand All @@ -35,18 +31,22 @@ def to_dict(self) -> Dict[str, Any]:
if not isinstance(self.updated_dt, Unset):
updated_dt = self.updated_dt.isoformat()

shipped_dt: Optional[str] = UNSET
if not isinstance(self.shipped_dt, Unset):
shipped_dt = self.shipped_dt.isoformat() if self.shipped_dt else None

field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
if not isinstance(et_id, Unset):
field_dict["et_id"] = et_id
if not isinstance(advisory_name, Unset):
field_dict["advisory_name"] = advisory_name
if not isinstance(shipped_dt, Unset):
field_dict["shipped_dt"] = shipped_dt
if not isinstance(created_dt, Unset):
field_dict["created_dt"] = created_dt
if not isinstance(updated_dt, Unset):
field_dict["updated_dt"] = updated_dt
if not isinstance(shipped_dt, Unset):
field_dict["shipped_dt"] = shipped_dt

return field_dict

Expand All @@ -57,13 +57,6 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:

advisory_name = d.pop("advisory_name", UNSET)

_shipped_dt = d.pop("shipped_dt", UNSET)
shipped_dt: datetime.datetime
if isinstance(_shipped_dt, Unset):
shipped_dt = UNSET
else:
shipped_dt = isoparse(_shipped_dt)

_created_dt = d.pop("created_dt", UNSET)
created_dt: datetime.datetime
if isinstance(_created_dt, Unset):
Expand All @@ -78,12 +71,21 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
else:
updated_dt = isoparse(_updated_dt)

_shipped_dt = d.pop("shipped_dt", UNSET)
shipped_dt: Optional[datetime.datetime]
if _shipped_dt is None:
shipped_dt = None
elif isinstance(_shipped_dt, Unset):
shipped_dt = UNSET
else:
shipped_dt = isoparse(_shipped_dt)

erratum = cls(
et_id=et_id,
advisory_name=advisory_name,
shipped_dt=shipped_dt,
created_dt=created_dt,
updated_dt=updated_dt,
shipped_dt=shipped_dt,
)

erratum.additional_properties = d
Expand All @@ -94,9 +96,9 @@ def get_fields():
return {
"et_id": int,
"advisory_name": str,
"shipped_dt": datetime.datetime,
"created_dt": datetime.datetime,
"updated_dt": datetime.datetime,
"shipped_dt": datetime.datetime,
}

@property
Expand Down
1 change: 1 addition & 0 deletions osidb_bindings/openapi_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7637,6 +7637,7 @@ components:
type: string
format: date-time
readOnly: true
nullable: true
created_dt:
type: string
format: date-time
Expand Down

0 comments on commit ee966f2

Please sign in to comment.