Skip to content

prefect_hightouch.api_client.models.model

Model

Bases: BaseModel

The SQL query that pulls data from your source to send to your destination. We send your SQL query directly to your source so any SQL that is valid for your source (including functions) is valid in Hightouch.

Attributes:
    created_at (datetime.datetime): The timestamp when model was created
    id (str): The id of the model
    is_schema (bool): If is_schema is true, the model is just used to build other models.
        Either as part of visual querying, or as the root of a visual query.
    name (str): The name of the model
    primary_key (str): The primary key will be null if the query doesn't get directly synced (e.g. a relationship
        table for visual querying)
    query_type (str): The type of the query. Available options: custom, raw_sql, tabel, dbt and visual.
    slug (str): The slug of the model
    source_id (str): The id of the source that model is connected to
    syncs (List[str]): The list of id of syncs that uses this model
    tags (ModelTags): The tags of the model
    updated_at (datetime.datetime): The timestamp when model was lastly updated
    workspace_id (str): The id of the workspace where the model belongs to
    custom (Union[Unset, ModelCustom]): Custom query for sources that doesn't support sql. For example, Airtable.
    dbt (Union[Unset, ModelDbt]): Query that is based on a dbt model
    raw (Union[Unset, ModelRaw]): Standard raw SQL query
    table (Union[Unset, ModelTable]): Table-based query that fetches on a table instead of SQL
    visual (Union[Unset, ModelVisual]): Visual query, used by audience
Source code in prefect_hightouch/api_client/models/model.py
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
class Model(BaseModel):
    """The SQL query that pulls data from your source to send to your destination.
    We send your SQL query directly to your source so any SQL that is valid for your source (including functions) is
    valid in Hightouch.

        Attributes:
            created_at (datetime.datetime): The timestamp when model was created
            id (str): The id of the model
            is_schema (bool): If is_schema is true, the model is just used to build other models.
                Either as part of visual querying, or as the root of a visual query.
            name (str): The name of the model
            primary_key (str): The primary key will be null if the query doesn't get directly synced (e.g. a relationship
                table for visual querying)
            query_type (str): The type of the query. Available options: custom, raw_sql, tabel, dbt and visual.
            slug (str): The slug of the model
            source_id (str): The id of the source that model is connected to
            syncs (List[str]): The list of id of syncs that uses this model
            tags (ModelTags): The tags of the model
            updated_at (datetime.datetime): The timestamp when model was lastly updated
            workspace_id (str): The id of the workspace where the model belongs to
            custom (Union[Unset, ModelCustom]): Custom query for sources that doesn't support sql. For example, Airtable.
            dbt (Union[Unset, ModelDbt]): Query that is based on a dbt model
            raw (Union[Unset, ModelRaw]): Standard raw SQL query
            table (Union[Unset, ModelTable]): Table-based query that fetches on a table instead of SQL
            visual (Union[Unset, ModelVisual]): Visual query, used by audience
    """

    created_at: datetime.datetime = None
    id: str = None
    is_schema: bool = None
    name: str = None
    primary_key: str = None
    query_type: str = None
    slug: str = None
    source_id: str = None
    syncs: List[str] = None
    tags: ModelTags = None
    updated_at: datetime.datetime = None
    workspace_id: str = None
    custom: Union[Unset, ModelCustom] = UNSET
    dbt: Union[Unset, ModelDbt] = UNSET
    raw: Union[Unset, ModelRaw] = UNSET
    table: Union[Unset, ModelTable] = UNSET
    visual: Union[Unset, ModelVisual] = UNSET
    additional_properties: Dict[str, Any] = Field(default_factory=dict)

    def to_dict(self) -> Dict[str, Any]:
        created_at = self.created_at.isoformat()

        id = self.id
        is_schema = self.is_schema
        name = self.name
        primary_key = self.primary_key
        query_type = self.query_type
        slug = self.slug
        source_id = self.source_id
        syncs = self.syncs

        tags = self.tags.to_dict()

        updated_at = self.updated_at.isoformat()

        workspace_id = self.workspace_id
        custom: Union[Unset, Dict[str, Any]] = UNSET
        if not isinstance(self.custom, Unset):
            custom = self.custom.to_dict()

        dbt: Union[Unset, Dict[str, Any]] = UNSET
        if not isinstance(self.dbt, Unset):
            dbt = self.dbt.to_dict()

        raw: Union[Unset, Dict[str, Any]] = UNSET
        if not isinstance(self.raw, Unset):
            raw = self.raw.to_dict()

        table: Union[Unset, Dict[str, Any]] = UNSET
        if not isinstance(self.table, Unset):
            table = self.table.to_dict()

        visual: Union[Unset, Dict[str, Any]] = UNSET
        if not isinstance(self.visual, Unset):
            visual = self.visual.to_dict()

        field_dict: Dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update(
            {
                "createdAt": created_at,
                "id": id,
                "isSchema": is_schema,
                "name": name,
                "primaryKey": primary_key,
                "queryType": query_type,
                "slug": slug,
                "sourceId": source_id,
                "syncs": syncs,
                "tags": tags,
                "updatedAt": updated_at,
                "workspaceId": workspace_id,
            }
        )
        if custom is not UNSET:
            field_dict["custom"] = custom
        if dbt is not UNSET:
            field_dict["dbt"] = dbt
        if raw is not UNSET:
            field_dict["raw"] = raw
        if table is not UNSET:
            field_dict["table"] = table
        if visual is not UNSET:
            field_dict["visual"] = visual

        return field_dict

    @classmethod
    def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
        if src_dict is None or src_dict is UNSET:
            return {}
        d = {k: v if v is not None else UNSET for k, v in src_dict.items()}
        created_at = isoparse(d.pop("createdAt"))

        id = d.pop("id")

        is_schema = d.pop("isSchema")

        name = d.pop("name")

        primary_key = d.pop("primaryKey")

        query_type = d.pop("queryType")

        slug = d.pop("slug")

        source_id = d.pop("sourceId")

        syncs = cast(List[str], d.pop("syncs"))

        tags = ModelTags.from_dict(d.pop("tags"))

        updated_at = isoparse(d.pop("updatedAt"))

        workspace_id = d.pop("workspaceId")

        _custom = d.pop("custom", UNSET)
        custom: Union[Unset, ModelCustom]
        if isinstance(_custom, Unset):
            custom = UNSET
        else:
            custom = ModelCustom.from_dict(_custom)

        _dbt = d.pop("dbt", UNSET)
        dbt: Union[Unset, ModelDbt]
        if isinstance(_dbt, Unset):
            dbt = UNSET
        else:
            dbt = ModelDbt.from_dict(_dbt)

        _raw = d.pop("raw", UNSET)
        raw: Union[Unset, ModelRaw]
        if isinstance(_raw, Unset):
            raw = UNSET
        else:
            raw = ModelRaw.from_dict(_raw)

        _table = d.pop("table", UNSET)
        table: Union[Unset, ModelTable]
        if isinstance(_table, Unset):
            table = UNSET
        else:
            table = ModelTable.from_dict(_table)

        _visual = d.pop("visual", UNSET)
        visual: Union[Unset, ModelVisual]
        if isinstance(_visual, Unset):
            visual = UNSET
        else:
            visual = ModelVisual.from_dict(_visual)

        model = cls(
            created_at=created_at,
            id=id,
            is_schema=is_schema,
            name=name,
            primary_key=primary_key,
            query_type=query_type,
            slug=slug,
            source_id=source_id,
            syncs=syncs,
            tags=tags,
            updated_at=updated_at,
            workspace_id=workspace_id,
            custom=custom,
            dbt=dbt,
            raw=raw,
            table=table,
            visual=visual,
        )

        model.additional_properties = d
        return model

    @property
    def additional_keys(self) -> List[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties.get(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

additional_keys: List[str] property

additional_properties: Dict[str, Any] = Field(default_factory=dict) class-attribute instance-attribute

created_at: datetime.datetime = None class-attribute instance-attribute

custom: Union[Unset, ModelCustom] = UNSET class-attribute instance-attribute

dbt: Union[Unset, ModelDbt] = UNSET class-attribute instance-attribute

id: str = None class-attribute instance-attribute

is_schema: bool = None class-attribute instance-attribute

name: str = None class-attribute instance-attribute

primary_key: str = None class-attribute instance-attribute

query_type: str = None class-attribute instance-attribute

raw: Union[Unset, ModelRaw] = UNSET class-attribute instance-attribute

slug: str = None class-attribute instance-attribute

source_id: str = None class-attribute instance-attribute

syncs: List[str] = None class-attribute instance-attribute

table: Union[Unset, ModelTable] = UNSET class-attribute instance-attribute

tags: ModelTags = None class-attribute instance-attribute

updated_at: datetime.datetime = None class-attribute instance-attribute

visual: Union[Unset, ModelVisual] = UNSET class-attribute instance-attribute

workspace_id: str = None class-attribute instance-attribute

from_dict classmethod

Source code in prefect_hightouch/api_client/models/model.py
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
    if src_dict is None or src_dict is UNSET:
        return {}
    d = {k: v if v is not None else UNSET for k, v in src_dict.items()}
    created_at = isoparse(d.pop("createdAt"))

    id = d.pop("id")

    is_schema = d.pop("isSchema")

    name = d.pop("name")

    primary_key = d.pop("primaryKey")

    query_type = d.pop("queryType")

    slug = d.pop("slug")

    source_id = d.pop("sourceId")

    syncs = cast(List[str], d.pop("syncs"))

    tags = ModelTags.from_dict(d.pop("tags"))

    updated_at = isoparse(d.pop("updatedAt"))

    workspace_id = d.pop("workspaceId")

    _custom = d.pop("custom", UNSET)
    custom: Union[Unset, ModelCustom]
    if isinstance(_custom, Unset):
        custom = UNSET
    else:
        custom = ModelCustom.from_dict(_custom)

    _dbt = d.pop("dbt", UNSET)
    dbt: Union[Unset, ModelDbt]
    if isinstance(_dbt, Unset):
        dbt = UNSET
    else:
        dbt = ModelDbt.from_dict(_dbt)

    _raw = d.pop("raw", UNSET)
    raw: Union[Unset, ModelRaw]
    if isinstance(_raw, Unset):
        raw = UNSET
    else:
        raw = ModelRaw.from_dict(_raw)

    _table = d.pop("table", UNSET)
    table: Union[Unset, ModelTable]
    if isinstance(_table, Unset):
        table = UNSET
    else:
        table = ModelTable.from_dict(_table)

    _visual = d.pop("visual", UNSET)
    visual: Union[Unset, ModelVisual]
    if isinstance(_visual, Unset):
        visual = UNSET
    else:
        visual = ModelVisual.from_dict(_visual)

    model = cls(
        created_at=created_at,
        id=id,
        is_schema=is_schema,
        name=name,
        primary_key=primary_key,
        query_type=query_type,
        slug=slug,
        source_id=source_id,
        syncs=syncs,
        tags=tags,
        updated_at=updated_at,
        workspace_id=workspace_id,
        custom=custom,
        dbt=dbt,
        raw=raw,
        table=table,
        visual=visual,
    )

    model.additional_properties = d
    return model

to_dict

Source code in prefect_hightouch/api_client/models/model.py
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def to_dict(self) -> Dict[str, Any]:
    created_at = self.created_at.isoformat()

    id = self.id
    is_schema = self.is_schema
    name = self.name
    primary_key = self.primary_key
    query_type = self.query_type
    slug = self.slug
    source_id = self.source_id
    syncs = self.syncs

    tags = self.tags.to_dict()

    updated_at = self.updated_at.isoformat()

    workspace_id = self.workspace_id
    custom: Union[Unset, Dict[str, Any]] = UNSET
    if not isinstance(self.custom, Unset):
        custom = self.custom.to_dict()

    dbt: Union[Unset, Dict[str, Any]] = UNSET
    if not isinstance(self.dbt, Unset):
        dbt = self.dbt.to_dict()

    raw: Union[Unset, Dict[str, Any]] = UNSET
    if not isinstance(self.raw, Unset):
        raw = self.raw.to_dict()

    table: Union[Unset, Dict[str, Any]] = UNSET
    if not isinstance(self.table, Unset):
        table = self.table.to_dict()

    visual: Union[Unset, Dict[str, Any]] = UNSET
    if not isinstance(self.visual, Unset):
        visual = self.visual.to_dict()

    field_dict: Dict[str, Any] = {}
    field_dict.update(self.additional_properties)
    field_dict.update(
        {
            "createdAt": created_at,
            "id": id,
            "isSchema": is_schema,
            "name": name,
            "primaryKey": primary_key,
            "queryType": query_type,
            "slug": slug,
            "sourceId": source_id,
            "syncs": syncs,
            "tags": tags,
            "updatedAt": updated_at,
            "workspaceId": workspace_id,
        }
    )
    if custom is not UNSET:
        field_dict["custom"] = custom
    if dbt is not UNSET:
        field_dict["dbt"] = dbt
    if raw is not UNSET:
        field_dict["raw"] = raw
    if table is not UNSET:
        field_dict["table"] = table
    if visual is not UNSET:
        field_dict["visual"] = visual

    return field_dict