sob.properties
This module defines classes for describing properties of a model.
Property
Property(
types: (
sob.abc.Types
| collections.abc.Sequence[
type | sob.properties.Property
]
| type
| sob.properties.Property
| sob._types.Undefined
| None
) = sob._types.UNDEFINED,
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
This is the base class for defining a property.
Attributes:
-
types
(sob.abc.Types | None
) –One or more types or property definitions. More than one types and/or property definitions results in a polymorphic interpretation wherein a value is un-marshalled in accordance with each type or property in the list (sequentially), until the value is un-marshalled without throwing a
TypeError
orValueError
. If the list of types and/or properties is exhausted without successfully un-marshalling the value, aTypeError
orValueError
error is raised. When types are sub-classes ofsob.Object
, each type is attempted, and of the resulting instances, the type resulting in the fewest extraneous attributes (attributes not corresponding to any metadata) is used.) -
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes.
Source code in sob/properties.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
StringProperty
StringProperty(
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
Bases: sob.properties.Property
, sob.abc.StringProperty
This class represents metadata describing a string property.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes.
Source code in sob/properties.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
DateProperty
DateProperty(
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None,
date2str: typing.Callable[
[datetime.date], str
] = sob.properties.DateProperty._date2str,
str2date: typing.Callable[
[str], datetime.date
] = sob.properties.DateProperty._str2date
)
Bases: sob.properties.Property
, sob.abc.DateProperty
This class represents metadata describing a date property.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes.
Parameters:
-
name
(str | None
, default:None
) – -
required
(bool
, default:False
) – -
versions
(str | sob.abc.Version | collections.abc.Iterable[str | sob.abc.Version] | None
, default:None
) – -
date2str
(typing.Callable[[datetime.date], str]
, default:sob.properties.DateProperty._date2str
) –A function, taking one argument (a python
date
json_object), and returning a date string in the desired format. The default isdatetime.date.isoformat
—returning an ISO-8601 compliant date string. -
str2date
(typing.Callable[[str], datetime.date]
, default:sob.properties.DateProperty._str2date
) –A function, taking one argument (a date string), and returning a python
date
object. By default, this isiso8601.iso8601.parse_date
.
Source code in sob/properties.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
DateTimeProperty
DateTimeProperty(
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None,
datetime2str: typing.Callable[
[datetime.datetime], str
] = sob.properties.DateTimeProperty._datetime2str,
str2datetime: typing.Callable[
[str], datetime.datetime
] = sob.properties.DateTimeProperty._str2datetime
)
Bases: sob.properties.Property
, sob.abc.DateTimeProperty
This class represents metadata describing a date property.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes.
Parameters:
-
name
(str | None
, default:None
) – -
required
(bool
, default:False
) – -
versions
(str | sob.abc.Version | collections.abc.Iterable[str | sob.abc.Version] | None
, default:None
) – -
datetime2str
(typing.Callable[[datetime.datetime], str]
, default:sob.properties.DateTimeProperty._datetime2str
) –A function, taking one argument (a python
datetime
json_object), and returning a date/time string in the desired format. The default isdatetime.datetime.isoformat
, returning an ISO-8601 compliant date/time string. -
str2datetime
(typing.Callable[[str], datetime.datetime]
, default:sob.properties.DateTimeProperty._str2datetime
) –A function, taking one argument (a datetime string), and returning a python
datetime.datetime
object. By default, this isiso8601.iso8601.parse_date
.
Source code in sob/properties.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
|
BytesProperty
BytesProperty(
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
Bases: sob.properties.Property
, sob.abc.BytesProperty
This class represents metadata describing a property with binary values.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes.
Source code in sob/properties.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
|
EnumeratedProperty
EnumeratedProperty(
types: (
sob.abc.Types
| collections.abc.Sequence[
type | sob.properties.Property
]
| type
| sob.properties.Property
| sob._types.Undefined
| None
) = sob._types.UNDEFINED,
values: (
collections.abc.Iterable[sob.abc.MarshallableTypes]
| None
) = None,
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
Bases: sob.properties.Property
, sob.abc.EnumeratedProperty
This class represents metadata describing a property having a finite, pre-determined, set of possible values.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes. -
values
(set[sob.abc.MarshallableTypes] | None
) –All possible values for this property.
Source code in sob/properties.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
NumberProperty
NumberProperty(
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
Bases: sob.properties.Property
, sob.abc.NumberProperty
This class represents metadata describing a property having numeric (decimal, float or integer) values.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes.
Source code in sob/properties.py
648 649 650 651 652 653 654 655 656 657 658 |
|
IntegerProperty
IntegerProperty(
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
Bases: sob.properties.Property
, sob.abc.IntegerProperty
This class represents metadata describing a property having integer values.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes.
Source code in sob/properties.py
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
|
BooleanProperty
BooleanProperty(
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
Bases: sob.properties.Property
, sob.abc.BooleanProperty
This class represents metadata describing a property having boolean values.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes.
Source code in sob/properties.py
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
|
ArrayProperty
ArrayProperty(
item_types: (
type
| collections.abc.Sequence[
type | sob.properties.Property
]
| sob._types.Undefined
| sob.abc.Types
| None
) = sob._types.UNDEFINED,
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
Bases: sob.properties.Property
, sob.abc.ArrayProperty
This class represents metadata describing a property accepting array (list/tuple) values.
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes. -
item_types
(sob.abc.Types | None
) –The type(s) of values/objects contained in the array. Similar to
sob.Property().types
, but applied to items in the array, not the array itself.
Source code in sob/properties.py
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
|
DictionaryProperty
DictionaryProperty(
value_types: (
type
| collections.abc.Sequence[
type | sob.properties.Property
]
| sob._types.Undefined
| sob.abc.Types
| None
) = sob._types.UNDEFINED,
name: str | None = None,
*,
required: bool = False,
versions: (
str
| sob.abc.Version
| collections.abc.Iterable[str | sob.abc.Version]
| None
) = None
)
Bases: sob.properties.Property
, sob.abc.DictionaryProperty
This class represents metadata describing a property accepting dictionary values (deserialized JSON objects without a pre-determined set of properties).
Attributes:
-
name
(str | None
) –The name of the property when loaded from or dumped into a JSON object. Specifying a
name
facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility functionsob.utilities.get_property_name
. -
required
(bool
) –If
True
, sob.validatewill raise a validation error if this property is missing (is
None`). -
versions
(collections.abc.Sequence[sob.abc.Version] | None
) –One or more version specifiers to which this property applies.
Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.
Versioning can be applied to a model's properties with
sob.version_model
. For example, one use would be within the__init__
method of ansob.Object
sub-class, in order to dynamically alter metadata based on version attributes. -
value_types
(sob.abc.Types | None
) –The type(s) of values/objects comprising the mapped values. Similar to
sob.Property().types
, but applied to values in the mapping/dictionary, not to the dictionary itself.
Source code in sob/properties.py
921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
|
has_mutable_types
This function returns True
if modification of the .types
member of a
property class or instance is permitted.
Parameters:
-
property
–
Source code in sob/properties.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|