schema_salad.avro.schema ======================== .. py:module:: schema_salad.avro.schema .. autoapi-nested-parse:: Contains the Schema classes. A schema may be one of: A record, mapping field names to field value data; An enum, containing one of a small set of symbols; An array of values, all of the same schema; A map of values, all of the same schema; A union of other schemas; A unicode string; A 32-bit signed int; A 64-bit signed long; A 32-bit floating-point float; A 64-bit floating-point double; A boolean; or Null. Attributes ---------- .. autoapisummary:: schema_salad.avro.schema.PRIMITIVE_TYPES schema_salad.avro.schema.NAMED_TYPES schema_salad.avro.schema.VALID_TYPES schema_salad.avro.schema.SCHEMA_RESERVED_PROPS schema_salad.avro.schema.JsonDataType schema_salad.avro.schema.AtomicPropType schema_salad.avro.schema.PropType schema_salad.avro.schema.PropsType schema_salad.avro.schema.FIELD_RESERVED_PROPS schema_salad.avro.schema.VALID_FIELD_SORT_ORDERS Exceptions ---------- .. autoapisummary:: schema_salad.avro.schema.AvroException schema_salad.avro.schema.SchemaParseException Classes ------- .. autoapisummary:: schema_salad.avro.schema.Schema schema_salad.avro.schema.Name schema_salad.avro.schema.Names schema_salad.avro.schema.NamedSchema schema_salad.avro.schema.Field schema_salad.avro.schema.PrimitiveSchema schema_salad.avro.schema.EnumSchema schema_salad.avro.schema.ArraySchema schema_salad.avro.schema.MapSchema schema_salad.avro.schema.NamedMapSchema schema_salad.avro.schema.UnionSchema schema_salad.avro.schema.NamedUnionSchema schema_salad.avro.schema.RecordSchema Functions --------- .. autoapisummary:: schema_salad.avro.schema.get_other_props schema_salad.avro.schema.make_avsc_object schema_salad.avro.schema.is_subtype Module Contents --------------- .. py:data:: PRIMITIVE_TYPES :value: ('null', 'boolean', 'string', 'int', 'long', 'float', 'double') .. py:data:: NAMED_TYPES :value: ('enum', 'record') .. py:data:: VALID_TYPES :value: ('null', 'boolean', 'string', 'int', 'long', 'float', 'double', 'enum', 'record', 'array',... .. py:data:: SCHEMA_RESERVED_PROPS :value: ('type', 'name', 'namespace', 'fields', 'items', 'names', 'symbols', 'values', 'doc') .. py:type:: JsonDataType :canonical: Any .. py:type:: AtomicPropType :canonical: Union[None, str, int, float, bool, 'Schema', list[str], list['Field']] .. py:type:: PropType :canonical: AtomicPropType | dict[str, AtomicPropType] | list[dict[str, AtomicPropType]] .. py:type:: PropsType :canonical: dict[str, PropType | None] .. py:data:: FIELD_RESERVED_PROPS :value: ('default', 'name', 'doc', 'order', 'type') .. py:data:: VALID_FIELD_SORT_ORDERS :value: ('ascending', 'descending', 'ignore') .. py:exception:: AvroException(msg, sl = None, children = None, bullet_for_children = '', detailed_message = None) Bases: :py:obj:`schema_salad.exceptions.SchemaException` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.AvroException :parts: 1 Indicates error with the provided schema definition. .. py:exception:: SchemaParseException(msg, sl = None, children = None, bullet_for_children = '', detailed_message = None) Bases: :py:obj:`AvroException` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.SchemaParseException :parts: 1 Indicates error with the provided schema definition. .. py:class:: Schema(atype, other_props = None) Base class for all Schema classes. .. py:attribute:: type .. py:property:: props :type: PropsType .. py:method:: get_prop(key) Retrieve a property from the Schema. .. py:method:: set_prop(key, value) Set a Schema property. .. py:class:: Name(name_attr = None, space_attr = None, default_space = None) Class to describe Avro name. .. py:property:: fullname :type: str | None Retrieve the computed full name. .. py:method:: get_space() Back out a namespace from full name. .. py:class:: Names(default_namespace = None) Track name set and default namespace during parsing. .. py:attribute:: names :type: dict[str, NamedSchema] .. py:attribute:: default_namespace :value: None .. py:method:: has_name(name_attr, space_attr) Test if the given namespace is stored. .. py:method:: get_name(name_attr, space_attr) Fetch the stored schema for the given namespace. .. py:method:: add_name(name_attr, space_attr, new_schema) Add a new schema object to the name set. :param name_attr: name value read in schema :param space_attr: namespace value read in schema. :returns: the Name that was just added. .. py:class:: NamedSchema(atype, name, namespace = None, names = None, other_props = None) Bases: :py:obj:`Schema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.NamedSchema :parts: 1 Named Schemas specified in NAMED_TYPES. .. py:property:: name :type: str .. py:class:: Field(atype, name, has_default, default = None, order = None, names = None, doc = None, other_props = None) .. py:attribute:: type .. py:attribute:: name .. py:property:: default :type: Any | None Return the default value, if any. .. py:method:: get_prop(key) Retrieve a property from the Field. .. py:method:: set_prop(key, value) Set a Field property. .. py:class:: PrimitiveSchema(atype, other_props = None) Bases: :py:obj:`Schema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.PrimitiveSchema :parts: 1 Valid primitive types are in PRIMITIVE_TYPES. .. py:attribute:: fullname .. py:class:: EnumSchema(name, namespace, symbols, names = None, doc = None, other_props = None) Bases: :py:obj:`NamedSchema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.EnumSchema :parts: 1 Named Schemas specified in NAMED_TYPES. .. py:property:: symbols :type: list[str] Retrieve the list of symbols. .. py:class:: ArraySchema(items, names, other_props = None) Bases: :py:obj:`Schema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.ArraySchema :parts: 1 Avro array schema class. .. py:property:: items :type: Schema Avro schema describing the array items' type. .. py:class:: MapSchema(values, names, other_props = None) Bases: :py:obj:`Schema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.MapSchema :parts: 1 Avro map schema class. .. py:property:: values :type: Schema Avro schema describing the map values' type. .. py:class:: NamedMapSchema(values, names, name, namespace = None, doc = None, other_props = None) Bases: :py:obj:`NamedSchema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.NamedMapSchema :parts: 1 Avro named map schema class. .. py:property:: values :type: Schema Avro schema describing the map values' type. .. py:class:: UnionSchema(schemas, names) Bases: :py:obj:`Schema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.UnionSchema :parts: 1 Avro union schema class. .. py:property:: schemas :type: list[Schema] Avro schemas composing the Union type. .. py:class:: NamedUnionSchema(schemas, names, name, namespace = None, doc = None) Bases: :py:obj:`NamedSchema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.NamedUnionSchema :parts: 1 Avro named union schema class. .. py:property:: schemas :type: list[Schema] Retrieve the list of schemas. .. py:class:: RecordSchema(name, namespace, fields, names, schema_type = 'record', doc = None, other_props = None) Bases: :py:obj:`NamedSchema` .. autoapi-inheritance-diagram:: schema_salad.avro.schema.RecordSchema :parts: 1 Named Schemas specified in NAMED_TYPES. .. py:method:: make_field_objects(field_data, names) :staticmethod: We're going to need to make message parameters too. .. py:property:: fields :type: list[Field] Retrieve the fields list. .. py:function:: get_other_props(all_props, reserved_props) Retrieve the non-reserved properties from a dictionary of properties. :param reserved_props: The set of reserved properties to exclude .. py:function:: make_avsc_object(json_data, names = None) Build Avro Schema from data parsed out of JSON string. :param names: A Name object (tracks seen names and default space) .. py:function:: is_subtype(types, existing, new) Check if a new type specification is compatible with an existing type spec.