# coding: utf-8 """ PeerTube The PeerTube API is built on HTTP(S) and is RESTful. You can use your favorite HTTP/REST library for your programming language to use PeerTube. The spec API is fully compatible with [openapi-generator](https://github.com/OpenAPITools/openapi-generator/wiki/API-client-generator-HOWTO) which generates a client SDK in the language of your choice - we generate some client SDKs automatically: - [Python](https://framagit.org/framasoft/peertube/clients/python) - [Go](https://framagit.org/framasoft/peertube/clients/go) - [Kotlin](https://framagit.org/framasoft/peertube/clients/kotlin) See the [REST API quick start](https://docs.joinpeertube.org/api/rest-getting-started) for a few examples of using the PeerTube API. # Authentication When you sign up for an account on a PeerTube instance, you are given the possibility to generate sessions on it, and authenticate there using an access token. Only __one access token can currently be used at a time__. ## Roles Accounts are given permissions based on their role. There are three roles on PeerTube: Administrator, Moderator, and User. See the [roles guide](https://docs.joinpeertube.org/admin/managing-users#roles) for a detail of their permissions. # Errors The API uses standard HTTP status codes to indicate the success or failure of the API call, completed by a [RFC7807-compliant](https://tools.ietf.org/html/rfc7807) response body. ``` HTTP 1.1 404 Not Found Content-Type: application/problem+json; charset=utf-8 { \"detail\": \"Video not found\", \"docs\": \"https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo\", \"status\": 404, \"title\": \"Not Found\", \"type\": \"about:blank\" } ``` We provide error `type` values for [a growing number of cases](https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/src/server/core-error-code.enum.ts), but it is still optional. Types are used to disambiguate errors that bear the same status code and are non-obvious: ``` HTTP 1.1 403 Forbidden Content-Type: application/problem+json; charset=utf-8 { \"detail\": \"Cannot get this video regarding follow constraints\", \"docs\": \"https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo\", \"status\": 403, \"title\": \"Forbidden\", \"type\": \"https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/does_not_respect_follow_constraints\" } ``` Here a 403 error could otherwise mean that the video is private or blocklisted. ### Validation errors Each parameter is evaluated on its own against a set of rules before the route validator proceeds with potential testing involving parameter combinations. Errors coming from validation errors appear earlier and benefit from a more detailed error description: ``` HTTP 1.1 400 Bad Request Content-Type: application/problem+json; charset=utf-8 { \"detail\": \"Incorrect request parameters: id\", \"docs\": \"https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo\", \"instance\": \"/api/v1/videos/9c9de5e8-0a1e-484a-b099-e80766180\", \"invalid-params\": { \"id\": { \"location\": \"params\", \"msg\": \"Invalid value\", \"param\": \"id\", \"value\": \"9c9de5e8-0a1e-484a-b099-e80766180\" } }, \"status\": 400, \"title\": \"Bad Request\", \"type\": \"about:blank\" } ``` Where `id` is the name of the field concerned by the error, within the route definition. `invalid-params..location` can be either 'params', 'body', 'header', 'query' or 'cookies', and `invalid-params..value` reports the value that didn't pass validation whose `invalid-params..msg` is about. ### Deprecated error fields Some fields could be included with previous versions. They are still included but their use is deprecated: - `error`: superseded by `detail` - `code`: superseded by `type` (which is now an URI) # Rate limits We are rate-limiting all endpoints of PeerTube's API. Custom values can be set by administrators: | Endpoint (prefix: `/api/v1`) | Calls | Time frame | |------------------------------|---------------|--------------| | `/*` | 50 | 10 seconds | | `POST /users/token` | 15 | 5 minutes | | `POST /users/register` | 2* | 5 minutes | | `POST /users/ask-send-verify-email` | 3 | 5 minutes | Depending on the endpoint, *failed requests are not taken into account. A service limit is announced by a `429 Too Many Requests` status code. You can get details about the current state of your rate limit by reading the following headers: | Header | Description | |-------------------------|------------------------------------------------------------| | `X-RateLimit-Limit` | Number of max requests allowed in the current time period | | `X-RateLimit-Remaining` | Number of remaining requests in the current time period | | `X-RateLimit-Reset` | Timestamp of end of current time period as UNIX timestamp | | `Retry-After` | Seconds to delay after the first `429` is received | # CORS This API features [Cross-Origin Resource Sharing (CORS)](https://fetch.spec.whatwg.org/), allowing cross-domain communication from the browser for some routes: | Endpoint | |------------------------- ---| | `/api/*` | | `/download/*` | | `/lazy-static/*` | | `/.well-known/webfinger` | In addition, all routes serving ActivityPub are CORS-enabled for all origins. The version of the OpenAPI document: 5.2.0 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. """ # noqa: E501 import unittest from peertube.models.video_details import VideoDetails class TestVideoDetails(unittest.TestCase): """VideoDetails unit test stubs""" def setUp(self): pass def tearDown(self): pass def make_instance(self, include_optional) -> VideoDetails: """Test VideoDetails include_option is a boolean, when False only required params are included, when True both required and optional params are included """ # uncomment below to create an instance of `VideoDetails` """ model = VideoDetails() if include_optional: return VideoDetails( id = 42, uuid = '9c9de5e8-0a1e-484a-b099-e80766180a6d', short_uuid = '2y84q2MQUMWPbiEcxNXMgC', is_live = True, created_at = '2017-10-01T10:52:46.396Z', published_at = '2018-10-01T10:52:46.396Z', updated_at = '2021-05-04T08:01:01.502Z', originally_published_at = '2010-10-01T10:52:46.396Z', category = peertube.models.video_constant_number_category.VideoConstantNumber-Category( id = 15, label = 'Science & Technology', ), licence = peertube.models.video_constant_number_licence.VideoConstantNumber-Licence( id = 2, label = 'Attribution - Share Alike', ), language = peertube.models.video_constant_string_language.VideoConstantString-Language( id = 'en', label = 'English', ), privacy = peertube.models.video_privacy_constant.VideoPrivacyConstant( id = 1, label = '', ), description = '**[Want to help to translate this video?](https://weblate.framasoft.org/projects/what-is-peertube-video/)**\r\n\r\n **Take back the control of your videos! [#JoinPeertube](https://joinpeertube.org)**\r\n*A decentralized video hosting network, based on fr... ', duration = 1419, is_local = True, name = 'What is PeerTube?', thumbnail_path = '/lazy-static/thumbnails/a65bc12f-9383-462e-81ae-8207e8b434ee.jpg', preview_path = '/lazy-static/previews/a65bc12f-9383-462e-81ae-8207e8b434ee.jpg', embed_path = '/videos/embed/a65bc12f-9383-462e-81ae-8207e8b434ee', views = 1337, likes = 42, dislikes = 7, nsfw = True, wait_transcoding = True, state = peertube.models.video_state_constant.VideoStateConstant( id = 1, label = '', ), scheduled_update = peertube.models.video_scheduled_update.VideoScheduledUpdate( privacy = 1, update_at = datetime.datetime.strptime('1975-12-30', '%Y-%m-%d').date(), ), blacklisted = True, blacklisted_reason = '', account = None, channel = None, user_history = peertube.models.video_user_history.Video_userHistory( current_time = 56, ), viewers = 56, description_path = '/api/v1/videos/9c9de5e8-0a1e-484a-b099-e80766180a6d/description', support = 'Please support our work on https://soutenir.framasoft.org/en/ <3', tags = ["flowers","gardening"], comments_enabled = True, download_enabled = True, input_file_updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), tracker_urls = ["https://peertube2.cpy.re/tracker/announce","wss://peertube2.cpy.re/tracker/socket"], files = [ peertube.models.video_file.VideoFile( id = 42, magnet_uri = 'magnet:?xt=urn:8:q6zgckec0l3o4gi7xhk0jcy075ua034p', resolution = peertube.models.video_resolution_constant.VideoResolutionConstant( id = 240, label = '240p', ), size = 56, torrent_url = '', torrent_download_url = '', file_url = '', file_download_url = '', fps = 1.337, metadata_url = '', ) ], streaming_playlists = [ null ] ) else: return VideoDetails( ) """ def testVideoDetails(self): """Test VideoDetails""" # inst_req_only = self.make_instance(include_optional=False) # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main()