catalog.api.views package#

Submodules#

catalog.api.views.audio_views module#

class catalog.api.views.audio_views.AudioViewSet(*args, **kwargs)#

Bases: MediaViewSet

Viewset for all endpoints pertaining to audio.

default_index = 'audio'#
get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

list(request, *_, **__)#
model_class#

alias of Audio

qa_index = 'search-qa-audio'#
query_serializer_class#

alias of AudioSearchRequestSerializer

related(request, identifier=None, *_, **__)#
report(*args, **kwargs)#
retrieve(request, *args, **kwargs)#
serializer_class#

alias of AudioSerializer

stats(*_, **__)#
thumbnail(request, *_, **__)#
waveform(*_, **__)#

catalog.api.views.health_views module#

exception catalog.api.views.health_views.ElasticsearchHealthcheckException(detail=None, code=None)#

Bases: APIException

status_code = 503#
class catalog.api.views.health_views.HealthCheck(**kwargs)#

Bases: APIView

Return a “200 OK” response if the server is running normally, 503 otherwise.

This endpoint is used in production to ensure that the server should receive traffic. If no response is provided, the server is deregistered from the load balancer and destroyed.

get(request: Request)#
swagger_schema = None#

catalog.api.views.image_views module#

class catalog.api.views.image_views.ImageViewSet(*args, **kwargs)#

Bases: MediaViewSet

Viewset for all endpoints pertaining to images.

OEMBED_HEADERS = {'User-Agent': 'OpenverseOEmbed/1.0.0 (https://wordpress.org/openverse)'}#
default_index = 'image'#
get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

list(request, *_, **__)#
model_class#

alias of Image

oembed(request, *_, **__)#
qa_index = 'search-qa-image'#
query_serializer_class#

alias of ImageSearchRequestSerializer

related(request, identifier=None, *_, **__)#
report(*args, **kwargs)#
retrieve(request, *args, **kwargs)#
serializer_class#

alias of ImageSerializer

stats(*_, **__)#
thumbnail(request, *_, **__)#
watermark(request, *_, **__)#

catalog.api.views.media_views module#

class catalog.api.views.media_views.MediaViewSet(*args, **kwargs)#

Bases: ReadOnlyModelViewSet

default_index = None#
get_db_results(results)#
get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

get_serializer_context()#

Extra context provided to the serializer class.

list(request, *_, **__)#
lookup_field = 'identifier'#
lookup_value_regex = '[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}'#
model_class = None#
pagination_class#

alias of StandardPagination

qa_index = None#
query_serializer_class = None#
related(request, identifier=None, *_, **__)#
report(request, *_, **__)#
stats(*_, **__)#
swagger_schema#

alias of CustomAutoSchema

thumbnail(image_url, request, *_, **__)#

catalog.api.views.oauth2_views module#

class catalog.api.views.oauth2_views.CheckRates(**kwargs)#

Bases: APIView

get(request, format=None)#
key_info_bash = '\ncurl \\\n  -H "Authorization: Bearer DLBYIcfnKfolaXKcmMC8RIDCavc2hW" \\\n  http://api.openverse.engineering/v1/rate_limit/\n'#
key_info_description = '\nkey_info is an API endpoint to get information about your API key.\n\nYou can use this endpoint to get information about your API key such as\n`requests_this_minute`, `requests_today`, and `rate_limit_model`.\n\n> **NOTE:** If you get a 403 Forbidden response, it means your access token has expired.\n\n\nYou can refer to the cURL request samples for examples on how to consume this\nendpoint.\n'#
key_info_response = {'200': {'description': 'OK', 'examples': {'application/json': {'rate_limit_model': 'enhanced', 'requests_this_minute': 2, 'requests_today': 40}}, 'schema': <class 'catalog.api.serializers.oauth2_serializers.OAuth2KeyInfo'>}, '403': {'description': 'Forbidden', 'examples': {'application/json': 'Forbidden'}, 'schema': <class 'catalog.api.serializers.error_serializers.ForbiddenErrorSerializer'>}, '500': {'description': 'Internal Server Error', 'examples': {'application/json': 'Unknown API key rate limit type'}, 'schema': <class 'catalog.api.serializers.error_serializers.InternalServerErrorSerializer'>}}#
swagger_schema#

alias of CustomAutoSchema

throttle_classes = (<class 'catalog.api.utils.throttle.OnePerSecond'>,)#
class catalog.api.views.oauth2_views.Register(**kwargs)#

Bases: APIView

post(request, format=None)#
register_api_oauth2_bash = '\n# Register for a key\ncurl \\\n  -X POST \\\n  -H "Content-Type: application/json" \\\n  -d \'{"name": "My amazing project", "description": "To access Openverse API", "email": "user@example.com"}\' \\\n  https://api.openverse.engineering/v1/auth_tokens/register/\n'#
register_api_oauth2_description = "\nregister_api_oauth2 is an API endpoint to register access to the API via OAuth2.\n\nUpon registering, you will receive a `client_id` and `client_secret`, which you can then\nuse to authenticate using the standard OAuth2 Client Credentials flow. See the Register\nand Authenticate section for instructions on registering access to the API via OAuth2.\n\n> **WARNING:** You must keep `client_secret` confidential, as anybody with your\n> `client_secret` can impersonate your application.\n\nAuthenticated users have higher rate limits than anonymous users. Additionally, by\nidentifying yourself, you can request Openverse to adjust your personal rate limit\ndepending on your organization's needs.\n\n\nYou can refer to the cURL request samples for examples on how to consume this\nendpoint.\n"#
register_api_oauth2_request = {'example': {'description': 'To access Openverse API', 'email': 'user@example.com', 'name': 'My amazing project'}, 'properties': {'description': {'description': 'A description of what you are trying to achieve with your project using the API. Please provide as much detail as possible!', 'maxLength': 10000, 'minLength': 1, 'title': 'Description', 'type': 'string'}, 'email': {'description': 'A valid email that we can reach you at if we have any questions about your use case or data consumption.', 'format': 'email', 'maxLength': 254, 'minLength': 1, 'title': 'Email', 'type': 'string'}, 'name': {'description': 'A unique human-readable name for your application or project requiring access to the Openverse API.', 'maxLength': 150, 'minLength': 1, 'title': 'Name', 'type': 'string'}}, 'required': ['name', 'description', 'email'], 'type': 'object'}#
register_api_oauth2_response = {'201': {'description': 'OK', 'examples': {'application/json': {'client_id': 'pm8GMaIXIhkjQ4iDfXLOvVUUcIKGYRnMlZYApbda', 'client_secret': 'YhVjvIBc7TuRJSvO2wIi344ez5SEreXLksV7GjalLiKDpxfbiM8qfUb5sNvcwFOhBUVzGNdzmmHvfyt6yU3aGrN6TAbMW8EOkRMOwhyXkN1iDetmzMMcxLVELf00BR2e', 'name': 'My amazing project'}}, 'schema': <class 'catalog.api.serializers.oauth2_serializers.OAuth2RegistrationSuccessful'>}}#
swagger_schema#

alias of CustomAutoSchema

throttle_classes = (<class 'catalog.api.utils.throttle.TenPerDay'>,)#
class catalog.api.views.oauth2_views.VerifyEmail(**kwargs)#

Bases: APIView

Enable a user’s OAuth2 key upon visiting the emailed verification link.

get(request, code, format=None)#
swagger_schema = None#

Module contents#