Skip to content

Instantly share code, notes, and snippets.

@markns
Created April 5, 2023 08:39
Show Gist options
  • Save markns/57fa82c32af212b25e6bc0c4df5c9387 to your computer and use it in GitHub Desktop.
Save markns/57fa82c32af212b25e6bc0c4df5c9387 to your computer and use it in GitHub Desktop.
Airbyte source_read.py
from typing import Any, Dict, List, Type, TypeVar, Union
import attr
from ..types import UNSET, Unset
T = TypeVar("T", bound="SourceRead")
@attr.s(auto_attribs=True)
class SourceRead:
"""
Attributes:
source_definition_id (str):
source_id (str):
workspace_id (str):
connection_configuration (Any): The values required to configure the source. The schema for this must match the
schema return by source_definition_specifications/get for the source. Example: {'user': 'charles'}.
name (str):
source_name (str):
icon (Union[Unset, str]):
"""
source_definition_id: str
source_id: str
workspace_id: str
connection_configuration: Any
name: str
source_name: str
icon: Union[Unset, str] = UNSET
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
source_definition_id = self.source_definition_id
source_id = self.source_id
workspace_id = self.workspace_id
connection_configuration = self.connection_configuration
name = self.name
source_name = self.source_name
icon = self.icon
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"sourceDefinitionId": source_definition_id,
"sourceId": source_id,
"workspaceId": workspace_id,
"connectionConfiguration": connection_configuration,
"name": name,
"sourceName": source_name,
}
)
if icon is not UNSET:
field_dict["icon"] = icon
return field_dict
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
source_definition_id = d.pop("sourceDefinitionId")
source_id = d.pop("sourceId")
workspace_id = d.pop("workspaceId")
connection_configuration = d.pop("connectionConfiguration")
name = d.pop("name")
source_name = d.pop("sourceName")
icon = d.pop("icon", UNSET)
source_read = cls(
source_definition_id=source_definition_id,
source_id=source_id,
workspace_id=workspace_id,
connection_configuration=connection_configuration,
name=name,
source_name=source_name,
icon=icon,
)
source_read.additional_properties = d
return source_read
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment