|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Segment Public API |
| 5 | +
|
| 6 | + The Segment Public API helps you manage your Segment Workspaces and its resources. You can use the API to perform CRUD (create, read, update, delete) operations at no extra charge. This includes working with resources such as Sources, Destinations, Warehouses, Tracking Plans, and the Segment Destinations and Sources Catalogs. All CRUD endpoints in the API follow REST conventions and use standard HTTP methods. Different URL endpoints represent different resources in a Workspace. See the next sections for more information on how to use the Segment Public API. |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 58.13.0 |
| 9 | + |
| 10 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 11 | +
|
| 12 | + Do not edit the class manually. |
| 13 | +""" # noqa: E501 |
| 14 | + |
| 15 | + |
| 16 | +from __future__ import annotations |
| 17 | +import pprint |
| 18 | +import re # noqa: F401 |
| 19 | +import json |
| 20 | + |
| 21 | + |
| 22 | +from typing import Any, Dict, List, Optional |
| 23 | +from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist |
| 24 | +from segment_public_api.models.profile import Profile |
| 25 | + |
| 26 | +class AudiencePreviewEntitiesResult(BaseModel): |
| 27 | + """ |
| 28 | + Result membership object for an audience preview with `audienceType: USERS` or `audienceType: LINKED`. # noqa: E501 |
| 29 | + """ |
| 30 | + id: StrictStr = Field(..., description="The entities associated with the profile. Will only have a value if the audience preview has `audienceType: LINKED` and entities are referenced in the audience preview's definition.") |
| 31 | + id_property: StrictStr = Field(..., alias="idProperty", description="The entity primary key column name.") |
| 32 | + relationship_slug: StrictStr = Field(..., alias="relationshipSlug", description="The entity relationship slug.") |
| 33 | + properties: Optional[Dict[str, Any]] = Field(None, description="Entity properties.") |
| 34 | + entities: Optional[Dict[str, Any]] = Field(None, description="Related entities that are one level deeper will only be returned if those entities are referenced in the audience definition.") |
| 35 | + profiles: Optional[conlist(Profile)] = Field(None, description="Related list of profiles.") |
| 36 | + profiles_truncated: StrictBool = Field(..., alias="profilesTruncated", description="Indicates if only a subset of the profiles associated with the entity were returned.") |
| 37 | + __properties = ["id", "idProperty", "relationshipSlug", "properties", "entities", "profiles", "profilesTruncated"] |
| 38 | + |
| 39 | + class Config: |
| 40 | + """Pydantic configuration""" |
| 41 | + allow_population_by_field_name = True |
| 42 | + validate_assignment = True |
| 43 | + |
| 44 | + def to_str(self) -> str: |
| 45 | + """Returns the string representation of the model using alias""" |
| 46 | + return pprint.pformat(self.dict(by_alias=True)) |
| 47 | + |
| 48 | + def to_json(self) -> str: |
| 49 | + """Returns the JSON representation of the model using alias""" |
| 50 | + return json.dumps(self.to_dict()) |
| 51 | + |
| 52 | + @classmethod |
| 53 | + def from_json(cls, json_str: str) -> AudiencePreviewEntitiesResult: |
| 54 | + """Create an instance of AudiencePreviewEntitiesResult from a JSON string""" |
| 55 | + return cls.from_dict(json.loads(json_str)) |
| 56 | + |
| 57 | + def to_dict(self): |
| 58 | + """Returns the dictionary representation of the model using alias""" |
| 59 | + _dict = self.dict(by_alias=True, |
| 60 | + exclude={ |
| 61 | + }, |
| 62 | + exclude_none=True) |
| 63 | + # override the default output from pydantic by calling `to_dict()` of each item in profiles (list) |
| 64 | + _items = [] |
| 65 | + if self.profiles: |
| 66 | + for _item in self.profiles: |
| 67 | + if _item: |
| 68 | + _items.append(_item.to_dict()) |
| 69 | + _dict['profiles'] = _items |
| 70 | + return _dict |
| 71 | + |
| 72 | + @classmethod |
| 73 | + def from_dict(cls, obj: dict) -> AudiencePreviewEntitiesResult: |
| 74 | + """Create an instance of AudiencePreviewEntitiesResult from a dict""" |
| 75 | + if obj is None: |
| 76 | + return None |
| 77 | + |
| 78 | + if not isinstance(obj, dict): |
| 79 | + return AudiencePreviewEntitiesResult.parse_obj(obj) |
| 80 | + |
| 81 | + _obj = AudiencePreviewEntitiesResult.parse_obj({ |
| 82 | + "id": obj.get("id"), |
| 83 | + "id_property": obj.get("idProperty"), |
| 84 | + "relationship_slug": obj.get("relationshipSlug"), |
| 85 | + "properties": obj.get("properties"), |
| 86 | + "entities": obj.get("entities"), |
| 87 | + "profiles": [Profile.from_dict(_item) for _item in obj.get("profiles")] if obj.get("profiles") is not None else None, |
| 88 | + "profiles_truncated": obj.get("profilesTruncated") |
| 89 | + }) |
| 90 | + return _obj |
| 91 | + |
| 92 | + |
0 commit comments