Skip to content

Commit

Permalink
Add explicit optional on all models (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldemarmiesse authored Jul 12, 2023
1 parent af04c5d commit 6549a4f
Show file tree
Hide file tree
Showing 17 changed files with 745 additions and 730 deletions.
12 changes: 6 additions & 6 deletions python_on_whales/components/buildx/imagetools/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ManifestConfig(pydantic.BaseModel):


class ManifestLayer(pydantic.BaseModel):
media_type: str = pydantic.Field(alias="mediaType")
media_type: Optional[str] = pydantic.Field(alias="mediaType")
digest: Optional[str]
size: Optional[int]

Expand All @@ -25,15 +25,15 @@ class ManifestPlatform(pydantic.BaseModel):


class ImageVariantManifest(pydantic.BaseModel):
media_type: str = pydantic.Field(alias="mediaType")
size: int
digest: str
media_type: Optional[str] = pydantic.Field(alias="mediaType")
size: Optional[int]
digest: Optional[str]
platform: Optional[ManifestPlatform]


class Manifest(pydantic.BaseModel):
media_type: str = pydantic.Field(alias="mediaType")
schema_version: int = pydantic.Field(alias="schemaVersion")
media_type: Optional[str] = pydantic.Field(alias="mediaType")
schema_version: Optional[int] = pydantic.Field(alias="schemaVersion")
layers: Optional[List[ManifestLayer]]
manifests: Optional[List[ImageVariantManifest]]
config: Optional[ManifestConfig]
132 changes: 66 additions & 66 deletions python_on_whales/components/compose/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,124 +8,124 @@

@all_fields_optional
class ServicePlacement(BaseModel):
constraints: List[str]
constraints: Optional[List[str]] = None


@all_fields_optional
class ResourcesLimits(BaseModel):
cpus: float
memory: int
cpus: Optional[float]
memory: Optional[int]


@all_fields_optional
class ResourcesReservation(BaseModel):
cpus: Union[float, str]
memory: int
cpus: Union[float, str, None]
memory: Optional[int]


@all_fields_optional
class ServiceResources(BaseModel):
limits: ResourcesLimits
reservations: ResourcesReservation
limits: Optional[ResourcesLimits]
reservations: Optional[ResourcesReservation]


@all_fields_optional
class ServiceDeployConfig(BaseModel):
labels: Dict[str, str]
resources: ServiceResources
placement: ServicePlacement
replicas: int
labels: Optional[Dict[str, str]]
resources: Optional[ServiceResources]
placement: Optional[ServicePlacement]
replicas: Optional[int]


@all_fields_optional
class DependencyCondition(BaseModel):
condition: str
condition: Optional[str]


@all_fields_optional
class ComposeServiceBuild(BaseModel):
context: Path
context: Optional[Path]


@all_fields_optional
class ComposeServicePort(BaseModel):
mode: str
protocol: str
published: int
target: int
mode: Optional[str]
protocol: Optional[str]
published: Optional[int]
target: Optional[int]


@all_fields_optional
class ComposeServiceVolume(BaseModel):
bind: dict
source: str
target: str
type: str
bind: Optional[dict]
source: Optional[str]
target: Optional[str]
type: Optional[str]


@all_fields_optional
class ComposeConfigService(BaseModel):
deploy: ServiceDeployConfig
blkio_config: Any
cpu_count: float
cpu_percent: float
cpu_shares: int
cpuset: str
build: ComposeServiceBuild
cap_add: List[str] = Field(default_factory=list)
cap_drop: List[str] = Field(default_factory=list)
cgroup_parent: str
command: List[str]
configs: Any
container_name: str
deploy: Optional[ServiceDeployConfig]
blkio_config: Optional[Any]
cpu_count: Optional[float]
cpu_percent: Optional[float]
cpu_shares: Optional[int]
cpuset: Optional[str]
build: Optional[ComposeServiceBuild]
cap_add: Optional[List[str]] = Field(default_factory=list)
cap_drop: Optional[List[str]] = Field(default_factory=list)
cgroup_parent: Optional[str]
command: Optional[List[str]]
configs: Any = None
container_name: Optional[str]
depends_on: Dict[str, DependencyCondition] = Field(default_factory=dict)
device_cgroup_rules: List[str] = Field(default_factory=list)
devices: Any
environment: Dict[str, Optional[str]]
entrypoint: List[str]
image: str
labels: Dict[str, str] = Field(default_factory=dict)
ports: List[ComposeServicePort]
volumes: List[ComposeServiceVolume]
devices: Any = None
environment: Optional[Dict[str, Optional[str]]]
entrypoint: Optional[List[str]]
image: Optional[str]
labels: Optional[Dict[str, str]] = Field(default_factory=dict)
ports: Optional[List[ComposeServicePort]]
volumes: Optional[List[ComposeServiceVolume]]


@all_fields_optional
class ComposeConfigNetwork(BaseModel):
driver: str
name: str
external: bool = False
driver_opts: Dict[str, Any]
attachable: bool
enable_ipv6: bool
ipam: Any
internal: bool
driver: Optional[str]
name: Optional[str]
external: Optional[bool] = False
driver_opts: Optional[Dict[str, Any]]
attachable: Optional[bool]
enable_ipv6: Optional[bool]
ipam: Any = None
internal: Optional[bool]
labels: Dict[str, str] = Field(default_factory=dict)


@all_fields_optional
class ComposeConfigVolume(BaseModel):
driver: str
driver_opts: Dict[str, Any]
external: bool
labels: Dict[str, str] = Field(default_factory=dict)
name: str
driver: Optional[str]
driver_opts: Optional[Dict[str, Any]]
external: Optional[bool]
labels: Optional[Dict[str, str]] = Field(default_factory=dict)
name: Optional[str]


@all_fields_optional
class ComposeConfig(BaseModel):
services: Dict[str, ComposeConfigService]
networks: Dict[str, ComposeConfigNetwork] = Field(default_factory=dict)
volumes: Dict[str, ComposeConfigVolume] = Field(default_factory=dict)
configs: Any
secrets: Any
services: Optional[Dict[str, ComposeConfigService]]
networks: Optional[Dict[str, ComposeConfigNetwork]] = Field(default_factory=dict)
volumes: Optional[Dict[str, ComposeConfigVolume]] = Field(default_factory=dict)
configs: Any = None
secrets: Any = None


class ComposeProject(BaseModel):
name: str
created: int = 0
running: int = 0
restarting: int = 0
exited: int = 0
paused: int = 0
dead: int = 0
name: Optional[str]
created: Optional[int] = 0
running: Optional[int] = 0
restarting: Optional[int] = 0
exited: Optional[int] = 0
paused: Optional[int] = 0
dead: Optional[int] = 0
config_files: Optional[List[Path]]
22 changes: 11 additions & 11 deletions python_on_whales/components/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@


class DockerObjectVersion(DockerCamelModel):
index: int
index: Optional[int] = None


class ConfigSpecDriver(DockerCamelModel):
name: str
options: Dict[str, Any]
name: Optional[str] = None
options: Optional[Dict[str, Any]] = None


class ConfigSpec(DockerCamelModel):
name: str
labels: Dict[str, str]
data: str
name: Optional[str]
labels: Optional[Dict[str, str]]
data: Optional[str]
templating: Optional[ConfigSpecDriver]


class ConfigInspectResult(DockerCamelModel):
id: str = pydantic.Field(alias="ID")
version: DockerObjectVersion
created_at: datetime
updated_at: datetime
spec: ConfigSpec
id: Optional[str] = pydantic.Field(None, alias="ID")
version: Optional[DockerObjectVersion]
created_at: Optional[datetime]
updated_at: Optional[datetime]
spec: Optional[ConfigSpec]
Loading

0 comments on commit 6549a4f

Please sign in to comment.