From eb95f5ee856e78ceb7874762e69d65e1bc65d931 Mon Sep 17 00:00:00 2001 From: szekelyzol Date: Tue, 16 Apr 2024 14:25:43 +0000 Subject: [PATCH] Add API rate limiting to the OAS --- .openapi-generator/FILES | 2 + .../oas_apivideo.yaml-defaut-cli.sha256 | 2 +- README.md | 1 + Sources/APIs/VideosAPI.swift | 4 ++ Sources/Models/TooManyRequests.swift | 43 +++++++++++++++++++ .../payloads/videos/upload/responses/429.json | 5 +++ .../uploadWithUploadToken/responses/429.json | 5 +++ docs/TooManyRequests.md | 12 ++++++ 8 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 Sources/Models/TooManyRequests.swift create mode 100644 Tests/TestResources/payloads/videos/upload/responses/429.json create mode 100644 Tests/TestResources/payloads/videos/uploadWithUploadToken/responses/429.json create mode 100644 docs/TooManyRequests.md diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index ccad4c1..1f69d82 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -24,6 +24,7 @@ Sources/Models/Environment.swift Sources/Models/Metadata.swift Sources/Models/NotFound.swift Sources/Models/RefreshTokenPayload.swift +Sources/Models/TooManyRequests.swift Sources/Models/Video.swift Sources/Models/VideoAssets.swift Sources/Models/VideoSource.swift @@ -43,6 +44,7 @@ docs/BadRequest.md docs/Metadata.md docs/NotFound.md docs/RefreshTokenPayload.md +docs/TooManyRequests.md docs/Video.md docs/VideoAssets.md docs/VideoSource.md diff --git a/.openapi-generator/oas_apivideo.yaml-defaut-cli.sha256 b/.openapi-generator/oas_apivideo.yaml-defaut-cli.sha256 index ee88061..644fa0c 100644 --- a/.openapi-generator/oas_apivideo.yaml-defaut-cli.sha256 +++ b/.openapi-generator/oas_apivideo.yaml-defaut-cli.sha256 @@ -1 +1 @@ -5678c55d78ebee898e89b47215b59cb855d1997cdda9202292548ec786d8e9f5 \ No newline at end of file +d7b342ceb1a4805da9e3d6355384e34c1a99e1300d01cac3ae3218c5738f11f1 \ No newline at end of file diff --git a/README.md b/README.md index 7f67aad..bcb92e0 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ Method | HTTP request | Description - [Metadata](https://github.com/apivideo/api.video-swift-uploader/blob/main/docs/Metadata.md) - [NotFound](https://github.com/apivideo/api.video-swift-uploader/blob/main/docs/NotFound.md) - [RefreshTokenPayload](https://github.com/apivideo/api.video-swift-uploader/blob/main/docs/RefreshTokenPayload.md) + - [TooManyRequests](https://github.com/apivideo/api.video-swift-uploader/blob/main/docs/TooManyRequests.md) - [Video](https://github.com/apivideo/api.video-swift-uploader/blob/main/docs/Video.md) - [VideoAssets](https://github.com/apivideo/api.video-swift-uploader/blob/main/docs/VideoAssets.md) - [VideoSource](https://github.com/apivideo/api.video-swift-uploader/blob/main/docs/VideoSource.md) diff --git a/Sources/APIs/VideosAPI.swift b/Sources/APIs/VideosAPI.swift index 925add5..ae9038e 100644 --- a/Sources/APIs/VideosAPI.swift +++ b/Sources/APIs/VideosAPI.swift @@ -113,6 +113,7 @@ The latter allows you to split a video source into X chunks and send those chunk Once all chunks have been sent, they are reaggregated to one source file. The video source is considered as "completely sent" when the "last" chunk is sent (i.e., the chunk that "completes" the upload). + - responseHeaders: [X-RateLimit-Limit(Int), X-RateLimit-Remaining(Int), X-RateLimit-Retry-After(Int)] - parameter videoId: (path) Enter the videoId you want to use to upload your video. - parameter file: (form) The path to the video you would like to upload. The path must be local. If you want to use a video from an online source, you must use the \\\"/videos\\\" endpoint and add the \\\"source\\\" parameter when you create a new video. - parameter chunkId: chunk or part id. If nil, it is not add to the request. @@ -171,6 +172,7 @@ The latter allows you to split a video source into X chunks and send those chunk Once all chunks have been sent, they are reaggregated to one source file. The video source is considered as "completely sent" when the "last" chunk is sent (i.e., the chunk that "completes" the upload). + - responseHeaders: [X-RateLimit-Limit(Int), X-RateLimit-Remaining(Int), X-RateLimit-Retry-After(Int)] - parameter videoId: (path) Enter the videoId you want to use to upload your video. - parameter file: (form) The path to the video you would like to upload. The path must be local. If you want to use a video from an online source, you must use the \\\"/videos\\\" endpoint and add the \\\"source\\\" parameter when you create a new video. - parameter chunkId: chunk or part id. If nil, it is not add to the request. @@ -315,6 +317,7 @@ The latter allows you to split a video source into X chunks and send those chunk Upload with an delegated upload token - POST /upload - This method allows you to send a video using an upload token. Upload tokens are especially useful when the upload is done from the client side. If you want to upload a video from your server-side application, you'd better use the [standard upload method](#upload). + - responseHeaders: [X-RateLimit-Limit(Int), X-RateLimit-Remaining(Int), X-RateLimit-Retry-After(Int)] - parameter token: (query) The unique identifier for the token you want to use to upload a video. - parameter file: (form) The path to the video you want to upload. - parameter chunkId: chunk or part id. If nil, it is not add to the request. @@ -358,6 +361,7 @@ The latter allows you to split a video source into X chunks and send those chunk Upload with an delegated upload token - POST /upload - This method allows you to send a video using an upload token. Upload tokens are especially useful when the upload is done from the client side. If you want to upload a video from your server-side application, you'd better use the [standard upload method](#upload). + - responseHeaders: [X-RateLimit-Limit(Int), X-RateLimit-Remaining(Int), X-RateLimit-Retry-After(Int)] - parameter token: (query) The unique identifier for the token you want to use to upload a video. - parameter file: (form) The path to the video you want to upload. - parameter chunkId: chunk or part id. If nil, it is not add to the request. diff --git a/Sources/Models/TooManyRequests.swift b/Sources/Models/TooManyRequests.swift new file mode 100644 index 0000000..62133ba --- /dev/null +++ b/Sources/Models/TooManyRequests.swift @@ -0,0 +1,43 @@ +// +// TooManyRequests.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if canImport(AnyCodable) +import AnyCodable +#endif + +public struct TooManyRequests: Codable, Hashable { + + /** A link to the error documentation. */ + public var type: String? + /** A description of the error that occurred. */ + public var title: String? + /** The HTTP status code. */ + public var status: Int? + + public init(type: String? = nil, title: String? = nil, status: Int? = nil) { + self.type = type + self.title = title + self.status = status + } + + public enum CodingKeys: String, CodingKey, CaseIterable { + case type + case title + case status + } + + // Encodable protocol methods + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(type, forKey: .type) + try container.encodeIfPresent(title, forKey: .title) + try container.encodeIfPresent(status, forKey: .status) + } +} + diff --git a/Tests/TestResources/payloads/videos/upload/responses/429.json b/Tests/TestResources/payloads/videos/upload/responses/429.json new file mode 100644 index 0000000..d312e2b --- /dev/null +++ b/Tests/TestResources/payloads/videos/upload/responses/429.json @@ -0,0 +1,5 @@ +{ + "type" : "https://docs.api.video/reference/too-many-requests", + "title" : "Too many requests.", + "status" : 429 +} \ No newline at end of file diff --git a/Tests/TestResources/payloads/videos/uploadWithUploadToken/responses/429.json b/Tests/TestResources/payloads/videos/uploadWithUploadToken/responses/429.json new file mode 100644 index 0000000..d312e2b --- /dev/null +++ b/Tests/TestResources/payloads/videos/uploadWithUploadToken/responses/429.json @@ -0,0 +1,5 @@ +{ + "type" : "https://docs.api.video/reference/too-many-requests", + "title" : "Too many requests.", + "status" : 429 +} \ No newline at end of file diff --git a/docs/TooManyRequests.md b/docs/TooManyRequests.md new file mode 100644 index 0000000..e010de3 --- /dev/null +++ b/docs/TooManyRequests.md @@ -0,0 +1,12 @@ +# TooManyRequests + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | A link to the error documentation. | [optional] +**title** | **String** | A description of the error that occurred. | [optional] +**status** | **Int** | The HTTP status code. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +