Source code for mgnipy.emgapi_v2_client.models.m_gnify_download_file_index_file
from __future__ import annotations
from collections.abc import Mapping
from typing import (
Any,
TypeVar,
cast,
)
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..models.m_gnify_download_file_index_file_index_type import (
MGnifyDownloadFileIndexFileIndexType,
)
from ..types import (
UNSET,
Unset,
)
T = TypeVar("T", bound="MGnifyDownloadFileIndexFile")
[docs]
@_attrs_define
class MGnifyDownloadFileIndexFile:
"""
Attributes:
index_type (MGnifyDownloadFileIndexFileIndexType):
path (str | Unset):
url (None | str | Unset): Full URL of the index file.
"""
index_type: MGnifyDownloadFileIndexFileIndexType
path: str | Unset = UNSET
url: None | str | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
[docs]
def to_dict(self) -> dict[str, Any]:
index_type = self.index_type.value
path = self.path
url: None | str | Unset
if isinstance(self.url, Unset):
url = UNSET
else:
url = self.url
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"index_type": index_type,
}
)
if path is not UNSET:
field_dict["path"] = path
if url is not UNSET:
field_dict["url"] = url
return field_dict
[docs]
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
index_type = MGnifyDownloadFileIndexFileIndexType(d.pop("index_type"))
path = d.pop("path", UNSET)
def _parse_url(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)
url = _parse_url(d.pop("url", UNSET))
m_gnify_download_file_index_file = cls(
index_type=index_type,
path=path,
url=url,
)
m_gnify_download_file_index_file.additional_properties = d
return m_gnify_download_file_index_file
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties