Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API rate limiting to the OAS #88

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .openapi-generator/oas_apivideo.yaml-defaut-cli.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5678c55d78ebee898e89b47215b59cb855d1997cdda9202292548ec786d8e9f5
d7b342ceb1a4805da9e3d6355384e34c1a99e1300d01cac3ae3218c5738f11f1
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Sources/APIs/VideosAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
43 changes: 43 additions & 0 deletions Sources/Models/TooManyRequests.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}

5 changes: 5 additions & 0 deletions Tests/TestResources/payloads/videos/upload/responses/429.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type" : "https://docs.api.video/reference/too-many-requests",
"title" : "Too many requests.",
"status" : 429
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type" : "https://docs.api.video/reference/too-many-requests",
"title" : "Too many requests.",
"status" : 429
}
12 changes: 12 additions & 0 deletions docs/TooManyRequests.md
Original file line number Diff line number Diff line change
@@ -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)


Loading