catalog.api.serializers package#

Submodules#

catalog.api.serializers.audio_serializers module#

class catalog.api.serializers.audio_serializers.AudioReportRequestSerializer(*args, **kwargs)#

Bases: MediaReportRequestSerializer

class Meta#

Bases: Meta

model#

alias of AudioReport

class catalog.api.serializers.audio_serializers.AudioSearchRequestSerializer(*args, **kwargs)#

Bases: MediaSearchRequestSourceSerializer, MediaSearchRequestSerializer

Parse and validate search query string parameters.

fields_names = ['q', 'license', 'license_type', 'creator', 'tags', 'title', 'filter_dead', 'extension', 'mature', 'qa', 'page_size', 'page', 'source', 'excluded_source', 'category', 'length']#

Keep the fields names in sync with the actual fields below as this list is used to generate Swagger documentation.

property needs_db: bool#
class catalog.api.serializers.audio_serializers.AudioSearchSerializer(*args, **kwargs)#

Bases: MediaSearchSerializer

The full audio search response.

This serializer is purely representational and not actually used to serialize the response.

class catalog.api.serializers.audio_serializers.AudioSerializer(*args, **kwargs)#

Bases: MediaHyperlinksSerializer, MediaSerializer

A single audio file. Used in search results.

class Meta#

Bases: object

fields = ['id', 'title', 'indexed_on', 'foreign_landing_url', 'url', 'creator', 'creator_url', 'license', 'license_version', 'license_url', 'provider', 'source', 'category', 'genres', 'filesize', 'filetype', 'tags', 'alt_files', 'attribution', 'fields_matched', 'mature', 'audio_set', 'duration', 'bit_rate', 'sample_rate', 'thumbnail', 'detail_url', 'related_url', 'waveform', 'peaks']#

Keep the fields names in sync with the actual fields below as this list is used to generate Swagger documentation.

model#

alias of Audio

get_peaks(obj) list[int]#
needs_db = True#

whether the serializer needs fields from the DB to process results

to_representation(instance)#

Object instance -> Dict of primitive datatypes.

class catalog.api.serializers.audio_serializers.AudioSetSerializer(*args, **kwargs)#

Bases: ModelSerializer

An audio set, rendered as a part of the AudioSerializer output.

class Meta#

Bases: object

fields = ['title', 'foreign_landing_url', 'creator', 'creator_url', 'url', 'filesize', 'filetype']#
model#

alias of AudioSet

class catalog.api.serializers.audio_serializers.AudioWaveformSerializer(*args, **kwargs)#

Bases: Serializer

static get_len(obj) int#

catalog.api.serializers.error_serializers module#

These serializers handle error responses sent by API endpoints.

Reference for exception handling in Django REST Framework:

https://www.django-rest-framework.org/api-guide/exceptions/

class catalog.api.serializers.error_serializers.ForbiddenErrorSerializer(*args, **kwargs)#

Bases: Serializer

Returned if access to requested content is forbidden.

class catalog.api.serializers.error_serializers.InputErrorSerializer(*args, **kwargs)#

Bases: Serializer

Returned if invalid query parameters are passed.

class catalog.api.serializers.error_serializers.InternalServerErrorSerializer(*args, **kwargs)#

Bases: Serializer

Returned if the request could not be processed.

class catalog.api.serializers.error_serializers.NotFoundErrorSerializer(*args, **kwargs)#

Bases: Serializer

Returned if the requested content could not be found.

catalog.api.serializers.image_serializers module#

class catalog.api.serializers.image_serializers.ImageReportRequestSerializer(*args, **kwargs)#

Bases: MediaReportRequestSerializer

class Meta#

Bases: Meta

model#

alias of ImageReport

class catalog.api.serializers.image_serializers.ImageSearchRequestSerializer(*args, **kwargs)#

Bases: MediaSearchRequestSourceSerializer, MediaSearchRequestSerializer

Parse and validate search query string parameters.

fields_names = ['q', 'license', 'license_type', 'creator', 'tags', 'title', 'filter_dead', 'extension', 'mature', 'qa', 'page_size', 'page', 'source', 'excluded_source', 'category', 'aspect_ratio', 'size']#

Keep the fields names in sync with the actual fields below as this list is used to generate Swagger documentation.

class catalog.api.serializers.image_serializers.ImageSearchSerializer(*args, **kwargs)#

Bases: MediaSearchSerializer

The full image search response.

This serializer is purely representational and not actually used to serialize the response.

class catalog.api.serializers.image_serializers.ImageSerializer(*args, **kwargs)#

Bases: MediaHyperlinksSerializer, MediaSerializer

A single image. Used in search results.

class Meta#

Bases: object

fields = ['id', 'title', 'indexed_on', 'foreign_landing_url', 'url', 'creator', 'creator_url', 'license', 'license_version', 'license_url', 'provider', 'source', 'category', 'filesize', 'filetype', 'tags', 'attribution', 'fields_matched', 'mature', 'height', 'width', 'thumbnail', 'detail_url', 'related_url']#

