|
| 1 | +# Copyright 2024 Palantir Technologies, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +from __future__ import annotations |
| 17 | + |
| 18 | +from typing import Optional |
| 19 | +from typing import cast |
| 20 | + |
| 21 | +import pydantic |
| 22 | + |
| 23 | +from foundry.v2.core.models._display_name import DisplayName |
| 24 | +from foundry.v2.ontologies.models._interface_shared_property_type_dict import ( |
| 25 | + InterfaceSharedPropertyTypeDict, |
| 26 | +) # NOQA |
| 27 | +from foundry.v2.ontologies.models._object_property_type import ObjectPropertyType |
| 28 | +from foundry.v2.ontologies.models._shared_property_type_api_name import ( |
| 29 | + SharedPropertyTypeApiName, |
| 30 | +) # NOQA |
| 31 | +from foundry.v2.ontologies.models._shared_property_type_rid import SharedPropertyTypeRid |
| 32 | + |
| 33 | + |
| 34 | +class InterfaceSharedPropertyType(pydantic.BaseModel): |
| 35 | + """ |
| 36 | + A shared property type with an additional field to indicate whether the property must be included on every |
| 37 | + object type that implements the interface, or whether it is optional. |
| 38 | + """ |
| 39 | + |
| 40 | + rid: SharedPropertyTypeRid |
| 41 | + |
| 42 | + api_name: SharedPropertyTypeApiName = pydantic.Field(alias=str("apiName")) # type: ignore[literal-required] |
| 43 | + |
| 44 | + display_name: DisplayName = pydantic.Field(alias=str("displayName")) # type: ignore[literal-required] |
| 45 | + |
| 46 | + description: Optional[str] = None |
| 47 | + |
| 48 | + """A short text that describes the SharedPropertyType.""" |
| 49 | + |
| 50 | + data_type: ObjectPropertyType = pydantic.Field(alias=str("dataType")) # type: ignore[literal-required] |
| 51 | + |
| 52 | + required: bool |
| 53 | + |
| 54 | + """Whether each implementing object type must declare an implementation for this property.""" |
| 55 | + |
| 56 | + model_config = {"extra": "allow", "populate_by_name": True} |
| 57 | + |
| 58 | + def to_dict(self) -> InterfaceSharedPropertyTypeDict: |
| 59 | + """Return the dictionary representation of the model using the field aliases.""" |
| 60 | + return cast( |
| 61 | + InterfaceSharedPropertyTypeDict, self.model_dump(by_alias=True, exclude_none=True) |
| 62 | + ) |
0 commit comments