Keep the fields names in sync with the actual fields below as this list is used to generate Swagger documentation.

model#

alias of Image

needs_db = True#

whether the serializer needs fields from the DB to process results

class catalog.api.serializers.image_serializers.OembedRequestSerializer(*args, **kwargs)#

Bases: Serializer

Parse and validate Oembed parameters.

static validate_url(value)#
class catalog.api.serializers.image_serializers.OembedSerializer(*args, **kwargs)#

Bases: BaseModelSerializer

The embedded content from a specified image URL.

This is essentially an ImageSerializer with some changes to match the oEmbed spec: https://oembed.com.

class Meta#

Bases: object

fields = ['version', 'type', 'width', 'height', 'title', 'author_name', 'author_url', 'license_url']#
model#

alias of Image

get_height(obj) int#
get_width(obj) int#
class catalog.api.serializers.image_serializers.WatermarkRequestSerializer(*args, **kwargs)#

Bases: Serializer

catalog.api.serializers.media_serializers module#

class catalog.api.serializers.media_serializers.MediaReportRequestSerializer(*args, **kwargs)#

Bases: ModelSerializer

class Meta#

Bases: object

fields = ['identifier', 'reason', 'description']#
model = None#
read_only_fields = ['identifier']#
validate(attrs)#
class catalog.api.serializers.media_serializers.MediaSearchRequestSerializer(*args, **kwargs)#

Bases: Serializer

This serializer parses and validates search query string parameters.

class DeprecatedParam(original, successor)#

Bases: tuple

original#

Alias for field number 0

successor#

Alias for field number 1

deprecated_params = [DeprecatedParam(original='li', successor='license'), DeprecatedParam(original='lt', successor='license_type'), DeprecatedParam(original='pagesize', successor='page_size'), DeprecatedParam(original='provider', successor='source')]#
fields_names = ['q', 'license', 'license_type', 'creator', 'tags', 'title', 'filter_dead', 'extension', 'mature', 'qa', 'page_size', 'page']#

Keep the fields names in sync with the actual fields below as this list is used to generate Swagger documentation.

property needs_db: bool#
validate(data)#
validate_creator(value)#
static validate_extension(value)#
static validate_license(value)#

Check whether license is a valid license code.

static validate_license_type(value)#

Check whether license type is a known collection of licenses.

validate_page_size(value)#
validate_q(value)#
validate_tags(value)#
validate_title(value)#
validate_unstable__sort_by(value)#
validate_unstable__sort_dir(value)#
class catalog.api.serializers.media_serializers.MediaSearchSerializer(*args, **kwargs)#

Bases: Serializer

This serializer serializes the full media search response.

The class should be inherited by all individual media serializers.

class catalog.api.serializers.media_serializers.MediaSerializer(*args, **kwargs)#

Bases: BaseModelSerializer

This serializer serializes a single media file.

The class should be inherited by all individual media serializers.

class Meta#

Bases: object

fields = ['id', 'indexed_on', 'title', 'foreign_landing_url', 'url', 'creator', 'creator_url', 'license', 'license_version', 'license_url', 'provider', 'source', 'category', 'filesize', 'filetype', 'tags', 'attribution', 'fields_matched', 'mature']#

Keep the fields names in sync with the actual fields below as this list is used to generate Swagger documentation.

model#

alias of AbstractMedia

needs_db = False#

whether the serializer needs fields from the DB to process results

to_representation(*args, **kwargs)#

Object instance -> Dict of primitive datatypes.

class catalog.api.serializers.media_serializers.MediaThumbnailRequestSerializer(*args, **kwargs)#

Bases: Serializer

This serializer parses and validates thumbnail query string parameters.

validate(data)#
class catalog.api.serializers.media_serializers.TagSerializer(*args, **kwargs)#

Bases: Serializer

This output serializer serializes a singular tag.

catalog.api.serializers.media_serializers.get_search_request_source_serializer(media_type)#

catalog.api.serializers.oauth2_serializers module#

class catalog.api.serializers.oauth2_serializers.OAuth2KeyInfo(*args, **kwargs)#

Bases: Serializer

class catalog.api.serializers.oauth2_serializers.OAuth2RegistrationSerializer(*args, **kwargs)#

Bases: ModelSerializer

class Meta#

Bases: object

fields = ('name', 'description', 'email')#
model#

alias of OAuth2Registration

class catalog.api.serializers.oauth2_serializers.OAuth2RegistrationSuccessful(*args, **kwargs)#

Bases: ModelSerializer

class Meta#

Bases: object

fields = ('name', 'client_id', 'client_secret')#
model#

alias of Application

catalog.api.serializers.provider_serializers module#

class catalog.api.serializers.provider_serializers.ProviderSerializer(*args, **kwargs)#

Bases: ModelSerializer

class Meta#

Bases: object

fields = ['source_name', 'display_name', 'source_url', 'logo_url', 'media_count']#
model#

alias of ContentProvider

get_media_count(obj) int#

Module contents#